feat(core): undecorated-classes migration should handle derived abstract classes (#35339)

In version 10, undecorated base classes that use Angular features need
to be decorated explicitly with `@Directive()`. Additionally, derived
classes of abstract directives need to be decorated.

The migration already handles this for undecorated classes that are
not explicitly decorated, but since in V9, abstract directives can be
used, we also need to handle this for explicitly decorated abstract
directives. e.g.

```
@Directive()
export class Base {...}

// needs to be decorated by migration when updating from v9 to v10
export class Wrapped extends Base {}

@Component(...)
export class Cmp extends Wrapped {}
```

PR Close #35339
This commit is contained in:
Paul Gschwendtner
2020-02-14 18:59:29 +01:00
committed by Kara Erickson
parent 78211c42ea
commit a631b99c69
6 changed files with 157 additions and 32 deletions

View File

@ -17,11 +17,11 @@ export function isFunctionLikeDeclaration(node: ts.Node): node is ts.FunctionLik
/**
* Unwraps a given expression TypeScript node. Expressions can be wrapped within multiple
* parentheses. e.g. "(((({exp}))))()". The function should return the TypeScript node
* referring to the inner expression. e.g "exp".
* parentheses or as expression. e.g. "(((({exp}))))()". The function should return the
* TypeScript node referring to the inner expression. e.g "exp".
*/
export function unwrapExpression(node: ts.Expression | ts.ParenthesizedExpression): ts.Expression {
if (ts.isParenthesizedExpression(node)) {
if (ts.isParenthesizedExpression(node) || ts.isAsExpression(node)) {
return unwrapExpression(node.expression);
} else {
return node;