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

Officia type definitions for 5.x? #1554

Open
justinfagnani opened this issue Dec 20, 2023 · 15 comments
Open

Officia type definitions for 5.x? #1554

justinfagnani opened this issue Dec 20, 2023 · 15 comments
Labels

Comments

@justinfagnani
Copy link

I notice that there are no type definitions for the 5.x branch, here or in Definitely Typed. Is there a chance of getting official types with the 5.x releases?

@keithamus
Copy link
Member

PRs welcome for adding official types.

@43081j
Copy link
Contributor

43081j commented Dec 21, 2023

we could generate types via --declarationOnly in tsc if we correct all the jsdoc, but its a chunky job

so maybe for now we just store hand written types alongside the sources? i can probably have a stab at it at some point

@justinfagnani
Copy link
Author

I'm hesitant to ask, but... it's there any appetite for a contribution of a port of the source to TypeScript syntax?

@43081j
Copy link
Contributor

43081j commented Dec 21, 2023

Tbh I would rather do that than work around it producing types from the js

If everyone's up for that I can probably sort it out

@justinfagnani
Copy link
Author

I could contribute too, though you might be faster.

I wonder if given the existing npm scripts, if Wireit would be a good addition to make sure everything's built before other scripts that need that.

@koddsson
Copy link
Member

Started a draft PR here. I'll be slogging through the types and trying to get them all done before the new year but who knows how long it will take :D

#1557

Feel free to help out by making PRs against this one.

@freshp86
Copy link

freshp86 commented Jun 25, 2024

Any updates here? The lack of TS definitions for v5 makes it harder to adopt this version in TS codebases.

FWIW, the following patch seems to do the minimum work needed to import assert and expect from a TS file.

-declare const chai: Chai.ChaiStatic;
-
-declare module "chai" {
-    export = chai;
-}
+export const assert: Chai.AssertStatic;
+export const expect: Chai.ExpectStatic;

@43081j
Copy link
Contributor

43081j commented Jun 26, 2024

i have a branch where i was working on converting the codebase to typescript overall, but i think @koddsson, @keithamus and i should really catch up on this

we need to decide if to provide a fixed set of types as step 1, then move to typescript. or just go all in and move to typescript

@freshp86
Copy link

freshp86 commented Jun 28, 2024

we need to decide if to provide a fixed set of types as step 1, then move to typescript

This seems like the best option to me.

... or just go all in and move to typescript

Blocking v5 TS definitions on the whole project moving to TS seems a bit unnecessary. As shown above manually crafting a d.ts file to properly reflect the newly exposed ES modules seems much easier (perhaps even trivial?) than migrating the whole project to TS and then relying on automatic .d.ts generation.

@43081j
Copy link
Contributor

43081j commented Jun 28, 2024

i think you're right

i have a bunch of travel in the coming weeks but ill try find time to at least sort out a types-only branch (before moving to typescript as a whole)

contributions welcome too of course, but im thinking we may as well roughly copy whats in my ts branch

@tpluscode
Copy link

Thought I'd give DT a go DefinitelyTyped/DefinitelyTyped#70397 before chai is migrated. And the type packages which depend on chai will need to be updated anyway so..

cc @43081j

@43081j
Copy link
Contributor

43081j commented Aug 27, 2024

Oof that's a chunky change 😅 I'll have a read through it when I can

I'm planning on working on shipping types with chai pretty soon too, but not through my ts conversion. Initially just hand writing them (from my branch)

@tpluscode
Copy link

The changes to chai itself aren't that big. But all the related packages 😵‍💫

@tpluscode
Copy link

@43081j following the advice from @andrewbranch on DT, I would also propose the same, that should chai bundle its own types at some point, you'd keep the global Chai namespace. Other way will likely be a breaking change, similarly to what I initially did in that PR. Keeping the global NS will help with backward compatibility.

@tpluscode
Copy link

@types/[email protected] has been published yesterday

@koddsson koddsson added the types label Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants