Free Essay

Typescript for Csharp Programmers

In:

Submitted By jettnorthcott
Words 1991
Pages 8
c# @
:
www.pooyablog.blogfa.com Pooya.Shahbazian@yahoo.com

> @ @ > ? >

>

@ >« >

>

@

»

>

< >

> > ClassBase @

Prototype
> . @ > ... < > < .> .... @

@

>>

> @ > @ > <

@ @ . @ ? > > > > > > @ <

@ @ . > @> > . > < @

.

>

www.infoQ.com
> > > > > @ > >

.

>

Pooya.shahbazian@Yahoo.com
. . >

< www.pooyablog.blogfa.com > Somamos-Co

www.somamos-co.com

1392

-

١Interface

2

C# @

5 ................................................................................................................................ 6....................................................................................................................................... @

@

>

1 2 3 4

7 ................................................................................................................................................ 9.......................................................................................................................... 10 .................................................................................................................................. 10...................................................................................................................... @ @

5 6 7 8 9 10 11 12 > 13 14 15 16

13 .......................................................................................................................................... > > 16 .................................................................................................................. <

20 ................................................................................................................................................. 26 ............................................................................................................................................ 28 ......................................................................................................................... 31 .................................................................................................................. > > 35 ................................................................................................................ @ >@ @ @ >> >>

38 ................................................................................................................................. 42 ......................................................................................................................................... 44 ............................................................................................................................................

3

C# @

50 ............................................................................................................................................. 53 ........................................................................................................................................... > 57 .......................................................................................................................................... 59 ................................................................................................................................ 62 ................................................................................................................................. @

17 18 19 20 21

4

C# @

@
. . > «4 > @ » >>  @ > > 2012 >«5 .> > @ @ > < . @ .> > > @ @ .> > @> > @ @ «3> >» » >
2

>

1

>

> 0.8

٢Steve Fenton ٣Dart ٤Coffee ٥Type

Script

Script

5

C# @

@
.
6

2
>

>

> @

> @
7

>

InfoQ

. .
> > @> >

@ >

@

>
<

@

8

StackOverFlow
.

> >@ @>

.

٦Ana MariaCiobotaru ٧Jonathan ٨Mark

Louis Allen

Jonse

6

C# @

3
9

< @ . @
11 10

.NET
>> < @ > >13 >@ > @ .14 >> < > < @ @ > > @
12

-

. @

@

. > . > >

ECMAScript6 > @ >

@

>

@ .

@

Node.Js

@

16

15

> > > . > >

< >

-

>

»

> >>

٩Type

Script

١٠Static Typing ١١Class-based Object ١٢Scalable ١٣Vanilla

Orientation

JavaScript

١٤Generics ١٥Annotation ١٦Interface

7

C# @

.> Var name: string = "Steve Fenton";

«17 > >

Var name = "Steve Fenton";
18



>>

0.8 > >>

2012 @

> 0.9

.

>>

Apache2
. @ .

>

> > >

>

Node.Js

> .

<

@

.> >@ @ @ >.

C#
. >

@
19

.NET
> »

>>

«23

» «22 >

»

١٧ Type

Erasure Hejlsberg

١٨ Anders ١٩ Syntax ٢٠ Type

System

٢١ Memory Management ٢٢ Events ٢٣ Exceptions

8

C# @

. > > > CodePlex > @ > @> < > @

>

http://typescript.codeplex.com/.
24

4
»> .> > > >

@

@

>

@

«

@ >

@ @

<

. @ « » ><

>« > .

»

«

»

>

< .

IL
>

@

