Skip to content

Commit 758053b

Browse files
authored
build(deps): upgrade to TypeScript 5.1 (#1389)
1 parent 909a580 commit 758053b

21 files changed

+87
-60
lines changed

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
"semver": "^7.3.4",
6767
"shell-env": "^3.0.1",
6868
"tmp": "0.2.1",
69-
"tslib": "^2.1.0",
69+
"tslib": "^2.6.0",
7070
"update-electron-app": "^2.0.1"
7171
},
7272
"devDependencies": {
@@ -117,7 +117,7 @@
117117
"eslint-plugin-prettier": "^3.3.1",
118118
"eslint-plugin-react": "^7.22.0",
119119
"fetch-mock-jest": "^1.5.1",
120-
"fork-ts-checker-webpack-plugin": "^7.2.11",
120+
"fork-ts-checker-webpack-plugin": "^8.0.0",
121121
"husky": "^5.1.1",
122122
"jest": "^29.5.0",
123123
"jest-environment-jsdom": "^29.5.0",
@@ -141,8 +141,8 @@
141141
"stylelint-config-standard": "^34.0.0",
142142
"terser-webpack-plugin": "^5.3.3",
143143
"ts-jest": "^29.1.1",
144-
"ts-loader": "^9.3.1",
145-
"typescript": "~4.3.0",
144+
"ts-loader": "^9.4.4",
145+
"typescript": "^5.1.6",
146146
"webpack": "^5.69.1"
147147
},
148148
"lint-staged": {

src/main/windows.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ export function createMainWindow(): Electron.BrowserWindow {
101101
});
102102

