-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve IDE integration for inferred object properties to support Go …
…To Definition, Rename Symbol, etc. (#1117) * Increase test coverage for type inference of optional object properties * Add test showing that Go To Definition is broken on object properties * Fix Go To Definition for inferred object properties * Fix Go To Definition for inferred merged object properties * Improve languageServerFeatures test names * Fix Go To Definition for inferred pick object properties * Fix Go To Definition for inferred omit object properties * Exclude languageServerFeatures tests from deno * Fix keyof issue * 3.14.5 * Remove tc dep Co-authored-by: Colin McDonnell <colinmcd@alum.mit.edu>
- Loading branch information
Showing
9 changed files
with
458 additions
and
48 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import * as z from "../index"; | ||
|
||
export const filePath = __filename; | ||
|
||
// z.object() | ||
|
||
export const Test = z.object({ | ||
f1: z.number(), | ||
}); | ||
|
||
export type Test = z.infer<typeof Test>; | ||
|
||
export const instanceOfTest: Test = { | ||
f1: 1, | ||
}; | ||
|
||
// z.object().merge() | ||
|
||
export const TestMerge = z | ||
.object({ | ||
f2: z.string().optional(), | ||
}) | ||
.merge(Test); | ||
|
||
export type TestMerge = z.infer<typeof TestMerge>; | ||
|
||
export const instanceOfTestMerge: TestMerge = { | ||
f1: 1, | ||
f2: "string", | ||
}; | ||
|
||
// z.union() | ||
|
||
export const TestUnion = z.union([ | ||
z.object({ | ||
f2: z.string().optional(), | ||
}), | ||
Test, | ||
]); | ||
|
||
export type TestUnion = z.infer<typeof TestUnion>; | ||
|
||
export const instanceOfTestUnion: TestUnion = { | ||
f1: 1, | ||
f2: "string", | ||
}; | ||
|
||
// z.object().partial() | ||
|
||
export const TestPartial = Test.partial(); | ||
|
||
export type TestPartial = z.infer<typeof TestPartial>; | ||
|
||
export const instanceOfTestPartial: TestPartial = { | ||
f1: 1, | ||
}; | ||
|
||
// z.object().pick() | ||
|
||
export const TestPick = TestMerge.pick({ f1: true }); | ||
|
||
export type TestPick = z.infer<typeof TestPick>; | ||
|
||
export const instanceOfTestPick: TestPick = { | ||
f1: 1, | ||
}; | ||
|
||
// z.object().omit() | ||
|
||
export const TestOmit = TestMerge.omit({ f2: true }); | ||
|
||
export type TestOmit = z.infer<typeof TestOmit>; | ||
|
||
export const instanceOfTestOmit: TestOmit = { | ||
f1: 1, | ||
}; |
Oops, something went wrong.