Skip to content

chore: move callback and object typedefs to a new types.d.ts #5351

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
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

JoshuaKGoldberg
Copy link
Member

@JoshuaKGoldberg JoshuaKGoldberg commented May 1, 2025

PR Checklist

Overview

Creates a new lib/types.d.ts and moves every @callback and @typedef {Object} to it. A new tsconfig.json & tsc script can be run to verify that the types in that file can be type checked.

Does not yet validate types in .js files (#4154, #4228). You can preview those by switching tsconfig.json's allowJs to checkJs. I made sure there are no more "Cannot find name ..." errors but fixing the rest of the ~650+ will be a lot more work. Much of the code will be much easier to get type-safe when it's ported from manual function prototypes to classes (#5025). I also held off porting all the info from @types/mocha there to keep the changes minimal.

Does not yet try to pull in types or descriptions from @types/mocha. That would be a bigger change too.

Moves error constants from errors.js to error-constants.js to avoid circular dependency errors.

@JoshuaKGoldberg JoshuaKGoldberg marked this pull request as ready for review May 2, 2025 13:26
@JoshuaKGoldberg JoshuaKGoldberg requested a review from a team May 2, 2025 13:39
@voxpelli
Copy link
Member

voxpelli commented May 5, 2025

Why everything in one large .d.ts?

Also: You can try to use (still sometimes buggy) the @import to import instead of using typedef, eg:

/** @import { Foo } from './bar.js' */

@JoshuaKGoldberg
Copy link
Member Author

JoshuaKGoldberg commented May 6, 2025

Why everything in one large .d.ts?

I don't have preferences on where to organize types, since this feels like a transient "we'll clean things up over time anyway" kind of situation to me 😄. Do you have a preference for where things should go?

@mark-wiemer mark-wiemer self-requested a review May 11, 2025 19:22
@JoshuaKGoldberg
Copy link
Member Author

ping @voxpelli did you mean for #5351 (comment) to be a full review? I'm not clear on whether you're requesting changes and waiting on me, or just posting thoughts pending a full review?

@voxpelli
Copy link
Member

@JoshuaKGoldberg Posting thoughts pending a full review, thanks for pinging and asking 🙏

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.

🛠 Repo: Split type declarations into standalone .d.ts files
2 participants