You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importvalue1from'./~.js';importvalue2from'./%7E.js';// Cannot find module or its corresponding type declarations.importvalue3from'./|.js';importvalue4from'./%7C.js';// Cannot find module or its corresponding type declarations.console.log(value1);console.log(value2);console.log(value3);console.log(value4);
How to reproduce:
$ npm i
$ npm start...
π Actual behavior
I get a compile errors that the module cannot be found.
> start
> run-s -c tsc:*
> tsc:bundler
> tsc -p tsconfig.bundler.json --noEmiterror TS5083: Cannot read file '/home/projects/tsconfig.base.json'.src/index.ts:2:20 - error TS2307: Cannot find module './%7E.js' or its corresponding type declarations.2 import value2 from './%7E.js'; // Cannot find module or its corresponding type declarations. ~~~~~~~~~~src/index.ts:4:20 - error TS2307: Cannot find module './%7C.js' or its corresponding type declarations.4 import value4 from './%7C.js'; // Cannot find module or its corresponding type declarations. ~~~~~~~~~~Found 3 errors in the same file, starting at: src/index.ts:2
> tsc:node
> tsc -p tsconfig.node.json --noEmiterror TS5083: Cannot read file '/home/projects/tsconfig.base.json'.src/index.ts:2:20 - error TS2307: Cannot find module './%7E.js' or its corresponding type declarations.2 import value2 from './%7E.js'; // Cannot find module or its corresponding type declarations. ~~~~~~~~~~src/index.ts:4:20 - error TS2307: Cannot find module './%7C.js' or its corresponding type declarations.4 import value4 from './%7C.js'; // Cannot find module or its corresponding type declarations. ~~~~~~~~~~Found 3 errors in the same file, starting at: src/index.ts:2ERROR: "tsc:node" exited with 2.npm ERR! code EIOnpm ERR! syscall writenpm ERR! errno -5npm ERR! EIO: i/o error, writenpm ERR! A complete log of this run can be found in: /home/.npm/_logs/2024-12-16T11_30_12_486Z-debug-0.logjsh: spawn npm EIO
π Expected behavior
No compilation errors.
Additional information about the issue
The resolution algorithm for import specifier is defined at the JavaScript runtime, not in ECMAScript. In Node.js and browsers, ~.mjs can be imported by import xxx from './%7E.mjs'. This is based on the following specifications:
I don't think URL-encoded is supported by all runtimes, but it seems to be common. This information will help you decide if you want TypeScript to support URL-encoded paths.
The text was updated successfully, but these errors were encountered:
π Search Terms
"import specifier", "resolution", "URL-encoded"
π Version & Regression Information
β― Playground Link
No response
π» Code
https://stackblitz.com/edit/stackblitz-starters-xjsggz7l?file=src%2Findex.ts&view=editor
How to reproduce:
π Actual behavior
I get a compile errors that the module cannot be found.
π Expected behavior
No compilation errors.
Additional information about the issue
The resolution algorithm for import specifier is defined at the JavaScript runtime, not in ECMAScript. In Node.js and browsers,
~.mjs
can be imported byimport xxx from './%7E.mjs'
. This is based on the following specifications:https://nodejs.org/docs/v23.4.0/api/esm.html#urls
https://html.spec.whatwg.org/multipage/webappapis.html#the-resolution-algorithm
I don't think URL-encoded is supported by all runtimes, but it seems to be common. This information will help you decide if you want TypeScript to support URL-encoded paths.
The text was updated successfully, but these errors were encountered: