Last active
June 4, 2019 19:01
-
-
Save phplaw/3db28131894a255e424cfe898eea860d to your computer and use it in GitHub Desktop.
Learn TypeScript
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
let title: string = 'Hello World'; | |
// or let title = $('#user_name').val(); | |
(title as string).split(' '); | |
(<string>title).split(' '); | |
// fix window issue | |
// Element implicitly has an 'any' type because type 'Window' has no index signature? | |
declare global { | |
interface Window { MyNamespace: any; } | |
} | |
window.MyNamespace = window.MyNamespace || {}; | |
// better than obove | |
interface Window: { | |
[key:string]: any; // Add index signature | |
} | |
// optional parameter syntax | |
function functionName(a: number, b?: number) { | |
} | |
// optional parameter check | |
function getSchool(name: string, address?: string, pinCode?: string): string { | |
if (address == undefined) { | |
console.log('address not defined'); | |
} | |
if (pinCode == undefined) { | |
console.log('pincode not defined'); | |
} | |
//... | |
} | |
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
#!/bin/bash | |
npm install @types/angular @types/jquery @types/node @types/socket.io @types/socket.io @types/socket.io-client @types/googlemaps @types/express |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment