Skip to content

Instantly share code, notes, and snippets.

View fay-jai's full-sized avatar
✌️

Willson Mock fay-jai

✌️
View GitHub Profile
@fay-jai
fay-jai / app.tsx
Created March 21, 2016 06:19
Getting Started with Typescript, ReactJS, and Webpack
// 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")
@fay-jai
fay-jai / webpack.config.js
Created March 21, 2016 06:22
Getting Started with Typescript, ReactJS, and Webpack
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"],
@fay-jai
fay-jai / index.html
Created March 21, 2016 06:36
Getting Started with Typescript, ReactJS, and Webpack
<!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>
@fay-jai
fay-jai / .eslintrc
Created March 30, 2016 19:10 — forked from cletusw/.eslintrc
ESLint Reset - A starter .eslintrc file that resets all rules to off and includes a description of what each rule does. From here, enable the rules that you care about by changing the 0 to a 1 or 2. 1 means warning (will not affect exit code) and 2 means error (will affect exit code).
{
// 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
@fay-jai
fay-jai / Hello.spec.tsx
Created March 31, 2016 06:01
Getting Started on Testing with Typescript, ReactJS, and Webpack
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();
@fay-jai
fay-jai / karma.conf.js
Last active August 29, 2016 16:07
Getting Started on Testing with Typescript, ReactJS, and Webpack
/*
* 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
@fay-jai
fay-jai / module1.ts
Created April 4, 2016 02:28
Exploring Typescript Internal and External Modules
function sayHello(name: string): string {
return `Hello, ${name}`;
}
@fay-jai
fay-jai / module2.ts
Created April 4, 2016 02:30
Exploring Typescript Internal and External Modules
namespace InternalModule {
export function add(...args: number[]): number {
return args.reduce((acc, cur) => acc + cur, 0);
}
}
@fay-jai
fay-jai / app.ts
Created April 4, 2016 02:31
Exploring Typescript Internal and External Modules
console.log(sayHello("Willson"));
console.log(InternalModule.add(1, 2, 3, 4));
@fay-jai
fay-jai / index.html
Created April 4, 2016 02:32
Exploring Typescript Internal and External Modules
<!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>