首页 文章

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

提问于
浏览
0

基本上,我有同样的问题here

我开发了一个NPM包(typed-lexer),它正确地发送了它的d.ts文件(在 package.json 文件中有相应的条目) . 通过npm install和tsc --init在普通节点js app中使用包正常工作 - IDE(在我的情况下是Visual Studio Code)和编译器都能够找到我的typed-lexer的类型定义文件 .

但是,当我通过jspm安装我的软件包时,它可以正常工作 . 由于d.ts文件是外部声明文件(其中没有 declare module ),我不能只是 <reference ... /> 它 . 通过jspm和npm安装软件包有助于IDE,但不能帮助编译typescript文件的浏览器 .

由于链接的问题没有真正的答案,现在已经发布了typescript 1.8,我想知道我能做些什么 . 我使用的是jspm 0.17.0-beta.12和typescript 1.9.0 .

1 回答

  • 0

    虽然我已经在网上搜索了大约一个小时左右,但我在进一步研究后发现了这个问题:https://github.com/Microsoft/TypeScript/issues/6012

    refresh09的最后一条评论是:

    而不是在Typescript 2.0 tsconfig中等待“路径”支持,使用typings可以完成同样的事情 . typings install --save @ angular / core = file:../ jspm_packages / npm / @ angular / core @ 2.0.0-rc.1 / index.d.ts
    或直接在typings.json {“name”:“”,“dependencies”:{“@ angular / core”:“file:../ jspm_packages / npm / @ angular / core @ 2.0.0-rc.1 / index .d.ts“}}

    就我而言,

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

    做到了 . 我希望很快就会解决这个问题 .

相关问题