vscode+volarでvue3のref sugerを使う際に型定義のimportでエラーが出る問題の解消
問題
script setup(ref suger)を使っている際、特に何も考えずimportすると、以下のようなエラーが出てしまう。
only refers to a type, but is being used as a value here.ts(2693)
解消法
- import { ControlElement } from '@jsonforms/core'; + import type { ControlElement } from '@jsonforms/core';
参考 github.com
import type
とすると良いらしい(こんな構文があるのか)
type-only-imports-and-exportというTS 3.8で入った構文らしい。