@@ -1917,22 +1917,24 @@ namespace ts {
19171917 Debug . assert ( ! ! sourceFile . bindDiagnostics ) ;
19181918
19191919 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 ) ;
19211923 const isTsNoCheck = ! ! sourceFile . checkJsDirective && sourceFile . checkJsDirective . enabled === false ;
19221924 // By default, only type-check .ts, .tsx, 'Deferred' and 'External' files (external files are added by plugins)
19231925 const includeBindAndCheckDiagnostics = ! isTsNoCheck &&
19241926 ( sourceFile . scriptKind === ScriptKind . TS
19251927 || sourceFile . scriptKind === ScriptKind . TSX
19261928 || isCheckJsTrue
1927- || isCheckJsUndefined && ( sourceFile . scriptKind === ScriptKind . JS || sourceFile . scriptKind === ScriptKind . JSX )
1929+ || isCheckJsUndefined
19281930 || sourceFile . scriptKind === ScriptKind . External
19291931 || sourceFile . scriptKind === ScriptKind . Deferred ) ;
1930- let bindDiagnostics : readonly Diagnostic [ ] = includeBindAndCheckDiagnostics ? sourceFile . bindDiagnostics : emptyArray ;
1932+ const bindDiagnostics : readonly Diagnostic [ ] = includeBindAndCheckDiagnostics && ! isCheckJsUndefined ? sourceFile . bindDiagnostics : emptyArray ;
19311933 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 ) ;
19361938 }
19371939 return getMergedBindAndCheckDiagnostics ( sourceFile , includeBindAndCheckDiagnostics , bindDiagnostics , checkDiagnostics , isCheckJsTrue ? sourceFile . jsDocDiagnostics : undefined ) ;
19381940 } ) ;
0 commit comments