I have a React type definition file (which is declared using an external module). In my source files, I usually do:
import * as R from "react"
and then can happily use R.createElement(... etc. in a strongly typed way.
I do not want to import R into each file, but instead use it as a global declaration (yes, I am ready to create a global namespace with a few variables). I tried:
import * as React from "react"; declare var R : React;
This does not work, I get "Cannot find name 'React'" . Is there any other way to export the whole module as global?
Edit 1 - I had to clarify: I am wondering how to export the global type definition to a .d.ts file. Therefore, suppose I have already bound R to window . Now I need typescript to know that R is of type React module .
source share