我在以ts编写的自定义节点模块中有一个类型类。我的仓库中使用了这个模块。路径-mode_modules / dist / myFile(转换为.js文件)。
在我的代码中导入此文件时,我无法在键入时使用导出。
它说-myType引用一个值,但是在这里被用作类型。
我尝试过的- 我需要将其称为类型的文件-
import {myTypes} from 'myModule'
const a: myTypes: myType1; //this works, but isn't desired.
//What I'm trying now
code in node module (myModule)-
1. classA.ts
class myType1 { //assume there is a myType2
varA : number;
varB : string;
}
2. mytypes/index.ts
import {myType1, myType2} from '..'
{
export {myType1, myType2};
}
src/index.ts file
import * as myTypes from './mytypes';
export {myTypes};
**importing through an index file in working repo- **
1. types/index.ts
import * as myTypes from 'myModule'
export const { myType1, myType2 } = myTypes;
file where I need to refer this as a type-
import {myType1} from '../index' . //path given is correct in my
// code, I checked
const a: myType1 //ERROR
ERROR - myType1 refers to a value, but is being used as a type here.
我需要能够从节点模块使用myType。
请让我知道是否有任何不清楚的地方。