Skip to content

Commit 482514b

Browse files
committed
fix(runtime-core): extra fixes for when V is unknown
1 parent 3c17382 commit 482514b

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

packages/dts-test/setupHelpers.test-d.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,20 +200,19 @@ describe('defineProps w/ generics and runtime declarations', () => {
200200
foo: {
201201
type: Object as PropType<T>,
202202
required: false,
203-
default: null,
203+
default: null
204204
},
205205
bar: {
206206
type: Object as PropType<T>,
207-
required: true,
208-
},
207+
required: true
208+
}
209209
})
210210
expectType<T | null>(props.foo)
211211
expectType<T>(props.bar)
212212
}
213213
test()
214214
})
215215

216-
217216
describe('defineEmits w/ type declaration', () => {
218217
const emit = defineEmits<(e: 'change') => void>()
219218
emit('change')

packages/runtime-core/src/componentProps.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,14 @@ type InferPropType<T> = [T] extends [null]
125125
: [T] extends [PropOptions<infer V, infer D>]
126126
? unknown extends D
127127
? V
128-
: V | D
129-
: [T] extends [Prop<infer V, infer D>]
130-
? unknown extends V
131-
? IfAny<V, V, D>
132-
: V
133-
: T
128+
: unknown extends V
129+
? IfAny<V, V, D>
130+
: V
131+
: [T] extends [Prop<infer V, infer D>]
132+
? unknown extends V
133+
? IfAny<V, V, D>
134+
: V
135+
: T
134136

135137
/**
136138
* Extract prop types from a runtime props options object.

0 commit comments

Comments
 (0)