Skip to content

Commit 6084866

Browse files
authored
Add @tsconfig/node16 (#1313)
* Add @tsconfig/node16; remove @tsconfig/node10 * fix tests * Re-add node10 config because ts2.7 can't handle node12 config * Fix * fix packagelock
1 parent c174a7a commit 6084866

File tree

7 files changed

+27
-6
lines changed

7 files changed

+27
-6
lines changed

node16/tsconfig.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "@tsconfig/node16/tsconfig.json"
3+
}

package-lock.json

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
"./transpilers/swc-experimental": "./transpilers/swc-experimental.js",
2727
"./node10/tsconfig.json": "./node10/tsconfig.json",
2828
"./node12/tsconfig.json": "./node12/tsconfig.json",
29-
"./node14/tsconfig.json": "./node14/tsconfig.json"
29+
"./node14/tsconfig.json": "./node14/tsconfig.json",
30+
"./node16/tsconfig.json": "./node16/tsconfig.json"
3031
},
3132
"types": "dist/index.d.ts",
3233
"bin": {
@@ -49,7 +50,8 @@
4950
"/tsconfig.schemastore-schema.json",
5051
"/node10/",
5152
"/node12/",
52-
"/node14/"
53+
"/node14/",
54+
"/node16/"
5355
],
5456
"scripts": {
5557
"lint": "prettier --check .",
@@ -156,6 +158,7 @@
156158
"@tsconfig/node10": "^1.0.7",
157159
"@tsconfig/node12": "^1.0.7",
158160
"@tsconfig/node14": "^1.0.0",
161+
"@tsconfig/node16": "^1.0.1",
159162
"arg": "^4.1.0",
160163
"create-require": "^1.1.0",
161164
"diff": "^4.0.1",

src/test/index.spec.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ test.suite('ts-node', (test) => {
133133
testsDirRequire.resolve('ts-node/node10/tsconfig.json');
134134
testsDirRequire.resolve('ts-node/node12/tsconfig.json');
135135
testsDirRequire.resolve('ts-node/node14/tsconfig.json');
136+
testsDirRequire.resolve('ts-node/node16/tsconfig.json');
136137
});
137138

138139
test.suite('cli', (test) => {
@@ -683,7 +684,8 @@ test.suite('ts-node', (test) => {
683684
semver.gte(ts.version, '3.5.0') &&
684685
semver.gte(process.versions.node, '14.0.0')
685686
) {
686-
test('implicitly uses @tsconfig/node14 compilerOptions when both TS and node versions support it', async (t) => {
687+
test('implicitly uses @tsconfig/node14 or @tsconfig/node16 compilerOptions when both TS and node versions support it', async (t) => {
688+
// node14 and node16 configs are identical, hence the "or"
687689
const {
688690
context: { tempDir },
689691
} = t;
@@ -708,7 +710,7 @@ test.suite('ts-node', (test) => {
708710
expect(stdout2).to.equal('10n\n');
709711
});
710712
} else {
711-
test('implicitly uses @tsconfig/* lower than node14 (node10 or node12) when either TS or node versions do not support @tsconfig/node14', async ({
713+
test('implicitly uses @tsconfig/* lower than node14 (node12) when either TS or node versions do not support @tsconfig/node14', async ({
712714
context: { tempDir },
713715
}) => {
714716
const { err, stdout, stderr } = await exec(`${BIN_PATH} -pe 10n`, {
@@ -778,6 +780,7 @@ test.suite('ts-node', (test) => {
778780
test(`ts-node/node10/tsconfig.json`, macro, 'node10');
779781
test(`ts-node/node12/tsconfig.json`, macro, 'node12');
780782
test(`ts-node/node14/tsconfig.json`, macro, 'node14');
783+
test(`ts-node/node16/tsconfig.json`, macro, 'node16');
781784
}
782785
);
783786
}

src/tsconfigs.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ const nodeMajor = parseInt(process.versions.node.split('.')[0], 10);
88
*/
99
export function getDefaultTsconfigJsonForNodeVersion(ts: TSCommon): any {
1010
const tsInternal = (ts as any) as TSInternal;
11+
if (nodeMajor >= 16) {
12+
const config = require('@tsconfig/node16/tsconfig.json');
13+
if (configCompatible(config)) return config;
14+
}
1115
if (nodeMajor >= 14) {
1216
const config = require('@tsconfig/node14/tsconfig.json');
1317
if (configCompatible(config)) return config;

tests/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"dependencies": {
3-
"ts-node": "file:ts-node-packed.tgz",
4-
"@swc/core": "latest"
3+
"@swc/core": "latest",
4+
"ts-node": "file:ts-node-packed.tgz"
55
}
66
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "ts-node/node16/tsconfig.json"
3+
}

0 commit comments

Comments
 (0)