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

fix: use default types location to comply legacy tsc moduleResolution #246

Conversation

antongolub
Copy link

12.1.1 brings a new types location, which differs from the default ./index.d.ts, so now it breaks transpilation for many legacy tsconfigs. Let's keep it compatible.

microsoft/TypeScript#51862

@sindresorhus
Copy link
Owner

No thanks. This is an ESM package and you are expected to use moduleResolution: node16.

https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c

@antongolub
Copy link
Author

antongolub commented Sep 18, 2023

Ok, how about deprecating 12.1.1 and rereleasing it as 13.0.0? 12.1.1 — was an unexpected breaking change.
Node16 is not just a minor tsconfig tweak up, it enforces to declare .js file extensions explicitly for the entire ts project codebase.

@antongolub
Copy link
Author

antongolub commented Sep 18, 2023

@sindresorhus,
The problem can be solved on our side, of course, but all available options are quite expensive to apply immediately to each affected point:

  1. pin version / use yarn resolutions / npm overrides / patch lockfiles
  2. patch packuments on proxy registry to omit >= 12.1.1
  3. apply patch-package
  4. switch moduleResolution to node16/nodenext, inject .js extensions to TS codebase
  5. switch moduleResolution to bundler (requires TS >=5.0)
  6. override libdefs in place
// meow.d.ts
declare module "meow" {
  import type * as meow from 'meow/build/index.d.ts'
  export = meow
}

@sindresorhus
Copy link
Owner

The change that defined exports in package.json was released with v11, in a major version, a long time ago. The change in 12.1.1 was techincally not breaking. It only breaks because you were using the package even though your project is not ESM.

@sindresorhus
Copy link
Owner

I suggest pinning the version until you move to ESM.

@antongolub
Copy link
Author

antongolub commented Sep 18, 2023

you were using the package even though your project is not ESM

I'm afraid, our case is a bit exotic: we use ESM ("exports, type: module" in pkg.json, "module": "esnext" in tsconfig), but we do not inject .js extensions to ts files. Instead, we use tsc-esm-fix for post-build patching.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants