Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6b6fcd7

Browse files
kyliaumhevery
authored andcommitted
fix(language-service): do not return external template that does not exist (#39898)
There is a bug in tsserver that causes it to crash when it tries to createscript info for an external template that does not exist.I've submitted an upstream PRmicrosoft/TypeScript#41737 to fix this, but beforethe commit lands in the stable release, we'll have to workaround the issuein language service.Closeangular/vscode-ng-language-service#1001PRClose#39898
1 parent3680ad1 commit6b6fcd7

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

‎packages/language-service/src/ts_plugin.ts‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,16 @@ export function getExternalFiles(project: tss.server.Project): string[] {
2929
return[];
3030
}
3131
constngLsHost=PROJECT_MAP.get(project);
32-
ngLsHost?.getAnalyzedModules();
33-
returnngLsHost?.getExternalTemplates()||[];
32+
if(ngLsHost===undefined){
33+
return[];
34+
}
35+
ngLsHost.getAnalyzedModules();
36+
returnngLsHost.getExternalTemplates().filter(fileName=>{
37+
// TODO(kyliau): Remove this when the following PR lands on the version of
38+
// TypeScript used in this repo.
39+
// https://github.com/microsoft/TypeScript/pull/41737
40+
returnproject.fileExists(fileName);
41+
});
3442
}
3543

3644
exportfunctioncreate(info:tss.server.PluginCreateInfo):tss.LanguageService{

‎packages/language-service/test/ts_plugin_spec.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const mockProject = {
2121
},
2222
},
2323
hasRoots:()=>true,
24+
fileExists:()=>true,
2425
}asany;
2526

2627
describe('plugin',()=>{
@@ -136,6 +137,12 @@ describe('plugin', () => {
136137
'/app/test.ng',
137138
]);
138139
});
140+
141+
it('should not return external template that does not exist',()=>{
142+
spyOn(mockProject,'fileExists').and.returnValue(false);
143+
constexternalTemplates=getExternalFiles(mockProject);
144+
expect(externalTemplates.length).toBe(0);
145+
});
139146
});
140147

141148
describe(`with config 'angularOnly = true`,()=>{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp