fix(compiler-cli): Emit type annotations for synthesized decorator fields (#43021)

Previously, the decorator transformer was annotating the synthesized properties with TS type annotations. However, because it ran after the JSDoc transformer, the TS types were just dropped from the emitted JS. Attempting to move the decorator transformer before the JSDoc transformer causes tsickle crashes because synthetic AST fragments are not attached to a SourceFile node.

PR Close #43021
This commit is contained in:
nickreid
2021-08-02 14:11:58 -07:00
committed by Alex Rickabaugh
parent 49766d2d0a
commit 4341a5f4cb
3 changed files with 96 additions and 113 deletions
+1 -1
View File
@@ -715,7 +715,7 @@ describe('ngc transformer command-line', () => {
const mymoduleSource = fs.readFileSync(mymodulejs, 'utf8');
expect(mymoduleSource).toContain('@fileoverview added by tsickle');
expect(mymoduleSource).toContain('@param {?} p');
expect(mymoduleSource).toMatch(/\/\*\* @nocollapse \*\/\s+MyComp\.ctorParameters = /);
expect(mymoduleSource).toContain('@nocollapse');
});
});
@@ -424,11 +424,18 @@ describe('downlevel decorator transform', () => {
expect(diagnostics.length).toBe(0);
expect(output).toContain(dedent`
/** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
MyDir.decorators = [
{ type: core_1.Directive }
];
/** @nocollapse */
MyDir.ctorParameters = () => [
/**
* @type {function(): !Array<(null|{
* type: ?,
* decorators: (undefined|!Array<{type: !Function, args: (undefined|!Array<?>)}>),
* })>}
* @nocollapse
*/
MyDir.ctorParameters = () => [
{ type: ClassInject }
];
`);