[英]How to use typescript typing for a legacy project in vscode
Currently I have a project with structure 目前我有一个结构项目
...
└───folder1
│ │ file011.js
│ │ file012.js
│ └───...
└───folder2
│ │ file021.js
│ └───file022.js
│
└─── files...
I tried to include a type.d.ts
to the root, then tried putting it in a typings folder but none worked. 我尝试将
type.d.ts
包含在根目录中,然后尝试将其放入类型文件夹中,但没有任何效果。
How do I enable typing for my case ? 如何启用我的案件类型? There is no folder with name
src
没有名为
src
文件夹
With TypeScript 2.3 you can specify the checkJS
option to type check JS files. 使用TypeScript 2.3,您可以指定
checkJS
选项来键入check JS文件。
Documentation: https://github.com/Microsoft/TypeScript/wiki/Type-Checking-JavaScript-Files 文档: https : //github.com/Microsoft/TypeScript/wiki/Type-Checking-JavaScript-Files
It won't work as long as your files are still named "*.js". 只要您的文件仍命名为“ * .js”,它就不会起作用。 Try renaming a file to ".ts", then the typescript compiler can do it's magic.
尝试将文件重命名为“ .ts”,然后打字稿编译器可以做到这一点。
You also have to create a tsconfig.json to configure the typescript compiler. 您还必须创建tsconfig.json来配置打字稿编译器。
The settings really depend on the type of project you are using. 设置实际上取决于您使用的项目类型。 If you don't use a module system like requirejs, you need to get typings for global modules.
如果您不使用requirejs之类的模块系统,则需要获取全局模块的类型。
EDIT: Removed reference to Visual Studio project settings as this question is about vscode 编辑:由于此问题与vscode有关,因此删除了对Visual Studio项目设置的引用
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.