22" File: tsc.vim
33" Description: TypeScript syntax checker
44" Maintainer: Bill Casarin <[email protected] >5+ "
56" ============================================================================
67
78if exists (' g:loaded_syntastic_typescript_tsc_checker' )
@@ -16,24 +17,24 @@ endif
1617let s: save_cpo = &cpo
1718set cpo &vim
1819
19- function ! SyntaxCheckers_typescript_tsc_GetLocList () dict
20- if ! exists (' s:tsc_new' )
20+ function ! SyntaxCheckers_typescript_tsc_IsAvailable () dict
21+ let version_output = split (syntastic#util#system (self .getExecEscaped () . ' --version' ), ' \n' , 1 )
22+ let ver = filter (copy (version_output), ' v:val =~# '' \m\<Version '' ' )
23+ let parsed_ver = len (ver) ? syntastic#util#parseVersion (ver[0 ], ' \v<Version \zs\d+(\.\d+)\ze' ) : []
24+
25+ if len (parsed_ver)
26+ call self .setVersion (parsed_ver)
27+ let s: tsc_new = syntastic#util#versionIsAtLeast (parsed_ver, [1 , 5 ])
28+ else
29+ call syntastic#log#ndebug (g: _SYNTASTIC_DEBUG_LOCLIST , ' checker output:' , version_output)
30+ call syntastic#log#error (" checker typescript/tsc: can't parse version string (abnormal termination?)" )
2131 let s: tsc_new = -1
22- try
23- let tsc_version = filter (split (syntastic#util#system (self .getExecEscaped () . ' --version' ), ' \n' ), ' v:val =~# '' \m\<Version '' ' )[0 ]
24- let ver = syntastic#util#parseVersion (tsc_version, ' \v<Version \zs\d+(\.\d+)\ze' )
25- call self .setVersion (ver)
26-
27- let s: tsc_new = syntastic#util#versionIsAtLeast (ver, [1 , 5 ])
28- catch /\m^Vim\%((\a\+)\)\=:E684/
29- call syntastic#log#error (" checker typescript/tsc: can't parse version string (abnormal termination?)" )
30- endtry
3132 endif
3233
33- if s: tsc_new < 0
34- return []
35- endif
34+ return s: tsc_new >= 0
35+ endfunction
3636
37+ function ! SyntaxCheckers_typescript_tsc_GetLocList () dict
3738 let makeprg = self .makeprgBuild ({
3839 \ ' args' : ' --module commonjs' ,
3940 \ ' args_after' : (s: tsc_new ? ' --noEmit' : ' --out ' . syntastic#util#DevNull ()) })
0 commit comments