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

[2.7.x] [typescript] Type inference breaks under specific circumstances #12902

Closed
last-partizan opened this issue Dec 15, 2022 · 2 comments
Closed

Comments

@last-partizan
Copy link

last-partizan commented Dec 15, 2022

Version

2.7.14

Reproduction link

github.com

Or create this file in minimal vue-ts (v2) project

import {defineComponent} from "vue";

import App from "./App.vue";

export default defineComponent({
  // comment next line, and it works fine.
  components: {App},
  // or uncomment next line, and it works fine
  //props: {},
  data() {
    return {};
  },
  provide(): any {
    return {
      fetchData: this.fetchData,
    };
  },
  created() {
    this.fetchData();
  },
  methods: {
    fetchData() {
      throw new Error("Not implemented.");
    },
  },
});

Steps to reproduce

Clone example repo, run pnpm install, run pnpm vue-tsc

What is expected?

No errors.

What is actually happening?

src/broken-method-type.ts:15:23 - error TS2339: Property 'fetchData' does not exist on type 'CreateComponentPublicInstance ...

It works if you remove components: ... line, or add empty props: {}.

(This is continuation of #12628 which is not fixed completely, or happened again, in my project it was working with vue-tsc<1.0, but happened again after update)

@rudyxu1102
Copy link

rudyxu1102 commented Feb 19, 2023

It works with vue-tsc ≥ 1.0.24.

@last-partizan
Copy link
Author

Confirmed, closing issue.

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