Skip to content

Commit 64de65d

Browse files
committed
Fix Quicktype's overly permissive type for baseline: "high" | "low" | false (continued)
1 parent 4990926 commit 64de65d

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

types.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable @typescript-eslint/no-unused-vars */
12
// Quicktype produces definitions that are correct, but not as narrow or
23
// well-named as hand-written type definition might produce. This module takes
34
// the Quicktype-generated types as renames or modifies the types to be somewhat
@@ -10,11 +11,11 @@ import type {
1011
Discouraged,
1112
GroupData,
1213
FeatureData as QuicktypeMonolithicFeatureData,
14+
Status as QuicktypeStatus,
1315
StatusHeadline as QuicktypeStatusHeadline,
1416
WebFeaturesData as QuicktypeWebFeaturesData,
1517
Release,
1618
SnapshotData,
17-
Status,
1819
Support,
1920
} from "./types.quicktype";
2021

@@ -27,21 +28,24 @@ export type {
2728
GroupData,
2829
Release,
2930
SnapshotData,
30-
Status,
3131
Support,
3232
};
3333

34+
export interface Status extends QuicktypeStatus {
35+
baseline: false | BaselineHighLow;
36+
}
37+
3438
export interface SupportStatus extends QuicktypeStatusHeadline {
3539
baseline: false | BaselineHighLow;
3640
}
3741

3842
// These are "tests" for our type definitions.
39-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
4043
const badQuicktypeStatusHeadline: QuicktypeStatusHeadline = {
4144
baseline: true, // This is an improper value in our actual published data
4245
support: {},
4346
};
44-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
47+
const badQuicktypeStatus: QuicktypeStatus = badQuicktypeStatusHeadline;
48+
4549
const badSupportStatus: SupportStatus = {
4650
// This validates that we're actually overriding Quicktype (and correctly). If
4751
// `baseline: true` ever becomes possible in the `SupportStatus`, then
@@ -50,7 +54,11 @@ const badSupportStatus: SupportStatus = {
5054
baseline: true,
5155
support: {},
5256
};
53-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
57+
const badStatus: Status = {
58+
// @ts-expect-error
59+
baseline: true,
60+
support: {},
61+
};
5462
const goodSupportStatus: QuicktypeStatusHeadline | SupportStatus = {
5563
baseline: false,
5664
support: {},
@@ -74,7 +82,6 @@ export type FeatureData = Required<
7482
>
7583
>;
7684

77-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
7885
const goodFeatureData: FeatureData = {
7986
name: "Test",
8087
description: "Hi",

0 commit comments

Comments
 (0)