打字稿:导入ts项目到另一个

时间:2018-07-08 18:46:24

标签: typescript

我正在写一个ts项目,取决于另一个项目-map-generate

int.Parse()

使用时出现错误// in package.json "dependencies": { ... "vaoc-map-generator": "git+https://github.com/Airyworks/vaoc-map-generator.git" }, ...

TS2339
vaoc-map-generator中的

'index.d.ts'输出如下:

import * as MapGenerator from 'vaoc-map-generator'
console.log(MapGenerator)
// no error but an object got
console.log(MapGenerator.Grid)
//                       ~~~~
// got error: TS2339: Property 'Grid' does not exist on type 'typeof import("C:/..../vaoc-game/node_modules/vaoc-map-generator/dist/...'.
import { Grid } from 'vaoc-map-generator'
//       ~~~~
// got error again

export * from '@/models'; export * from '@/controllers'; export * from '@/Constants'; // '@' represent 'src/' 和/或tsconfig是否配置了'vaoc-map-generator'类型信息丢失的原因?
或一般来说,如何从ts项目导入到另一个ts项目中仍保留类型信息?

PS
tsconfig.json of vaoc-map-generator(可能是两个项目中“ @ / *”路径设置冲突的原因?)
build script in package.json of vaoc-map-generator(注意package.json"types"
./dist dir of vaoc-map-generator

0 个答案:

没有答案