Skip to content

Commit

Permalink
Revert "fix(types): correct withDefaults return type for boolean prop…
Browse files Browse the repository at this point in the history
… with undefined default value (vuejs#8602)"

This reverts commit f07cb18.
  • Loading branch information
zhangenming committed Jul 11, 2023
1 parent 2a2810c commit 4b05bec
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 27 deletions.
20 changes: 0 additions & 20 deletions packages/dts-test/setupHelpers.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,26 +134,6 @@ describe('defineProps w/ generic type declaration + withDefaults', <T extends nu
expectType<boolean>(res.bool)
})

describe('withDefaults w/ boolean type', () => {
const res1 = withDefaults(
defineProps<{
bool?: boolean
}>(),
{ bool: false }
)
expectType<boolean>(res1.bool)

const res2 = withDefaults(
defineProps<{
bool?: boolean
}>(),
{
bool: undefined
}
)
expectType<boolean | undefined>(res2.bool)
})

describe('defineProps w/ runtime declaration', () => {
// runtime declaration
const props = defineProps({
Expand Down
8 changes: 1 addition & 7 deletions packages/runtime-core/src/apiSetupHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,13 +303,7 @@ type PropsWithDefaults<
? T[K]
: NotUndefined<T[K]>
: never
} & {
readonly [K in BKeys]-?: K extends keyof Defaults
? Defaults[K] extends undefined
? boolean | undefined
: boolean
: boolean
}
} & { readonly [K in BKeys]-?: boolean }

/**
* Vue `<script setup>` compiler macro for providing props default values when
Expand Down

0 comments on commit 4b05bec

Please sign in to comment.