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

#272 broke new TS 4.1+ typing features #291

Closed
tec27 opened this issue Feb 21, 2023 · 6 comments
Closed

#272 broke new TS 4.1+ typing features #291

tec27 opened this issue Feb 21, 2023 · 6 comments

Comments

@tec27
Copy link

tec27 commented Feb 21, 2023

The changes in #272 seem to break the new typing features (e.g. automatically extracting types from route strings). According to the TS docs on typeVersions:

https://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html#multiple-fields

Since ranges have the potential to overlap, determining which redirect applies is order-specific.

By moving >=4.1 below a * match string, the 4.1+ case will never be hit (even if no files inside the * block are being looked for). Testing locally, reversing the order of these blocks makes things work on my machine again.

This seems like a possibly simple fix (just reverse the order of these blocks, duplicate the content of the * block in the >=4.1 block as well), but as I'm not sure what issue this change was solving in the first place/how to test it, I don't really feel comfortable making that change myself.

tec27 added a commit to ShieldBattery/ShieldBattery that referenced this issue Feb 21, 2023
Held back got and query-string because they moved to pure ESM and I'm
still not sure how to get them working in our convoluted build.

Had to switch to a fork of wouter for the time being, can switch back
once molefrog/wouter#291 is fixed.
@molefrog
Copy link
Owner

molefrog commented Feb 21, 2023

I did a simple experiment and sadly reversing the order didn't help. It worked for the main entry, but it broke types of the other files such as wouter/use-location. I don't have the expertise to say for sure why it didn't work, but perhaps we could use a more bulletproof approach here:

  "typesVersions": {
    ">=4.1": {
      "types/ts3.9.4/index.d.ts": [
        "types/ts4.1/index.d.ts"
      ],
      "use-location": [
        "types/use-location.d.ts"
      ],
      "matcher": [
        "types/matcher.d.ts"
      ],
      "static-location": [
        "types/static-location.d.ts"
      ]
    },
    "<4.1": {
      "use-location": [
        "types/use-location.d.ts"
      ],
      "matcher": [
        "types/matcher.d.ts"
      ],
      "static-location": [
        "types/static-location.d.ts"
      ]
    }
  },

@tec27
Copy link
Author

tec27 commented Feb 21, 2023

I definitely don't have the expertise there either :) This is the change I applied for the time being (which I assume is what you tested, but just making sure):

tec27@6c0159e

Very possible that breaks other things of course, but it did fix my own project's build. Changing the wildcard to match less than a specific version seems sound to me, I see other projects doing that, but I don't get why that would differ from the wildcard in this case.

@vicero
Copy link

vicero commented Mar 29, 2023

I just ran into this issue as well! ➕ 1️⃣

@molefrog
Copy link
Owner

Hey @vicero, I've published a test version with the fix applied 2.10.2-dev.1
Could you please check if it solves your problem?

@vicero
Copy link

vicero commented Apr 19, 2023

@molefrog yes this works perfectly! Thank you! FWIW my project with issues is on Typescript 4.7.4

@molefrog
Copy link
Owner

@vicero Great, I will include it in the next release along with some new features.

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

No branches or pull requests

3 participants