我的文件目录是这样的
add.js
export const add = (a, b) => a + b
add.d.ts
export declare type add = (a: string, b: string) => string;
index.ts
import { add } from "./add";
const a = add('11', '11')
在index中引入时会报错,编辑器误将add仅仅当作一个type
我在tsconfig里也配置了
{
"compilerOptions": {
"outDir": "lib",
"module": "esnext",
"target": "es6",
"declaration": true,
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"skipLibCheck": true,
"typeRoots": ["./node_modules/@types", "./src/add/add.d.ts"]
},
"include": ["src"],
"exclude": []
}
是哪里出了问题呢