GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Decorator type metadata by rbuckton · Pull Request #2589 · microsoft/TypeScript

Conversation

@rbuckton

@rbuckton Ron Buckton (rbuckton) commented Apr 2, 2015

Copy link
Copy Markdown
Contributor

Resolves #2577

Adds support behind an experimental compiler option to emit design-time type metadata for decorated declarations in source.

  • Adds a __metadata helper that depends on a polyfill for a proposed Reflect.metadata decorator.
  • Adds a __param helper decorator used to apply parameter decorators after metadata is applied and before the method's decorators are run.
  • Emits calls to __metadata for class and member (property and method) decorators
  • For a class declaration, emits the type metadata for constructor parameters of the constructor with a body.
  • For a method declaration, emits the type metadata for the member, its parameters, and its return type.
  • For an accessor or property declaration, emits the type metadata for the member.
  • Adds compiler option to enable experimental metadata support (--emitDecoratorMetadata).

A few notes on metadata:

  • Type metadata uses the metadata key "design:type".
  • Parameter type metadata uses the metadata key "design:paramtypes".
  • Return type metadata uses the metadata key "design:returntype".

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

idchlife reacted with heart emoji
All reactions
  • ❤️ 1 reaction
Ron Buckton (rbuckton) added 12 commits March 25, 2015 17:23
@rbuckton
Type serialization for decorators
2a907a9
@rbuckton
Updated baselines
a1d445e
@rbuckton
Minor emit cleanup
71803c6
@rbuckton
Type serialization for decorators
9aa3af8
@rbuckton
Updated baselines
2b78424
@rbuckton
Minor emit cleanup
f556d46
@rbuckton
Updated baselines
ce5910e
@rbuckton
Minor emit cleanup
c5f49de
@rbuckton
Fix merge conflict
8a7fa55
@rbuckton
Cleanup emit for type metadata for #2577
98afb92
@rbuckton
Fix for checking type nodes with separate compilation, removed duplic…
c804f5b
…ate functions due to merge conflict
@rbuckton
Added __param helper for parameter decorators and cleaned up __decora…
5c44038
…te and __metadata
@msftclas Microsoft Contribution License Agreements (msftclas) added the cla-not-required label Apr 2, 2015
@rbuckton Ron Buckton (rbuckton) changed the title Decorators types Decorator type metadata Apr 2, 2015
Ron Buckton (rbuckton) added 2 commits April 2, 2015 11:32
@rbuckton
Updated baseline
d9078e9
@rbuckton
Fix for #2561
f15ff32
mhegazy
mhegazy reviewed Apr 2, 2015
View reviewed changes
Comment thread src/compiler/emitter.ts Outdated

@mhegazy Mohamed Hegazy (mhegazy) Apr 2, 2015

Copy link
Copy Markdown
Contributor

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@rbuckton
PR feedback
9a590db
CyrusNajmabadi
CyrusNajmabadi reviewed Apr 2, 2015
View reviewed changes
Comment thread src/compiler/checker.ts Outdated

@CyrusNajmabadi Cyrus Najmabadi (CyrusNajmabadi) Apr 2, 2015

Copy link
Copy Markdown
Contributor

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?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@rbuckton Ron Buckton (rbuckton) Apr 2, 2015

Copy link
Copy Markdown
Contributor Author

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
CyrusNajmabadi
CyrusNajmabadi reviewed Apr 2, 2015
View reviewed changes
Comment thread src/compiler/checker.ts

@CyrusNajmabadi Cyrus Najmabadi (CyrusNajmabadi) Apr 2, 2015

Copy link
Copy Markdown
Contributor

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?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Ron Buckton (rbuckton) added 3 commits April 6, 2015 10:42
@rbuckton
PR feedback
98c56ae
@rbuckton
Merge branch 'master' into decorators_types
1a18133
@rbuckton
Updated baselines
1bab233
Ron Buckton (rbuckton) added a commit that referenced this pull request Apr 6, 2015
@rbuckton
Merge pull request #2589 from Microsoft/decorators_types
e195d89
Experimental support for decorator type metadata. 
NOTE: Requires a polyfill for `Reflect.metadata` which has not yet been considered by TC39 for ES7.
@rbuckton
Ron Buckton (rbuckton) merged commit e195d89 into master Apr 6, 2015
@rbuckton
Ron Buckton (rbuckton) deleted the decorators_types branch April 6, 2015 19:50
@rbuckton Ron Buckton (rbuckton) mentioned this pull request Apr 6, 2015
Too wide highlighting for a decorator issue #2561
Closed
@basarat Basarat Ali Syed (basarat) mentioned this pull request Apr 6, 2015
Decorators #2249
Closed
@mhegazy Mohamed Hegazy (mhegazy) mentioned this pull request May 18, 2015
Expose new compiler flags in the .targets file #3034
Closed
14 tasks done
@brettle Dean Brettle (brettle) mentioned this pull request Jul 20, 2015
Use decorators/metadata to create SimpleSchema Meteor-Community-Packages/meteor-simple-schema#416
Closed
@WorldMaker Max Battcher (WorldMaker) mentioned this pull request Aug 25, 2015
Suggestion: Use Decorators for Schema scottwrobinson/camo#6
Closed
This was referenced Sep 14, 2015
Discussion: (Reflective) Type Model #3628
Closed
"design:paramnames" metadata key #4905
Open
@doriansmiley Dorian Smiley (doriansmiley) mentioned this pull request Sep 1, 2017
Create typescript injector and data binding utils using decorators doriansmiley/lotusJS#43
Closed
@microsoft Microsoft (microsoft) locked and limited conversation to collaborators Jun 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Emit serialized design-time type metadata for decorators

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@rbuckton @CyrusNajmabadi @mhegazy @msftclas
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.