@@ -105,6 +105,58 @@ describe('openTypeScriptProject', () => {
105105 ) . toEqual ( [ `Using the compiler options of "${ path . join ( root , 'app/tsconfig.json' ) } ".` ] )
106106 } )
107107
108+ // the old trailing comma regex backtracked exponentially on these, never finishing
109+ it ( 'reads the references of tsconfigs with a slash banner and back-to-back block comments' , ( ) => {
110+ write (
111+ 'tsconfig.json' ,
112+ `{
113+ "files": [],
114+ "references": [{ "path": "./app" }],
115+ ${ '/* reference */' . repeat ( 40 ) }
116+ }` ,
117+ )
118+ write (
119+ 'app/tsconfig.json' ,
120+ `{
121+ "compilerOptions": {
122+ "strict": true,
123+ ${ '/' . repeat ( 80 ) }
124+ "noEmit": true,
125+ ${ ' /* option */\n' . repeat ( 40 ) }
126+ },
127+ "include": ["."],
128+ }` ,
129+ )
130+ write ( 'app/router.ts' , 'export const router = 1\n' )
131+
132+ expect (
133+ open ( { file : path . join ( root , 'app/router.ts' ) , tsconfig : root } , ( project ) =>
134+ project . describeConfig ( ) ,
135+ ) ,
136+ ) . toEqual ( [ `Using the compiler options of "${ path . join ( root , 'app/tsconfig.json' ) } ".` ] )
137+ } )
138+
139+ it ( 'reads the references of a solution tsconfig keeping strings with comment markers and commas' , ( ) => {
140+ write (
141+ 'tsconfig.json' ,
142+ `{
143+ "files": [],
144+ "references": [
145+ { "path": "./*/../a,b//c", }, // trailing commas before comments
146+ /* and */
147+ ],
148+ }` ,
149+ )
150+ write ( 'a,b/c/tsconfig.json' , JSON . stringify ( { include : [ '.' ] } ) )
151+ write ( 'a,b/c/router.ts' , 'export const router = 1\n' )
152+
153+ expect (
154+ open ( { file : path . join ( root , 'a,b/c/router.ts' ) , tsconfig : root } , ( project ) =>
155+ project . describeConfig ( ) ,
156+ ) ,
157+ ) . toEqual ( [ `Using the compiler options of "${ path . join ( root , 'a,b/c/tsconfig.json' ) } ".` ] )
158+ } )
159+
108160 it ( 'lists no exports of a script, read from a path relative to the current working directory' , ( ) => {
109161 write ( 'tsconfig.json' , JSON . stringify ( { include : [ '*.ts' ] } ) )
110162 write ( 'script.ts' , 'const router = 1\n' )
0 commit comments