Skip to content

Commit 5a82dd6

Browse files
committed
Update to TypeScript 4
1 parent 0cd1362 commit 5a82dd6

File tree

8 files changed

+283
-91
lines changed

8 files changed

+283
-91
lines changed

.eslintignore

+2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
public
2+
node_modules
23
resources/views
4+
webpack.config.js

.eslintrc.yml

+7
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,13 @@ rules:
7676
- 1
7777
- "line-aligned"
7878
"react/jsx-closing-tag-location": 1
79+
# This setup is required to avoid a spam of errors when running eslint about React being
80+
# used before it is defined.
81+
#
82+
# see https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-use-before-define.md#how-to-use
83+
no-use-before-define: 0
84+
"@typescript-eslint/no-use-before-define":
85+
- warn
7986
overrides:
8087
- files:
8188
- "**/*.tsx"

package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@
7575
"@types/uuid": "^3.4.5",
7676
"@types/webpack-env": "^1.15.2",
7777
"@types/yup": "^0.29.3",
78-
"@typescript-eslint/eslint-plugin": "^3.5.0",
79-
"@typescript-eslint/parser": "^3.5.0",
78+
"@typescript-eslint/eslint-plugin": "^4.22.1",
79+
"@typescript-eslint/parser": "^4.22.1",
8080
"autoprefixer": "^10.1.0",
8181
"babel-loader": "^8.0.6",
8282
"babel-plugin-styled-components": "^1.12.0",
@@ -90,15 +90,15 @@
9090
"eslint-plugin-react": "^7.20.3",
9191
"eslint-plugin-react-hooks": "^4.0.5",
9292
"eslint-plugin-standard": "^4.0.1",
93-
"fork-ts-checker-webpack-plugin": "^5.0.6",
93+
"fork-ts-checker-webpack-plugin": "^6.2.6",
9494
"postcss": "^8.2.1",
9595
"redux-devtools-extension": "^2.13.8",
9696
"source-map-loader": "^1.0.1",
9797
"style-loader": "^1.2.1",
9898
"svg-url-loader": "^6.0.0",
9999
"terser-webpack-plugin": "^3.0.6",
100100
"twin.macro": "^2.0.7",
101-
"typescript": "^3.9.6",
101+
"typescript": "^4.2.4",
102102
"webpack": "^4.43.0",
103103
"webpack-assets-manifest": "^3.1.1",
104104
"webpack-bundle-analyzer": "^3.8.0",

resources/scripts/components/server/WebsocketHandler.tsx

+12-12
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,18 @@ export default () => {
2020
const setServerStatus = ServerContext.useStoreActions(actions => actions.status.setServerStatus);
2121
const { setInstance, setConnectionState } = ServerContext.useStoreActions(actions => actions.socket);
2222

23+
const updateToken = (uuid: string, socket: Websocket) => {
24+
if (updatingToken) return;
25+
26+
updatingToken = true;
27+
getWebsocketToken(uuid)
28+
.then(data => socket.setToken(data.token, true))
29+
.catch(error => console.error(error))
30+
.then(() => {
31+
updatingToken = false;
32+
});
33+
};
34+
2335
const connect = (uuid: string) => {
2436
const socket = new Websocket();
2537

@@ -73,18 +85,6 @@ export default () => {
7385
.catch(error => console.error(error));
7486
};
7587

76-
const updateToken = (uuid: string, socket: Websocket) => {
77-
if (updatingToken) return;
78-
79-
updatingToken = true;
80-
getWebsocketToken(uuid)
81-
.then(data => socket.setToken(data.token, true))
82-
.catch(error => console.error(error))
83-
.then(() => {
84-
updatingToken = false;
85-
});
86-
};
87-
8888
useEffect(() => {
8989
connected && setError('');
9090
}, [ connected ]);

resources/scripts/components/server/files/FileEditContainer.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const LazyCodemirrorEditor = lazy(() => import(/* webpackChunkName: "editor" */'
2424

2525
export default () => {
2626
const [ error, setError ] = useState('');
27-
const { action } = useParams();
27+
const { action } = useParams<{ action: 'new' | string }>();
2828
const [ loading, setLoading ] = useState(action === 'edit');
2929
const [ content, setContent ] = useState('');
3030
const [ modalVisible, setModalVisible ] = useState(false);

tsconfig.json

+9-7
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,20 @@
33
"target": "es2015",
44
"module": "es2020",
55
"jsx": "react",
6-
"strict": true,
7-
"noEmit": true,
8-
"noImplicitReturns": true,
96
"moduleResolution": "node",
10-
"allowSyntheticDefaultImports": true,
11-
"esModuleInterop": true,
12-
"sourceMap": true,
13-
"baseUrl": ".",
147
"lib": [
158
"es2015",
169
"dom"
1710
],
11+
"strict": true,
12+
"noEmit": true,
13+
"sourceMap": true,
14+
"noImplicitReturns": true,
15+
"skipLibCheck": true,
16+
"skipDefaultLibCheck": true,
17+
"esModuleInterop": true,
18+
"allowSyntheticDefaultImports": true,
19+
"baseUrl": ".",
1820
"importsNotUsedAsValues": "preserve",
1921
"paths": {
2022
"@/*": [

webpack.config.js

+10-3
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,17 @@ module.exports = {
7171
},
7272
plugins: [
7373
new AssetsManifestPlugin({ writeToDisk: true, publicPath: true, integrity: true, integrityHashes: ['sha384'] }),
74-
new ForkTsCheckerWebpackPlugin(isProduction ? {} : {
75-
eslint: {
76-
files: `${path.join(__dirname, '/resources/scripts')}/**/*.{ts,tsx}`,
74+
new ForkTsCheckerWebpackPlugin({
75+
typescript: {
76+
mode: 'write-references',
77+
diagnosticOptions: {
78+
semantic: true,
79+
syntactic: true,
80+
},
7781
},
82+
eslint: isProduction ? undefined : {
83+
files: `${path.join(__dirname, '/resources/scripts')}/**/*.{ts,tsx}`,
84+
}
7885
}),
7986
process.env.ANALYZE_BUNDLE ? new BundleAnalyzerPlugin({
8087
analyzerHost: '0.0.0.0',

0 commit comments

Comments
 (0)