microsoft / microsoft/TypeScript

TS does not support resolving paths with colons

Open
#57,529 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Domain: Module Resolution Help Wanted
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
1d 19h
Merged PRs (30d)
117

Description

🔎 Search Terms

https://github.com/microsoft/TypeScript/issues?q=is%3Aissue+colon+exports+is%3Aclosed

colon, exports

🕗 Version & Regression Information
  • This is the behavior in every version I tried
⏯ Playground Link

https://stackblitz.com/edit/stackblitz-starters-d2rfdx?description=Starter%20project%20for%20Node.js,%20a%20JavaScript%20runtime%20built%20on%20Chrome%27s%20V8%20JavaScript%20engine&file=package.json&title=node.new%20Starter

💻 Code

Consumer module:

import a from 'my-library';
import b from 'my-library/foo';
import c from 'my-library/foo:virtual';
import d from 'my-library/bar';
import e from 'my-library/colon:here';

console.log({ a, b, c, d, e });

package.json for my-library:

{
  "name": "my-library",
  "version": "0.0.1",
  "type": "module",
  "exports": {
    ".": {
      "types": "./foo.d.ts",
      "default": "./foo.js"
    },
    "./foo": {
      "types": "./foo.d.ts",
      "import": "./foo.js"
    },
    "./foo:virtual": {
      "types": "./foo.d.ts",
      "default": "./foo.js"
    },
    "./*": {
      "types": "./*.d.ts",
      "default": "./*.js"
    }
  },
  "scripts": {
    "lint": "attw --pack; pnpm publint"
  },
  "dependencies": {
    "@arethetypeswrong/cli": "^0.14.1",
    "publint": "^0.2.7"
  }
}

every imported module is supposed to resolve, and then print:

{ a: 2, b: 2, c: 2, d: 2, e: 'two' }

(pnpm start in the consumer package in the repro link shows this)

🙁 Actual behavior

Errors, cannot find module
image

🙂 Expected behavior

align with JS, resolve the module

Additional information about the issue

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the StackBlitz repro and the consumer package's pnpm start, then inspect the shown package.json exports entries containing colons. Trace TypeScript's module-resolution behavior for these package subpaths and compare it with the JavaScript runtime result. Done means all five imports resolve and produce the expected output.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.