What does the at sign mean in the latest TypeScript presumably v1 5 example

0 votes

A very interesting image has been posted on the official TypeScript blog.

Wierd syntax

I'm curious what the @ (at sign) symbol is doing there since it can't be used in JavaScript identifiers (as far as I know).

Aug 1 in TypeSript by Elton
• 400 points
11 views

1 answer to this question.

0 votes

The big news this week is the merging of AtScript and TypeScript.

The following example from the AtScript documentation...

@Component()
class MyApp {
  server:Server;
  @Bind('name') name:string;
  @Event('foo') fooFn:Function;
  @Inject()
  constructor(@parent server:Server) {}
  greet():string {}
}

Compiles into the following JavaScript...

function MyApp() {}
MyApp.properties = {
  'server': { is: Server },
  'name': { is:string,
            annotate: [new Bind('name']},
  'fooFn': { is:Function,
             annotate:[new Event('foo')]}
}
MyApp.annotate = [
  new Component(),
  new Inject()
];
MyApp.parameters = [
  {is:Server, annotate:[parent]}
];
MyApp.prototype.greet = function() {}
MyApp.prototype.greet.returns = string;

AtScript was planned to be a layer on top of TypeScript (i.e. a super-set of a super-set) - but now the two projects are one.

Annotations are described thus:

  • AtScript annotation syntax is just a shorthand of placing the same information in ES5. It would be reasonable for an ES5 developer to write these annotations manually. A helper library could even be provided.
  • Annotations can only be placed on functions.

  • An annotation placed on a class is an annotation placed on the class’ constructor function.

  • An annotation placed on a field gets moved to the constructor function.

  • All annotations are translated as properties on a function.

answered Aug 3 by Abhinaya
• 760 points

Related Questions In TypeSript

0 votes
1 answer

What does the @ (at sign) sign do in TypeScript?

The big news this week is the ...READ MORE

answered Jun 10 in TypeSript by Nina
• 3,020 points
23 views
0 votes
1 answer

What does the ! (exclamation mark) do in TypeScript?

The exclamation mark is called the non-null ...READ MORE

answered Jun 1 in TypeSript by Nina
• 3,020 points
127 views
0 votes
1 answer

What do square brackets mean in a type definition in Typescript?

I've missed a basic type of TypeScript: Tuples. So ...READ MORE

answered Jun 22 in TypeSript by Nina
• 3,020 points
72 views
0 votes
0 answers

What is a type in Typescript for the Component class in Angular 2+?

I have a small problem, but big ...READ MORE

Jul 5 in TypeSript by Logan
• 2,140 points
12 views
0 votes
1 answer

How to set meta tags using Angular universal SSR and ngx-seo plug-in?

first Install the plug-in with npm i ngx-seo ...READ MORE

answered Feb 11 in Others by narikkadan
• 11,280 points
704 views
0 votes
0 answers

Can't bind to 'ngModel' since it isn't a known property of 'input'

I have this  input in my component ...READ MORE

Apr 29 in Other DevOps Questions by Kichu
• 19,040 points
143 views
0 votes
1 answer

VS Code enforces semicolons, but why doesn't Angular and TypeScript not use it consistently?

JavaScript has a syntactic feature known as semicolon ...READ MORE

answered May 31 in TypeSript by Nina
• 3,020 points
48 views
0 votes
1 answer

Square brackets around vs after expression in Typescript

x is an Array, while y is a Tuple. The ...READ MORE

answered Jun 7 in TypeSript by Nina
• 3,020 points
126 views
0 votes
1 answer

What is the question mark for in a Typescript parameter name?

It is to mark the parameter as optional. TypeScript ...READ MORE

answered Aug 3 in TypeSript by Abhinaya
• 760 points
12 views
0 votes
1 answer

The Angular Compiler requires TypeScript >=3.4.0 and <3.5.0 but 3.5.3 was found instead

Run this script to find exact version npm ...READ MORE

answered Aug 3 in TypeSript by Abhinaya
• 760 points
11 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP