javascript - How should I tell the Typescript compiler about a global variable defined elsewhere? -


i'm writing vanilla javascript , trying use ts type checking in vscode specifying checkjs flag. (this has been of adventure on past week!)

my project uses es6 modules bundled webpack / babel; entry point (app.js) exports global variable:

var viewer; viewer = ... window.viewer = viewer; 

i tell other modules variable eslint won't bother me:

/* global viewer */ var val = viewer.val; 

this works fine, ts checker complaining

[js] cannot find name 'viewer'. 

how can tell ts compiler i've defined outside of current file? ts need updated respect eslint global comment, or maybe has own comment directive syntax?

typescript not respect eslint note, since comment. telling ts external variable available, write declare let viewer: any; (or const instead of let).


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -