@@ -1282,6 +1282,65 @@ describe('inject migration', () => {
12821282 ] ) ;
12831283 } ) ;
12841284
1285+ it ( 'should preserve type literals in @Inject parameter' , async ( ) => {
1286+ writeFile (
1287+ '/dir.ts' ,
1288+ [
1289+ `import { Directive, Inject } from '@angular/core';` ,
1290+ `import { FOO_TOKEN } from 'foo';` ,
1291+ `` ,
1292+ `@Directive()` ,
1293+ `class MyDir {` ,
1294+ ` constructor(@Inject(FOO_TOKEN) private foo: {id: number}) {}` ,
1295+ `}` ,
1296+ ] . join ( '\n' ) ,
1297+ ) ;
1298+
1299+ await runMigration ( ) ;
1300+
1301+ expect ( tree . readContent ( '/dir.ts' ) . split ( '\n' ) ) . toEqual ( [
1302+ `import { Directive, inject } from '@angular/core';` ,
1303+ `import { FOO_TOKEN } from 'foo';` ,
1304+ `` ,
1305+ `@Directive()` ,
1306+ `class MyDir {` ,
1307+ ` private foo = inject<{` ,
1308+ ` id: number;` ,
1309+ `}>(FOO_TOKEN);` ,
1310+ `}` ,
1311+ ] ) ;
1312+ } ) ;
1313+
1314+ it ( 'should preserve tuple types in @Inject parameter' , async ( ) => {
1315+ writeFile (
1316+ '/dir.ts' ,
1317+ [
1318+ `import { Directive, Inject } from '@angular/core';` ,
1319+ `import { FOO_TOKEN } from 'foo';` ,
1320+ `` ,
1321+ `@Directive()` ,
1322+ `class MyDir {` ,
1323+ ` constructor(@Inject(FOO_TOKEN) private foo: [a: number, b: number]) {}` ,
1324+ `}` ,
1325+ ] . join ( '\n' ) ,
1326+ ) ;
1327+
1328+ await runMigration ( ) ;
1329+
1330+ expect ( tree . readContent ( '/dir.ts' ) . split ( '\n' ) ) . toEqual ( [
1331+ `import { Directive, inject } from '@angular/core';` ,
1332+ `import { FOO_TOKEN } from 'foo';` ,
1333+ `` ,
1334+ `@Directive()` ,
1335+ `class MyDir {` ,
1336+ ` private foo = inject<[` ,
1337+ ` a: number,` ,
1338+ ` b: number` ,
1339+ `]>(FOO_TOKEN);` ,
1340+ `}` ,
1341+ ] ) ;
1342+ } ) ;
1343+
12851344 it ( 'should unwrap forwardRef with an implicit return' , async ( ) => {
12861345 writeFile (
12871346 '/dir.ts' ,
0 commit comments