【发布时间】:2018-03-12 14:06:58
【问题描述】:
假设我有一个项目 X,它的 package.json 中有以下内容:
"typings": "lib/index.d.ts",
"types": "lib/index.d.ts",
我想将 index.d.ts 文件中的所有类型导入另一个项目。
index.d.ts 文件如下所示:
export declare const makePathExecutable: (runPath: string, cb: Function) => void;
export declare const checkForEquality: (arr1: string[], arr2: string[]) => boolean;
export declare const arrayHasDuplicates: (a: any[]) => boolean;
export declare const isStringWithPositiveLn: (s: string) => boolean;
export declare const findNearestRunAndTransform: (root: string, pth: string, cb: Function) => any;
export declare const findSumanMarkers: (types: string[], root: string, files: string[], cb: IMapCallback) => void;
export declare const isObject: (v: any) => boolean;
在我的另一个项目中,我尝试像这样导入这些类型:
import * as X from "x"
但这似乎并没有真正起作用。
导入这些类型的正确方法是什么?
【问题讨论】:
-
import * as X from "x"好像导入了.js文件,但我只想导入类型
标签: typescript typescript2.0 .d.ts declaration-files