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

fix: avoid accessing undeclared instance fields on type level #189

Merged
merged 2 commits into from
Feb 17, 2020

Conversation

ktsn
Copy link
Member

@ktsn ktsn commented Nov 12, 2019

fix #187

As never is bottom type, ExtractPropTypes<never> is resolved as a type that accepts any field access:

ExtractPropTypes<never> = {
    readonly [x: string]: undefined;
    readonly [x: number]: undefined;
}

which is included in intersections of ComponentRenderProxy type, consists of VueProxy instance type.

The default type of Props seems to be unknown. As it is top type, ExtractPropTypes<unknown> will be {} which is expected type in this case.

type VueConstructorProxy<PropsOptions, RawBindings> = {
new (): ComponentRenderProxy<
type VueConstructorProxy<PropsOptions, RawBindings> = VueConstructor & {
new (...args: any[]): ComponentRenderProxy<
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modified this type as it cannot match existing typings which expects VueConstructor like vue-router. By writing argument as (...args: any[]), we can mix it with the intersected constructor so that ComponentRenderProxy retains even after inherit VueConstructor.

https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-2.html

This probably fixes #185 ?

@ux-engineer
Copy link

Does this get merged?

@dodas
Copy link

dodas commented Dec 1, 2019

This solves #185 for me!

@haoqunjiang haoqunjiang requested a review from liximomo December 10, 2019 11:17
@yoyo930021
Copy link
Member

yoyo930021 commented Dec 30, 2019

This PR can fix #185 for me.

@haoqunjiang haoqunjiang merged commit 1b58a67 into vuejs:master Feb 17, 2020
@ktsn ktsn deleted the improve-type-without-props branch February 22, 2020 18:37
pikax pushed a commit to pikax/vue-function-api that referenced this pull request Apr 19, 2020
)

* fix: avoid accessing undeclared instance fields on type level

* fix: inherit vue constructor type for constructor proxy

fix vuejs#187 
fix vuejs#185
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

Successfully merging this pull request may close these issues.

Instance type of VueProxy allows any field access when props is not specified
6 participants