@@ -168,6 +168,50 @@ describe("loadConfig", () => {
168
168
} ) ;
169
169
} ) ;
170
170
171
+ it ( "It should load a config with extends from node_modules and overwrite all options" , ( ) => {
172
+ const firstConfig = {
173
+ extends : "my-package/base-config.json" ,
174
+ compilerOptions : { baseUrl : "kalle" , paths : { foo : [ "bar2" ] } }
175
+ } ;
176
+ const firstConfigPath = join ( "/root" , "dir1" , "tsconfig.json" ) ;
177
+ const baseConfig = {
178
+ compilerOptions : {
179
+ baseUrl : "olle" ,
180
+ paths : { foo : [ "bar1" ] } ,
181
+ strict : true
182
+ }
183
+ } ;
184
+ const baseConfigPath = join (
185
+ "/root" ,
186
+ "dir1" ,
187
+ "node_modules" ,
188
+ "my-package" ,
189
+ "base-config.json"
190
+ ) ;
191
+ const res = loadTsconfig (
192
+ join ( "/root" , "dir1" , "tsconfig.json" ) ,
193
+ path => path === firstConfigPath || path === baseConfigPath ,
194
+ path => {
195
+ if ( path === firstConfigPath ) {
196
+ return JSON . stringify ( firstConfig ) ;
197
+ }
198
+ if ( path === baseConfigPath ) {
199
+ return JSON . stringify ( baseConfig ) ;
200
+ }
201
+ return "" ;
202
+ }
203
+ ) ;
204
+
205
+ assert . deepEqual ( res , {
206
+ extends : "my-package/base-config.json" ,
207
+ compilerOptions : {
208
+ baseUrl : "kalle" ,
209
+ paths : { foo : [ "bar2" ] } ,
210
+ strict : true
211
+ }
212
+ } ) ;
213
+ } ) ;
214
+
171
215
it ( "Should use baseUrl relative to location of extended tsconfig" , ( ) => {
172
216
const firstConfig = { compilerOptions : { baseUrl : "." } } ;
173
217
const firstConfigPath = join ( "/root" , "first-config.json" ) ;
0 commit comments