From 1e5825574942fa1fcbe8c73ee06886efb62ef356 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Mon, 3 Jul 2023 09:40:58 -0700 Subject: [PATCH] Fix auto import path mapping when first pattern fails --- src/compiler/moduleSpecifiers.ts | 4 +++- tests/cases/fourslash/autoImportPaths.ts | 25 ++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 tests/cases/fourslash/autoImportPaths.ts diff --git a/src/compiler/moduleSpecifiers.ts b/src/compiler/moduleSpecifiers.ts index d2332db89a182..8ebb6cf96554d 100644 --- a/src/compiler/moduleSpecifiers.ts +++ b/src/compiler/moduleSpecifiers.ts @@ -775,7 +775,9 @@ function tryGetModuleNameFromPaths(relativeToBaseUrl: string, paths: MapLike + +// @Filename: /package1/jsconfig.json +//// { +//// "compilerOptions": { +//// checkJs: true, +//// "paths": { +//// "package1/*": ["./*"], +//// "package2/*": ["../package2/*"] +//// }, +//// "baseUrl": "." +//// }, +//// "include": [ +//// ".", +//// "../package2" +//// ] +//// } + +// @Filename: /package1/file1.js +//// bar/**/ + +// @Filename: /package2/file1.js +//// export const bar = 0; + +verify.importFixModuleSpecifiers("", ["package2/file1"], { importModuleSpecifierPreference: "shortest" });