Search code examples
angulartypescriptangular2-nativescript

access native js global object in angular4 or exclude single typescript line from compiling?


In ts I would like to keep a single line of Javascript code native as it is, because it uses a type, which is not known to the tsc (no node_module available) but at runtime it exists in global window object from browser. Is there an easy solution? (by annotation i.e.). I use angular4.


Solution

  • Use the any type if you do not know its type.

    const foo: any = window.globalVar
    

    or

    const foo = windows.globalVar as any