@@ -26,7 +26,8 @@ const x = new (<Foo>Generic<string>)();
26
26
const x = new (<Foo>Generic<string>)('string');
27
27
const x = () => <Foo>{ bar: 5 };
28
28
const x = () => <Foo>({ bar: 5 });
29
- const x = () => <Foo>bar;` ;
29
+ const x = () => <Foo>bar;
30
+ const x = <Foo>bar<string>\`\${"baz"}\`;` ;
30
31
31
32
const ANGLE_BRACKET_TESTS = `${ ANGLE_BRACKET_TESTS_EXCEPT_CONST_CASE }
32
33
const x = <const>{ key: 'value' };
@@ -45,7 +46,8 @@ const x = new (Generic<string> as Foo)();
45
46
const x = new (Generic<string> as Foo)('string');
46
47
const x = () => ({ bar: 5 } as Foo);
47
48
const x = () => ({ bar: 5 } as Foo);
48
- const x = () => (bar as Foo);` ;
49
+ const x = () => (bar as Foo);
50
+ const x = bar<string>\`\${"baz"}\` as Foo;` ;
49
51
50
52
const AS_TESTS = `${ AS_TESTS_EXCEPT_CONST_CASE }
51
53
const x = { key: 'value' } as const;
@@ -69,13 +71,15 @@ function b(x = {} as Foo.Bar) {}
69
71
function c(x = {} as Foo) {}
70
72
print?.({ bar: 5 } as Foo)
71
73
print?.call({ bar: 5 } as Foo)
74
+ print\`\${{ bar: 5 } as Foo}\`
72
75
` ;
73
76
const OBJECT_LITERAL_ARGUMENT_ANGLE_BRACKET_CASTS = `
74
77
print(<Foo>{ bar: 5 })
75
78
new print(<Foo>{ bar: 5 })
76
79
function foo() { throw <Foo>{ bar: 5 } }
77
80
print?.(<Foo>{ bar: 5 })
78
81
print?.call(<Foo>{ bar: 5 })
82
+ print\`\${<Foo>{ bar: 5 }}\`
79
83
` ;
80
84
81
85
ruleTester . run ( 'consistent-type-assertions' , rule , {
@@ -230,6 +234,10 @@ ruleTester.run('consistent-type-assertions', rule, {
230
234
messageId : 'angle-bracket' ,
231
235
line : 15 ,
232
236
} ,
237
+ {
238
+ messageId : 'angle-bracket' ,
239
+ line : 16 ,
240
+ } ,
233
241
] ,
234
242
} ) ,
235
243
...batchedSingleLineTests < MessageIds , Options > ( {
@@ -296,6 +304,10 @@ ruleTester.run('consistent-type-assertions', rule, {
296
304
messageId : 'as' ,
297
305
line : 15 ,
298
306
} ,
307
+ {
308
+ messageId : 'as' ,
309
+ line : 16 ,
310
+ } ,
299
311
] ,
300
312
output : AS_TESTS ,
301
313
} ) ,
@@ -359,6 +371,10 @@ ruleTester.run('consistent-type-assertions', rule, {
359
371
messageId : 'never' ,
360
372
line : 14 ,
361
373
} ,
374
+ {
375
+ messageId : 'never' ,
376
+ line : 15 ,
377
+ } ,
362
378
] ,
363
379
} ) ,
364
380
...batchedSingleLineTests < MessageIds , Options > ( {
@@ -421,6 +437,10 @@ ruleTester.run('consistent-type-assertions', rule, {
421
437
messageId : 'never' ,
422
438
line : 14 ,
423
439
} ,
440
+ {
441
+ messageId : 'never' ,
442
+ line : 15 ,
443
+ } ,
424
444
] ,
425
445
} ) ,
426
446
...batchedSingleLineTests < MessageIds , Options > ( {
@@ -660,6 +680,17 @@ ruleTester.run('consistent-type-assertions', rule, {
660
680
} ,
661
681
] ,
662
682
} ,
683
+ {
684
+ messageId : 'unexpectedObjectTypeAssertion' ,
685
+ line : 12 ,
686
+ suggestions : [
687
+ {
688
+ messageId : 'replaceObjectTypeAssertionWithSatisfies' ,
689
+ data : { cast : 'Foo' } ,
690
+ output : `print\`\${{ bar: 5 } satisfies Foo}\`` ,
691
+ } ,
692
+ ] ,
693
+ } ,
663
694
] ,
664
695
} ) ,
665
696
...batchedSingleLineTests < MessageIds , Options > ( {
@@ -769,6 +800,17 @@ ruleTester.run('consistent-type-assertions', rule, {
769
800
} ,
770
801
] ,
771
802
} ,
803
+ {
804
+ messageId : 'unexpectedObjectTypeAssertion' ,
805
+ line : 10 ,
806
+ suggestions : [
807
+ {
808
+ messageId : 'replaceObjectTypeAssertionWithSatisfies' ,
809
+ data : { cast : 'Foo' } ,
810
+ output : `print\`\${{ bar: 5 } satisfies Foo}\`` ,
811
+ } ,
812
+ ] ,
813
+ } ,
772
814
] ,
773
815
} ) ,
774
816
{
0 commit comments