-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(micro-dash): improve the typing of
omit()
- Loading branch information
Showing
4 changed files
with
57 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
44 changes: 44 additions & 0 deletions
44
projects/micro-dash/src/typing-tests/object/omit.dts-spec.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { omit } from '../../lib/object'; | ||
|
||
declare const str: string; | ||
declare const num: number; | ||
|
||
declare const obj: { | ||
a: number; | ||
b: Date; | ||
}; | ||
// $ExpectType { a: number; } | ||
omit(obj, 'b'); | ||
|
||
declare const indexed: { | ||
[k: string]: number; | ||
[k: number]: number; | ||
}; | ||
// $ExpectType { [x: string]: number; [x: number]: number; } | ||
omit(indexed, 'hi'); | ||
// $ExpectType { [x: string]: number; [x: number]: number; } | ||
omit(indexed, 5); | ||
// $ExpectType { [x: string]: number; [x: number]: number; } | ||
omit(indexed, 'hi', 5); | ||
// $ExpectType { [x: string]: number; [x: number]: number; } | ||
omit(indexed, str); | ||
|
||
declare const record: Record<string, number>; | ||
// $ExpectType { [x: string]: number; } | ||
omit(record, str); | ||
|
||
declare const composite: { | ||
[k: number]: Date; | ||
a: 'eh'; | ||
b: 'bee'; | ||
}; | ||
// $ExpectType { [x: number]: Date; b: "bee"; } | ||
omit(composite, 'a'); | ||
// $ExpectType { [x: number]: Date; } | ||
omit(composite, 'a', 'b'); | ||
// $ExpectType { [x: number]: Date; a: "eh"; b: "bee"; } | ||
omit(composite, 1); | ||
// $ExpectType { [x: number]: Date; a: "eh"; b: "bee"; } | ||
omit(composite, num); | ||
// $ExpectType { [x: number]: Date; b: "bee"; } | ||
omit(composite, num, 'a'); |