jaredpalmer / tsdx

Zero-config CLI for TypeScript package development
https://tsdx.io
MIT License
11.2k stars 505 forks source link

Can't use Typescript 4 features / Use project's Typescript version #1121

Closed thany closed 2 years ago

thany commented 2 years ago

Current Behavior

It's compiling against its own installed version of typescript 🤨

Expected behavior

Use the typescript version that's installed with a project, to compile it.

Suggested solution(s)

Set typescript as a peerDependency and tell users to install it themselves. I dont know how TSDX would handle that, but dictating a specific version is ridiculous, given the amount of new features Typescript still has from version to version.

Additional context

I don't want to be dependent on TSDX to dictate which version of Typescript can be used. Doesn't that make sense?

Your environment

  System:
    OS: Windows 10 10.0.19043
    CPU: (12) x64 Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz
    Memory: 10.51 GB / 31.76 GB
  Binaries:
    Node: 16.14.0 - C:\Program Files\nodejs\node.EXE
    npm: 8.3.2 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: 99.0.4844.51
    Edge: Spartan (44.19041.1266.0), Chromium (99.0.1150.36)
    Internet Explorer: 11.0.19041.1202
  npmPackages:
    tsdx: 0.14.1 => 0.14.1
    typescript: 4.4.2 => 4.4.2

(browser is missing though, but who cares about browsers in TSDX)

thany commented 2 years ago

A workaround, if you can even call it that, is to use overrides in the package.json:

{
  "overrides": {
    "tsdx": {
      "typescript": "4.4.2"
    }
  }
}

Now, every single mention of the use of overrides, on the whole internet, entirely fails to mention that you should also reinstall any affected packages, so following this change with a npm i tsdx should solidify this override.

However, it's a really sorry excuse for a workaround, because it reveals errors when doing a npm list --depth=1. At least this command reveals if the override has worked:

image

In my case, those errors do not appear to break anything, but still. I feel dirty 🙂 This just emphasises how important it is to keep up.

agilgur5 commented 2 years ago

Duplicate of #926 etc

Regarding peerDeps, that is much easier said than done, please see https://github.com/jaredpalmer/tsdx/pull/985#issuecomment-791479189 for a summary.