Last 12 weeks · 30 commits
5 of 6 standards met
Fixes #717. Problem When is used without the optional argument, it doesn't only strip — it also changes the object's structure. The clearest symptom is an index signature: currently resolves to — a spurious numeric index signature gets added. This happens because the default (all-keys) case still goes through the rebuild, and that / round-trip does not faithfully reproduce the original shape. Fix As suggested in the issue thread ("add an overload when that parameter is not passed and use the simple handling"), the default case now uses a plain homomorphic mapped type: This only removes the modifier and otherwise preserves the input structure exactly, including index signatures — matching the simpler community implementations referenced in the issue. The explicit subset-of- path () is left completely unchanged, so all existing behavior and tests are preserved. The all-keys case is detected with (already used internally by ), which is both when is omitted and when the full key set is passed explicitly — semantically identical intents. Tests Added two assertions to : → → Both fail on the current code (the result carries the extra index signature) and pass with the fix. Verified with on the source change. The full ( + + + linter) passes.
fails to compile for a generic (#991). can include bare numeric-literal keys (e.g. alongside ), which for an unresolved generic TypeScript treats structurally as . 's parameter was constrained to string only, so it rejected the and the whole expression failed to typecheck. This widens 's constraint to also accept and normalizes the path through before splitting, so a bare-number path resolves the same as its string form. Added a case for with a generic . It fails to compile without the fix and passes with it. , , and all green. Closes #991
This PR primarily fixes the behavior of types when instantiated with a union of literals and non-literals. For example, currently returns , instead it should return . This PR also makes a couple of other things: Replaces certain complicated/contrived JSDoc examples with simpler ones. Removes unclear use-cases section from JSDoc. IMO, the use-cases mentioned were not adding much value. Separates the different literal types into individual files. Rewrites both the implementation and tests for all literal types from scratch. Fixes behavior with / types. Also, the input to these literal types is currently unconstrained, but I think that should be constrained. For example, instead of _just_ .
Repository: sindresorhus/type-fest. Description: A collection of essential TypeScript types Stars: 17274, Forks: 722. Primary language: TypeScript. Languages: TypeScript (84.4%), JavaScript (15.6%). License: CC0-1.0. Topics: npm-package, types, typescript, typescript-definitions, utilities. Latest release: v5.8.0 (13h ago). Open PRs: 43, open issues: 185. Last activity: 14h ago. Community health: 100%. Top contributors: sindresorhus, som-sm, Emiyaaaaa, skarab42, voxpelli, trevorade, privatenumber, kainiedziela, tommy-mitchell, taiyakihitotsu and others.