refactor(core): undecorated-classes migration should properly construct object literal from metadata (#32319)

The `undecorated-classes-with-di` migration currently creates invalid object literals from parsed
NGC metadata files if there are object literal properties with keys that contain special characters.

e.g. consider a decorated base class with a host binding using `[class.X]`. Currently the migration
parses and converts the metadata to TypeScript code but incorrectly uses `[class.X]` unquoted as
identifier.

PR Close #32319
This commit is contained in:
Paul Gschwendtner
2019-08-26 18:26:04 +02:00
committed by Miško Hevery
parent d0f3539e6e
commit 543631f2b3
2 changed files with 33 additions and 6 deletions

View File

@ -1027,7 +1027,10 @@ describe('Undecorated classes with DI migration', () => {
provide: NG_VALIDATORS,
useExisting: BaseComponent,
multi: true
}]
}],
host: {
"[class.is-enabled]": "isEnabled === true"
}
})
export class PassThrough extends BaseComponent {}`);
expect(tree.readContent('/index.ts')).toContain(dedent `
@ -1040,7 +1043,10 @@ describe('Undecorated classes with DI migration', () => {
provide: NG_VALIDATORS,
useExisting: BaseComponent,
multi: true
}]
}],
host: {
"[class.is-enabled]": "isEnabled === true"
}
})
export class MyComp extends PassThrough {}`);
expect(tree.readContent('/index.ts')).toContain(dedent `
@ -1081,7 +1087,10 @@ describe('Undecorated classes with DI migration', () => {
provide: NG_VALIDATORS,
useExisting: BaseComponent,
multi: true
}]
}],
host: {
"[class.is-enabled]": "isEnabled === true"
}
})
export class MyComp extends BaseComponent {}`);
});
@ -1238,6 +1247,9 @@ describe('Undecorated classes with DI migration', () => {
member: 'None'
},
providers: [{__symbolic: 'reference', name: 'testValidators'}],
host: {
'[class.is-enabled]': 'isEnabled === true',
}
}]
}],
members: {}