Skip to content

Fix export=global auto-import exclusion #32898

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/services/completions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1289,7 +1289,7 @@ namespace ts.Completions {
if (resolvedModuleSymbol !== moduleSymbol &&
// Don't add another completion for `export =` of a symbol that's already global.
// So in `declare namespace foo {} declare module "foo" { export = foo; }`, there will just be the global completion for `foo`.
some(resolvedModuleSymbol.declarations, d => !!d.getSourceFile().externalModuleIndicator)) {
every(resolvedModuleSymbol.declarations, d => !!d.getSourceFile().externalModuleIndicator)) {
symbols.push(resolvedModuleSymbol);
symbolToSortTextMap[getSymbolId(resolvedModuleSymbol)] = SortText.AutoImportSuggestions;
symbolToOriginInfoMap[getSymbolId(resolvedModuleSymbol)] = { kind: SymbolOriginInfoKind.Export, moduleSymbol, isDefaultExport: false };
Expand Down
31 changes: 31 additions & 0 deletions tests/cases/fourslash/completionsImport_exportEquals_global.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/// <reference path="fourslash.ts" />

// @module: es6

// @Filename: /console.d.ts
////interface Console {}
////declare var console: Console;
////declare module "console" {
//// export = console;
////}

// @Filename: /react-native.d.ts
//// import 'console';
////declare global {
//// interface Console {}
//// var console: Console;
////}

// @Filename: /a.ts
////conso/**/

verify.completions({
exact: completion.globalsPlus([{
hasAction: undefined, // asserts that it does *not* have an action
name: "console"
}]),
preferences: {
includeCompletionsForModuleExports: true,
includeInsertTextCompletions: true
}
});