TypeScript/tests/cases/fourslash/importNameCodeFixNewImportExportEqualsCommonJSInteropOn.ts
Andrew Branch 62f65a7884
Make auto-imports more likely to be valid for the file (including JS) & project settings (#32684)
* Add failing tests

* Use default import or namespace import for import fixes when compiler options allow

* Don’t do import * for export=, ever

* Only do import default for export equals if nothing else will work

* Never do import/require in a JavaScript file

* Update tests for changes in master

* Add const/require fix for JS and select based on usage heuristic

* Fix JS UMD import
2019-08-02 15:58:10 -07:00

51 lines
960 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/// <reference path="fourslash.ts" />
// @Module: commonjs
// @EsModuleInterop: true
// @Filename: /foo.d.ts
////declare module "bar" {
//// const bar: number;
//// export = bar;
////}
////declare module "foo" {
//// const foo: number;
//// export = foo;
////}
////declare module "es" {
//// const es = 0;
//// export default es;
////}
// @Filename: /a.ts
////import bar from "bar";
////
////foo
// @Filename: /b.ts
////foo
// @Filename: /c.ts
////import es from "es";
////
////foo
// 1. Should match existing imports of 'export ='
goTo.file('/a.ts');
verify.importFixAtPosition([`import bar from "bar";
import foo from "foo";
foo`]);
// 2. Should default to ImportEquals
goTo.file('/b.ts');
verify.importFixAtPosition([`import foo = require("foo");
foo`]);
// 3. Importing an 'export default' doesnt count toward the usage heursitic
goTo.file('/c.ts');
verify.importFixAtPosition([`import es from "es";
import foo = require("foo");
foo`]);