Typescript: IMPLEMENT GET SET similar c# "NOT DUPLICATE"

Created on 6 Oct 2017  ·  9Comments  ·  Source: microsoft/TypeScript

class Car{

public name {get; set; }
public marca {get; set;}

}

var c = new Car();

c.name = "fusca"; //SET

console.log(c.name); //GET

In case the compiler only needs to remove the
{get; set;} and set a common variable what do they think?

Duplicate

Most helpful comment

already discussed in #7628 mate..

One reason for this design tenet is that TS wants to stay compatible with future JS standards.

What if in the future JS chooses a different syntax for simplified properties? This happened in the past with modules and it was a little messy to recover from. Worse: what if JS introduces a new syntax that is plain incompatible with your proposed syntax?!

As kitsonk said, you probably should raise your voice at TC39 first so that the idea can trickle down from JS to TS.

the nearest that even got votes from the contributors is this #2763 where it considered its translation, compatibility and benefit towards .JS.

All 9 comments

Hey, thanks for filing, but this seems to be a duplicate of #10911

In the future using the issue tracker's search functionality can make it easier for us to triage issues. Thanks!

That applies to decorators who yes is a useless implementation does not make sense even by how decorator the expression is simple

"public name {get; set;}"

example is decorators

"@get public name"

7628

Where in the typescrypt compiler is the class counter in the typescrypt core so I can commit it and you see it's simple

typescrypt.

class Car {
   
   public name {get; set;}

}

javascript example

var Car = function (...) {

     Car.prototype.name = null;

}

public name {get; set;} not is function !!!

default ->>
get : any
set: any

or

public name {get:string;set:any}

already discussed in #7628 mate..

One reason for this design tenet is that TS wants to stay compatible with future JS standards.

What if in the future JS chooses a different syntax for simplified properties? This happened in the past with modules and it was a little messy to recover from. Worse: what if JS introduces a new syntax that is plain incompatible with your proposed syntax?!

As kitsonk said, you probably should raise your voice at TC39 first so that the idea can trickle down from JS to TS.

the nearest that even got votes from the contributors is this #2763 where it considered its translation, compatibility and benefit towards .JS.

I'm just sorry

Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

siddjain picture siddjain  ·  3Comments

DanielRosenwasser picture DanielRosenwasser  ·  3Comments

fwanicka picture fwanicka  ·  3Comments

MartynasZilinskas picture MartynasZilinskas  ·  3Comments

zhuravlikjb picture zhuravlikjb  ·  3Comments