Skip to content

Commit d5e910e

Browse files
authored
chore(api): remove type-fest (#4605)
1 parent fa028eb commit d5e910e

File tree

4 files changed

+39
-46
lines changed

4 files changed

+39
-46
lines changed

.changes/remove-type-fest.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"api": patch
3+
---
4+
5+
Remove the `type-fest` dependency, changing the OS types to the specific enum instead of allowing any string.

tooling/api/package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,5 @@
6767
"typedoc": "0.23.5",
6868
"typedoc-plugin-markdown": "3.13.3",
6969
"typescript": "4.7.4"
70-
},
71-
"dependencies": {
72-
"type-fest": "2.16.0"
7370
}
7471
}

tooling/api/src/os.ts

Lines changed: 34 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,36 @@
2323
* @module
2424
*/
2525

26-
import { LiteralUnion } from 'type-fest'
2726
import { isWindows } from './helpers/os-check'
2827
import { invokeTauriCommand } from './helpers/tauri'
2928

29+
type Platform =
30+
| 'linux'
31+
| 'darwin'
32+
| 'ios'
33+
| 'freebsd'
34+
| 'dragonfly'
35+
| 'netbsd'
36+
| 'openbsd'
37+
| 'solaris'
38+
| 'android'
39+
| 'win32'
40+
41+
type OsType = 'Linux' | 'Darwin' | 'Windows_NT'
42+
43+
type Arch =
44+
| 'x86'
45+
| 'x86_64'
46+
| 'arm'
47+
| 'aarch64'
48+
| 'mips'
49+
| 'mips64'
50+
| 'powerpc'
51+
| 'powerpc64'
52+
| 'riscv64'
53+
| 's390x'
54+
| 'sparc64'
55+
3056
/**
3157
* The operating system-specific end-of-line marker.
3258
* - `\n` on POSIX
@@ -43,22 +69,8 @@ const EOL = isWindows() ? '\r\n' : '\n'
4369
* const platformName = await platform();
4470
* ```
4571
*/
46-
async function platform(): Promise<
47-
LiteralUnion<
48-
| 'linux'
49-
| 'darwin'
50-
| 'ios'
51-
| 'freebsd'
52-
| 'dragonfly'
53-
| 'netbsd'
54-
| 'openbsd'
55-
| 'solaris'
56-
| 'android'
57-
| 'win32',
58-
string
59-
>
60-
> {
61-
return invokeTauriCommand<string>({
72+
async function platform(): Promise<Platform> {
73+
return invokeTauriCommand<Platform>({
6274
__tauriModule: 'Os',
6375
message: {
6476
cmd: 'platform'
@@ -91,10 +103,8 @@ async function version(): Promise<string> {
91103
* const osType = await type();
92104
* ```
93105
*/
94-
async function type(): Promise<
95-
LiteralUnion<'Linux' | 'Darwin' | 'Windows_NT', string>
96-
> {
97-
return invokeTauriCommand<string>({
106+
async function type(): Promise<OsType> {
107+
return invokeTauriCommand<OsType>({
98108
__tauriModule: 'Os',
99109
message: {
100110
cmd: 'osType'
@@ -111,23 +121,8 @@ async function type(): Promise<
111121
* const archName = await arch();
112122
* ```
113123
*/
114-
async function arch(): Promise<
115-
LiteralUnion<
116-
| 'x86'
117-
| 'x86_64'
118-
| 'arm'
119-
| 'aarch64'
120-
| 'mips'
121-
| 'mips64'
122-
| 'powerpc'
123-
| 'powerpc64'
124-
| 'riscv64'
125-
| 's390x'
126-
| 'sparc64',
127-
string
128-
>
129-
> {
130-
return invokeTauriCommand<string>({
124+
async function arch(): Promise<Arch> {
125+
return invokeTauriCommand<Arch>({
131126
__tauriModule: 'Os',
132127
message: {
133128
cmd: 'arch'
@@ -153,3 +148,4 @@ async function tempdir(): Promise<string> {
153148
}
154149

155150
export { EOL, platform, version, type, arch, tempdir }
151+
export type { Platform, OsType, Arch }

tooling/api/yarn.lock

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3255,11 +3255,6 @@ type-check@^0.4.0, type-check@~0.4.0:
32553255
dependencies:
32563256
prelude-ls "^1.2.1"
32573257

3258-
type-fest@2.16.0:
3259-
version "2.16.0"
3260-
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-2.16.0.tgz#1250fbd64dafaf4c8e405e393ef3fb16d9651db2"
3261-
integrity sha512-qpaThT2HQkFb83gMOrdKVsfCN7LKxP26Yq+smPzY1FqoHRjqmjqHXA7n5Gkxi8efirtbeEUxzfEdePthQWCuHw==
3262-
32633258
type-fest@^0.20.2:
32643259
version "0.20.2"
32653260
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.20.2.tgz#1bf207f4b28f91583666cb5fbd327887301cd5f4"

0 commit comments

Comments
 (0)