From c1ffa36fbd1088f2dbdb00c9500eecfce70eafc0 Mon Sep 17 00:00:00 2001 From: Andrew Bradley Date: Tue, 28 Jun 2022 20:47:52 -0400 Subject: [PATCH] feat: Add `.cts` to support typescript 4.7 (#90) Co-authored-by: Blaine Bublitz --- index.js | 1 + test/fixtures/cts/0/package.json | 6 ++++++ test/fixtures/cts/0/test.cts | 19 +++++++++++++++++++ test/fixtures/cts/0/tsconfig.json | 11 +++++++++++ test/fixtures/ts/0/package.json | 4 ++-- test/fixtures/tsx/0/package.json | 4 ++-- test/index.js | 1 + 7 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 test/fixtures/cts/0/package.json create mode 100644 test/fixtures/cts/0/test.cts create mode 100644 test/fixtures/cts/0/tsconfig.json diff --git a/index.js b/index.js index 8c79279..b951fd9 100644 --- a/index.js +++ b/index.js @@ -425,6 +425,7 @@ var extensions = { }, }, ], + '.cts': ['ts-node/register'], '.tsx': [ 'ts-node/register', 'sucrase/register/tsx', diff --git a/test/fixtures/cts/0/package.json b/test/fixtures/cts/0/package.json new file mode 100644 index 0000000..e11b5ba --- /dev/null +++ b/test/fixtures/cts/0/package.json @@ -0,0 +1,6 @@ +{ + "dependencies": { + "ts-node": "^10.8.0", + "typescript": "^4.7.4" + } +} diff --git a/test/fixtures/cts/0/test.cts b/test/fixtures/cts/0/test.cts new file mode 100644 index 0000000..3fa0969 --- /dev/null +++ b/test/fixtures/cts/0/test.cts @@ -0,0 +1,19 @@ +var test: { + data: { + trueKey: boolean; + falseKey: boolean; + subKey: { + subProp: number; + }; + }; +} = { + data: { + trueKey: true, + falseKey: false, + subKey: { + subProp: 1, + }, + }, +}; + +export default test; diff --git a/test/fixtures/cts/0/tsconfig.json b/test/fixtures/cts/0/tsconfig.json new file mode 100644 index 0000000..ca687b6 --- /dev/null +++ b/test/fixtures/cts/0/tsconfig.json @@ -0,0 +1,11 @@ +{ + "compilerOptions": { + "target": "es5", + "module": "commonjs", + "declaration": false, + "noImplicitAny": false, + "removeComments": true, + "sourceMap": true, + "outDir": ".tmp" + } +} diff --git a/test/fixtures/ts/0/package.json b/test/fixtures/ts/0/package.json index 5240475..e11b5ba 100644 --- a/test/fixtures/ts/0/package.json +++ b/test/fixtures/ts/0/package.json @@ -1,6 +1,6 @@ { "dependencies": { - "ts-node": "^7.0.1", - "typescript": "^3.2.2" + "ts-node": "^10.8.0", + "typescript": "^4.7.4" } } diff --git a/test/fixtures/tsx/0/package.json b/test/fixtures/tsx/0/package.json index 5240475..b5ae145 100644 --- a/test/fixtures/tsx/0/package.json +++ b/test/fixtures/tsx/0/package.json @@ -1,6 +1,6 @@ { "dependencies": { - "ts-node": "^7.0.1", - "typescript": "^3.2.2" + "ts-node": "^10.8.0", + "typescript": "4.7.4" } } diff --git a/test/index.js b/test/index.js index 295a860..1f9ca83 100644 --- a/test/index.js +++ b/test/index.js @@ -154,6 +154,7 @@ describe('interpret.extensions', function () { switch (extension) { case '.ts': + case '.cts': case '.tsx': case '.esm.js': case '.babel.tsx':