@@ -1917,22 +1917,24 @@ namespace ts {
1917
1917
Debug . assert ( ! ! sourceFile . bindDiagnostics ) ;
1918
1918
1919
1919
const isCheckJsTrue = isCheckJsEnabledForFile ( sourceFile , options ) ;
1920
- const isCheckJsUndefined = includeUncheckedJS && sourceFile . checkJsDirective === undefined && options . checkJs === undefined ;
1920
+ const isCheckJsUndefined = includeUncheckedJS
1921
+ && sourceFile . checkJsDirective === undefined && options . checkJs === undefined
1922
+ && ( sourceFile . scriptKind === ScriptKind . JS || sourceFile . scriptKind === ScriptKind . JSX ) ;
1921
1923
const isTsNoCheck = ! ! sourceFile . checkJsDirective && sourceFile . checkJsDirective . enabled === false ;
1922
1924
// By default, only type-check .ts, .tsx, 'Deferred' and 'External' files (external files are added by plugins)
1923
1925
const includeBindAndCheckDiagnostics = ! isTsNoCheck &&
1924
1926
( sourceFile . scriptKind === ScriptKind . TS
1925
1927
|| sourceFile . scriptKind === ScriptKind . TSX
1926
1928
|| isCheckJsTrue
1927
- || isCheckJsUndefined && ( sourceFile . scriptKind === ScriptKind . JS || sourceFile . scriptKind === ScriptKind . JSX )
1929
+ || isCheckJsUndefined
1928
1930
|| sourceFile . scriptKind === ScriptKind . External
1929
1931
|| sourceFile . scriptKind === ScriptKind . Deferred ) ;
1930
- let bindDiagnostics : readonly Diagnostic [ ] = includeBindAndCheckDiagnostics ? sourceFile . bindDiagnostics : emptyArray ;
1932
+ const bindDiagnostics : readonly Diagnostic [ ] = includeBindAndCheckDiagnostics && ! isCheckJsUndefined ? sourceFile . bindDiagnostics : emptyArray ;
1931
1933
let checkDiagnostics = includeBindAndCheckDiagnostics ? typeChecker . getDiagnostics ( sourceFile , cancellationToken ) : emptyArray ;
1932
- if ( isCheckJsUndefined && ( sourceFile . scriptKind === ScriptKind . JS || sourceFile . scriptKind === ScriptKind . JSX ) ) {
1933
- // TODO: It can just be checkDiagnostics srsly
1934
- bindDiagnostics = bindDiagnostics . filter ( d => d . code === Diagnostics . Cannot_find_name_0_Did_you_mean_1 . code || d . code === Diagnostics . Property_0_does_not_exist_on_type_1_Did_you_mean_2 . code ) ;
1935
- checkDiagnostics = checkDiagnostics . filter ( d => d . code === Diagnostics . Cannot_find_name_0_Did_you_mean_1 . code || d . code === Diagnostics . Property_0_does_not_exist_on_type_1_Did_you_mean_2 . code ) ;
1934
+ if ( isCheckJsUndefined ) {
1935
+ checkDiagnostics = checkDiagnostics . filter ( d =>
1936
+ d . code === Diagnostics . Cannot_find_name_0_Did_you_mean_1 . code
1937
+ || d . code === Diagnostics . Property_0_does_not_exist_on_type_1_Did_you_mean_2 . code ) ;
1936
1938
}
1937
1939
return getMergedBindAndCheckDiagnostics ( sourceFile , includeBindAndCheckDiagnostics , bindDiagnostics , checkDiagnostics , isCheckJsTrue ? sourceFile . jsDocDiagnostics : undefined ) ;
1938
1940
} ) ;
0 commit comments