cevek / ttypescript

Over TypeScript tool to use custom transformers in the tsconfig.json

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"TypeError: Cannot read property 'split' of undefined" when getting Typescript version numbers

ccmetz opened this issue · comments

I just started getting this error today when compiling my typescript project. It's really confusing because as far as I can tell, I've been using the same versions of these dependencies for awhile.

Relevant dependencies:
ttypescript: 1.5.12
typescript: 4.3.4

/app/node_modules/ttypescript/lib/loadTypescript.js:29
cc_api  |     var _e = ts.versionMajorMinor.split('.'), major = _e[0], minor = _e[1];
cc_api  |                                   ^
cc_api  |
cc_api  | TypeError: Cannot read property 'split' of undefined
cc_api  |     at Object.loadTypeScript (/app/node_modules/ttypescript/lib/loadTypescript.js:29:35)
cc_api  |     at Object.<anonymous> (/app/node_modules/ttypescript/lib/tsc.js:8:27)
cc_api  |     at Module._compile (internal/modules/cjs/loader.js:1114:14)
cc_api  |     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1143:10)
cc_api  |     at Module.load (internal/modules/cjs/loader.js:979:32)
cc_api  |     at Function.Module._load (internal/modules/cjs/loader.js:819:12)
cc_api  |     at Module.require (internal/modules/cjs/loader.js:1003:19)
cc_api  |     at require (internal/modules/cjs/helpers.js:107:18)
cc_api  |     at Object.<anonymous> (/app/node_modules/ttypescript/bin/tsc:2:1)
cc_api  |     at Module._compile (internal/modules/cjs/loader.js:1114:14)

Does anyone know of anything that changed lately that could've caused this to break?

Upgrade ts version to latest

Upgrade ts version to latest

I have the same problem with the latest versions: typescript: 4.9.5 and ttypescript: 1.5.15.

@Eoic Double check that your build is using those versions in your package-lock.json file. I just updated to typescript 4.9.5 and ttypescript 1.5.15 and it seems to have fixed the issue for me

Seeing the issue as well, but only after upgrading my node version from 14.20.0 to 14.21.3. I think the security releases from February 16 may have screwed something up for ttypescript.

EDIT
Verified that

  1. The build works without issue up to the point release before the security issue (v 14.21.2 for me)
  2. Following @ccmetz advice and updating to the latest typescript and ttypescript versions does in fact fix the issue.

@egriff38 That could definitely be it. I was using a base node:14 docker image and it looks like there was a commit just a few days ago to update from node 14.21.2 to 14.21.3. I started noticing the issue just yesterday.

anyone know the newest node version where this isn't broken? i tried on some old 18 and 19 releases but it seems to have been broken on those for a while.

@DetachHead According to @egriff38 's comment above, it appears to be node 14.21.2

It still works on node 15.4 as well

@DetachHead ah okay, there could be a range of node versions where it might be broken then. It broke for me once my node 14 docker image was updated to 14.21.3.