103103
ipcMainManager.handle(IpcEvents.GET_APP_PATHS, () => {
104-
const paths = {};
105104
const pathsToQuery = [
106105
'home',
107106
'appData',
@@ -110,6 +109,7 @@ export function createMainWindow(): Electron.BrowserWindow {
110109
'downloads',
111110
'desktop',
112111
] as const;
112+
const paths = {} as Record<typeof pathsToQuery[number], string>;
113113
for (const path of pathsToQuery) {
114114
paths[path] = app.getPath(path);
115115
}

src/renderer/app.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@ import * as path from 'node:path';
22

33
import { autorun, reaction, when } from 'mobx';
44

5-
import { EditorValues, PACKAGE_NAME, SetFiddleOptions } from '../interfaces';
5+
import {
6+
EditorId,
7+
EditorValues,
8+
PACKAGE_NAME,
9+
SetFiddleOptions,
10+
} from '../interfaces';
611
import { defaultDark, defaultLight } from '../themes-defaults';
712
import { USER_DATA_PATH } from './constants';
813
import { ElectronTypes } from './electron-types';
@@ -92,7 +97,10 @@ export class App {
9297
const values = this.state.editorMosaic.values();
9398

9499
if (options) {
95-
values[PACKAGE_NAME] = await getPackageJson(this.state, options);
100+
values[PACKAGE_NAME as EditorId] = await getPackageJson(
101+
this.state,
102+
options,
103+
);
96104
}
97105

98106
return values;

src/renderer/components/commands-action-button.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ import { when } from 'mobx';
1414
import { observer } from 'mobx-react';
1515

1616
import {
17+
EditorId,
1718
EditorValues,
1819
GistActionState,
1920
GistActionType,
21+
PACKAGE_NAME,
2022
} from '../../interfaces';
2123
import { AppState } from '../state';
2224
import { ensureRequiredFiles } from '../utils/editor-utils';
@@ -125,7 +127,8 @@ export const GistActionButton = observer(
125127
options,
126128
);
127129

128-
defaultGistValues['package.json'] = currentEditorValues['package.json'];
130+
defaultGistValues[PACKAGE_NAME as EditorId] =
131+
currentEditorValues[PACKAGE_NAME as EditorId];
129132

130133
try {
131134
const gistFilesList = appState.isPublishingGistAsRevision

src/renderer/components/output-editors-wrapper.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ export class OutputEditorsWrapper extends React.Component<
5454
public render() {
5555
return (
5656
<Mosaic<WrapperEditorId>
57-
renderTile={(id: string) => this.MOSAIC_ELEMENTS[id]}
57+
renderTile={(id: string) =>
58+
this.MOSAIC_ELEMENTS[id as keyof typeof this.MOSAIC_ELEMENTS]
59+
}
5860
resize={{ minimumPaneSizePercentage: 15 }}
5961
value={this.state.mosaic}
6062
onChange={this.onChange}

src/renderer/components/settings-execution.tsx

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,10 @@ import { observer } from 'mobx-react';
1515
import { GlobalSetting, IPackageManager } from '../../interfaces';
1616
import { AppState } from '../state';
1717

18-
/**
19-
* @TODO make this a proper enum again once we update Typescript
20-
*/
21-
export const SettingItemType = {
22-
EnvVars: GlobalSetting.environmentVariables,
23-
Flags: GlobalSetting.executionFlags,
24-
} as const;
18+
export enum SettingItemType {
19+
EnvVars = GlobalSetting.environmentVariables,
20+
Flags = GlobalSetting.executionFlags,
21+
}
2522

2623
interface ExecutionSettingsProps {
2724
appState: AppState;
@@ -118,11 +115,11 @@ export const ExecutionSettings = observer(
118115
* run with the Electron executable.
119116
*
120117
* @param {React.ChangeEvent<HTMLInputElement>} event
121-
* @param {GlobalSetting} type
118+
* @param {SettingItemType} type
122119
*/
123120
public handleSettingsItemChange(
124121
event: React.ChangeEvent<HTMLInputElement>,
125-
type: GlobalSetting,
122+
type: SettingItemType,
126123
) {
127124
const { name, value } = event.currentTarget;
128125

@@ -137,9 +134,9 @@ export const ExecutionSettings = observer(
137134
/**
138135
* Adds a new settings item input field.
139136
*
140-
* @param {GlobalSetting} type
137+
* @param {SettingItemType} type
141138
*/
142-
private addNewSettingsItem(type: GlobalSetting) {
139+
private addNewSettingsItem(type: SettingItemType) {
143140
const array = Object.entries(this.state[type]);
144141

145142
this.setState((prevState) => ({
@@ -163,7 +160,7 @@ export const ExecutionSettings = observer(
163160
appState.packageManager = value as IPackageManager;
164161
};
165162

166-
public renderDeleteItem(idx: string, type: GlobalSetting): JSX.Element {
163+
public renderDeleteItem(idx: string, type: SettingItemType): JSX.Element {
167164
const updated = this.state[type];
168165

169166
const removeFn = () => {

src/renderer/components/sidebar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export const Sidebar = ({ appState }: { appState: AppState }) => {
1313
};
1414
return (
1515
<Mosaic<string>
16-
renderTile={(id) => ELEMENT_MAP[id]}
16+
renderTile={(id) => ELEMENT_MAP[id as keyof typeof ELEMENT_MAP]}
1717
initialValue={{
1818
first: 'fileTree',
1919
second: 'packageManager',

src/renderer/file-manager.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import * as fs from 'fs-extra';
44
import semver from 'semver';
55

66
import {
7+
EditorId,
8+
EditorValues,
79
FileTransform,
810
Files,
911
GenericDialogType,
@@ -70,7 +72,7 @@ export class FileManager {
7072
console.log(`FileManager: Asked to open`, filePath);
7173
if (!filePath || typeof filePath !== 'string') return;
7274

73-
const editorValues = {};
75+
const editorValues: EditorValues = {};
7476
const files: [string, string][] = Object.entries(
7577
await readFiddle(filePath, true),
7678
);
@@ -115,7 +117,7 @@ export class FileManager {
115117
}
116118

117119
if (isKnownFile(name) || (await app.remoteLoader.confirmAddFile(name))) {
118-
editorValues[name] = value;
120+
editorValues[name as EditorId] = value;
119121
}
120122
}
121123

@@ -185,7 +187,7 @@ export class FileManager {
185187

186188
let output: Files = new Map(Object.entries(values));
187189

188-
output.set(PACKAGE_NAME, values[PACKAGE_NAME]!);
190+
output.set(PACKAGE_NAME, values[PACKAGE_NAME as EditorId]!);
189191

190192
for (const transform of transforms) {
191193
try {

src/renderer/remote-loader.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import semver from 'semver';
22

33
import {
4+
EditorId,
45
EditorValues,
56
ElectronReleaseChannel,
67
GenericDialogType,
@@ -27,7 +28,7 @@ export class RemoteLoader {
2728
'setElectronVersion',
2829
'verifyReleaseChannelEnabled',
2930
'verifyRemoteLoad',
30-
]) {
31+
] as const) {
3132
this[name] = this[name].bind(this);
3233
}
3334
}
@@ -100,7 +101,7 @@ export class RemoteLoader {
100101
fetch(child.download_url)
101102
.then((r) => r.text())
102103
.then((t) => {
103-
values[child.name] = t;
104+
values[child.name as EditorId] = t;
104105
}),
105106
);
106107
}

src/renderer/themes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export async function getTheme(
4343
async function getCssStringForTheme(theme: FiddleTheme): Promise<string> {
4444
let cssContent = '';
4545

46-
Object.keys(theme.common).forEach((key) => {
46+
Object.keys(theme.common).forEach((key: keyof typeof theme.common) => {
4747
cssContent += ` --${key}: ${theme.common[key]};\n`;
4848
});
4949

0 commit comments

Comments
 (0)