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:

committed by
Miško Hevery

parent
d0f3539e6e
commit
543631f2b3
@ -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: {}
|
||||
|
Reference in New Issue
Block a user