String name = 'Tamino';
string name = 'Tamino';
NSString name = 'Tamino';
const name: string = 'Tamino';
const name = 'Tamino';
const name: any = 'Tamino';
const name: string = 'Tamino';
const name = 'Tamino';
const name: string = 'Tamino';
const luckyNumber: number = 8;
const isActive: boolean = false;
const name: string = 'Tamino';
let param: string | undefined;
param = 'foo';
param = undefined;
param = 8; // 💩
type optionalString = string | undefined; let param: optionalString; let param?: string;
type vote = 'yay' | 'nay';
const shifts: Shift[];
const shifts: Array<Shift>;
const shiftLists: Shift[][];
const phoneBook: { [name: string]: string };phoneBook['Tamino'] = '01577 1234567';
phoneBook['Tamino'] = 15771234567; // 💩
phoneBook[0] = '01577 1234567'; // 💩
const phoneBook: {
emergency: string;
[name: string]: string;
};class Foo {
[key: string]: any;
}const callback: ( shifts: Shift[]) => void;
class Foo {
bar(params: string[]): string { ... }
}class Foo {
bar(params: string[]): string { ... }
}type nuStr = number | str;
class Foo {
bar(params: nuStr[]): nuStr { ... }
}class Foo {
bar(params: string[]): string
bar(params: number[]): number
{ ... }
}class Foo {
public static readonly TABLE_NAME = 1;
private static _name: string;
}class Foo {
public static readonly TABLE_NAME;
private static _name: string;
static get TABLE_NAME {
return this._name.toUpperCase();
}
}interface IEmailable {
name: string;
email: string;
}interface Employment extends IEmailable
class Employment implements IEmailable
interface IEmailable {
name: string;
email: string;
}interface Employment extends IEmailable
class Employment implements IEmailable
class A extends B implements D, E
enum Style {
NONE = 0,
BOLD = 1,
ITALIC = 2,
UNDERLINE = 4,
EMPHASIS = Style.BOLD | Style.ITALIC,
HYPERLINK = Style.BOLD | Style.UNDERLINE,
}enum ShiftplanStatus {
New,
Published,
}const style: number = Style.ITALIC; // 2
let status: string; status = Status[Status.New]; // 'New'
module Shyftplan {
export class Employment;
...
}interface Array<T> {
...
map<U>(cb: (value: T) => U): U[];
...
}npm install typescript -g