简体   繁体   English

使用TypeScript为JSPM应用程序开发NPM软件包

[英]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). 我已经开发了一个NPM软件包(类型化词法分析器),该软件包可以正确地运送其d.ts文件(在package.json文件中具有相应的条目)。 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. 通过npm install和tsc --init在普通节点js应用程序中使用该程序包可以正常工作-IDE(在我的情况下为Visual Studio Code)和编译器都可以找到我的typed-lexer的类型定义文件。

However, it works everything else than fine when I install my package via jspm. 但是,当我通过jspm安装我的软件包时,它可以正常工作。 As the d.ts file is an external declaration file (there is no declare module in it) I cannot just <reference ... /> it. 由于d.ts文件是一个外部声明文件(其中没有declare module ,因此我不能仅对其进行<reference ... /> Installing the package both via jspm and npm helps the IDE but not the browser where the typescript files are compiled. 通过jspm和npm安装软件包都可以帮助IDE,但不能帮助编译打字稿文件的浏览器。

As the linked question has no real answer and typescript 1.8 has been released now, I wonder what I can do about this. 由于链接的问题没有真正的答案,并且现在已经发布了打字稿1.8,我不知道该怎么办。 I am using jspm 0.17.0-beta.12 and typescript 1.9.0. 我正在使用jspm 0.17.0-beta.12和打字稿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 尽管我已经在网上搜索了大约一个小时左右,但在进一步研究后发现了这个问题: https : //github.com/Microsoft/TypeScript/issues/6012

The last comment by refresh09 is: refresh09最后的评论是:

Instead of waiting for "paths" support in the Typescript 2.0 tsconfig, the same thing can be done using typings. 不用等待Typescript 2.0 tsconfig中的“路径”支持,可以使用键入完成相同的操作。

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

or directly in typings.json 或直接在types.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. 我希望这会尽快解决。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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