-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
TypeScript 1.5 - Metadata Annotations / Interfaces #2305
Comments
See #2249 and the proposal for decorators in ES7. As for type serialization, interfaces will actually not carry any metadata (they will just represented as the |
Thanks @DanielRosenwasser for the info!!! I think I understand a little better now what's happening... it all looks great EXCEPT the interfaces... don't you think it's a serious problem that there's no way to query metadata for interfaces? In my case for example I would never ever do the first example I gave above. Instead I would always do the second which is program against an interface, and I would dare say this is usually the norm rather than the exception among devs. At the very least you guys could write out the fully qualified name of the interface. I never really understood why you guys don't produce a JS function for TS interface declarations. One other question I have... is TS going to always automatically generate basic metadata about TS classes OR do we always have to create and use decorators for this? For example, I believe AtScript was going to always generate metadata about the constructor function's parameter types without the developer having to do anything (see "Metadata Annotations" section of https://docs.google.com/document/d/11YUzC-1d0V1-Q3V0fQ7KSit97HnZoKVygDxpWzEYW0U/mobilebasic?viewopt=127). Is TS going to do the same? I hope so.... Thanks again |
since i got no response i guess it's best to close this item and ask my follow up questions in a new item. |
@giancarloa I found this article very helpful: https://smellegantcode.wordpress.com/2015/04/02/typescript-1-5-get-the-decorators-in/ Here is the example in Playground:
|
Maybe this should be renamed as asking for documentation for annotations? I tried to find annotations from handbook, there is no mention of "@", "decorator" or "annotations". Also noticed the language spec is TS 1.4 so it wasn't helpful either. |
@Ciantic I agree that we need to improve our documentation - the handbook is fairly outdated. We're currently fixing it up, and decorators are one of the new topics we intend to write about. |
Hi there... I am struggling trying to find documentation on the TypeScript metadata annotation features that are apparently coming in 1.5... my question is how will interfaces work with metadata annotations knowing that TS interfaces have no runtime form???? take the following TS code:
class Server{
}
class Client{
constructor(svr: Server){
}
}
I have not been able to find much detail on how TS will handle this, but based on the old AtScript documentation, I believe the transpiled JS code will look something like this:
function Server(){
}
function Client(svr){
}
Client.parameters = [{is: Server}];
That's all fine and good but what will the JS look like if the TS is like that below whereby we introduce an interface??????
class IServer{
}
class Server implements IServer{
}
class Client{
constructor(svr: IServer){
}
}
The text was updated successfully, but these errors were encountered: