40 Commits

Author SHA1 Message Date
Tobias Bosch
bc69c74be0 fix(tsc-wrapped): still emit version 1 metadata to allow to use new components in old setups 2016-11-28 15:18:57 -08:00
Tobias Bosch
f5c8e0989d feat(core): properly support inheritance
## Inheritance Semantics:

Decorators:
1) list the decorators of the class and its parents in the ancestor first order
2) only use the last decorator of each kind (e.g. @Component / ...)

Constructor parameters:
If a class inherits from a parent class and does not declare
a constructor, it inherits the parent class constructor,
and with it the parameter metadata of that parent class.

Lifecycle hooks:
Follow the normal class inheritance model,
i.e. lifecycle hooks of parent classes will be called
even if the method is not overwritten in the child class.

## Example

E.g. the following is a valid use of inheritance and it will
also inherit all metadata:

```
@Directive({selector: 'someDir'})
class ParentDirective {
  constructor(someDep: SomeDep) {}

  ngOnInit() {}
}

class ChildDirective extends ParentDirective {}
```

Closes 
Closes 
2016-11-28 14:12:12 -08:00
Bowen Ni
2c02d34c05 refactor(lint): Don't allow console.log
Enable tslint check for `console.log` as a follow-up to
https://github.com/angular/angular/issues/13018
2016-11-23 15:47:01 -08:00
Tobias Bosch
dddbb1c1cb refactor(tsc-wrapped): collect all exported functions and classes and bump metadata version from 1 to 2
This is needed to resolve symbols without `.d.ts` files.
This bumps the version of the metadata from 1 to 2.
This adds logic into `ng_host.ts` to automatically upgrade
version 1 to version 2 metadata by adding the exported symbols
from the `.d.ts` file.
2016-11-18 10:04:14 -08:00
Alex Eagle
664a6273e1 feature(tsc-wrapped): add option for closure compiler JSDoc annotations 2016-11-18 09:37:40 -08:00
Chuck Jazdzewski
c1a62e2154 feat(tools): allow disabling annotation lowering 2016-11-18 09:37:40 -08:00
Joao Dias
77ee27c59e refactor(): use const and let instead of var 2016-11-12 16:40:17 -08:00
Chuck Jazdzewski
69f87ca075 fix(tools): harden colletor against invalid asts () 2016-11-10 11:58:55 -08:00
Joao Dias
a382d6dd20 style: add missing semicolons 2016-10-31 14:25:53 -07:00
Joao Dias
52bf188b8f style: add missing copyright headers 2016-10-31 14:25:53 -07:00
Miško Hevery
979657989b fix(packages): use ES modules for primary build () 2016-08-30 18:07:40 -07:00
Chuck Jazdzewski
fc2fe00d16 fix(compiler): allow tsc-wrapped to be compile with TypeScript 2.0 () 2016-08-25 17:28:20 -07:00
Alex Eagle
c7a874dd2f feature(ngc): allow codegen to skip over .d.ts inputs () 2016-08-23 16:26:35 -07:00
Chuck Jazdzewski
39a2c39cef feat(compiler): Added "strictMetadataEmit" option to ngc ()
ngc can now validate metadata before emitting to verify it doesn't
contain an error symbol that will result in a runtime error if
it is used by the StaticReflector.

To enable this add the section,

  "angularCompilerOptions": {
    "strictMetadataEmit": true
  }

to the top level of the tsconfig.json file passed to ngc.

Enabled metadata validation for packages that are intended to be
used statically.
2016-08-22 17:37:48 -07:00
Chuck Jazdzewski
a7b76826a0 fix(compiler): Only emit metadata for exported enums ()
Closes: 
2016-08-22 10:26:22 -07:00
Alex Eagle
9317056138 fix(ngc): Revert "fix(ngc): add an option to produce TS1.9-pathMapping imports ()" ()
This reverts commit beadf6167a24e9ee0a567f2b4800a318785e00ec.
2016-08-12 17:38:29 -07:00
Matias Niemelä
6580d67875 feat(i18n): pass translation config directly into ngc () 2016-08-12 14:45:36 -07:00
Alex Eagle
beadf6167a fix(ngc): add an option to produce TS1.9-pathMapping imports ()
This fixes a regression in 
2016-08-09 14:58:19 -07:00
Hans
01bca41168 fix: allow users to pass in absolute paths to ngc () 2016-08-09 09:36:37 -07:00
Chuck Jazdzewski
9925aa89dc fix(compiler): Report references to non-exported symbols.
Includes fixes to places now reported as errors.

