Skip to content

Commit 711a470

Browse files
committed
docs (ts-conversion): mark all non-implemented as "empty"
1 parent e8d4401 commit 711a470

File tree

7 files changed

+9
-56
lines changed

7 files changed

+9
-56
lines changed

packages/ts-conversion/src/components/Intro.tsx

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,11 @@
1-
import { getProgress } from "../utils/getProgress";
2-
import { ProgressBar } from "./ProgressBar";
31
import styles from "./Intro.module.css";
4-
import { roundTo1DecimalPlace } from "./roundTo1DecimalPlace";
5-
6-
const { missing, total } = getProgress();
7-
const percent = roundTo1DecimalPlace(((total - missing) / total) * 100);
82

93
export const Intro = () => (
104
<div className={styles.Intro}>
115
<h2>
126
Converting types in TypeScript
13-
<sup className={styles.ProgressData}>
14-
{percent < 100 ? "alpha" : "beta"}
15-
</sup>
7+
<sup className={styles.ProgressData}>beta</sup>
168
</h2>
17-
{percent < 100 && <ProgressBar percent={percent} />}
189
<p>
1910
Interactive website, helping engineers understand, how they can convert
2011
one type to another in TypeScript, with examples and links to TypeScript

packages/ts-conversion/src/components/ProgressBar.module.css

Lines changed: 0 additions & 9 deletions
This file was deleted.

packages/ts-conversion/src/components/ProgressBar.tsx

Lines changed: 0 additions & 19 deletions
This file was deleted.

packages/ts-conversion/src/components/TsConversion.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,7 @@ export const TsConversion = () => {
7777
label="Target"
7878
handleChange={handleTargetChange}
7979
options={inputs}
80-
isOptionDisabled={(input) =>
81-
!source || map[source][input] === "missing"
82-
}
80+
isOptionDisabled={() => !source}
8381
getLabel={(input) => {
8482
if (
8583
source &&
@@ -112,7 +110,7 @@ export const TsConversion = () => {
112110
</>
113111
</Message>
114112
</div>
115-
) : map[source][target] === "missing" ? null : (
113+
) : (
116114
<>
117115
{(Warning = map[source][target].Warning) && (
118116
<div>

packages/ts-conversion/src/utils/getProgress.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { map } from "./map";
22

33
export const getProgress = () => {
4-
let missing = 0;
4+
const missing = 0;
55
let empty = 0;
66
let implemented = 0;
77
let total = 0;
@@ -12,8 +12,6 @@ export const getProgress = () => {
1212

1313
if (value === "empty") {
1414
empty++;
15-
} else if (value === "missing") {
16-
missing++;
1715
} else {
1816
implemented++;
1917
}

packages/ts-conversion/src/utils/map.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ describe("map", () => {
55
const { empty, implemented, missing, total } = getProgress();
66

77
test("returns a number of combinations that don't have practical example", () => {
8-
expect(empty).toBe(9);
8+
expect(empty).toBe(11);
99
});
1010

1111
test("returns a number of implemented combinations", () => {
1212
expect(implemented).toBe(25);
1313
});
1414

1515
test("returns a number of combinations with a missing example", () => {
16-
expect(missing).toBe(2);
16+
expect(missing).toBe(0);
1717
});
1818

1919
test("returns a number of total combinations", () => {

packages/ts-conversion/src/utils/map.tsx

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import { InputType } from "./inputs";
1010
import { KeyRemappingNote } from "../notes/KeyRemappingNote";
1111
import { ConditionalTypesNote } from "../notes/ConditionalTypesNote";
1212

13-
type MapConfigMissingExample = "missing";
1413
type MapConfigWithExample = {
1514
label?: string;
1615
code: string;
@@ -23,10 +22,7 @@ type MapConfigWithExample = {
2322
};
2423
type MapConfigWithoutExample = "empty";
2524

26-
type MapConfig =
27-
| MapConfigMissingExample
28-
| MapConfigWithExample
29-
| MapConfigWithoutExample;
25+
type MapConfig = MapConfigWithExample | MapConfigWithoutExample;
3026

3127
// eslint-disable-next-line react-refresh/only-export-components
3228
const DistributiveConditionalTypes = () => (
@@ -565,8 +561,7 @@ export const map: Record<InputType, Record<InputType, MapConfig>> = {
565561
playgroundUrl: "https://tsplay.dev/NBrXxN",
566562
},
567563
stringLiteral: "empty",
568-
// TODO: number of keys
569-
numericLiteral: "missing",
564+
numericLiteral: "empty",
570565
},
571566
union: {
572567
array: {
@@ -789,8 +784,7 @@ export const map: Record<InputType, Record<InputType, MapConfig>> = {
789784
],
790785
},
791786
stringLiteral: "empty",
792-
// TODO: number of union elements
793-
numericLiteral: "missing",
787+
numericLiteral: "empty",
794788
},
795789
stringLiteral: {
796790
array: "empty",

0 commit comments

Comments
 (0)