DEV Community

loading...

CDN and TypeScript support (also JavaScript typing for IDE)

patarapolw profile image Pacharapol Withayasakpunt ・1 min read

This is quite easy. You will need cdn.d.ts, but you will also need to install the module in package.json, (or at least @types/), no matter what.

declare module 'https://cdn.skypack.dev/js-yaml@*' {
  export * from 'js-yaml'
}
Enter fullscreen mode Exit fullscreen mode

Also, I am consider if cdn.d.ts file can be generated programmatically? (Next.js also generate typings for CSS modules on the fly.)

It would be nice if I can use Deno for Skypack CDN, but it seems that it does not have web-browser-related typings.

Or, do have have a better way?

Discussion

pic
Editor guide
Collapse
patarapolw profile image
Pacharapol Withayasakpunt Author

tsconfig.json / jsconfig.json path aliases might be a much much easier option.

Collapse
mzaini30 profile image
Zen

I've never tried deno. maybe, I'll try later.