< @ > [IL C#]

C#
> @

>

< . >« > @ . « < »@ «

>

@ <

>>

.

@

C++

» > >

C++ PHP

٢٤Transpiling

> .[ ] « »

>

> >

> > >

9

C# @

>

>

« > . >

»

>

» > «

> »

@ >

>

@
@ @ @ > = > @ . . > >@
27 26

5

>

@

C#
> @ .> .

C#

C#

><

. > 30 > > > < @ > > > > >

>
29

>> >> @ . >

28

@ >>

@

.> > > < . >. @ >> >

@ >>

@
2012 > > > @ = > > «.ts» @ @

6

http://www.typescriptlang.org/:

٢٥Explicit ٢٦Classes

Type Annotation

٢٧Interfaces ٢٨Statically ٢٩Type

Typed Language

Safety

٣٠auto-completion

10

C# @

:

> >

@

@

http://www.typescriptlang.org/Playground/
@ @ @ . @ > » .> @
33

> @ » < » @ > > . < «34 >« @ » > @ > .> > > > >

@

@

@ > @ @

C#

>«31

@ @

> . . > « » > > .

«32

> «

Node.JS
« > » »

-

/// Var example = new Dependency.MyClass();
>

RequireJS

«

»

> .

> >

@

@

import

> NodJS

Import dependency = module('Dependency'); Var example = new dependency.MyClass();
>. ( > @ « > > » >

import >

>

RequireJS) CommonJS<

٣١namespace ٣٢Module

Loader

٣٣Dependencies ٣٤reference

comment

11

C# @

>

> .

@

.(

>

NodeJS )AMD
> > > >

AMD CommonJS

@

@

@

@

Var dependency = require("./CommonJSDependency"); define(["require", "exports", 'AmdDependency'], function (require, exports, __dependency__) { Var dependency = __dependency__; } )
@ > > . > ""

‘’
.>

>

<

@ @

@

@

RequireJS

CommonJS >
. @ >

.>

12

C# @

35

>>

7

>. > >

undefined null > ( @ >> . >> @ @ [] . > @ >< > >
36

@ @ )

>> >

.

any

@ >> > dynamic @

@ . > ( )

C#

>>

@

string[]

.

>

>

>

> @ >>

37

>>
@

>
> >> >

7.1

>

@

< . > @

.

>

>

@ >>

Var myString = 'A String'; var myNumber = 1; var myBoolean = true;
> @ . @ >> > @ > @ @ >> > > @ <

٣٥Types ٣٦Dynamic Type ٣٧Type

Inference

13

C# @

.

>

@

Var example = { name: 'Example', id: 5, collection: ['a', 'b', 'c'] }
"id" > . < > > @ @ @ < > > < > . > > > "example." > "Collection"

example string @

"example.collection."> >> >

.
> > .> > > > > > @

.> > > @

> . >(

@

>

< >>

>

@ >>

>

)

>

Var unknown; unknown = 'A String';
>> 38« > > @ » . >> >< > "any" > >

unkown C# >
.

>

dynamic > >

>>
@ > < > >> >

@ @

7.2

٣٨Type safety

14

C# @

@ >> «:» . .> > > >> @
39

C#

.

>

>>

@ > >> @ @ > @ >> @ <

<

> >> > @ < >

> @ > <

>

.> @ < > > .

Var myString: string = 'A String'; Var myNumber: number = 1; Var myBoolean: boolean= true; Var example: { name: string; id: number; collection: string[]; } = { name: 'Example', id: 5, collection: ['a', 'b', 'c'] } Var unknown: any;

٣٩Interface

15

C# @

42

41

8

C# > «43

@

»

>

> < @ > > exported

.

.

>

@

@ « @ > > . » @

>.

C# @
> «44

> » >.

> >

> 46 45

.

private public @
. @ >

> @ <

> @ @

> . @ . >
48 49 47

>

>@ >

> > >

٤٠ ٤١ ٤٢ ٤٣

Modules Classes Interfaces Namespace

٤٤Prototype-based object system ٤٥Constructor ٤٦Property ٤٧Private ٤٨Public ٤٩Access

Modifier

16

C# @

@ >

< <

@ «

@ >@

@ > » >

>

» < «.>

ModuleShapes { export interface IPoint { getDist(): number; } export class Point implements IPoint { constructor(public x: number, public y: number) { } getDist() { returnMath.sqrt(this.x * this.x + this.y * this.y); } Static origin = new Point(0, 0); } } Var point = new Shapes.Point(50, 243); Var dist = point.getDist();

>< @ @

> @ @ > @ > .C# > @

> .

@

@

> export @ > >

@

> .

=> >

>

implements

extends @

Module Animals {

17

C# @

export class Animal { constructor(public animalName) { } move() { returnthis.animalName + ' the animal moves'; } } export class Snake extends Animal { constructor(animalName) { super(animalName); } move() { returnthis.animalName + ' the snake slithers'; } } export class Cat extends Animal { constructor(animalName) { super(animalName); } move() { returnthis.animalName +' the cat cannot be bothered to move'; } } } Var slippy = new Animals.Snake('Slippy'); alert(slippy.move());

18

C# @

@ >

@ [ > @ > @ < @

@ >

] >@ .

> >

this @
@

super @
> .> =

50

@ < <

> .>

@ > «.»

@

@ <

.

> >

> > > C# > using >

.

@

ModuleProgram.Utilities.Logging { export class Console { log(message: string): void { if(typeofconsole !== 'undefined') { console.log(message); } } } } Var logger = new Program.Utilities.Logging.Console(); logger.log('Test message.');

٥٠Override

19

C# @

51

9
9.1
> .

54

@
@ >@

53

@
@

< @

52

@

<

@

>

@

.

>>

C#

> .

@ >> @ @

.>

>

«=» . @

@ @ @

@ @

moduleParameters { export class Example { optionalParameter(name?: string) { returnname; } } }
> => . >> > @ > >> > > @ @

moduleParameters { export class Example {

٥١Functions ٥٢Optional

Parameter

٥٣Default Parameter ٥٤Rest

Parameter

20

C# @

defaultParameter(name: string = 'Default') { returnname; } }

}
> @ . >> .> «...» > @ > < @

moduleParameters { export class Example { restParameter(...name: string[]) { returnname.toString(); } } }
> > .> @ . @>

C#

> string.format >

< @ @ >

. > moduleSystem { export class String { staticformat(formatString: string, ...args: any[]) { // ... } } }
21
C# @

System.String.format('My {0}{1} format example', 1, 'st');
> @ @ @ @ >

Java C#
.> > @ >@

> @ >

>

.

.
@ ] > > > < > @

@

>

@

C# >
4 @> " @
55

Whatever"
< @ >>

@ .["Mr."

C#

> >=

.

string.Empty >
> > @ <

.

@

>@

findLastIndex(predicate: (T) =>boolean, index: number = this.length): number { for(vari = index; i > -1; i--) { if(predicate(this.list[i])) { returni; } } return-1; }

٥٥Instance

22

C# @

> > > @ >

>

< > > >@ @ @ >@ < @ @ . < .

> List @

> >

this.length
. > < > @

:

56

(index: number = this.length) (index: number = this.someMethod()) (index: number = this.someDependency.someMethod()) (index: number = StaticClass.someMethod())
> .>> @ @ @ < > .> . > > > > > > > < @ @ >

List.prototype.findLastIndex = function (predicate, index) { if (typeof index === "undefined") { index = this.length; } for(var i = index; i > -1; i--) { if (predicate(this.list[i])) {

٥٦Static

23

C# @

return i; } } return -1;};

@
> @ > » ) >. @ > > . @ > . >

9.2
@

C#

> @ @ >. @ @ >

> >> > > @ > (>

>

C# >
->

@
57

«@

number string
.

>

any

>>

moduleOverloads { export class Example { overloadedMethod(input: string); overloadedMethod(input: number); overloadedMethod(input: any) { return input.toString(); } } } Var example = new Overloads.Example(); example.overloadedMethod(1); example.overloadedMethod('A String');
٥٧

implementation signature

24

C# @

25

C# @

58

@ >>
> @ >>

10

>

>.

C# >

>> . @ >

enum >

Enum States { Solid, Liquid, Gas } Enum Sizes { Small = 3, Medium = 5, Large = 8 }
.

States

>>

>

Var States; ( function(States) { States._map = []; States._map[0] = "Solid"; States.Solid = 0; States._map[1] = "Liquid"; States.Liquid = 1; States._map[2] = "Gas";

٥٨Enumeration

26

C# @

States.Gas = 2; })(States || (States = {}));
>> > > >> @ @ @ >

States._Map
> .

> . >>

. >> @

Var state = States.Liquid; alert((States)._map[state]); // "Liquid"

27

C# @

59

@

>>

11
>

> >

> @ >> @

> > .

@ >>

C#

>

@ >>

>>

. moduleGenerics { interfaceIExample { getById(id: number): T;

} Class MyClass { constructor() { } } classExample implements IExample { getById(id: number) { return new MyClass(); } } }

@
>= >. >> @ >> > >> > extends @ @ @

>>

> >>

11.1
C# >

where @
> > . > @

C# >

@ >>

@

«< > »

٥٩Generics

28

C# @

>

@

> >

IMyInterface

>>

> @ >

@ >> @ >

IExample
.

. moduleGenericConstraints { export interface IMyInterface{ name: string; } export interface IExample { getById(id: number): T; } export class MyClassimplements IMyInterface{ publicname: string; constructor() { this.name = 'A string'; } } export class Example implements IExample { getById(id: number) { return new MyClass(); } } }
@ >> @ @ . > > > > >
C# @

@ >>

@

>

29

>

> > ClassTwo

Classone @

>> .> > > >

>

. interfaceISuperInterfaceextends ClassOne, ClassTwo { }

export interface IExample { getById(id: number): T; }
Additionally, you can specify a type constraint that is also generic.

interfaceINested { }

30

C# @

60

>>

@
@ >> =

12
C# > > >

@
61

@ >> > @ >> >. > > > . = > >> @ > >. @ < > @ > >>

>> >

@ .>

@

C#

> >< @ >> >

>

@

ClassB ClassA
@ >

public class ClassA { public string SomeMethod(string name) { return name; } } public class ClassB { public string SomeMethod(string name) { return name; } }
> @ . > >

٦٠Structural

Typing

٦١Compatible

31

C# @

@

< >>

. >

>

ClassA @
>>

ExampleC ClassB
>

. classClassA {

SomeMethod(name: string) { returnname; } } classClassB { SomeMethod(name: string) { return'Arbitrary value'; } } Var ExampleC = function () { this.SomeMethod = function (name: string) { returnname; } } varproof: ClassA = new ExampleC();

@ >> > > >@ > @ >>

> >> .

@ >> >> >

.

32

C# @

@ >>

@

@

.>
. >>

>

C# > 63
@

@

>> )

@

>> >

62

>> >>

>

>@ (

.

>

Var objA = { firstName: 'Steve', lastName: 'Fenton' }; Var objB = { firstName: 'Mark', lastName: 'Jones' }; Var objC = { firstName: 'James', lastName: 'Llang' }; // { firstName: string; lastName: string; }[] Var arrayA = [objA, objB, objC];
:> >> >

{ firstName: string; lastName: string; }

٦٢Type

Interface Types

٦٣Anonymous

33

C# @

>> > . >

@ > FirstName @ @ >> @ >>

@

> @> .

> . @ > >> @ >>

.>

>

Var objA = { firstName: 'Steve', lastName: 'Fenton' }; Var objB = { firstName: 'Nick' }; // { firstName: string; }[] Var arrayB = [objA, objB];
. > > « > @ >> @ > >> > < > » @ > @ >>

. varobjD = { firstName: 'Nick' }; // Not allowed //objD.lastName = 'Llang';

34

C# @

64

>@
@ @ @ >

>

13

>

> @ >

> <

> >> .

>@ .

>

@

> @ <
65

@ Export @ @ > >> @ < > >

>

> . . >

@ > >

export @
@ >> .

@ > > > @ >

>@ > . > @

>

.

Private @
> > @ >> @

public @
. >

moduleAccessModifiers { // A private class (no export keyword) classPrivateClass { //... } // A public class export class PublicClass {

٦٤Access

Modifiers

٦٥Private

35

C# @

privateprivateProperty: string = 'Private'; publicProperty: string = 'Public'; implicitPublicMethod() { return'Public'; } publicexplicitPublicMethod() { return'Public'; } privateprivateMethod() { return'Private'; } } } Var publicClass = new AccessModifiers.PublicClass(); alert(publicClass.publicProperty); // Not allowed //alert(publicClass.privateProperty); // Not allowed //var privateClass = new AccessModifiers.PrivateClass(); >@ > > >

Protected
<

internal @

>

@ @

> @

>

.

36

C# @

moduleInheritanceAccess { classBaseClass { publicProperty = 'Public'; privateprivateProperty = 'Private'; } classMyClassextends BaseClass { myMethod() { super.publicProperty = 'Public'; // Not allowed //super.privateProperty = 'Private'; } } }

37

C# @

14
.> >
66

@ >> @ > @ @ @ < >> >>

> .> > .Net .>> @ > < @ @ >

@ @ > > >@ @ @ > @ < > > < @ @ @ @ > > > @ .>> > >

-

.
< > > >

C#

. > < @ > < >> . @
67

> . >

@

@

@ . > > .>

>

14.1

٦٦ Garbage Collector ٦٧ Mark and sweep

38

C# @

@ .> @

> @

> > <

<

>> > >

@ >> >

>

@

14.2

> < @ @ @ >

>

< @ >

@

> > > >

C#
>

.>

>

.>

>

>

>

39

C# @

>
> @ @ > > @
69

>

14.3

Node.Js >

@ @ @
68

.

>

> «>

> @ . »

<

@> @ . > >

Var sensorChange = function (proximity) { Var proximity = proximity.near ? 'Near' :'Far'; alert(proximity); } window.addEventListener('userproximity', sensorChange, true);
> . >> > > > @ @ @ > @ . >@ @ . > finally . > >
70

@>

>

Node.Js >
> >

>

Try/finally @
?

< > > Try

varfile = File.open(); try{ file.write('Example');

٦٨Callback ٦٩

Proximity API

٧٠Event

40

C# @

} finally { file.close(); }

41

C# @

71

15
>

>.

> > >> @

throw@
@ .

> @ >>

>

>

>

Throw

.>

>

Error

throw

Throw (new Error('An error has occurred.'));
> @ < @ @ > > @ @ > . < > . >

Error

> @ >> @

@ .

@

>

Catch

>

Class ExampleError implements Error { Public name: string = 'ExampleError'; constructor (public message: string) { } }
. >

Try-catch @
<

>

@

. try{ >

@ catch

C#

>

>

if(true) { throw(new ExampleError('An error has occurred.')); }

٧١Exceptions

42

C# @

} catch (error) { switch(error.name) { case'ExampleError': alert(error.message); break; default: throw error; } }
. >

finally

@ @

>

@

@ >@

. >>

finally

43

C# @

72

16
0.9 >

@ . > .

@ >

@ «[]»

>>

@ >> > >> >> @ >>

. Class MyType { constructor(public name: string) { } } Var simpleTypedArray: string[] = []; Var complexTypedArray: MyType[] = []; //simpleTypedArray.push(2); // not allowed simpleTypedArray.push('Some String'); var arrayItem = simpleTypedArray[0]; // string
>@ > >> @ @ @ > > .> > > @ >

>

C# >

>

Class List { private list: T[] = []; constructor(list?: T[]) { this.list = list || []; } getlength(): number {

٧٢arrays

44

C# @

returnthis.list.length; } add(obj: T): void { this.list.push(obj); } addRange(...items: T[]): void; addRange(items: T[]): void; addRange(items: T[]): void { this.list = this.list.concat(items); } clear() { this.list = []; } contains(obj: T): boolean{ for(var i = 0; i TOutput): List { Var list = new List(); For (var i = 0; i boolean): T { for(var i = 0; i boolean): T { var results = new List(); for(var i = 0; i boolean, index: number = 0): number{ for(var i = index || 0; i boolean, index: number = this.length): number { for(var i = index; i > -1; i--) { if(predicate(this.list[i])) { returni; } } return-1; } forEach(action: (obj: T) =>any): void { for(vari = 0; i . > @ @ @ > >. > >

List
@

.Net >

Var list = new List(['One', 'Two']); alert(list.length.toString()); // 2 alert(list.getItem(1)); // 'Two' list.addRange(['Three', 'Four']); alert(list.length.toString()); // 4 // Example using rest parameters overload

48

C# @

list.addRange('Five', 'Six'); // Example using the array overload list.addRange(['Seven', 'Eight']); var stringList = new List(['12', '12', '3']); stringList.forEach(function (str: string): void { alert(str); } );

49

C# @

17
@> > Date @ > > 00:00:00 1970 1

.>

Date

.

// Year, Month, Day Var myDate = new Date(2012, 05, 12); // Year, Month, Day, Hours, Minutes, Seconds, Milliseconds Var myDateTime = new Date(2012, 05, 12, 15, 33, 10, 100);

@> 1970 1

@

ISO RFC
> > >

> > > @ > 00:00:00

.

Var dateFromRfc = new Date('12 Dec 2011 00:50:00 +0000'); Var dateFromIso = new Date('2011-01-31T18:30:00'); vardateFromNumber = new Date(1369251402587);

Now 17.1

> @

@ >

.

>

Date.now() Date
> . >

>@

Var now = new Date(Date.now());

50

C# @

@
@ > > > >. < . 1> 0> > > @ @ > . @ >> >@ > Date @ >. ( )

17.2

>

UTC
1> @

getUTCMonth >

getMonth@
73

>

>

Var year = now.getUTCFullYear(); Var month = now.getUTCMonth() + 1; Var date = now.getUTCDate(); alert(year + ' ' + month + ' ' + date);
> . < >< < = 3 >> @ @ < : > > > . @ . @ @ > > 2013 > @ UTC

getUTCDay getDay @
1> < > > 0> > @

alert(now.toDateString()); // Mon Jun 03 2013 alert(now.toISOString()); // 2013-06-03T21:25:05.531Z

٧٣Zero

base

51

C# @

alert(now.toJSON()); // 2013-06-03T21:25:05.531Z alert(now.toLocaleDateString()); // 03 June 2013 alert(now.toLocaleString()); // 03 June 2013 22:25:05 alert(now.toLocaleTimeString()); // 22:25:05

52

C# @

74

>
> >

18

>

@

@

< .

75

@ @ > > > @ @ >
76

>

@

>

>

@

.

@ >
> .> .> .> >> >> .> .> > > > . > .>> < > > @> @ @ > @ @> @ @ @ @
78

18.1

> 77

Onblur Onclick Ondblclick
@

onfocus Onmousedown Onmousemove Onmouseover Onmouseout Onmouseup

٧٤Events ٧٥Document ٧٦Mouse ٧٧Element ٧٨Double

Object Model API

Click

53

C# @

@ >
> .> > > .>> > > > > > > @ @ @

18.2

Onkeydown Onkeypress Onkeyup

>
> . . .> .> > @ @ @ @ @ @

18.3

Onload Onresize Onscroll Onunload

@ >

18.4

>
. @ >> > .> .>> @ @

Onchange Onreset Onsubmit

54

C# @

79

@ >

18.5

@>

.>

>

>

80

>> .

@ > 82 > @ <
81

.

>

>

classListenerOne { constructor() { document.addEventListener('myCustomEvent',this.eventListener); } eventListener(e: Event) { alert('Event caught by ListenerOne'); } }
: > @

export class TriggeringClass { triggerEvent() { var evt = document.createEvent('Event'); evt.initEvent('myCustomEvent', true, true); document.dispatchEvent(evt); } }
٧٩

Custom

٨٠Dispatch ٨١Listener ٨٢

Dispatchers

55

C# @

.

>

@

>>

@

<

>

>

>

18.6
@ . 5 . > @ > >@ @ 5 @ > > @ . ( ) > @ @ >> > @ > @ .> > >

.> @

eventListener(e: Event) { window.setTimeout(longRunningMethod, 0); }
@ @ > @ @ @ > @ .

.

>

@

56

C# @

83

19

>> . > . <

> > > > @ @ >

@ @

C:\Program Files (x86)\MicrosoftSDKs\TypeScript\lib.d.ts.
@ @ >@ >> > @ @ . @ > > > >> @ . . > ClientRectList > > @ > >>

interface ClientRectList { length: number; item(index: number): ClientRect; [index: number]: ClientRect; }
> . > >

ClientRectList >
@ > @ >

isOrdered
< >

interface ClientRectList { isOrdered: boolean;}
> . > > @ @ >@

.>

>

>

٨٣Framework

57

C# @

> > .

> . > length isOrdered > @ @ > @ >> >

ClientRectList
> >< > C# @

@

Item
@

< >

.> @

.> > > @ @ > > > > >

@ > . >

@

@

>

>

Angular
> > @ @ .

Knockout onGitHub >

@

@

58

C# @

84

20
>

.> > @ >

@ > >>

> > > >

.

@

.

20.1
@ @ > @ @> @ @ > @ > . @ >

any @

@ .>

.> >
Declare var$: any; $.anythingYouLike();
>@ > > .> @ > >> .

>

> >>

declare
> >. >

> @ > <

>

@

>>
@ @ .> > @ < @

@
>

20.2
@

٨٤ Creating Definitions

59

C# @

@

> @ @ . . @ >

< . > > declare @ > > > >

declare module ExternalToolKit { export class ExternalClass { static externalProperty: bool; static run(iterations: number, text: string): void; } } ExternalToolKit.ExternalClass.run(5, 'Hello World');
@ > @ @ @ > > . @ > . @ @ > @ @

declare class CanBeExtended { run(): string; } declarevarlib1: CanBeExtended; interfaceCannotBeExtended { run(): string; } declarevarlib2: CannotBeExtended;
@ @ >> @ > > @ @ > > @ > > > >. @ > >> >. >

60

C# @

>

@ @ . @ >

.

>

@ >

>

>

> @

.

interfaceAmazingMove { (x: number, y: number): void; up(distance: number): void; down(distance: number): void; left(distance: number): void; right(distance: number): void; } interface Amazing { move: AmazingMove; } declarevaramazing: Amazing; amazing.move(40, 30); amazing.move.up(40);
>> @ @ > @ @ @ @ . > > > > Amazing @

Amazing
. >@ > @

>

Angular RequireJS - Knockout - jQueryto
.

61

C# @

@ >
.> > > @ @ C# > . .

21 21.1
>

>>
> @

>

<

>

classTypes { staticgetType(inputClass) { var funcNameRegex = /function (.{1,})\(/; var results = (funcNameRegex).exec(( inputClass).constructor.toString()); return(results &&results.length> 1) ? results[1] : ''; } } Class Example { } Class AnotherClass extends Example { } Var x = new Example(); Var y = new AnotherClass(); alert(Types.getType(x)); // Example alert(Types.getType(y)); // AnotherClass

62

C# @

.

>

>

javascript
> . > .> > .

getType @
> @ <

MyModule.Example,SomeOtherModule.Example

Example @

>> lib.d.ts
@ @ @ > > > . @ . > . > > > NodeLies @ > > . > < > . >

21.2

>

Onclick >

Document.querySelectorAll

NodeList.prototype.onclick = function (handler) { for(var i = 0; i > >>
85

@ > @ .>

h

onClick

NodeList

٨٥

Warning

63

C# @

.> >

NideList

interfaceNodeList { onclick: (handler: Function) =>void; }

lib.d.ts
> @ >

> > >

>

<

> >> < @

> < < .> > > .> >

64

C# @

Similar Documents