angular-docs-cn/packages/tsc-wrapped
Chuck Jazdzewski 0e64261f26 feat(compiler-cli): lower metadata `useValue` and `data` literal fields (#18905)
With this commit the compiler will "lower" expressions into exported
variables for values the compiler does not need to know statically
in order to be able to generate a factory. For example:

```
  providers: [{provider: 'token', useValue: calculated()}]
```

produced an error as the expression `calculated()` is not supported
by the compiler because `calculated` is not a
[known function](https://angular.io/guide/metadata#annotationsdecorators)

With this commit this is rewritten, during emit of the .js file, into
something like:

```
export var ɵ0 = calculated();

  ...

  provdiers: [{provider: 'token', useValue: ɵ0}]
```

The compiler then will now generate a reference to the exported `ɵ0`
instead of failing to evaluate `calculated()`.

PR Close #18905
2017-08-31 09:46:16 -07:00
..
src feat(compiler-cli): lower metadata `useValue` and `data` literal fields (#18905) 2017-08-31 09:46:16 -07:00
test fix(tsc-wrapped): add metadata for `type` declarations (#18704) 2017-08-17 18:01:10 -05:00
BUILD.bazel build: Bazel builds ngfactories for packages/core (#18289) 2017-07-21 18:09:47 -05:00
README.md refactor(tsc-wrapped): move tsc-wrapped to the packages directory (#18160) 2017-07-21 12:26:16 -05:00
index.ts refactor(tsc-wrapped): move tsc-wrapped to the packages directory (#18160) 2017-07-21 12:26:16 -05:00
package.json refactor(tsc-wrapped): move tsc-wrapped to the packages directory (#18160) 2017-07-21 12:26:16 -05:00
tsconfig-build.json build: Bazel builds ngfactories for packages/core (#18289) 2017-07-21 18:09:47 -05:00
tsconfig.json refactor(tsc-wrapped): update tsc-wrapped to pass strictNullCheck (#18160) 2017-07-21 12:26:20 -05:00

README.md

tsc-wrapped

This package is an internal dependency used by @angular/compiler-cli. Please use that instead.

This is a wrapper around TypeScript's tsc program that allows us to hook in extra extensions. TypeScript will eventually have an extensibility model for arbitrary extensions. We don't want to constrain their design with baggage from a legacy implementation, so this wrapper only supports specific extensions developed by the Angular team:

  • tsickle down-levels Decorators into Annotations so they can be tree-shaken
  • tsickle can also optionally produce Closure Compiler-friendly code
  • ./collector.ts emits an extra .metadata.json file for every .d.ts file written, which retains metadata about decorators that is lost in the TS emit
  • @angular/compiler-cli extends this library to additionally generate template code

TypeScript Decorator metadata collector

The .d.ts format does not preserve information about the Decorators applied to symbols. Some tools, such as Angular template compiler, need access to statically analyzable information about Decorators, so this library allows programs to produce a foo.metadata.json to accompany a foo.d.ts file, and preserves the information that was lost in the declaration emit.

Releasing

$ $(npm bin)/tsc -p tools
$ cp tools/tsc-wrapped/package.json dist/tools/@angular/tsc-wrapped/
$ npm login [angular]
$ npm publish dist/tools/@angular/tsc-wrapped