Skip to content

betterDefine cannot work with resolve.alias options in Vite #945

@Lutymane

Description

@Lutymane

Describe the bug

Type imports only work when using relative paths without utilizing Vite resolve alias functionality:

import { TProps } from "@/config/props" -- ❌ doesn't work ("warning: unplugin-vue-better-define TransformError: Cannot resolve TS type: TProps")

import { TProps } from "../../config/props" -- ✅ works as intended.

Current solution is to disable betterDefine in vue-macros.config since this feature works natively as expected and following resolve.alias starting from Vue 3.3

Reproduction

import { TProps } from "@/config/props"

System Info

unrelated

Used Package Manager

pnpm

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions