vite icon indicating copy to clipboard operation
vite copied to clipboard

Typescript latest features are not supported under latest version of vite

Open tsknoff opened this issue 3 years ago • 2 comments

Describe the bug

I want to use "accessor" feature in my project under vite and typescript. It throws an error when im trying to start dev server. When i check project for typescript errors by tsc -p tsconfig.json --noEmit

It comes with no errors. But when i start dev server with npm run dev

It throw the following:

[plugin:vite:esbuild] Transform failed with 1 error:
/Users/Egor/WebstormProjects/infraforecast-frontend/frontend/src/DataFlow/domain/entity/AbstractModel.ts:4:11: ERROR: Expected ";" but found "item"
/Users/Egor/WebstormProjects/infraforecast-frontend/frontend/src/DataFlow/domain/entity/AbstractModel.ts:4:11
Expected ";" but found "item"
2  |  
3  |  export abstract class AbstractModel<E> implements IModel<E> {
4  |    accessor item: E | undefined;
   |             ^
5  |  
6  |    setItem(item: E): void {

There is example of typescript latest feature "accessor" usage in sandbox. For some reason it throws an error thats looks like the oldest version of typescript. Can somebody explain why? https://stackblitz.com/edit/vitejs-vite-flaxyi?file=src/model.ts

Reproduction

https://stackblitz.com/edit/vitejs-vite-flaxyi?file=src/model.ts

Steps to reproduce

No response

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (4) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 16.14.2 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 7.17.0 - /usr/local/bin/npm
  npmPackages:
    @vitejs/plugin-react: ^3.1.0-beta.0 => 3.1.0-beta.0 
    vite: ^4.1.0-beta.1 => 4.1.0-beta.2

Used Package Manager

npm

Logs

No response

Validations

tsknoff avatar Feb 01 '23 18:02 tsknoff

It seems accessor feature is not yet supported by esbuild. esbuild repl

sapphi-red avatar Feb 02 '23 03:02 sapphi-red

Related issue: https://github.com/evanw/esbuild/issues/104

yay avatar Feb 04 '23 10:02 yay