microsoft / microsoft/TypeScript
Bug: Incorrect module resolution for "valid" ES2015 specifiers with hashes and/or search parameters
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
TypeScript Version: 2.8.0-dev.20180315
Search Terms: moduleResolution "module path" hash
Code
import { x as x1 } from './x.m.js'; // Typed correctly on hover
import { x as x2 } from './x.m.js#esm' // Typed as "import x…" on hover
Expected behavior:
Since module specifiers are now standardized, whereby if given an absolute specifier (or a relative specifier and the absolute referrer) should always result in a validly constructed new URL(specifier, referrer) it is expected that when a specifier includes suffix aspects like hash and search, that those aspects would be excluded from the pathname that is being resolved.
The implications of hash and search in runtime is beyond the scope of TypeScript and should remain so unless somehow the environment is customized to behave different (plugins maybe). However, if at all relevant, the specs have stated that at runtime each unique "resolved" URL (including hash and search) evaluates to a single unique instance of the respective module. It is not expected that TypeScript would need to determine if and when a module is a specific unique instance. It is however expected that when suffix aspects are included in the specifier that TypeScript would still resolve it's types identically as it does for the pathname sans hash and search.
Sorry for the long text!
Actual behavior:
TypeScript does not resolve pathnames with hash or search parameters.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with the two import statements shown, comparing resolution of './x.m.js' with './x.m.js#esm' and the expected pathname without hash or search. Start by tracing TypeScript's module-resolution handling for import specifiers; done means both specifiers resolve the same types while retaining any runtime-specific suffix semantics outside TypeScript.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100