node.js - In typescript, how to restrict a typing reference to a certain file? -


i'm trying cleanly write universal javascript code, node , browser.

most of code env-agnostic, however, implementation parts detect environment (node or browser) , conditionally execute different code.

i activate node typings only specific files. however, couldn't find way so. either:

  • node typings, when referenced in 1 file only, made effective files (bad, since inadvertently rely on node specificities)
  • if not referencing node typings @ all, typescript complains lot of unknown definitions, painful patch hand

do has clean way of activating type definitions selected set of files ?

it's not possible @ time.

a solution: building node-dependant , node-independant files separately. done automatically script.


Comments