Visual Studio 2015 如何解析 TypeScript 类型(.d.ts 文件)
我通过 nuget 添加了 datatables.net 的类型.之后,我不断收到如下错误:
I added the typings for datatables.net via nuget. After that I kept getting errors like:
错误 TS2322 类型 '{ dom: string;}' 不可分配给类型'设置'.类型 '{ dom: string; ' 中缺少属性 'oFeatures'}'.
Error TS2322 Type '{ dom: string; }' is not assignable to type 'Settings'. Property 'oFeatures' is missing in type '{ dom: string; }'.
我终于意识到nuget包在/scripts/typings中丢了两个typings文件:
I finally realized that the nuget package dropped two typings files in /scripts/typings:
- jquery.dataTables-1.9.4.d.ts
- jquery.dataTables.d.ts
注释掉整个 1.9.4 文件解决了我的问题,但这让我提出了一个问题:visual studio 是如何决定首先包含该文件的?我希望在文件顶部需要///reference 声明,但显然不是.vs2015 是否只是拾取所有 d.ts 文件?除了删除文件或将其注释掉之外,还有其他方法可以排除文件吗?
Commenting out the entire 1.9.4 file fixed my issue, but this made me ask the question: How did visual studio determine to include that file to begin with? I expected to need ///reference declarations at the top of the file but apparently not. Does vs2015 just pick up all d.ts files? Is there a way to exclude a file other than deleting it or commenting it out?
Visual Studio 应该能够自动获取定义.
Visual studio should be able to pick up definitions automatically.
要从项目中排除定义,请使用以下的排除"部分:tsconfig.json 指定要排除的文件.
To exclude definition from project use "exclude" section of : tsconfig.json to specify what files to exclude.