Saturday 15 September 2012

Reference javascript file inside typescript -



Reference javascript file inside typescript -

i utilize javascript function within typescript file. how can reference javascript file containing function within typescript file?

i tried

<reference path="../libs/myjsfile.js" />

this brings error while building like: cannot resolve referenced file: ../libs/myjsfile.js

while 2 answers above work little or single variable api, right reply write type declaration file javascript file.

the type declaration file illustration named myjsfile.d.ts, .d.ts prefix tells typescript compiler it's parsing declaration file. if utilize visual studio, declaration file recognized typescript compiler long somewhere (anywhere) in project working on.

declaration files store metadata javascript variables, functions , objects typescript compiler can job. if javascript file happens library or framework in mutual use, definitelytyped place find definition file need.

if javascript own work or less known, you'll have write own type declaration file. see section writing .d.ts files in the typescript handbook.

if name declaration file sounds intimidating, don't worry - far easier write programs. also, remember don't need specify metadata javascript file, functionality need.

let me know if need help!

javascript reference typescript

No comments:

Post a Comment