Skip to content

Commit 674a8e1

Browse files
committed
Add AutoImportSuggestions for UMD module export declarations instead of global keywords
1 parent 8dbc226 commit 674a8e1

File tree

2 files changed

+6
-24
lines changed

2 files changed

+6
-24
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39187,7 +39187,7 @@ namespace ts {
3918739187
if (file.moduleAugmentations.length) {
3918839188
(augmentations || (augmentations = [])).push(file.moduleAugmentations);
3918939189
}
39190-
if (file.symbol && file.symbol.globalExports) {
39190+
if (file.symbol && file.symbol.globalExports && (compilerOptions.allowUmdGlobalAccess || !isExternalOrCommonJsModule(file))) {
3919139191
// Merge in UMD exports with first-in-wins semantics (see #9771)
3919239192
const source = file.symbol.globalExports;
3919339193
source.forEach((sourceSymbol, id) => {

tests/cases/fourslash/importNameCodeFixNewImportExportEqualES2015.ts renamed to tests/cases/fourslash/completionsImport_UmdModules.ts

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,22 @@
44
//// { "dependencies": { "@types/classnames": "*" } }
55

66
// @filename: /tsconfig.json
7-
//// {
8-
//// "compilerOptions": {
9-
//// "module": "esnext",
10-
//// "target": "es2015",
11-
//// "esModuleInterop": true,
12-
//// "allowSyntheticDefaultImports": true
13-
//// }
14-
//// }
7+
//// {}
158

169
// @filename: /node_modules/@types/classnames/package.json
1710
//// { "name": "@types/classnames", "types": "index.d.ts" }
1811

1912
// @filename: /node_modules/@types/classnames/index.d.ts
20-
//// declare const classNames = () => string;
13+
//// declare const classNames: () => string;
2114
//// export = classNames;
15+
//// export as namespace classNames;
2216

2317
// @filename: /SomeReactComponent.tsx
2418
//// import * as React from 'react';
2519
////
26-
//// const el = <div className={class/*0*/}>foo</div>;
27-
//// const el = <div className={classNames/*1*/}>foo</div>;
20+
//// const el1 = <div className={class/*1*/}>foo</div>;
2821

29-
goTo.marker("0");
22+
goTo.marker("1");
3023

3124
verify.completions({
3225
includes: [{
@@ -39,14 +32,3 @@ verify.completions({
3932
includeCompletionsForModuleExports: true,
4033
}
4134
});
42-
43-
goTo.marker("1");
44-
45-
format.setOption("newLineCharacter", "\n");
46-
verify.importFixAtPosition([
47-
`import classNames from 'classnames';
48-
import * as React from 'react';
49-
50-
const el = <div className={class}>foo</div>;
51-
const el = <div className={classNames}>foo</div>;`
52-
]);

0 commit comments

Comments
 (0)