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

The inject option in Mixins cant be inferred #7751

Open
rudyxu1102 opened this issue Feb 18, 2023 · 1 comment · May be fixed by #7750
Open

The inject option in Mixins cant be inferred #7751

rudyxu1102 opened this issue Feb 18, 2023 · 1 comment · May be fixed by #7750

Comments

@rudyxu1102
Copy link
Contributor

rudyxu1102 commented Feb 18, 2023

Vue version

3.2.47

Link to minimal reproduction

https://www.typescriptlang.org/play?#code/JYWwDg9gTgLgBAbzgEwKYDNgDtUGELgQ5bwC+c6UBcA5AG4CuqNAsAFDsDGRAzvALLAAHtgCCcALwoM2PAUjEYACgTs4cbACtUnGAC44AbRroIEGgF12pAJTsuvePnCTpmHM4WoSKtXBDC2DwGhoIiWKIWADR+nFCoAIYwqMhKNoh+6gD0WXCoQmA68DAAnoVwMBBwDFgA1lgQAO5YmXDcWDwQADaoAHRdEADmSjAAFsA8vaYQdmzqpNY2QA

Steps to reproduce

As you can see, there is a ts error in the minimal reproduction above.

import { defineComponent } from 'vue'

const MixinA = defineComponent({
  inject: ['foo']
})

const Comp = defineComponent({
  mixins: [MixinA],
  created() {
    // expect type to unknown
    console.log(this.foo)
  }
})

What is expected?

foo should be inferred to unknown.

What is actually happening?

ts error: Property 'foo' does not exist on type 'CreateComponentPublicInstance<{}, {}, {}, {}, {}, DefineComponent<{}, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<...>, {}>, ... 12 more ..., {}>'

System Info

No response

Any additional comments?

No response

@rudyxu1102 rudyxu1102 linked a pull request Feb 18, 2023 that will close this issue
@rudyxu1102
Copy link
Contributor Author

Related to vuejs/vue#12931

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants