I've pulled the react.d.ts
file from DefinitelyTyped, and included it in my project as node_modules/react/react.d.ts
. Now, when I write import * as React from "node_modules/react/react"
, I get the following error:
Error TS2306: File '.../node_modules/react/react.d.ts' is not a module.
I can work around this by changing the following lines in react.d.ts
:
declare module "react" {
export = __React;
}
to:
export = __React;
My question is: what's the suggested workflow for working with TypeScript definition files?
With the new TypeScript 2.0, still in beta (npm install typescript@beta -g
), you should grab your definition files with npm install @types/react
.
Secondly, if there is a statement export =
in a module (or a declaration of a module), you should import accordingly with syntax import =
like the following: import React = require('react');