File tree Expand file tree Collapse file tree 1 file changed +13
-15
lines changed Expand file tree Collapse file tree 1 file changed +13
-15
lines changed Original file line number Diff line number Diff line change @@ -25,23 +25,21 @@ function init(modules: { typescript: typeof tsserver }): any {
2525 proxy [ k ] = ( ...args : Array < { } > ) => x . apply ( info . languageService , args ) ;
2626 }
2727
28+ const program = info . languageService . getProgram ( ) ;
29+ if ( program === undefined ) {
30+ return proxy ;
31+ }
32+
33+ const checker = makeFunctionlessChecker ( program . getTypeChecker ( ) ) ;
34+
2835 proxy . getSemanticDiagnostics = ( fileName ) : ts . Diagnostic [ ] => {
2936 const errors = info . languageService . getSemanticDiagnostics ( fileName ) ;
30- const program = info . languageService . getProgram ( ) ;
31- if ( program ) {
32- const checker = makeFunctionlessChecker ( program . getTypeChecker ( ) ) ;
33- const sf = program . getSourceFile ( fileName ) ;
34-
35- if ( sf ) {
36- info . project . projectService . logger . info (
37- `Calling validate on file: ${ fileName } `
38- ) ;
39- const customErrors = validate ( ts as any , checker , sf ) ;
40- info . project . projectService . logger . info (
41- `Detected ${ customErrors . length } custom errors in file: ${ fileName } `
42- ) ;
43- return [ ...errors , ...customErrors ] ;
44- }
37+
38+ const sf = program . getSourceFile ( fileName ) ;
39+
40+ if ( sf ) {
41+ const customErrors = validate ( ts as any , checker , sf ) ;
42+ return [ ...errors , ...customErrors ] ;
4543 }
4644
4745 return errors ;
You can’t perform that action at this time.
0 commit comments