Part of 
2016-08-03 15:42:38 -07:00
Chuck Jazdzewski
82e7ecd611 fix(compiler): StaticReflect now resolves re-exported symbols ()
Fixes: 
2016-08-02 11:45:14 -07:00
Chuck Jazdzewski
763ca60f5b feat(compiler): Support default parameters in static reflector ()
Closes: 
2016-07-29 09:10:45 -07:00
Chuck Jazdzewski
20b03bad11 feat(compiler): Added support for conditional expressions. ()
Expression evaluated by the static reflector can now supports
conditional expressions.

Closes: 
2016-07-28 17:32:29 -07:00
Alex Eagle
0a46f37444 fix(metadata): fix typechecking with typescript@next 2016-07-28 11:17:53 -07:00
Chuck Jazdzewski
b58e9ea775 feat(compiler): Added support for references to static fields. ()
Closes: 
2016-07-27 19:26:59 -07:00
Chuck Jazdzewski
b449467940 feat(compiler): Allow calls to simple static methods ()
Closes: 
2016-07-26 10:18:35 -07:00
Chuck Jazdzewski
4ef86891a3 fix(compiler): Ignore references to declared modules and unneeded types ()
Fixes: 
2016-07-11 17:26:35 -07:00
Chuck Jazdzewski
e6b24437a9 fix(compiler): Collector collects enum values. ()
Fixes: 
2016-07-11 11:50:33 -07:00
Alex Eagle
f463e09b9f fix(ngc): work with typescript@next
This is required due to breaking change in TS, see
https://github.com/Microsoft/TypeScript/pull/8841#issuecomment-227300348
2016-06-24 10:27:31 -07:00
ScottSWu
8899b83927 chore(typescript): Enabled noFallthroughCasesInSwitch
Turned on the noFallthroughCasesInSwitch flag in tsconfig and fixed
a few cases where there were fallthroughs.
2016-06-22 16:08:55 -07:00
Chuck Jazdzewski
791153c93c fix(compiler): StaticReflector ignores unregistered decorators. ()
Also modified static reflector to allow writing tests in using
the .ts and using the MetadataCollector.

Also made MetadataCollector be able to use SourceFiles that have
not been bound (that is, don't have the parent property set).

Fixes 
Fixes 
2016-06-17 13:11:00 -07:00
Victor Berchet
1eaa193c51 feat(compiler-cli): add a debug option to control the output
fixes 
2016-06-15 18:13:57 -07:00
Chuck Jazdzewski
5504ca1e38 feat(compiler): Added support for limited function calls in metadata. ()
The collector now collects the body of functions that return an
expression as a symbolic 'function'. The static reflector supports
expanding these functions statically to allow provider macros.

Also added support for the array spread operator in both the
collector and the static reflector.
2016-06-13 15:56:51 -07:00
Alex Eagle
bbed364e7b chore(tsc-wrapped): update to newest tsickle 2016-06-09 16:45:16 -07:00
Chuck Jazdzewski
e178ee4ba0 fix(compiler): Added support for '* as m' style imports. ()
Also includes fixes for broken test.
2016-06-09 13:23:29 -07:00
Alex Eagle
d38aa5e25f chore(lint): sort imports in tools/ 2016-06-08 11:29:37 -07:00
Chuck Jazdzewski
cf3548a02f fix(compiler): Improved error reporting of the static reflector.
StaticReflector provides more context on errors reported by the
collector.

The metadata collector now records the line and character of the node that
caused it to report the error.

Includes other minor fixes to error reporting and a wording change.

Fixes 
Closes 
2016-06-07 08:38:32 -07:00
Chuck Jazdzewski
2d8f776e38 feat(build): Added a version stamp in .metadata.json files.
Also modified StaticReflector to handle multiple versions in a
single .metadata.json file.

Fixes 
Closes 
2016-06-03 10:40:49 -07:00
Chuck Jazdzewski
01dd7dde24 chore(tools): Remove use of TypeChecker from metadata collector.
The metadata collector was modified to look up references in the
import list instead of resolving the symbol using the TypeChecker
making the use of the TypeChecker vestigial. This change removes
all uses of the TypeChecker.

Modified the schema to be able to record global and local (non-module
specific references).

Added error messages to the schema and errors are recorded in
the metadata file allowing the static reflector to throw errors
if an unsupported construct is referenced by metadata.

Closes 
Fixes 
Fixes 
2016-06-02 13:39:15 -07:00
Alex Eagle
3331321f64 build(ngc): run integration test hermetically
This ensures we run in a clean directory, using our real distribution. It finds bugs like @internal
APIs needed to type-check in the offline compiler, as well as problems in package.json.

Also move tsc-wrapped under tools/@angular
2016-05-27 17:21:35 -07:00