fix(npm): support bare specifiers in package.json having a path (#17903)

For example `import * as test from "package/path.js"`
This commit is contained in:
David Sherret 2023-02-23 12:33:23 -05:00 committed by GitHub
parent 344317ec50
commit 6233c0aff0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 110 additions and 20 deletions

View file

@ -1,2 +1,3 @@
2
2
2

View file

@ -1,13 +1,16 @@
import * as myImport1 from "@denotest/esm-basic";
import * as myImport2 from "./node_modules/@denotest/esm-basic/main.mjs";
import * as myImport3 from "@denotest/esm-basic/main.mjs";
myImport1.setValue(5);
myImport2.setValue(2);
// these should both give type errors
// these should all give type errors
const value1: string = myImport1.getValue();
const value2: string = myImport2.getValue();
const value3: string = myImport3.getValue();
// these should both be equal because it should be mutating the same module
// these should all be equal because it should be mutating the same module
console.log(value1);
console.log(value2);
console.log(value3);

View file

@ -1,11 +1,16 @@
error: TS2322 [ERROR]: Type 'number' is not assignable to type 'string'.
const value1: string = myImport1.getValue();
~~~~~~
at file:///[WILDCARD]/npm/node_modules_import/main.ts:8:7
at file:///[WILDCARD]/npm/node_modules_import/main.ts:9:7
TS2322 [ERROR]: Type 'number' is not assignable to type 'string'.
const value2: string = myImport2.getValue();
~~~~~~
at file:///[WILDCARD]/npm/node_modules_import/main.ts:9:7
at file:///[WILDCARD]/npm/node_modules_import/main.ts:10:7
Found 2 errors.
TS2322 [ERROR]: Type 'number' is not assignable to type 'string'.
const value3: string = myImport3.getValue();
~~~~~~
at file:///[WILDCARD]/npm/node_modules_import/main.ts:11:7
Found 3 errors.