feat(types): update to Typescript 3.9 (#1106)
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import { expectError, expectAssignable } from 'tsd'
|
||||
import {
|
||||
describe,
|
||||
h,
|
||||
@@ -7,21 +6,28 @@ import {
|
||||
Fragment,
|
||||
Teleport,
|
||||
Suspense,
|
||||
Component
|
||||
Component,
|
||||
expectError,
|
||||
expectAssignable
|
||||
} from './index'
|
||||
|
||||
describe('h inference w/ element', () => {
|
||||
// key
|
||||
h('div', { key: 1 })
|
||||
h('div', { key: 'foo' })
|
||||
// @ts-expect-error
|
||||
expectError(h('div', { key: [] }))
|
||||
// @ts-expect-error
|
||||
expectError(h('div', { key: {} }))
|
||||
// ref
|
||||
h('div', { ref: 'foo' })
|
||||
h('div', { ref: ref(null) })
|
||||
h('div', { ref: el => {} })
|
||||
// @ts-expect-error
|
||||
expectError(h('div', { ref: [] }))
|
||||
// @ts-expect-error
|
||||
expectError(h('div', { ref: {} }))
|
||||
// @ts-expect-error
|
||||
expectError(h('div', { ref: 123 }))
|
||||
})
|
||||
|
||||
@@ -29,14 +35,19 @@ describe('h inference w/ Fragment', () => {
|
||||
// only accepts array children
|
||||
h(Fragment, ['hello'])
|
||||
h(Fragment, { key: 123 }, ['hello'])
|
||||
// @ts-expect-error
|
||||
expectError(h(Fragment, 'foo'))
|
||||
// @ts-expect-error
|
||||
expectError(h(Fragment, { key: 123 }, 'bar'))
|
||||
})
|
||||
|
||||
describe('h inference w/ Teleport', () => {
|
||||
h(Teleport, { to: '#foo' }, 'hello')
|
||||
// @ts-expect-error
|
||||
expectError(h(Teleport))
|
||||
// @ts-expect-error
|
||||
expectError(h(Teleport, {}))
|
||||
// @ts-expect-error
|
||||
expectError(h(Teleport, { to: '#foo' }))
|
||||
})
|
||||
|
||||
@@ -47,6 +58,7 @@ describe('h inference w/ Suspense', () => {
|
||||
h(Suspense, null, {
|
||||
default: () => 'foo'
|
||||
})
|
||||
// @ts-expect-error
|
||||
expectError(h(Suspense, { onResolve: 1 }))
|
||||
})
|
||||
|
||||
@@ -54,8 +66,11 @@ describe('h inference w/ functional component', () => {
|
||||
const Func = (_props: { foo: string; bar?: number }) => ''
|
||||
h(Func, { foo: 'hello' })
|
||||
h(Func, { foo: 'hello', bar: 123 })
|
||||
// @ts-expect-error
|
||||
expectError(h(Func, { foo: 123 }))
|
||||
// @ts-expect-error
|
||||
expectError(h(Func, {}))
|
||||
// @ts-expect-error
|
||||
expectError(h(Func, { bar: 123 }))
|
||||
})
|
||||
|
||||
@@ -85,10 +100,11 @@ describe('h inference w/ defineComponent', () => {
|
||||
h(Foo, { bar: 1, foo: 'ok' })
|
||||
// should allow extraneous props (attrs fallthrough)
|
||||
h(Foo, { bar: 1, foo: 'ok', class: 'extra' })
|
||||
// should fail on missing required prop
|
||||
// @ts-expect-error should fail on missing required prop
|
||||
expectError(h(Foo, {}))
|
||||
// @ts-expect-error
|
||||
expectError(h(Foo, { foo: 'ok' }))
|
||||
// should fail on wrong type
|
||||
// @ts-expect-error should fail on wrong type
|
||||
expectError(h(Foo, { bar: 1, foo: 1 }))
|
||||
})
|
||||
|
||||
@@ -101,10 +117,11 @@ describe('h inference w/ defineComponent + optional props', () => {
|
||||
h(Foo, { bar: 1, foo: 'ok' })
|
||||
// should allow extraneous props (attrs fallthrough)
|
||||
h(Foo, { bar: 1, foo: 'ok', class: 'extra' })
|
||||
// should fail on missing required prop
|
||||
// @ts-expect-error should fail on missing required prop
|
||||
expectError(h(Foo, {}))
|
||||
// @ts-expect-error
|
||||
expectError(h(Foo, { foo: 'ok' }))
|
||||
// should fail on wrong type
|
||||
// @ts-expect-error should fail on wrong type
|
||||
expectError(h(Foo, { bar: 1, foo: 1 }))
|
||||
})
|
||||
|
||||
@@ -115,10 +132,11 @@ describe('h inference w/ defineComponent + direct function', () => {
|
||||
h(Foo, { bar: 1, foo: 'ok' })
|
||||
// should allow extraneous props (attrs fallthrough)
|
||||
h(Foo, { bar: 1, foo: 'ok', class: 'extra' })
|
||||
// should fail on missing required prop
|
||||
// @ts-expect-error should fail on missing required prop
|
||||
expectError(h(Foo, {}))
|
||||
// @ts-expect-error
|
||||
expectError(h(Foo, { foo: 'ok' }))
|
||||
// should fail on wrong type
|
||||
// @ts-expect-error should fail on wrong type
|
||||
expectError(h(Foo, { bar: 1, foo: 1 }))
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user