Use compilerOptionsIndicateEs6Modules over program contains es6 modules for determining auto import offering. Also dont depend on uncheck js file for this.

Fixes #28696
This commit is contained in:
Sheetal Nandi
2018-11-29 11:58:32 -08:00
parent 36dc04b982
commit 23abcc02a3
3 changed files with 53 additions and 25 deletions

View File

@@ -1050,12 +1050,10 @@ namespace ts.Completions {
if (sourceFile.externalModuleIndicator) return true;
// If already using commonjs, don't introduce ES6.
if (sourceFile.commonJsModuleIndicator) return false;
// For JS, stay on the safe side.
if (isUncheckedFile) return false;
// If some file is using ES6 modules, assume that it's OK to add more.
if (programContainsEs6Modules(program)) return true;
// If module transpilation is enabled or we're targeting es6 or above, or not emitting, OK.
return compilerOptionsIndicateEs6Modules(program.getCompilerOptions());
if (compilerOptionsIndicateEs6Modules(program.getCompilerOptions())) return true;
// If some file is using ES6 modules, assume that it's OK to add more.
return programContainsEs6Modules(program);
}
function isSnippetScope(scopeNode: Node): boolean {