angular-cn/packages/compiler-cli
George Kalpakas bb6a3632f6 refactor(ivy): correctly type class declarations in `ngtsc`/`ngcc` (#29209)
Previously, several `ngtsc` and `ngcc` APIs dealing with class
declaration nodes used inconsistent types. For example, some methods of
the `DecoratorHandler` interface expected a `ts.Declaration` argument,
but actual `DecoratorHandler` implementations specified a stricter
`ts.ClassDeclaration` type.

As a result, the stricter methods would operate under the incorrect
assumption that their arguments were of type `ts.ClassDeclaration`,
while the actual arguments might be of different types (e.g. `ngcc`
would call them with `ts.FunctionDeclaration` or
`ts.VariableDeclaration` arguments, when compiling ES5 code).

Additionally, since we need those class declarations to be referenced in
other parts of the program, `ngtsc`/`ngcc` had to either repeatedly
check for `ts.isIdentifier(node.name)` or assume there was a `name`
identifier and use `node.name!`. While this assumption happens to be
true in the current implementation, working around type-checking is
error-prone (e.g. the assumption might stop being true in the future).

This commit fixes this by introducing a new type to be used for such
class declarations (`ts.Declaration & {name: ts.Identifier}`) and using
it consistently throughput the code.

PR Close #29209
2019-03-21 22:20:23 +00:00
..
integrationtest fix(bazel): add missing binary path for api-extractor (#29202) 2019-03-12 10:49:49 -07:00
ngcc refactor(ivy): correctly type class declarations in `ngtsc`/`ngcc` (#29209) 2019-03-21 22:20:23 +00:00
src refactor(ivy): correctly type class declarations in `ngtsc`/`ngcc` (#29209) 2019-03-21 22:20:23 +00:00
test build(bazel): back out of @bazel/jasmine 0.27.7 with shard count (#29444) 2019-03-21 09:59:13 -07:00
BUILD.bazel refactor(ivy): move ngcc into a higher level folder (#29092) 2019-03-20 14:45:54 -04:00
index.ts feat(compiler-cli): expose ngtsc as a TscPlugin (#28435) 2019-01-29 16:41:59 -08:00
ngtools2.ts refactor(compiler-cli): expose ngtools api separately (#18978) 2017-08-31 14:37:13 -07:00
package.json refactor(ivy): move ngcc into a higher level folder (#29092) 2019-03-20 14:45:54 -04:00
tsconfig-build.json build(compiler-cli): enable full TypeScript strictness (#29436) 2019-03-21 12:14:39 -04:00
tsconfig.json build(compiler-cli): enable full TypeScript strictness (#29436) 2019-03-21 12:14:39 -04:00