@@ -12,6 +12,10 @@ describe('Fragment + operations', () => {
1212 const outfileCombo = path . join ( projectPath , 'simple.ts' ) ;
1313 const outfileTypeCondition = path . join ( projectPath , 'type-condition.ts' ) ;
1414 const outfileUnusedFragment = path . join ( projectPath , 'unused-fragment.ts' ) ;
15+ const outfileUsedFragmentMask = path . join (
16+ projectPath ,
17+ 'used-fragment-mask.ts'
18+ ) ;
1519 const outfileCombinations = path . join ( projectPath , 'fragment.ts' ) ;
1620
1721 let server : TSServer ;
@@ -38,6 +42,11 @@ describe('Fragment + operations', () => {
3842 fileContent : '// empty' ,
3943 scriptKindName : 'TS' ,
4044 } satisfies ts . server . protocol . OpenRequestArgs ) ;
45+ server . sendCommand ( 'open' , {
46+ file : outfileUsedFragmentMask ,
47+ fileContent : '// empty' ,
48+ scriptKindName : 'TS' ,
49+ } satisfies ts . server . protocol . OpenRequestArgs ) ;
4150
4251 server . sendCommand ( 'updateOpen' , {
4352 openFiles : [
@@ -69,6 +78,13 @@ describe('Fragment + operations', () => {
6978 'utf-8'
7079 ) ,
7180 } ,
81+ {
82+ file : outfileUsedFragmentMask ,
83+ fileContent : fs . readFileSync (
84+ path . join ( projectPath , 'fixtures/used-fragment-mask.ts' ) ,
85+ 'utf-8'
86+ ) ,
87+ } ,
7288 ] ,
7389 } satisfies ts . server . protocol . UpdateOpenRequestArgs ) ;
7490
@@ -88,11 +104,16 @@ describe('Fragment + operations', () => {
88104 file : outfileUnusedFragment ,
89105 tmpfile : outfileUnusedFragment ,
90106 } satisfies ts . server . protocol . SavetoRequestArgs ) ;
107+ server . sendCommand ( 'saveto' , {
108+ file : outfileUsedFragmentMask ,
109+ tmpfile : outfileUsedFragmentMask ,
110+ } satisfies ts . server . protocol . SavetoRequestArgs ) ;
91111 } ) ;
92112
93113 afterAll ( ( ) => {
94114 try {
95115 fs . unlinkSync ( outfileUnusedFragment ) ;
116+ fs . unlinkSync ( outfileUsedFragmentMask ) ;
96117 fs . unlinkSync ( outfileCombinations ) ;
97118 fs . unlinkSync ( outfileCombo ) ;
98119 fs . unlinkSync ( outfileTypeCondition ) ;
@@ -386,6 +407,29 @@ List out all Pokémon, optionally in pages`
386407 ` ) ;
387408 } , 30000 ) ;
388409
410+ it ( 'should not warn about unused fragments when using maskFragments' , async ( ) => {
411+ server . sendCommand ( 'saveto' , {
412+ file : outfileUsedFragmentMask ,
413+ tmpfile : outfileUsedFragmentMask ,
414+ } satisfies ts . server . protocol . SavetoRequestArgs ) ;
415+
416+ await server . waitForResponse (
417+ e =>
418+ e . type === 'event' &&
419+ e . event === 'semanticDiag' &&
420+ e . body ?. file === outfileUsedFragmentMask
421+ ) ;
422+
423+ const res = server . responses . filter (
424+ resp =>
425+ resp . type === 'event' &&
426+ resp . event === 'semanticDiag' &&
427+ resp . body ?. file === outfileUsedFragmentMask
428+ ) ;
429+ // Should have no diagnostics about unused fragments since maskFragments uses them
430+ expect ( res [ 0 ] . body . diagnostics ) . toMatchInlineSnapshot ( `[]` ) ;
431+ } , 30000 ) ;
432+
389433 it ( 'gives quick-info at start of word (#15)' , async ( ) => {
390434 server . send ( {
391435 seq : 11 ,
0 commit comments