fix(tsc-wrapped): support as and class expressions (#16904)
This commit is contained in:
parent
1bf7ba87a0
commit
45ffe54ae4
|
@ -647,6 +647,11 @@ export class Evaluator {
|
||||||
return result;
|
return result;
|
||||||
}, this.evaluateNode(templateExpression.head));
|
}, this.evaluateNode(templateExpression.head));
|
||||||
}
|
}
|
||||||
|
case ts.SyntaxKind.AsExpression:
|
||||||
|
const asExpression = <ts.AsExpression>node;
|
||||||
|
return this.evaluateNode(asExpression.expression);
|
||||||
|
case ts.SyntaxKind.ClassExpression:
|
||||||
|
return {__symbolic: 'class'};
|
||||||
}
|
}
|
||||||
return recordEntry(errorSymbol('Expression form not supported', node), node);
|
return recordEntry(errorSymbol('Expression form not supported', node), node);
|
||||||
}
|
}
|
||||||
|
|
|
@ -727,6 +727,21 @@ describe('Collector', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should treat exported class expressions as a class', () => {
|
||||||
|
const source = ts.createSourceFile(
|
||||||
|
'', `
|
||||||
|
export const InjectionToken: {new<T>(desc: string): InjectionToken<T>;} = class extends OpaqueToken {
|
||||||
|
constructor(desc: string) {
|
||||||
|
super(desc);
|
||||||
|
}
|
||||||
|
|
||||||
|
toString(): string { return \`InjectionToken ${this._desc}\`; }
|
||||||
|
} as any;`,
|
||||||
|
ts.ScriptTarget.Latest, true);
|
||||||
|
const metadata = collector.getMetadata(source);
|
||||||
|
expect(metadata.metadata).toEqual({InjectionToken: {__symbolic: 'class'}});
|
||||||
|
});
|
||||||
|
|
||||||
describe('in strict mode', () => {
|
describe('in strict mode', () => {
|
||||||
it('should throw if an error symbol is collecting a reference to a non-exported symbol', () => {
|
it('should throw if an error symbol is collecting a reference to a non-exported symbol', () => {
|
||||||
const source = program.getSourceFile('/local-symbol-ref.ts');
|
const source = program.getSourceFile('/local-symbol-ref.ts');
|
||||||
|
|
Loading…
Reference in New Issue