When you use typings and Typescript, you can use ES6 imports (rather than require). For instance, you would do this:
import * as React from 'react';
interface IMessage {
msg: String;
}
class TestApp extends React.Component {
public render(): Element {
return test;
}
}
To get React to be available, you would first need to install it:
typings install react --ambient --save
You also need a tsconfig.json to list the files you want to import. Importing the main.d.ts auto imports everything you’ve installed:
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"jsx": "react",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"outDir": "dist"
},
"exclude": [
"node_modules",
"dist",
"node_modules",
"typings"
],
"files": [
"./app/index.tsx",
"./typings/main.d.ts"
]
}