Develop NPM Package with TypeScript for JSPM Appli

2019-09-10 12:21发布

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.

1条回答
该账号已被封号
2楼-- · 2019-09-10 13:01

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.

查看更多
登录 后发表回答