mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-16 15:45:27 -05:00
Merge pull request #17302 from minestarks/removeimportfix
Bugs in missing import codefix
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
//// [|f1/*0*/('');|]
|
||||
|
||||
// @Filename: package.json
|
||||
//// { "dependencies": { "package-name": "latest" } }
|
||||
|
||||
// @Filename: node_modules/package-name/bin/lib/libfile.d.ts
|
||||
//// export function f1(text: string): string;
|
||||
|
||||
// @Filename: node_modules/package-name/bin/lib/libfile.js
|
||||
//// function f1(text) { }
|
||||
//// exports.f1 = f1;
|
||||
|
||||
// @Filename: node_modules/package-name/package.json
|
||||
//// {
|
||||
//// "main": "bin/lib/libfile.js",
|
||||
//// "types": "bin/lib/libfile.d.ts"
|
||||
//// }
|
||||
|
||||
verify.importFixAtPosition([
|
||||
`import { f1 } from "package-name";
|
||||
|
||||
f1('');`
|
||||
]);
|
||||
@@ -0,0 +1,25 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
//// [|f1/*0*/('');|]
|
||||
|
||||
// @Filename: package.json
|
||||
//// { "dependencies": { "package-name": "latest" } }
|
||||
|
||||
// @Filename: node_modules/package-name/node_modules/package-name2/bin/lib/libfile.d.ts
|
||||
//// export function f1(text: string): string;
|
||||
|
||||
// @Filename: node_modules/package-name/node_modules/package-name2/bin/lib/libfile.js
|
||||
//// function f1(text) { }
|
||||
//// exports.f1 = f1;
|
||||
|
||||
// @Filename: node_modules/package-name/node_modules/package-name2/package.json
|
||||
//// {
|
||||
//// "main": "bin/lib/libfile.js",
|
||||
//// "types": "bin/lib/libfile.d.ts"
|
||||
//// }
|
||||
|
||||
verify.importFixAtPosition([
|
||||
`import { f1 } from "package-name/node_modules/package-name2";
|
||||
|
||||
f1('');`
|
||||
]);
|
||||
@@ -0,0 +1,25 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
//// [|f1/*0*/('');|]
|
||||
|
||||
// @Filename: package.json
|
||||
//// { "dependencies": { "package-name": "latest" } }
|
||||
|
||||
// @Filename: node_modules/package-name/bin/lib/index.d.ts
|
||||
//// export function f1(text: string): string;
|
||||
|
||||
// @Filename: node_modules/package-name/bin/lib/index.js
|
||||
//// function f1(text) { }
|
||||
//// exports.f1 = f1;
|
||||
|
||||
// @Filename: node_modules/package-name/package.json
|
||||
//// {
|
||||
//// "main": "bin/lib/index.js",
|
||||
//// "types": "bin/lib/index.d.ts"
|
||||
//// }
|
||||
|
||||
verify.importFixAtPosition([
|
||||
`import { f1 } from "package-name";
|
||||
|
||||
f1('');`
|
||||
]);
|
||||
@@ -0,0 +1,29 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
//// [|f1/*0*/('');|]
|
||||
|
||||
// @Filename: package.json
|
||||
//// { "dependencies": { "package-name": "0.0.1" } }
|
||||
|
||||
// @Filename: node_modules/package-name/bin/lib/libfile.d.ts
|
||||
//// export declare function f1(text: string): string;
|
||||
|
||||
// @Filename: node_modules/package-name/bin/lib/libfile.js
|
||||
//// function f1(text) {}
|
||||
//// exports.f1 = f1;
|
||||
|
||||
// @Filename: node_modules/package-name/package.json
|
||||
//// { "main": "bin/lib/libfile.js" }
|
||||
|
||||
|
||||
// In this case, importing the module by its package name:
|
||||
// import { f1 } from 'package-name'
|
||||
// could in theory work, however the resulting code compiles with a module resolution error
|
||||
// since bin/lib/libfile.d.ts isn't declared under "typings" in package.json
|
||||
// Therefore just import the module by its qualified path
|
||||
|
||||
verify.importFixAtPosition([
|
||||
`import { f1 } from "package-name/bin/lib/libfile";
|
||||
|
||||
f1('');`
|
||||
]);
|
||||
Reference in New Issue
Block a user