bigopon
bigopon

Reputation: 1964

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.

How do I enable typing for my case ? There is no folder with name src

Upvotes: 1

Views: 486

Answers (2)

Saravana
Saravana

Reputation: 40554

With TypeScript 2.3 you can specify the checkJS option to type check JS files.

Documentation: https://github.com/Microsoft/TypeScript/wiki/Type-Checking-JavaScript-Files

Upvotes: 3

mode777
mode777

Reputation: 3187

It won't work as long as your files are still named "*.js". Try renaming a file to ".ts", then the typescript compiler can do it's magic.

You also have to create a tsconfig.json to configure the typescript compiler.

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.

EDIT: Removed reference to Visual Studio project settings as this question is about vscode

Upvotes: 2

Related Questions