Skip to content

Commit

Permalink
fix(runtime-core): extra fixes for when V is unknown
Browse files Browse the repository at this point in the history
  • Loading branch information
pfumagalli committed Nov 28, 2023
1 parent 3c17382 commit 482514b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
7 changes: 3 additions & 4 deletions packages/dts-test/setupHelpers.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,20 +200,19 @@ describe('defineProps w/ generics and runtime declarations', () => {
foo: {
type: Object as PropType<T>,
required: false,
default: null,
default: null
},
bar: {
type: Object as PropType<T>,
required: true,
},
required: true
}
})
expectType<T | null>(props.foo)
expectType<T>(props.bar)
}
test()
})


describe('defineEmits w/ type declaration', () => {
const emit = defineEmits<(e: 'change') => void>()
emit('change')
Expand Down
14 changes: 8 additions & 6 deletions packages/runtime-core/src/componentProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,14 @@ type InferPropType<T> = [T] extends [null]
: [T] extends [PropOptions<infer V, infer D>]
? unknown extends D
? V
: V | D
: [T] extends [Prop<infer V, infer D>]
? unknown extends V
? IfAny<V, V, D>
: V
: T
: unknown extends V
? IfAny<V, V, D>
: V
: [T] extends [Prop<infer V, infer D>]
? unknown extends V
? IfAny<V, V, D>
: V
: T

/**
* Extract prop types from a runtime props options object.
Expand Down

0 comments on commit 482514b

Please sign in to comment.