@@ -861,4 +861,76 @@ declare module '@custom/plugin' {
861861 ] ) ;
862862 } ) ;
863863 } ) ;
864+
865+ describe ( "unittests:: tsserver:: Project Errors with resolveJsonModule" , ( ) => {
866+ function createSessionForTest ( { include } : { include : readonly string [ ] ; } ) {
867+ const test : File = {
868+ path : `${ projectRoot } /src/test.ts` ,
869+ content : `import * as blabla from "./blabla.json";
870+ declare var console: any;
871+ console.log(blabla);`
872+ } ;
873+ const blabla : File = {
874+ path : `${ projectRoot } /src/blabla.json` ,
875+ content : "{}"
876+ } ;
877+ const tsconfig : File = {
878+ path : `${ projectRoot } /tsconfig.json` ,
879+ content : JSON . stringify ( {
880+ compilerOptions : {
881+ resolveJsonModule : true ,
882+ composite : true
883+ } ,
884+ include
885+ } )
886+ } ;
887+
888+ const host = createServerHost ( [ test , blabla , libFile , tsconfig ] ) ;
889+ const session = createSession ( host , { canUseEvents : true } ) ;
890+ openFilesForSession ( [ test ] , session ) ;
891+ return { host, session, test, blabla, tsconfig } ;
892+ }
893+
894+ it ( "should not report incorrect error when json is root file found by tsconfig" , ( ) => {
895+ const { host, session, test } = createSessionForTest ( {
896+ include : [ "./src/*.ts" , "./src/*.json" ]
897+ } ) ;
898+ verifyGetErrRequest ( {
899+ session,
900+ host,
901+ expected : [
902+ {
903+ file : test ,
904+ syntax : [ ] ,
905+ semantic : [ ] ,
906+ suggestion : [ ]
907+ }
908+ ]
909+ } ) ;
910+ } ) ;
911+
912+ it ( "should report error when json is not root file found by tsconfig" , ( ) => {
913+ const { host, session, test, blabla, tsconfig } = createSessionForTest ( {
914+ include : [ "./src/*.ts" ]
915+ } ) ;
916+ const span = protocolTextSpanFromSubstring ( test . content , `"./blabla.json"` ) ;
917+ verifyGetErrRequest ( {
918+ session,
919+ host,
920+ expected : [ {
921+ file : test ,
922+ syntax : [ ] ,
923+ semantic : [
924+ createDiagnostic (
925+ span . start ,
926+ span . end ,
927+ Diagnostics . File_0_is_not_listed_within_the_file_list_of_project_1_Projects_must_list_all_files_or_use_an_include_pattern ,
928+ [ blabla . path , tsconfig . path ]
929+ )
930+ ] ,
931+ suggestion : [ ]
932+ } ]
933+ } ) ;
934+ } ) ;
935+ } ) ;
864936}
0 commit comments