Skip to content

Module resolution using nodenext and a wildcard in package.json exports #55021

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

Open
mikearnaldi opened this issue Jul 14, 2023 · 3 comments
Open
Assignees
Labels
Needs Investigation This issue needs a team member to investigate its status. Rescheduled This issue was previously scheduled to an earlier milestone

Comments

@mikearnaldi
Copy link

Bug Report

🔎 Search Terms

Nodenext wildcard, type cannot be named

🕗 Version & Regression Information

The bug only appears when using nodenext for module resolution

⏯ Playground Link

Cloneable repo: https://github.com/geoffreytools/effect-test-tsc

💻 Code

import { TaggedClass } from '@effect/data/Data';
// import '@effect/data/Equal';

export class Foo extends TaggedClass('Foo')<{}> {}

🙁 Actual behavior

The inferred type of 'Foo' cannot be named without a reference to '../node_modules/@effect/data/Equal'. This is likely not portable. A type annotation is necessary.

🙂 Expected behavior

To compile correctly, without using nodenext it works fine and the same issue doesn't apply to other transitive imports such as Hash that are identically exported. All goes away the very moment there is either an explicit import of Equal or when adding to the library package.json the following:

{
  "exports": {
    "./Equal": {
      "import": {
        "types": "./Equal.d.ts",
        "default": "./mjs/Equal.mjs"
      }
    }
  }
}

Note that the library uses a wildcard ./* as each import map to a file and this is perfectly resolvable by node

@RyanCavanaugh RyanCavanaugh added the Needs Investigation This issue needs a team member to investigate its status. label Jul 24, 2023
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 5.3.0 milestone Jul 24, 2023
@datner
Copy link

datner commented Aug 27, 2023

This impacts all multi-module/multi-entry modules..
Can someone take a look at this? it's really tedious trying to build in esm with this bug.
This bug appears with a module self-import as well

import Foo from "app/Foo" // <-- types broken with `/*` exports

@andrewbranch
Copy link
Member

andrewbranch commented Nov 3, 2023

I think #56107 was a duplicate of this—see my analysis there.

This impacts all multi-module/multi-entry modules.

#56107 was specific to a re-export pattern used by Effect; I haven’t seen other libraries affected by this. @datner, you may have been running into something else entirely. If anyone is having issues with this outside of Effect, please provide a repro so we can see if there’s something different going on.

@mikearnaldi
Copy link
Author

I think #56107 was a duplicate of this—see my analysis there.

This impacts all multi-module/multi-entry modules.

#56107 was specific to a re-export pattern used by Effect; I haven’t seen other libraries affected by this. @datner, you may have been running into something else entirely. If anyone is having issues with this outside of Effect, please provide a repro so we can see if there’s something different going on.

What's specific to Effect here? we are just re-exporting a module

@RyanCavanaugh RyanCavanaugh added the Rescheduled This issue was previously scheduled to an earlier milestone label Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Investigation This issue needs a team member to investigate its status. Rescheduled This issue was previously scheduled to an earlier milestone
Projects
None yet
Development

No branches or pull requests

5 participants