Closed bmayen closed 8 years ago
Thanks for raising this, it is not implemented yet, I need to read up on this feature and figure out how it will work in plugin-typescript.
I use typescript@beta and works
tsconfig.json
{
"compilerOptions": {
"target": "es5",
"module": "system",
"moduleResolution": "node",
"sourceMap": false,
"inlineSourceMap": false,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"types": [ "core-js", "jasmine" ]
},
"exclude": [
"node_modules"
]
}
systemjs.config.js
typescriptOptions: {
tsconfig: true,
types: []
}
@frankwallis @types/ replace typings config,no more typings.json or typings install The Future of Declaration Files
What version of the plugin and JSPM are you using? And where did you install the types; under jspm_packages or node_modules?
"systemjs": "0.19.32" "systemjs-builder": "0.15.23" "plugin-typescript": "5.0.1"
all installed in node_modules, not using jspm packages
Interesting. I'm on systemjs@0.19.31, but that doesn't seem likely to be the issue.
Latest version of the plugin though. Any chance you could update the plugin to verify if it still works at latest?
If so, the only difference I see is that I'm using JSPM. @guybedford, do you have any insight as to why this might not work using JSPM?
@fchiumeo Are you sure it is working? I think your types: [] is overriding the first one and nullifying the load of the type declarations.
@frankwallis I took a look into this and the blocking point is that the compiler host in plugin-typescript doesn't provide the files that Typescript is looking for.
Installing to jspm_packages does not seem possible because Typescript search for things like jspm_packages/@types/package_name without the added @version_number.
When using node_modules the problem is that Typescript starts looking for http://localhost:xxx/node_modules/angular/package.json and index.d.ts in the Host files but on the first transpile call the host files only contain the main file.
I wonder if the plugin could do a scan of all files under typeRoots, similar to what Typescript does in: https://github.com/Microsoft/TypeScript/blob/v2.0.0-beta/src/compiler/program.ts#L1058 and make those files available in the compiler host for when typescript requests them.
I would love to help out with this but my knowledge is so far a couple of hours of debugging and reading the source code so I don't know what's the best way to address it.
@dballesteros7 is right, it can't work with current implementation of plugin-typescript. At least it shouldn't....
Actually, most of the time, in tsc one does not need to provide explicit types
in tsconfig. There is additional property typeRoots
which has some defaults for node_modules/@types
Looks like ts expose speciall method ts.resolveTypeReferenceDirective
which one can use to properly resolve @types
, maybe it can be used in host's resolveModuleNames
function. This method depends on other host functions like getSourceFile
, fileExists
, etc.
I'm not really familiar with typescript API, but that is what I found looking around.
Also I've found few existing bugs related to type resolution, e.g: https://github.com/Microsoft/TypeScript/issues/9831
For more details see https://github.com/Microsoft/TypeScript/issues/9184
I have implemented some basic support for the types
configuration option in 5.0.18. It is now used in the react and angular1 example projects. Also there is some information on the readme: https://github.com/frankwallis/plugin-typescript/blob/master/README.md#types-types-support
Let me know if you find any issues, thanks
This seems to look for the typings in the wrong place:
jspm bundle-sfx app/app build/app.js
Building the single-file sfx bundle for app/app...
err Error on fetch for npm:@types/react-dom@0.14.15.js/index.d.ts!github:frankwallis/plugin-typescript@5.0.18/plugin.js at file:///Users/tamird/src/go/src/github.com/cockroachdb/cockroach/ui/jspm_packages/npm/@types/react-dom@0.14.15.js/index.d.ts!file:///Users/tamird/src/go/src/github.com/cockroachdb/cockroach/ui/jspm_packages/github/frankwallis/plugin-typescript@5.0.18/plugin.js
Loading app/app.tsx
Error: ENOENT: no such file or directory, open '/Users/tamird/src/go/src/github.com/cockroachdb/cockroach/ui/jspm_packages/npm/@types/react-dom@0.14.15.js/index.d.ts'
Note that .js
suffix on the directory name - this suffix is not present on disk.
I think this is caused by jspm@0.16 and the defaultJsExtensions behaviour. I am not able to recreate in the react example project using jspm@0.17-beta. I have added a patch in 5.0.19 which I hope will fix this.
Using typescript@beta. My tsconfig.json has
"types": ["jquery"]
and I have installed @types/jquery under both node_modules and jspm_packages (as part of my debugging effort). When I build my project I get the following error: "Cannot find type definition file for 'jquery'. (TS2688)"I have tried other packages as well, but none are found.