typescript-tutorial icon indicating copy to clipboard operation
typescript-tutorial copied to clipboard

本地声明文件没有被自动解析到

Open tomwang1013 opened this issue 5 years ago • 0 comments
trafficstars

在声明文件这一章中:

https://ts.xcatliu.com/basics/declaration-files#shen-me-shi-sheng-ming-wen-jian

您提到只要把声明文件放在本地src目录下,不用引用就可以直接使用。但是试了下不行呢。我有两个文件,在同一个src目录下:

// index.d.ts
declare let gl: string;
// index.ts
console.log(gl); // 直接报错:找不到gl的定义

tsconfig.json中有include的配置:

"include": ["src/**/*"] 

看起来typescript没有解析index.d.ts

这是啥问题呢?

补充:在index.ts中使用///就不报错了: /// <reference path="index.d.ts" />

tomwang1013 avatar May 26 '20 09:05 tomwang1013