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 / custom_form.jsx
Last active April 19, 2016 05:49
React Component - CustomForm
// Here's a React Component class
class CustomForm extends React.Component {
constructor(props) {
super(props);
this.state = {
inputText: "Willson"
};
this.handleInputChange = this.handleInputChange.bind(this);
@fay-jai
fay-jai / hello_world.jsx
Created April 17, 2016 23:40
React Elements - Hello World
// This uses JSX syntax.
var helloWorld = <div>Hello World!</div>;
// And this is what the JSX syntax compiles into in JavaScript:
var helloWorld = React.createElement(
"div",
null,
"Hello World!"
);
@fay-jai
fay-jai / index.html
Created April 4, 2016 03:22
Exploring Typescript Internal and External Modules
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Typescript Modules</title>
</head>
<body>
<script src="build/bundle.js"></script>
</body>
</html>
@fay-jai
fay-jai / app.ts
Created April 4, 2016 03:21
Exploring Typescript Internal and External Modules
import * as SomeModule from "./module1";
import * as AnotherModule from "./module2";
console.log(SomeModule.sayHello("Willson"));
console.log(AnotherModule.add(1, 2, 3, 4));
/*
NOTE: this is the compiled JavaScript, assuming CommonJS module format
"use strict";
var SomeModule = require("./module1");
@fay-jai
fay-jai / module2.ts
Created April 4, 2016 03:20
Exploring Typescript Internal and External Modules
namespace InternalModule {
export function add(...args: number[]): number {
return args.reduce((acc, cur) => acc + cur, 0);
}
}
export = InternalModule;
/*
NOTE: this is the compiled JavaScript, assuming CommonJS module format
@fay-jai
fay-jai / module1.ts
Created April 4, 2016 03:19
Exploring Typescript Internal and External Modules
export function sayHello(name: string): string {
return `Hello, ${name}`;
}
/*
NOTE: this is the compiled JavaScript, assuming CommonJS module format
"use strict";
function sayHello(name) {
return "Hello, " + name;
}
@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>
@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 / 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 / module1.ts
Created April 4, 2016 02:28
Exploring Typescript Internal and External Modules
function sayHello(name: string): string {
return `Hello, ${name}`;
}