Skip to content

Commit

Permalink
Use TypeScript 5 while keeping current tools and avoiding the new TS5…
Browse files Browse the repository at this point in the history
… "tsconfig.extends array" feature. (#313)

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

* `npm install --save-dev @tsconfig/strictest @tsconfig/node16`

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

* Apply newstyle of combined tsconfig

* Apply type prefix to care verbatimModuleSyntax

* `npm uninstall tsx`

* Import derprecated combined tsconfig from tsconfig/bases

tsconfig/bases@0ae4791

* Update importsNotUsedAsValues to verbatimModuleSyntax

tsconfig/bases@00fa4ee

* Remove unused tsconfig family now

* Bump nixpkgs to latest

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

* tsx again

* Remove outdated task `npm run all`

* Prefer module.exports since enabling verbatimModuleSyntax

ref: https://zenn.dev/teppeis/articles/2023-04-typescript-5_0-verbatim-module-syntax

* Add eslint rule for TS5 era
  • Loading branch information
kachick authored Apr 17, 2023
1 parent f085ead commit c153114
Show file tree
Hide file tree
Showing 8 changed files with 248 additions and 251 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
2 changes: 1 addition & 1 deletion __tests__/main.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { wait } from '../src/wait';
import { env, execPath } from 'process';
import { execFileSync, ExecFileSyncOptions } from 'child_process';
import { execFileSync, type ExecFileSyncOptions } from 'child_process';
import { join } from 'path';
import { expect, test } from '@jest/globals';

Expand Down
2 changes: 1 addition & 1 deletion default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ pkgs ? import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/b77bbeca8ba3069eea82a3711242cdc2240cc7c9.tar.gz") { } }:
{ pkgs ? import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/4c3edba85629ec304b5269e4b0ac7f26c433df23.tar.gz") { } }:

pkgs.mkShell {
buildInputs = [
Expand Down
2 changes: 1 addition & 1 deletion jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ const config: Config.InitialOptions = {
extensionsToTreatAsEsm: ['.ts'],
testMatch: ['**/**/*.test.ts'],
};
export default config;
module.exports = config;
450 changes: 208 additions & 242 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
"pretest": "npm run package",
"test": "jest",
"typecheck": "tsc",
"repl": "tsx",
"all": "npm run format:check && npm run lint:check && npm run build && npm run package && npm test"
"repl": "tsx"
},
"repository": {
"type": "git",
Expand All @@ -32,7 +31,6 @@
},
"devDependencies": {
"@octokit/types": "^9.0.0",
"@tsconfig/node16-strictest-esm": "^1.0.3",
"@types/node": "^16.18.23",
"@typescript-eslint/eslint-plugin": "^5.58.0",
"@typescript-eslint/parser": "^5.58.0",
Expand All @@ -44,6 +42,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 c153114

Please sign in to comment.