delucis/astro-embed

Could not find a declaration file for module

studiohic opened this issue · 4 comments

Have this alert when using:

import { YouTube } from '@astro-community/astro-embed-youtube';

Could not find a declaration file for module '@astro-community/astro-embed-youtube'. '/Users/xxxx/Astro/xxxx/node_modules/@astro-community/astro-embed-youtube/index.js' implicitly has an 'any' type. Try npm i --save-dev @types/astro-community__astro-embed-youtubeif it exists or add a new declaration (.d.ts) file containingdeclare module '@astro-community/astro-embed-youtube';`ts(7016)

Ah, yes! I think this is because we export via .js files. I think we may be able to switch those all over to .ts — haven’t had time to test that.

Is it not usable with TypeScript or is there a workaround? Im unfortunately not experienced enough to figure that out.

It should work fine, but you’ll see warnings like the above in your editor and it can cause errors if type checking an Astro project using astro check.

You can hide these using a // @ts-expect-error comment on the line above where you see the warning:

// @ts-expect-error No type definitions available for this package.
import { YouTube } from '@astro-community/astro-embed-youtube';

Fixed in the latest release — you shouldn’t see errors now or need the @ts-expect-error comment.