Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
forked fromvuejs/vue

Commit7644380

Browse files
thenicknameyyx990803
authored andcommitted
Typings: Improve $slots and $scopedSlots type to prevent unchecked access to undefined (vuejs#8946)
* fix(types): Declare $scopedSlots as potentially undefined to enable stricter TS checks* fix(types): Fix tests* fix(types): declare $slots option as potentially undefineddeclare $slots option as potentially undefined to enable stricter TS checks
1 parent3cd4af4 commit7644380

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

‎types/test/options-test.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,8 @@ Vue.component('component-with-scoped-slot', {
304304
child:{
305305
render(this:Vue,h:CreateElement){
306306
returnh('div',[
307-
this.$scopedSlots['default']({msg:'hi'}),
308-
this.$scopedSlots['item']({msg:'hello'})
307+
this.$scopedSlots['default']!({msg:'hi'}),
308+
this.$scopedSlots['item']!({msg:'hello'})
309309
])
310310
}
311311
}
@@ -314,7 +314,7 @@ Vue.component('component-with-scoped-slot', {
314314

315315
Vue.component('narrow-array-of-vnode-type',{
316316
render(h):VNode{
317-
constslot=this.$scopedSlots.default({})
317+
constslot=this.$scopedSlots.default!({})
318318
if(typeofslot!=='string'){
319319
constfirst=slot[0]
320320
if(!Array.isArray(first)&&typeoffirst!=='string'){

‎types/vue.d.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ export interface Vue {
2727
readonly$root:Vue;
2828
readonly$children:Vue[];
2929
readonly$refs:{[key:string]:Vue|Element|Vue[]|Element[]};
30-
readonly$slots:{[key:string]:VNode[]};
31-
readonly$scopedSlots:{[key:string]:ScopedSlot};
30+
readonly$slots:{[key:string]:VNode[]|undefined};
31+
readonly$scopedSlots:{[key:string]:ScopedSlot|undefined};
3232
readonly$isServer:boolean;
3333
readonly$data:Record<string,any>;
3434
readonly$props:Record<string,any>;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp