-
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
Decorator type metadata #2589
Decorator type metadata #2589
Conversation
…ate functions due to merge conflict
…te and __metadata
// | ||
function emitDecoratorArray(decorators: NodeArray<Decorator>, writeComma: boolean, prefix?: string, postfix?: string): boolean { | ||
if (decorators) { | ||
let decoratorCount = decorators ? decorators.length : 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you already check for decorators is truthy.
function checkParameterTypeAnnotationsAsExpressions(node: FunctionLikeDeclaration) { | ||
// ensure all type annotations with a value declaration are checked as an expression | ||
if (node) { | ||
forEach(node.parameters, checkTypeAnnotationAsExpression); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will stop with the first checkTypeAnnotationAsExpression that returns something 'truthy'. Is that what you wanted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
checkTypeAnnotationAsExpression returns undefined
, so generally this is fine. I have been periodically migrating these to for..of
since its available in the compiler now, though it wasn't when this was originally written.
for (var i = 0; i < parameterCount; i++) { | ||
if (parameters[i].dotDotDotToken) { | ||
var parameterType = parameters[i].type; | ||
if (parameterType.kind === SyntaxKind.ArrayType) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we're doing this stuff syntactically only? Is that ok? Should we consider using the type information isntead?
Experimental support for decorator type metadata. NOTE: Requires a polyfill for `Reflect.metadata` which has not yet been considered by TC39 for ES7.
Resolves #2577
Adds support behind an experimental compiler option to emit design-time type metadata for decorated declarations in source.
__metadata
helper that depends on a polyfill for a proposedReflect.metadata
decorator.__param
helper decorator used to apply parameter decorators after metadata is applied and before the method's decorators are run.__metadata
for class and member (property and method) decorators--emitDecoratorMetadata
).A few notes on metadata: