feat: add glob (*) pattern to DeepStrictObjectKeys#27
Merged
Conversation
…election Add `*` pattern support to DeepStrictObjectKeys, enabling wildcard key selection at any nesting level (e.g., `'*'`, `'a.*'`, `'items[*].*'`). DeepStrictPick and DeepStrictOmit handle glob patterns correctly. Closes #2 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…formatting Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
*(glob/wildcard) pattern toDeepStrictObjectKeysenabling patterns like'*','a.*','items[*].*'for wildcard key selectionExpandGlobhelper type to convert glob patterns into template literal matchersDeepStrictPickandDeepStrictOmitto handle glob patterns correctly (Pick<T, '*'>returnsT,Omit<T, '*'>returns{})Changes
src/types/DeepStrictObjectKeys.ts— Append| '*'toInferoutput with empty-object guardsrc/types/ExpandGlob.ts— New helper type for expanding glob patternssrc/types/DeepStrictPick.ts— Add'*' extends K ? Tshort-circuit +ExpandGlob<K>+ doubleExcludeto filter glob from omit setsrc/types/DeepStrictOmit.ts— Add'*' extends K ? {}at both entry andInferlevelsrc/functions/DeepStrictObjectKeys.ts— AddWithoutGlobto exclude glob patterns from runtime return typeTest plan
npm run build:test && npm run test)DeepStrictPick<T, '*'>returns fullTDeepStrictOmit<T, '*'>returns{}DeepStrictPick<T, 'a.*'>returns{ a: T['a'] }DeepStrictOmit<T, 'a.*'>returns{ a: {}; ...rest }deepStrictObjectKeysreturn type excludes'*'patternsCloses #2
🤖 Generated with Claude Code