-
Notifications
You must be signed in to change notification settings - Fork 0
fix(types): fix normalizeAbsent.test.tsx type errors #520
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -4,13 +4,13 @@ import { normalizeOptionalFields, normalizeList } from "./normalizeAbsent"; | |||||
|
|
||||||
| type MockObject = { | ||||||
| name: string; | ||||||
| temperature?: string | null; | ||||||
| targetYear?: number | null; | ||||||
| targetType?: "absolute" | "intensity" | null; | ||||||
| abool?: boolean | null; | ||||||
| zero?: number | null; | ||||||
| empty?: string | null; | ||||||
| missing?: string; | ||||||
| temperature?: string | null | undefined; | ||||||
| targetYear?: number | null | undefined; | ||||||
| targetType?: "absolute" | "intensity" | null | undefined; | ||||||
| abool?: boolean | null | undefined; | ||||||
| zero?: number | null | undefined; | ||||||
| empty?: string | null | undefined; | ||||||
| missing?: string | undefined; | ||||||
| }; | ||||||
|
|
||||||
| describe("normalizeOptionalFields", () => { | ||||||
|
|
@@ -49,7 +49,6 @@ describe("normalizeOptionalFields", () => { | |||||
| const n = normalizeOptionalFields(base, ["temperature"] as const); | ||||||
| expect(isAbsent(n.temperature)).toBe(true); | ||||||
| // not selected -> remains null | ||||||
| // @ts-expect-error - targetYear is still possibly null/undefined | ||||||
| expect(n.targetYear).toBeNull(); | ||||||
| }); | ||||||
| }); | ||||||
|
|
@@ -62,6 +61,8 @@ describe("normalizeList", () => { | |||||
| { name: "C" }, // missing | ||||||
| ]; | ||||||
| const out = normalizeList(list, ["temperature"] as const); | ||||||
| if (!out[0] || !out[1] || !out[2]) | ||||||
|
||||||
| if (!out[0] || !out[1] || !out[2]) | |
| if (out.length !== 3) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Adding
| undefinedto optional properties is redundant in TypeScript. The?operator already includesundefinedin the type union. For consistency and conciseness, consider removing the explicit| undefinedfrom all optional property declarations (lines 7-13).