Skip to content

Commit 1d231d2

Browse files
ZhangYiJiangtaneliangli-kai
authored
Upgrade to TypeScript 5.1 (#3458)
* Bump TS to v5 and fix some issues and add some hacks * Upgrade typescript in scrapers/nus-v2 * Upgrade all jest (#3454) * Remove volta config * Bump babel etc to support TS 5 syntax * Fix tsconfig rootDir * website: fix remaining errors * Upgrade typescript in export * Revert ApiError fix in favor of breakpointUp fix * Try to enable declare support and bump axios * Fix preset ordering * Run prettier * Lint with prettier * Upgrade node from 16 to 18 (#3453) * Upgrade docs to node 16 * Upgrade node to lts/hydrogen * Fix yarn lock files * Fix typescript definitions * Fix export typescript errors --------- Co-authored-by: E-Liang Tan <[email protected]> Co-authored-by: Li Kai <[email protected]> Co-authored-by: Kai Li <[email protected]>
1 parent aa358f4 commit 1d231d2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+4471
-4139
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ version: 2.1
33
executors:
44
node-executor:
55
docker:
6-
- image: cimg/node:16.20
6+
- image: cimg/node:18.16
77

88
jobs:
99
checkout:

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
lts/gallium
1+
lts/hydrogen

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Tip: Pick an area you're interested in, and just focus on it. It is not necessar
3535

3636
## Development Tools
3737

38-
You should have [Node.js](https://nodejs.org/) version 16 or above (use Node 16 LTS or `lts/gallium` if possible) and [Yarn](https://yarnpkg.com/en/) version 1.2.0 or above. We recommend using [fnm](https://github.com/Schniz/fnm) to manage your Node versions.
38+
You should have [Node.js](https://nodejs.org/) version 18 or above (use Node 18 LTS or `lts/hydrogen` if possible) and [Yarn](https://yarnpkg.com/en/) version 1.2.0 or above. We recommend using [fnm](https://github.com/Schniz/fnm) to manage your Node versions.
3939

4040
## Proposing a Change
4141

export/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"dev": "run-p nodemon watch",
1515
"devtools": "cross-env DEVTOOLS=1 yarn dev",
1616
"deploy": "rsync -avu --delete-after . ../../nusmods-export && pm2 restart ecosystem.config.js",
17-
"lint": "prettier --write"
17+
"lint": "prettier . --check"
1818
},
1919
"dependencies": {
2020
"@sentry/node": "5.30.0",
@@ -33,11 +33,11 @@
3333
},
3434
"devDependencies": {
3535
"@types/fs-extra": "9.0.6",
36-
"@types/koa": "2.11.7",
36+
"@types/koa": "2.13.8",
3737
"@types/koa-router": "7.4.1",
3838
"@types/koa-views": "2.0.4",
3939
"@types/lodash": "4.14.170",
40-
"@types/node": "14.14.22",
40+
"@types/node": "18.16.19",
4141
"@types/pug": "2.0.4",
4242
"@types/puppeteer": "^5.4.7",
4343
"@vercel/node": "1.9.0",
@@ -46,6 +46,6 @@
4646
"npm-run-all": "4.1.5",
4747
"prettier": "2.8.8",
4848
"puppeteer": "~6.0.0",
49-
"typescript": "4.1.3"
49+
"typescript": "5.1.6"
5050
}
5151
}

export/public/404.html

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
<!DOCTYPE html>
22
<html lang="en">
3-
<head>
4-
<meta charset="UTF-8">
5-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6-
<title>Error - NUSMods</title>
7-
<link rel="stylesheet" href="/styles.css">
8-
</head>
9-
<body>
10-
<h1>Page Not Found</h1>
11-
<p>
12-
We&apos;re not sure how you got here. If you were trying to save a timetable as
13-
image or PDF, please check your link and try again.
14-
</p>
15-
<a href="https://nusmods.com" class="btn btn-primary">Back to NUSMods</a>
16-
</body>
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>Error - NUSMods</title>
7+
<link rel="stylesheet" href="/styles.css" />
8+
</head>
9+
<body>
10+
<h1>Page Not Found</h1>
11+
<p>
12+
We&apos;re not sure how you got here. If you were trying to save a timetable as image or PDF,
13+
please check your link and try again.
14+
</p>
15+
<a href="https://nusmods.com" class="btn btn-primary">Back to NUSMods</a>
16+
</body>
1717
</html>

export/src/data.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export async function getModules(moduleCodes: string[]) {
4343
export const parseExportData: Middleware<State> = (ctx, next) => {
4444
if (ctx.query.data) {
4545
try {
46+
// @ts-expect-error: type string[] is not assignable to type string
4647
const data = JSON.parse(ctx.query.data);
4748
validateExportData(data);
4849
ctx.state.data = data;

export/tsconfig.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
{
22
"compilerOptions": {
3+
"outDir": "build",
34
"esModuleInterop": true,
45
"strict": true,
5-
"outDir": "build"
6+
"useUnknownInCatchVariables": false,
7+
"skipLibCheck": true
68
}
79
}

export/yarn.lock

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,10 @@
215215
"@types/koa-compose" "*"
216216
"@types/node" "*"
217217

218-
"@types/koa@2.11.7":
219-
version "2.11.7"
220-
resolved "https://registry.yarnpkg.com/@types/koa/-/koa-2.11.7.tgz#3b38f3b9faa66315a84890a771d166fb36463100"
221-
integrity sha512-1iXJZZWCePoMe9LGSIPWsu5k5RI4ooXijW78c+nljMn3YbUts8PXoEESu1OeFmrazLPl1l97vTxzwvmH32TWVQ==
218+
"@types/koa@2.13.8":
219+
version "2.13.8"
220+
resolved "https://registry.yarnpkg.com/@types/koa/-/koa-2.13.8.tgz#4302d2f2712348aadb6c0b03eb614f30afde486b"
221+
integrity sha512-Ugmxmgk/yPRW3ptBTh9VjOLwsKWJuGbymo1uGX0qdaqqL18uJiiG1ZoV0rxCOYSaDGhvEp5Ece02Amx0iwaxQQ==
222222
dependencies:
223223
"@types/accepts" "*"
224224
"@types/content-disposition" "*"
@@ -244,10 +244,10 @@
244244
resolved "https://registry.yarnpkg.com/@types/node/-/node-12.6.3.tgz#44d507c5634f85e7164707ca36bba21b5213d487"
245245
integrity sha512-7TEYTQT1/6PP53NftXXabIZDaZfaoBdeBm8Md/i7zsWRoBe0YwOXguyK8vhHs8ehgB/w9U4K/6EWuTyp0W6nIA==
246246

247-
"@types/node@14.14.22":
248-
version "14.14.22"
249-
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.22.tgz#0d29f382472c4ccf3bd96ff0ce47daf5b7b84b18"
250-
integrity sha512-g+f/qj/cNcqKkc3tFqlXOYjrmZA+jNBiDzbP3kH+B+otKFqAdPgVTGP1IeKRdMml/aE69as5S4FqtxAbl+LaMw==
247+
"@types/node@18.16.19":
248+
version "18.16.19"
249+
resolved "https://registry.yarnpkg.com/@types/node/-/node-18.16.19.tgz#cb03fca8910fdeb7595b755126a8a78144714eea"
250+
integrity sha512-IXl7o+R9iti9eBW4Wg2hx1xQDig183jj7YLn8F7udNceyfkbn1ZxmzZXuak20gR40D7pIkIY1kYGx5VIGbaHKA==
251251

252252
"@types/node@^10.11.7":
253253
version "10.12.27"
@@ -2613,10 +2613,10 @@ [email protected]:
26132613
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.3.tgz#d3ac8883a97c26139e42df5e93eeece33d610b8a"
26142614
integrity sha512-D/wqnB2xzNFIcoBG9FG8cXRDjiqSTbG2wd8DMZeQyJlP1vfTkIxH4GKveWaEBYySKIg+USu+E+EDIR47SqnaMQ==
26152615

2616-
typescript@4.1.3:
2617-
version "4.1.3"
2618-
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.1.3.tgz#519d582bd94cba0cf8934c7d8e8467e473f53bb7"
2619-
integrity sha512-B3ZIOf1IKeH2ixgHhj6la6xdwR9QrLC5d1VKeCSY4tvkqhF2eqd9O7txNlS0PO3GrBAFIdr3L1ndNwteUbZLYg==
2616+
typescript@5.1.6:
2617+
version "5.1.6"
2618+
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.1.6.tgz#02f8ac202b6dad2c0dd5e0913745b47a37998274"
2619+
integrity sha512-zaWCozRZ6DLEWAWFrVDz1H6FVXzUSfTy5FUMWsQlU8Ym5JP9eO4xkTIROFCQvhQf61z6O/G6ugw3SgAnvvm+HA==
26202620

26212621
unbzip2-stream@^1.3.3:
26222622
version "1.4.3"

packages/nusmoderator/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
"prettier": "2.8.8",
5656
"rimraf": "3.0.2",
5757
"ts-jest": "26.4.4",
58-
"typescript": "4.1.3"
58+
"typescript": "5.1.6"
5959
},
6060
"dependencies": {
6161
"date-fns": "2.16.1"

packages/nusmoderator/yarn.lock

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9037,7 +9037,12 @@ typedarray-to-buffer@^3.1.5:
90379037
dependencies:
90389038
is-typedarray "^1.0.0"
90399039

9040-
[email protected], typescript@^4.1.3:
9040+
9041+
version "5.1.6"
9042+
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.1.6.tgz#02f8ac202b6dad2c0dd5e0913745b47a37998274"
9043+
integrity sha512-zaWCozRZ6DLEWAWFrVDz1H6FVXzUSfTy5FUMWsQlU8Ym5JP9eO4xkTIROFCQvhQf61z6O/G6ugw3SgAnvvm+HA==
9044+
9045+
typescript@^4.1.3:
90419046
version "4.1.3"
90429047
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.1.3.tgz#519d582bd94cba0cf8934c7d8e8467e473f53bb7"
90439048
integrity sha512-B3ZIOf1IKeH2ixgHhj6la6xdwR9QrLC5d1VKeCSY4tvkqhF2eqd9O7txNlS0PO3GrBAFIdr3L1ndNwteUbZLYg==

0 commit comments

Comments
 (0)