This repo provides example usage of TypeScript Decorators and Metadata. Hopefully this will provide a base for people to experiment and learn!
These examples were produced based on information presented by Wolk Software Limited's three part series on Decorators & metadata reflection in Typescript: From Novice to Expert, the metadata PR #2589 and rbuckton's ES7 Reflection Prototype. Thanks!
npm install
grunt test-proxy
- open http://localhost:9000/node_modules/intern/client.html?config=_build/tests/intern-local
This directory has example usage and comments about decorators and metadata. Examples show how to use the four different decorators (class, method, parameter, and property), decorator factories used when parameters are passed in a decorator, and custom metadata usage.
Includes examples of using decorators to facilitate mixins and dependency injection
This directory has some unit tests illustrating how the different descriptors behave
As of version 4.2.0.beta1 grunt-ts
doesn't yet have support for the experimentalDecorators flag
issue #259. We work around this by declaring
--experimentalDecorators
in additionalFlags
.
Metadata support is polyfilled using reflect-metadata More information about how TypeScript leverages it is here:
grunt lint
- validates style rulesgrunt test
- runs intern's node clientgrunt test-local
- runs intern's runner with local configuration (Selenium required)grunt test-proxy
- starts intern's testing proxygrunt test-runner
- runs intern's runner (BrowserStack/SauceLabs required)grunt ci
- runs tests in a continuous integration environmentgrunt clean
- cleans development workgrunt
- compiles files