-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Suggestion about decorators #53411
Comments
Because that's not what they are there for. Decorators are a JavaScript feature, not a TypeScript one. JavaScript has no interfaces, so there's nothing the decorator can decorate. A few options you have:
|
Isn't TypeScript supposed to be a superset of Javascript? You should have some vision and bring some transcendental value to this great invention. Currently, at least pre 5.0, decorators on interfaces can be correctly parsed with a warning. I simply suggest you keep it that way because it won't break anything. And secondly, it will bring tremendous value beyond simple Javascript transpilation!
|
@MartinJohns, TypeScript/src/compiler/factory/utilities.ts Line 1130 in f2df10f
So apparently TypeScript has been very thoughtful about this matter. Though it appears that there had been a code change to rename "decorators" into "illegalDecorators" for some classes, which I will need to look into details later. |
Duplicate #2900 |
This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
Suggestion
Relax syntax restrictions on decorations. At least do not remove parser support for decorators on interfaces.
I wouldn't mind parser-generated warnings because those can be suppressed. But if TypeScript stops parsing decorators on interfaces and interface members I will be really disappointed.
🔍 Search Terms
decorator syntax restriction interface
✅ Viability Checklist
My suggestion meets these guidelines:
⭐ Suggestion
TypeScript works great as an "intermediate programming language", which is always transpiled into other languages.
Let's keep it that way! And make sure the design meets the requirements.
I would suggest TypeScript keep decorators on interfaces and interface members.
📃 Motivating Example
I am using TypeScript to transpile to Lua. And I need decorators on interfaces.
💻 Use Cases
Why can't decorators just "decorate"? It doesn't have to be meaningfully executable at all! After all, it is what meta-programming is about.
The text was updated successfully, but these errors were encountered: