jaredpalmer / tsdx

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

Can't use accessors according to VSCode -- templates have no `target` #1045

Open adriano-di-giovanni opened 3 years ago

adriano-di-giovanni commented 3 years ago

Current Behavior

Can't use accessors in a project created with the latest version of tsdx. It seems to be an editor integration issue because the code compiles.

image

You should be able to reproduce the issue easily by creating a class such as

export class Entity {
  get name() {
    return 'Entity'
  }
}

Your environment

  System:
    OS: macOS 11.1
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 19.36 GB / 32.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 14.15.5 - ~/.nvm/versions/node/v14.15.5/bin/node
    npm: 6.14.11 - ~/.nvm/versions/node/v14.15.5/bin/npm
  Browsers:
    Chrome: 91.0.4472.101
    Firefox: 70.0.1
    Safari: 14.0.2
  npmPackages:
    tsdx: ^0.14.1 => 0.14.1
    typescript: ^4.3.2 => 4.3.2

Here is the VS Code info

Version: 1.57.0
Commit: b4c1bd0a9b03c749ea011b06c6d2676c8091a70c
Date: 2021-06-09T17:22:31.215Z
Electron: 12.0.9
Chrome: 89.0.4389.128
Node.js: 14.16.0
V8: 8.9.255.25-electron.0
OS: Darwin x64 20.2.0
orest22 commented 3 years ago

@adriano-di-giovanni Hey, make sure your VSCode uses workspace typescript.

Screen Shot 2021-06-23 at 2 48 42 PM
agilgur5 commented 2 years ago

Per the error, that would be because your tsconfig.json's target setting isn't ES5 or above.

That might be because you used the templates, which don't have a target setting since #466 as it is overwritten by TSDX. target's default when unset is still ES3 per the above link.

You can set it to ESNext to reflect TSDX's setting, but keep in mind that is not actually used by TSDX. That might be a new error from the VSCode TS integration as I haven't seen it before