Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unsupported syntax "optionalChainingAssign" #37

Closed
5 tasks done
itmanyong opened this issue Jun 26, 2024 · 6 comments
Closed
5 tasks done

Unsupported syntax "optionalChainingAssign" #37

itmanyong opened this issue Jun 26, 2024 · 6 comments

Comments

@itmanyong
Copy link

Describe the bug

不支持链式判断的语法,如下图所示
image

Reproduction

null

System Info

win10 x64
vite5+
vue3.4

Used Package Manager

npm

Validations

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.
@yuyinws
Copy link
Member

yuyinws commented Jun 26, 2024

你是不是安装了vite-plugin-babel插件来支持这个语法?
在vite配置中,把TurboConsole()放到babel()的后面再试试

import vue from '@vitejs/plugin-vue'
import TurboConsole from 'unplugin-turbo-console/vite'
import babel from 'vite-plugin-babel';

export default defineConfig({
plugins: [
    vue(),
    babel(),
    TurboConsole(), // 放在babel后面
  ],
})

@itmanyong
Copy link
Author

你是不是安装了vite-plugin-babel插件来支持这个语法? 在vite配置中,把TurboConsole()放到babel()的后面再试试

import vue from '@vitejs/plugin-vue'
import TurboConsole from 'unplugin-turbo-console/vite'
import babel from 'vite-plugin-babel';

export default defineConfig({
plugins: [
    vue(),
    babel(),
    TurboConsole(), // 放在babel后面
  ],
})

并没有,没有安装任何babel之类的扩展插件,就是基于vite的,vite默认是支持这类语法的,很奇怪的是我其他地方写这种语法没事,就这个地方用了就显示这个错误

@yuyinws
Copy link
Member

yuyinws commented Jun 26, 2024

@itmanyong

把unplugin-turbo-console禁用了,还会不会有这个错误

@yuyinws
Copy link
Member

yuyinws commented Jun 26, 2024

在最新的beta版本(1.8.8-beta.1)中把插件内部的babel插件选项暴露出来了,可以升级到最新的beta版本再尝试一下。
Vite 配置文件进行以下配置:

export default defineConfig({
  plugins: [
    vue(),
    TurboConsole({
      babelParserPlugins: [
        ['optionalChainingAssign', {version: '2023-07'}]
      ]
    }),
  ],
})

@itmanyong
Copy link
Author

在最新的beta版本(1.8.8-beta.1)中把插件内部的babel插件选项暴露出来了,可以升级到最新的beta版本再尝试一下。 Vite 配置文件进行以下配置:

export default defineConfig({
  plugins: [
    vue(),
    TurboConsole({
      babelParserPlugins: [
        ['optionalChainingAssign', {version: '2023-07'}]
      ]
    }),
  ],
})

更新到beta后设置了这个配置后就没有报错问题了,应该就是内部这个配置导致的问题

@yuyinws
Copy link
Member

yuyinws commented Jun 27, 2024

已在v1.8.8 发布.

@yuyinws yuyinws closed this as completed Jun 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants