Skip to content

Commit 3b78f90

Browse files
author
Jeongho Nam
committed
Fix cevek#134 - support TS 4.9
1 parent a81ff17 commit 3b78f90

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

packages/ttypescript/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"ttsc": "./bin/tsc",
55
"ttsserver": "./bin/tsserver"
66
},
7-
"version": "1.5.12",
7+
"version": "1.5.13",
88
"description": "Over TypeScript tool to use custom transformers in the tsconfig.json",
99
"main": "lib/typescript.js",
1010
"files": [

packages/ttypescript/src/tsc.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,19 @@ import { runInThisContext } from 'vm';
66

77
const ts = loadTypeScript('typescript', { folder: process.cwd(), forceConfigLoad: true });
88
const tscFileName = resolve.sync('typescript/lib/tsc', { basedir: process.cwd() });
9+
const [major, minor]: [number, number] =
10+
ts.version.split(".").map(
11+
(str: string) => Number(str)
12+
) as [number, number];
13+
914
const commandLineTsCode = fs
1015
.readFileSync(tscFileName, 'utf8')
11-
.replace(/^[\s\S]+(\(function \(ts\) \{\s+function countLines[\s\S]+)$/, '$1');
16+
.replace(
17+
major >= 4 && minor >= 9
18+
? /^[\s\S]+(\(function \(ts\) {\s+var StatisticType;[\s\S]+)$/
19+
: /^[\s\S]+(\(function \(ts\) \{\s+function countLines[\s\S]+)$/,
20+
'$1'
21+
);
1222

1323
const globalCode = (fs.readFileSync(tscFileName, 'utf8').match(/^([\s\S]*?)var ts;/) || ['', ''])[1];
1424
runInThisContext(

0 commit comments

Comments
 (0)