This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Remember to rename the file from app.ts to app.tsx | |
// and to keep it in the src/ directory. | |
import * as React from "react"; | |
import * as ReactDOM from "react-dom"; | |
import Hello from "./Hello"; | |
ReactDOM.render( | |
<Hello name="Willson" />, | |
document.getElementById("root") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var path = require("path"); | |
var config = { | |
/* | |
* app.ts represents the entry point to your web application. Webpack will | |
* recursively go through every "require" statement in app.ts and | |
* efficiently build out the application's dependency tree. | |
*/ | |
entry: ["./src/app.tsx"], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Getting Started with Typescript, ReactJS, and Webpack</title> | |
</head> | |
<body> | |
<!-- this is where our Hello component will get rendered into --> | |
<div id="root"></div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
// http://eslint.org/docs/rules/ | |
"ecmaFeatures": { | |
"binaryLiterals": false, // enable binary literals | |
"blockBindings": false, // enable let and const (aka block bindings) | |
"defaultParams": false, // enable default function parameters | |
"forOf": false, // enable for-of loops | |
"generators": false, // enable generators | |
"objectLiteralComputedProperties": false, // enable computed object literal property names |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as React from "react"; | |
import * as ReactDOM from "react-dom"; | |
import * as TestUtils from "react-addons-test-utils"; | |
import Hello from "../src/Hello"; | |
describe("Hello", () => { | |
let renderer: React.ShallowRenderer; | |
beforeEach(() => { | |
renderer = TestUtils.createRenderer(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* More detailed explanation here: http://karma-runner.github.io/0.13/config/configuration-file.html | |
*/ | |
var webpackConfig = require("./webpack.config"); | |
module.exports = function(config) { | |
config.set({ | |
/* | |
* Enable or disable watching files and executing the tests whenever |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sayHello(name: string): string { | |
return `Hello, ${name}`; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace InternalModule { | |
export function add(...args: number[]): number { | |
return args.reduce((acc, cur) => acc + cur, 0); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log(sayHello("Willson")); | |
console.log(InternalModule.add(1, 2, 3, 4)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Typescript Modules</title> | |
</head> | |
<body> | |
<script src="build/module1.js"></script> | |
<script src="build/module2.js"></script> | |
<script src="build/app.js"></script> |