Skip to content

Commit c601db8

Browse files
fix: when installed typescript version contains 0 it would cause error to be thrown "Expected version to be parsed" (#399)
I was using this transformer with the rollup typescript plugin but noticed when the installed typescript version is "5.0.4" an error is thrown "Expected version to be parsed". I believe this is caused by checking the installed version to see if they are undefined by number 0 is also considered to be falsy in javascript causing this check to fail despite having typescript installed correctly
1 parent 32d0b3a commit c601db8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/transformer.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export default function transformer(
104104
const { tryParsePatterns } = tsInstance;
105105
const [tsVersionMajor, tsVersionMinor] = tsInstance.versionMajorMinor.split(".").map((v) => +v);
106106

107-
if (!tsVersionMajor || !tsVersionMinor) throw new Error("Expected version to be parsed");
107+
if (tsVersionMajor === undefined || tsVersionMinor === undefined) throw new Error("Expected version to be parsed");
108108

109109
const tsTransformPathsContext: TsTransformPathsContext = {
110110
compilerOptions,

0 commit comments

Comments
 (0)