I’m working on an Astro project and have installed the @datocms/astro package using npm install @datocms/astro. However, when I try to import the StructuredText component from @datocms/astro/src/StructuredText, I encounter the following error in VSCode:
Error: 'StructuredText' is declared but its value is never read.ts(6133)Cannot find module '@datocms/astro/StructuredText' or its corresponding type declarations.
I’ve tried importing from different paths such as @datocms/astro and @datocms/astro/src/StructuredText, but the issue persists.
Could you please advise on how to properly import and use the StructuredText component in this setup? Any help would be greatly appreciated!
There are a couple different things going on here. Could I please suggest you use our Astro Starter Kit to begin with? Or look at an example file from it to see how we use Structured Text there?
To answer your questions, though, there are two separate errors: 'StructuredText' is declared but its value is never read.ts(6133)
This just means you imported it but haven’t used it in the file yet. It’s just a warning that you have a import you don’t need. Once you use the <StructuredText/> component, it will go away.
As for: Cannot find module '@datocms/astro/StructuredText' or its corresponding type declarations.
Please be sure you’re importing it like this (with curly braces, and without a specific folder):
// Do this
import { StructuredText } from '@datocms/astro';
If you try to import it like:
// Not this. This is wrong and won't work.
import StructuredText from '@datocms/astro/src/StructuredText';