Skip to content

[global.d.ts] 引入編輯器提示後導致 $t、$route等報錯 #1786

@wcnhna

Description

@wcnhna

tdesign-mobile-vue 版本

1.8.2

重现链接

No response

重现步骤

// package.json

    "tdesign-mobile-vue": "^1.8.2",
    "vue": "^3.5.13",
    "vue-i18n": "^11.1.1",
    "vue-router": "^4.5.0"

// tsconfig.app.json

  "extends": "@vue/tsconfig/tsconfig.dom.json",
  "include": [
    "env.d.ts",
    "src/**/*",
    "src/**/*.vue",
    "src/**/*.ts",
    "src/**/*.tsx",
    "node_modules/tdesign-mobile-vue/global.d.ts"
  ],
  "exclude": ["src/**/__tests__/*"],
  "compilerOptions": {
    "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",

    "paths": {
      "@/*": ["./src/*"]
    },
    "baseUrl": "."
  }
}

// App.vue

<template>
  <div class="h-100vh flex-col-center gap-15px">
    <t-result
      theme="error"
      title="Error"
      :description="$t('errMsg')"
    />
    {{ $route.name }}
  </div>
</template>
<script lang="ts" setup>
</script>
<style lang="scss" scoped></style>

期望结果

引入编辑器提示不影響原有TS類型定義

实际结果

功能是正常的,但是TS類型報錯

報錯:
類型 'CreateComponentPublicInstanceWithMixins<ToResolvedProps<{}, {}>, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, PublicProps, ... 16 more ..., {}>' 沒有屬性 '$t'。ts-plugin(2339)
類型 'CreateComponentPublicInstanceWithMixins<ToResolvedProps<{}, {}>, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, PublicProps, ... 16 more ..., {}>' 沒有屬性 '$route'。ts-plugin(2339)

框架版本

Vue(3.5.13)

浏览器版本

No response

系统版本

MacOS(15.3.1)

Node版本

v23.7.0

补充说明

No response
錯誤
Image
移除 "node_modules/tdesign-mobile-vue/global.d.ts" 後$route和$t完全正常
Image

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions