Skip to content

[2.7.x] [typescript] Type augmentation does not work #12642

Closed
@last-partizan

Description

@last-partizan

Version

2.7.4

Reproduction link

github.com

Steps to reproduce

look at the example repo, or, install vue@2.7.4 and add type augmentation:

// env.d.ts
declare module "vue/types/vue" {
  interface Vue {
    $t: (s: string) => string
  }
}
// broken-augment.ts
import {defineComponent} from "vue";

export default defineComponent({
  methods: {
    getTranslatedText() {
      return this.$t("hello.vue");
    },
  },
});

What is expected?

Expected no erros.

What is actually happening?

> pnpm vue-tsc
src/broken-augment.ts:6:14 - error TS2571: Object is of type 'unknown'.

6       return this.$t("hello.vue");
               ~~~~~~~


Found 1 error in src/broken-augment.ts:6

Metadata

Metadata

Assignees

No one assigned

    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