Javascript 打字脚本可以';我看不到申报文件
我有Javascript 打字脚本可以';我看不到申报文件,javascript,angular,typescript,Javascript,Angular,Typescript,我有app.ts import { Name } from './hello' 我有hello.js module.exports.Name = "great"; 我有typings文件夹,其中有hello文件夹,其中有index.d.ts,在此文件中,我有: export const Name: string; 我有tsconfig.json,其中 "typeRoots" : ["./typings"] 所发生的是intellisence在app.ts的/hello位置给我错误信息。
app.ts
import { Name } from './hello'
我有hello.js
module.exports.Name = "great";
我有typings
文件夹,其中有hello
文件夹,其中有index.d.ts
,在此文件中,我有:
export const Name: string;
我有tsconfig.json
,其中
"typeRoots" : ["./typings"]
所发生的是intellisence在app.ts
的/hello
位置给我错误信息。它说它找不到声明文件。我的问题是为什么?假设它开始在当前目录中查找声明。它找不到它。然后它应该搜索typings
文件夹,并在那里找到它。但为什么它会给我错误
我观察到的是,如果我运行
tsc--traceResolution
,它会在当前目录中搜索hello.ts,hello.d.ts
,在没有找到它之后,它会在当前目录中搜索hello.js
,当它找到它时,它会解析它。然后它继续进入打字
文件夹,并再次解析index.d.ts
。但是为什么intellisence会给我一个错误?模块导出和导入(ESM)可以混合吗?是的。设想一些为ES5编写的模块,我们仍然将它们作为ES6导入。导出和导入(ESM)是否可以混合使用?是的。设想一些为ES5编写的模块,我们仍然将它们作为ES6导入。