chai
chai copied to clipboard
Officia type definitions for 5.x?
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?
PRs welcome for adding official types.
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
I'm hesitant to ask, but... it's there any appetite for a contribution of a port of the source to TypeScript syntax?
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
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.
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
https://github.com/chaijs/chai/pull/1557
Feel free to help out by making PRs against this one.
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;
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
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.
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