Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respect types@ exports condition or typesVersions #27861

Open
nicolo-ribaudo opened this issue Jan 29, 2025 · 0 comments
Open

Respect types@ exports condition or typesVersions #27861

nicolo-ribaudo opened this issue Jan 29, 2025 · 0 comments
Labels
bug Something isn't working correctly node resolution

Comments

@nicolo-ribaudo
Copy link

nicolo-ribaudo commented Jan 29, 2025

Version: Deno 2.1.7

Deno is resolving the wrong types in @babel/[email protected].

Try with this file:

import * as t from "npm:@babel/[email protected]";

type X = t.Identifier;

Go-to-definition goes to /Users/nic/Library/Caches/deno/npm/registry.npmjs.org/@babel/types/7.26.7/lib/index-legacy.d.ts, but it should go to /Users/nic/Library/Caches/deno/npm/registry.npmjs.org/@babel/types/7.26.7/lib/index.d.ts.

These are the relevant parts of package.json:

{
  "name": "@babel/types",
  "version": "7.26.7",
  "main": "./lib/index.js",
  "types": "./lib/index-legacy.d.ts",
  "typesVersions": {
    ">=4.1": {
      "lib/index-legacy.d.ts": [
        "lib/index.d.ts"
      ]
    }
  }
}

The same behavior happens with @babel/[email protected], which actually includes one more "tool" for Deno to resolve TS types (package.json#exports):

{
  "name": "@babel/types",
  "version": "8.0.0-alpha.15",
  "main": "./lib/index.js",
  "types": "./lib/index-legacy.d.ts",
  "typesVersions": {
    ">=4.1": {
      "lib/index-legacy.d.ts": [
        "lib/index.d.ts"
      ]
    }
  },
  "exports": {
    ".": {
      "types@>=4.1": "./lib/index.d.ts",
      "types": "./lib/index-legacy.d.ts",
      "default": "./lib/index.js"
    },
    "./package.json": "./package.json"
  },
  "type": "module"
}

Relevant TS docs:

@nicolo-ribaudo nicolo-ribaudo changed the title types@ exports condition or typesVersions Respect types@ exports condition or typesVersions Jan 29, 2025
@dsherret dsherret added bug Something isn't working correctly node resolution labels Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly node resolution
Projects
None yet
Development

No branches or pull requests

2 participants