visual studio - Typescript Type Definition References -


i have project multiple typescript files. if add new typescript file have reference typings in order compile it, vs couldn't resolve them itself. have empty .ts file doesn't require referencing typings, put code , works.

when found out kept file , when need create new .ts file, copy file , works charm.

so suppose in folder have 2 .ts files side side: copy of magic file , newly created one.

if put code in magic file

class test {     test: knockoutobservable<string>; } 

it compiles. if put same code file says

cannot find name knockoutobservable

what special first file?

i'm using visual studio 2015. have installed knockout typings. have empty tsconfig.json file in solution. don't want reference typings using /// reference comment.

thanks.

you need use tsd , install appropriate ".d.ts" file, e.g. knockout:

tsd install knockout 

it downloads "knockout.d.ts" project , places definition typings folder:

typings/knockout/knockout.d.ts  

then can add corresponding reference top or "ts" file. e.g.:

/// <reference path="../../typings/knockout/knockout.d.ts" /> 

Comments