DEV Community

Pacharapol Withayasakpunt
Pacharapol Withayasakpunt

Posted on

CDN and TypeScript support (also JavaScript typing for IDE)

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?

Top comments (2)

Collapse
 
patarapolw profile image
Pacharapol Withayasakpunt

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.