Skip to content

Commit

Permalink
Migrate to TypeScript 5 (#453)
Browse files Browse the repository at this point in the history
* Update tsconfig and eslint config for TS5 era

* `npm uninstall typescript && npm install --save-dev typescript`

* `npm uninstall @tsconfig/node16-strictest-esm`

* Update jest config and code for TS5
  • Loading branch information
kachick authored Apr 17, 2023
1 parent 6b5c96b commit 6e0266f
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 28 deletions.
3 changes: 3 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ rules:
'@typescript-eslint/prefer-readonly-parameter-types':
- error
- ignoreInferredTypes: true
# See https://zenn.dev/teppeis/articles/2023-04-typescript-5_0-verbatim-module-syntax for enabling reason
'@typescript-eslint/consistent-type-imports': 'error'
'@typescript-eslint/no-import-type-side-effects': 'error'
parser: '@typescript-eslint/parser'
parserOptions:
ecmaVersion: 12
Expand Down
3 changes: 2 additions & 1 deletion __tests__/postbuild/main.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { env, execPath } from 'process';
import { execFileSync, ExecFileSyncOptions } from 'child_process';
import type { ExecFileSyncOptions } from 'child_process';
import { execFileSync } from 'child_process';
import { join } from 'path';
import { expect, test } from '@jest/globals';

Expand Down
2 changes: 1 addition & 1 deletion jest.post.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ const config: Config.InitialOptions = {
extensionsToTreatAsEsm: ['.ts'],
testMatch: ['**/__tests__/postbuild/**/*.test.ts'],
};
export default config;
module.exports = config;
2 changes: 1 addition & 1 deletion jest.pre.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ const config: Config.InitialOptions = {
extensionsToTreatAsEsm: ['.ts'],
testMatch: ['**/__tests__/prebuild/**/*.test.ts'],
};
export default config;
module.exports = config;
29 changes: 8 additions & 21 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
},
"devDependencies": {
"@octokit/types": "^9.0.0",
"@tsconfig/node16-strictest-esm": "^1.0.3",
"@types/jest": "^29.5.0",
"@types/node": "^16.18.23",
"@typescript-eslint/eslint-plugin": "^5.58.0",
Expand All @@ -46,6 +45,6 @@
"jest": "^29.5.0",
"ts-node": "^10.9.1",
"tsx": "^3.12.6",
"typescript": "^4.9.5"
"typescript": "^5.0.4"
}
}
30 changes: 30 additions & 0 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
// Import from https://github.com/tsconfig/bases/commit/0ae4791797d8ba3dd2bca9aca880eb2d3e30e6fb
// To avoid issues around tsconfig.extends array
"$schema": "https://json.schemastore.org/tsconfig",
"display": "Node 16 + Strictest",
"compilerOptions": {
"lib": [
"es2021"
],
"module": "commonjs",
"target": "es2021",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"moduleResolution": "node",
"allowUnusedLabels": false,
"allowUnreachableCode": false,
"exactOptionalPropertyTypes": true,
"noFallthroughCasesInSwitch": true,
"noImplicitOverride": true,
"noImplicitReturns": true,
"noPropertyAccessFromIndexSignature": true,
"noUncheckedIndexedAccess": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"verbatimModuleSyntax": true,
"checkJs": true
}
}
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
// https://github.com/tsconfig/bases/blob/d1543a94d47c3ef9af9987790742b09caf71b71d/bases/node16-strictest-esm.combined.json
"extends": "@tsconfig/node16-strictest-esm/tsconfig.json",
// TODO: Use tsconfig/base after all tools support tsconfig.extends array
"extends": "./tsconfig.base.json",
"compilerOptions": {
// https://www.typescriptlang.org/docs/handbook/esm-node.html
"module": "node16",
Expand Down

0 comments on commit 6e0266f

Please sign in to comment.