Skip to content

Commit

Permalink
Add @tsconfig/node20, add node 20 to test matrix (#2003)
Browse files Browse the repository at this point in the history
---------

Co-authored-by: Andrew Bradley <cspotcode@gmail.com>
  • Loading branch information
chentsulin and cspotcode committed May 31, 2023
1 parent 8f6f4e5 commit 47d4f45
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 7 deletions.
14 changes: 10 additions & 4 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
matrix:
os: [ubuntu, windows]
# Don't forget to add all new flavors to this list!
flavor: [1, 2, 3, 4, 5]
flavor: [1, 2, 3, 4, 5, 6]
include:
# Node 16
- flavor: 1
Expand All @@ -87,10 +87,16 @@ jobs:
nodeFlag: 18
typescript: next
typescriptFlag: next
# Node nightly
# Node 20
- flavor: 5
node: 20-nightly
nodeFlag: 20_nightly
node: 20
nodeFlag: 20
typescript: latest
typescriptFlag: latest
# Node nightly
- flavor: 6
node: 21-nightly
nodeFlag: 21_nightly
typescript: latest
typescriptFlag: latest
steps:
Expand Down
3 changes: 3 additions & 0 deletions node20/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "@tsconfig/node20/tsconfig.json"
}
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"./transpilers/swc-experimental": "./transpilers/swc-experimental.js",
"./node14/tsconfig.json": "./node14/tsconfig.json",
"./node16/tsconfig.json": "./node16/tsconfig.json",
"./node18/tsconfig.json": "./node18/tsconfig.json"
"./node18/tsconfig.json": "./node18/tsconfig.json",
"./node20/tsconfig.json": "./node20/tsconfig.json"
},
"types": "dist/index.d.ts",
"bin": {
Expand All @@ -55,7 +56,8 @@
"/tsconfig.schemastore-schema.json",
"/node14/",
"/node16/",
"/node18/"
"/node18/",
"/node20/"
],
"scripts": {
"lint": "dprint check",
Expand Down Expand Up @@ -161,6 +163,7 @@
"@tsconfig/node14": "*",
"@tsconfig/node16": "*",
"@tsconfig/node18": "*",
"@tsconfig/node20": "*",
"acorn": "^8.4.1",
"acorn-walk": "^8.1.1",
"arg": "^4.1.0",
Expand Down
1 change: 1 addition & 0 deletions src/test/package.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,5 @@ test('should export all CJS entrypoints', () => {
testsDirRequire.resolve('ts-node/node14/tsconfig.json');
testsDirRequire.resolve('ts-node/node16/tsconfig.json');
testsDirRequire.resolve('ts-node/node18/tsconfig.json');
testsDirRequire.resolve('ts-node/node20/tsconfig.json');
});
3 changes: 2 additions & 1 deletion src/test/tsconfig-bases.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ test.suite('should use implicit @tsconfig/bases config when one is not loaded fr
lib = 'es2023';
}

test('implicitly uses @tsconfig/node14, @tsconfig/node16, or @tsconfig/node18 compilerOptions when both TS and node versions support it', async (t) => {
test('implicitly uses @tsconfig/node14, @tsconfig/node16, @tsconfig/node18, or @tsconfig/node20 compilerOptions when both TS and node versions support it', async (t) => {
const r1 = await exec(`${BIN_PATH} --showConfig`, {
cwd: t.context.tmpDir,
});
Expand Down Expand Up @@ -94,4 +94,5 @@ test.suite('should bundle @tsconfig/bases to be used in your own tsconfigs', (te
test(`ts-node/node14/tsconfig.json`, macro, 'node14');
test(`ts-node/node16/tsconfig.json`, macro, 'node16');
test(`ts-node/node18/tsconfig.json`, macro, 'node18');
test(`ts-node/node20/tsconfig.json`, macro, 'node20');
});
4 changes: 4 additions & 0 deletions src/tsconfigs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ const nodeMajor = parseInt(process.versions.node.split('.')[0], 10);
*/
export function getDefaultTsconfigJsonForNodeVersion(ts: TSCommon): any {
const tsInternal = ts as any as TSInternal;
if (nodeMajor >= 20) {
const config = require('@tsconfig/node20/tsconfig.json');
if (configCompatible(config)) return config;
}
if (nodeMajor >= 18) {
const config = require('@tsconfig/node18/tsconfig.json');
if (configCompatible(config)) return config;
Expand Down
3 changes: 3 additions & 0 deletions tests/tsconfig-bases/node20/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "ts-node/node20/tsconfig.json"
}
8 changes: 8 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,13 @@ __metadata:
languageName: node
linkType: hard

"@tsconfig/node20@npm:*":
version: 1.0.0
resolution: "@tsconfig/node20@npm:1.0.0"
checksum: bb2f9ffeb73d1317f3ebfb260109b5e382cab228da2bc8b6202979605820a771fa7cf7a8defc19c9c9ae9d91d6da7b586ca3d9a1e7e1547af6a5118c462bacef
languageName: node
linkType: hard

"@types/argparse@npm:1.0.38":
version: 1.0.38
resolution: "@types/argparse@npm:1.0.38"
Expand Down Expand Up @@ -3812,6 +3819,7 @@ __metadata:
"@tsconfig/node14": "*"
"@tsconfig/node16": "*"
"@tsconfig/node18": "*"
"@tsconfig/node20": "*"
"@types/diff": ^4.0.2
"@types/lodash": ^4.14.151
"@types/node": 13.13.5
Expand Down

0 comments on commit 47d4f45

Please sign in to comment.