jspm / project

Roadmap and management repo for the jspm project
161 stars 8 forks source link

Deno TypeScript support #55

Open KSXGitHub opened 4 years ago

KSXGitHub commented 4 years ago

Currently, JavaScript files provided by jspm CDN can be used by Deno but without TypeScript types.

Request

Position of TypeScript definition files (*.d.ts) can be inferred from:

JSPM can then inform Deno of TypeScript definition by either:

Deno does not understand Node.js module path, so make sure to resolve all URLs found within TypeScript files to valid URLs.

guybedford commented 4 years ago

The position of jspm with respect to typing is that it will rather as a project follow best practises here once they are fully stable and established, instead of aiming to pioneer any work in this space.

As far as I'm aware, a deps.ts pattern can also work as entirely complimentary to jspm without needing core integration correct?

KSXGitHub commented 4 years ago

@guybedford I don't quite understand your question, I don't think deps.ts has anything to do with typing.

guybedford commented 4 years ago

Ah, I was under the impression that it also provided the typings and not just reexports of the dependencies, ok I see.

I suppose a types.d.ts pattern with namespaces is more what I was thinking that provides a constructed type manifold for the app, similarly to the deps but for typing.

Ciantic commented 4 years ago

I'm wondering about this too at the moment

JSPM could read package.json, search for types property. If it finds it, it would flatten it (turn it to single file), and serve that like rest of the JS files.

For instance, I'm trying to use PostCSS with deno and TypeScript.

JSPM would start looking for types in package.json: https://raw.githubusercontent.com/postcss/postcss/master/package.json

It would end up here: https://raw.githubusercontent.com/postcss/postcss/master/lib/postcss.d.ts

Next JSPM should convert the first import * as mozilla from 'source-map'; line to Deno compatible format by processing all commonjs style imports. In this case it should read the source-map's package.json and then copy types from it to the: https://jspm.dev/postcss/types.d.ts which would then contain both postcss and source-map types in one single file.

There needs to be some standard naming, thus it could be: https://jspm.dev/PACKAGENAME/types.d.ts.

User could then use it always like @deno-types="https://jspm.dev/PACKAGENAME/types.d.ts" if the package provides types.

As a side note, I figured how to use Postcss with deno: https://gist.github.com/Ciantic/8a4ad213f1d0b947db7ff578720f5826 but of course I want typescript support, so trying to solve that now.

haylinmoore commented 4 years ago

Has there been any work on this?

boison-ranga commented 3 years ago

Providing a X-TypeScript-Types header that points to the corresponding types of a packages would be a nice addition to overall TypeScript support with Deno.

Skypack already does this with some packages, if I am not mistaken.