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

Split internal.d.ts into multiple files #906

Merged
merged 10 commits into from
Jul 14, 2024

Conversation

tommy-mitchell
Copy link
Contributor

@tommy-mitchell tommy-mitchell commented Jul 6, 2024

Splits the types in internal.d.ts into multiple category-based files to improve maintainability, with the following structure:

\_ source/
   \_ internal/
      \_ array.d.ts
      \_ characters.d.ts
      \_ keys.d.ts
      \_ numeric.d.ts
      \_ object.d.ts
      \_ string.d.ts
      \_ tuple.d.ts
      \_ type.d.ts (misc types)
      \_ index.d.ts (so imports don't need updated)
   \_ ...
\_ test-d/
   \_ internal/
      \_ [category]/
         \_ [type].ts
   \_ ...

Other miscellaneous changes:

  • Updates test script to detect source files in subfolders.
  • Removes unused type imports.
  • Renames ArrayMax/ArrayMin to TupleMax/TupleMin. This can be reverted if desired.

I tried maintaining the order of types and their formatting when copying them over, but I could've missed something.

@sindresorhus
Copy link
Owner

I don't mind this, but I also don't see a strong need to do it. Ideally, many of these types should be exported publicly instead (#676).

One thing I don't want is to nest the tests into folder. I think all the internal types should be top-level tests in the tests/internal folder.

@tommy-mitchell tommy-mitchell changed the title Split internal.d.ts into multiple files Split internal.d.ts into multiple files, expose some types Jul 10, 2024
@tommy-mitchell
Copy link
Contributor Author

Updated tests and exposes some internal types that I found requests for in the issues. Please see the lines marked TODO for outstanding questions.

@sindresorhus
Copy link
Owner

When I mentioned exporting types, I didn't really mean in this pull request. It would be better to have separate pull requests for each exposed type, to make it easier to review and also to track changes for release notes.

readme.md Outdated Show resolved Hide resolved
source/non-empty-tuple.d.ts Outdated Show resolved Hide resolved
source/non-empty-tuple.d.ts Outdated Show resolved Hide resolved
@tommy-mitchell
Copy link
Contributor Author

Unexposed types and added to separate PRs.

Comment on lines +10 to +14
/**
Matches any unknown array or tuple.
*/
export type UnknownArrayOrTuple = readonly [...unknown[]];
// TODO: should unknown-array be updated?
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need both of these types?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know. I don't think that's relevant to this pull request though. Open a separate issue about it.

@tommy-mitchell tommy-mitchell changed the title Split internal.d.ts into multiple files, expose some types Split internal.d.ts into multiple files Jul 14, 2024
@sindresorhus sindresorhus merged commit 3b1ceeb into sindresorhus:main Jul 14, 2024
8 checks passed
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.

3 participants