Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TypeScript 2 support #107

Merged
merged 1 commit into from
Feb 27, 2017
Merged

Add TypeScript 2 support #107

merged 1 commit into from
Feb 27, 2017

Conversation

likerRr
Copy link
Collaborator

@likerRr likerRr commented Feb 24, 2017

No description provided.

@likerRr likerRr mentioned this pull request Feb 24, 2017
@hustcc
Copy link
Owner

hustcc commented Feb 27, 2017

I have never use TypeScript.

What's the meaning of code <reference types="jquery" />?

@likerRr
Copy link
Collaborator Author

likerRr commented Feb 27, 2017

Typescript is typed (optionally) language and for better support we should help ts' compiler with typings. Literaly saying it allows typescript use jquery selector as a parameter for render method. You can see a line:

render<T>(nodes: Node|NodeList|JQuery, locale?: string): void;

That means render method can accept a single node (Node), an array of nodes (NodeList) or a jquery selector (JQuery). But unlike Node and NodeList which are native constructors, typescript know nothing about JQuery (because it's not native constructor).

By doing this <reference types="jquery" />, we are saying to ts compiler: "man, this file depends on jquery typings and probably there you can find definition of JQuery constructor". "Probably" - because it could be several references. Also we include this definition for jquery as a dependency: @types/jquery": "^2.0.40. Don't worry, this dependency will be installed by the client (by doing npm install) but it will never be included in project sources.

Typescript definitions are only files that help ts' compiler understand which libraries are in project.

@hustcc
Copy link
Owner

hustcc commented Feb 27, 2017

Got it.

@hustcc hustcc merged commit 435845d into master Feb 27, 2017
@likerRr likerRr deleted the ts-support branch February 27, 2017 08:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants