I have TypeScript and Typings working in vs2015 with the Web Analyzer plugin. I've resolved all vs2015 errors. Now I am trying to set it up in vscode. I've setup a gulp task and vscode reports:
error TS2304: Cannot find name 'angular'
I can resolve it with the following line, but is there a simpler way than listing out each file individually? I.e., vs2015 compiles the TypeScript without issue and knows how to use the Typings files.
/// <reference path="../typings/browser/ambient/angular/index.d.ts" />
I started with gulp-tsc and also tried gulp-typescript, but both require this.
var tsc = require("gulp-tsc");
var typescript = require("gulp-typescript");
var $ = require("gulp-load-plugins")({ lazy: true });
gulp.task("ts-watcher", function() {
gulp.watch("./app/**/*.ts", ["ts-compile"]);
});
gulp.task("ts-compile", function() {
var tsProject = typescript.createProject('tsconfig.json');
return gulp.src(config.allts) //["./app/**/*.ts"]
.pipe(typescript(tsProject))
.pipe(gulp.dest("dest/"));
});
gulp.task("default", ["ts-watcher"]);
{
"compilerOptions": {
"module": "amd",
"rootDir": "src",
"sourceMap": true,
"target": "es5",
"removeComments": true,
"outFile": "./build/build.js"
},
"compileOnSave": true,
"exclude": [
"node_modules",
"typings/main",
"typings/main.d.ts",
"packages"
]
}
My typings folder is in the same folder as tsconfig.json.
Restarting VSCode did not help.
This is similar to Including d.ts type definition files in VSCode, but I am 1) including more information, 2) using VSCode 1.1.0, and 3) I have a TSconfig, not a JSconfig. Would a jsconfig help?
Add a main.d.ts file in your app folder. (Or the src folder where all your ts file resides) with below content, (check the relative path based upon your project structure)
/// <reference path="../typings/main.d.ts" />
you might have to restart VS code.