Skip to content

Conversation

cexbrayat
Copy link
Member

This commit tidies up the types in mount. The goal is to enable strict: true in the future on the project, and this commit fixes up a bunch of errors that the strict mode complains about.

The only change for VTU users is that GlobalMountOptions.config now does not allow to override isNativeTag as it is private and readonly in AppConfig: https://github.com/vuejs/vue-next/blob/71a942b25a2cad61c3d670075523c31d296c7089/packages/runtime-core/src/apiCreateApp.ts#L46-L48

This commit tidies up the types in mount. The goal is to enable `strict: true` in the future on the project, and this commit fixes up a bunch of errors that the strict mode complains about.
if (global.config) {
for (const [k, v] of Object.entries(global.config)) {
for (const [k, v] of Object.entries(global.config) as [
keyof Omit<AppConfig, 'isNativeTag'>,
Copy link
Member

Choose a reason for hiding this comment

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

nice!

for (const [k, v] of Object.entries(
global.mocks as { [key: string]: any }
)) {
;(this as any)[k] = v
Copy link
Member

Choose a reason for hiding this comment

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

TS is so ugly sometimes (or maybe due to Vue's dynamic nature it cannot be avoided...)

export type GlobalMountOptions = {
plugins?: Plugin[]
config?: AppConfig
config?: Omit<AppConfig, 'isNativeTag'> // isNativeTag is readonly, so we omit it
Copy link
Member

Choose a reason for hiding this comment

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

so this is how you do it, awesome, was trying to figure this out

@lmiller1990 lmiller1990 merged commit 112f29a into vuejs:master May 18, 2020
@lmiller1990
Copy link
Member

Great, thanks a lot. strict: true would be great.

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.

2 participants