File tree Expand file tree Collapse file tree 3 files changed +27
-4
lines changed
testRunner/unittests/tsserver
tests/baselines/reference/api Expand file tree Collapse file tree 3 files changed +27
-4
lines changed Original file line number Diff line number Diff line change @@ -706,10 +706,10 @@ namespace ts.server {
706706 return this . projectName ;
707707 }
708708
709- protected removeLocalTypingsFromTypeAcquisition ( newTypeAcquisition : TypeAcquisition | undefined ) : TypeAcquisition {
709+ protected removeLocalTypingsFromTypeAcquisition ( newTypeAcquisition : TypeAcquisition ) : TypeAcquisition {
710710 if ( ! newTypeAcquisition || ! newTypeAcquisition . include ) {
711711 // Nothing to filter out, so just return as-is
712- return newTypeAcquisition || { } ;
712+ return newTypeAcquisition ;
713713 }
714714 return { ...newTypeAcquisition , include : this . removeExistingTypings ( newTypeAcquisition . include ) } ;
715715 }
@@ -1410,7 +1410,9 @@ namespace ts.server {
14101410 }
14111411
14121412 setTypeAcquisition ( newTypeAcquisition : TypeAcquisition | undefined ) : void {
1413- this . typeAcquisition = this . removeLocalTypingsFromTypeAcquisition ( newTypeAcquisition ) ;
1413+ if ( newTypeAcquisition ) {
1414+ this . typeAcquisition = this . removeLocalTypingsFromTypeAcquisition ( newTypeAcquisition ) ;
1415+ }
14141416 }
14151417
14161418 getTypeAcquisition ( ) {
Original file line number Diff line number Diff line change @@ -429,5 +429,26 @@ namespace ts.projectSystem {
429429 configuredRemoved . clear ( ) ;
430430 }
431431 } ) ;
432+
433+ it ( "regression test - should infer typeAcquisition for inferred projects when set undefined" , ( ) => {
434+ const file1 = { path : "/a/file1.js" , content : "" } ;
435+ const host = createServerHost ( [ file1 ] ) ;
436+
437+ const projectService = createProjectService ( host ) ;
438+
439+ projectService . openClientFile ( file1 . path ) ;
440+
441+ checkNumberOfProjects ( projectService , { inferredProjects : 1 } ) ;
442+ const inferredProject = projectService . inferredProjects [ 0 ] ;
443+ checkProjectActualFiles ( inferredProject , [ file1 . path ] ) ;
444+ inferredProject . setTypeAcquisition ( undefined ) ;
445+
446+ const expected = {
447+ enable : true ,
448+ include : [ ] ,
449+ exclude : [ ]
450+ } ;
451+ assert . deepEqual ( inferredProject . getTypeAcquisition ( ) , expected , "typeAcquisition should be inferred for inferred projects" ) ;
452+ } ) ;
432453 } ) ;
433454}
Original file line number Diff line number Diff line change @@ -9307,7 +9307,7 @@ declare namespace ts.server {
93079307 enableLanguageService(): void;
93089308 disableLanguageService(lastFileExceededProgramSize?: string): void;
93099309 getProjectName(): string;
9310- protected removeLocalTypingsFromTypeAcquisition(newTypeAcquisition: TypeAcquisition | undefined ): TypeAcquisition;
9310+ protected removeLocalTypingsFromTypeAcquisition(newTypeAcquisition: TypeAcquisition): TypeAcquisition;
93119311 getExternalFiles(): SortedReadonlyArray<string>;
93129312 getSourceFile(path: Path): SourceFile | undefined;
93139313 close(): void;
You can’t perform that action at this time.
0 commit comments