Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add @tsconfig/node16 #1313

Merged
merged 6 commits into from May 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions node16/tsconfig.json
@@ -0,0 +1,3 @@
{
"extends": "@tsconfig/node16/tsconfig.json"
}
5 changes: 5 additions & 0 deletions package-lock.json

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

7 changes: 5 additions & 2 deletions package.json
Expand Up @@ -26,7 +26,8 @@
"./transpilers/swc-experimental": "./transpilers/swc-experimental.js",
"./node10/tsconfig.json": "./node10/tsconfig.json",
"./node12/tsconfig.json": "./node12/tsconfig.json",
"./node14/tsconfig.json": "./node14/tsconfig.json"
"./node14/tsconfig.json": "./node14/tsconfig.json",
"./node16/tsconfig.json": "./node16/tsconfig.json"
},
"types": "dist/index.d.ts",
"bin": {
Expand All @@ -49,7 +50,8 @@
"/tsconfig.schemastore-schema.json",
"/node10/",
"/node12/",
"/node14/"
"/node14/",
"/node16/"
],
"scripts": {
"lint": "prettier --check .",
Expand Down Expand Up @@ -156,6 +158,7 @@
"@tsconfig/node10": "^1.0.7",
"@tsconfig/node12": "^1.0.7",
"@tsconfig/node14": "^1.0.0",
"@tsconfig/node16": "^1.0.1",
"arg": "^4.1.0",
"create-require": "^1.1.0",
"diff": "^4.0.1",
Expand Down
7 changes: 5 additions & 2 deletions src/test/index.spec.ts
Expand Up @@ -133,6 +133,7 @@ test.suite('ts-node', (test) => {
testsDirRequire.resolve('ts-node/node10/tsconfig.json');
testsDirRequire.resolve('ts-node/node12/tsconfig.json');
testsDirRequire.resolve('ts-node/node14/tsconfig.json');
testsDirRequire.resolve('ts-node/node16/tsconfig.json');
});

test.suite('cli', (test) => {
Expand Down Expand Up @@ -683,7 +684,8 @@ test.suite('ts-node', (test) => {
semver.gte(ts.version, '3.5.0') &&
semver.gte(process.versions.node, '14.0.0')
) {
test('implicitly uses @tsconfig/node14 compilerOptions when both TS and node versions support it', async (t) => {
test('implicitly uses @tsconfig/node14 or @tsconfig/node16 compilerOptions when both TS and node versions support it', async (t) => {
// node14 and node16 configs are identical, hence the "or"
const {
context: { tempDir },
} = t;
Expand All @@ -708,7 +710,7 @@ test.suite('ts-node', (test) => {
expect(stdout2).to.equal('10n\n');
});
} else {
test('implicitly uses @tsconfig/* lower than node14 (node10 or node12) when either TS or node versions do not support @tsconfig/node14', async ({
test('implicitly uses @tsconfig/* lower than node14 (node12) when either TS or node versions do not support @tsconfig/node14', async ({
context: { tempDir },
}) => {
const { err, stdout, stderr } = await exec(`${BIN_PATH} -pe 10n`, {
Expand Down Expand Up @@ -778,6 +780,7 @@ test.suite('ts-node', (test) => {
test(`ts-node/node10/tsconfig.json`, macro, 'node10');
test(`ts-node/node12/tsconfig.json`, macro, 'node12');
test(`ts-node/node14/tsconfig.json`, macro, 'node14');
test(`ts-node/node16/tsconfig.json`, macro, 'node16');
}
);
}
Expand Down
4 changes: 4 additions & 0 deletions src/tsconfigs.ts
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 >= 16) {
const config = require('@tsconfig/node16/tsconfig.json');
if (configCompatible(config)) return config;
}
if (nodeMajor >= 14) {
const config = require('@tsconfig/node14/tsconfig.json');
if (configCompatible(config)) return config;
Expand Down
4 changes: 2 additions & 2 deletions tests/package.json
@@ -1,6 +1,6 @@
{
"dependencies": {
"ts-node": "file:ts-node-packed.tgz",
"@swc/core": "latest"
"@swc/core": "latest",
"ts-node": "file:ts-node-packed.tgz"
}
}
3 changes: 3 additions & 0 deletions tests/tsconfig-bases/node16/tsconfig.json
@@ -0,0 +1,3 @@
{
"extends": "ts-node/node16/tsconfig.json"
}