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

Feature suggestion: Optionally emit property names #33197

Closed
htinc opened this issue Sep 2, 2019 · 6 comments
Closed

Feature suggestion: Optionally emit property names #33197

htinc opened this issue Sep 2, 2019 · 6 comments
Labels
Duplicate An existing issue was already created

Comments

@htinc
Copy link

htinc commented Sep 2, 2019

Hello Team,

I've created a lot of generic solutions with TypeScript but always struggled with this one. Is there a way to get all properties defined in TypeScript, but at runtime. For Example

class Car { name: string; }

will compile to var Car = /** @class */ (function () { function Car() { } return Car; }());

Could there be a compiler option which would emit

var Car = /** @class */ (function () { function Car() { this.name = null; } return Car; }());

This would allow us to create better generic solutions with Typescript. I searched a lot and maybe used the wrong search terms, but I could not find a solution to this.

@AnyhowStep
Copy link
Contributor

undefined is better than null

@ark120202
Copy link

With recent changes to the proposal (see #27644) that would be standard behavior (with undefined instead of null and [[Define]] instead of [[Set]]).

@sandersn
Copy link
Member

sandersn commented Sep 3, 2019

As @ark120202 points out, at this point, this is basically a duplicate of #27644, since the new property emit will be something like Object.defineProperty(this, "name", undefined) for name: string.

@sandersn sandersn added the Duplicate An existing issue was already created label Sep 3, 2019
@typescript-bot
Copy link
Collaborator

This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes.

1 similar comment
@typescript-bot
Copy link
Collaborator

This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes.

@typescript-bot
Copy link
Collaborator

This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

5 participants