简体   繁体   中英

Develop NPM Package with TypeScript for JSPM Application

Basically, I have the same question as asked here :

I have developed a NPM Package (typed-lexer) that properly ships its d.ts file (with corresponding entries in the package.json file). Consuming the package in a plain node js app via npm install and tsc --init works fine - both the IDE (in my case Visual Studio Code) and the compiler are able to locate my typed-lexer's type definition file.

However, it works everything else than fine when I install my package via jspm. As the d.ts file is an external declaration file (there is no declare module in it) I cannot just <reference ... /> it. Installing the package both via jspm and npm helps the IDE but not the browser where the typescript files are compiled.

As the linked question has no real answer and typescript 1.8 has been released now, I wonder what I can do about this. I am using jspm 0.17.0-beta.12 and typescript 1.9.0.

Although I already searched the web for about an hour or so, I found this issue after further research: https://github.com/Microsoft/TypeScript/issues/6012

The last comment by refresh09 is:

Instead of waiting for "paths" support in the Typescript 2.0 tsconfig, the same thing can be done using typings.

 typings install --save @angular/core=file:../jspm_packages/npm/@angular/core@2.0.0-rc.1/index.d.ts 

or directly in typings.json

 { "name": "", "dependencies": { "@angular/core": "file:../jspm_packages/npm/@angular/core@2.0.0-rc.1/index.d.ts" } } 

In my case,

typings install --save typed-lexer=file:jspm_packages/npm/typed-lexer@1.0.2/dist/typed-lexer.d.ts

did it. I hope this will be fixed soon.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM