feat(types): update to Typescript 3.9 (#1106)
This commit is contained in:
@@ -1,13 +1,15 @@
|
||||
import { expectError, expectType } from 'tsd'
|
||||
import { FunctionalComponent } from './index'
|
||||
import { FunctionalComponent, expectError, expectType } from './index'
|
||||
|
||||
// simple function signature
|
||||
const Foo = (props: { foo: number }) => props.foo
|
||||
|
||||
// TSX
|
||||
expectType<JSX.Element>(<Foo foo={1} />)
|
||||
// expectError(<Foo />) // tsd does not catch missing type errors
|
||||
// @ts-expect-error
|
||||
expectError(<Foo />)
|
||||
// @ts-expect-error
|
||||
expectError(<Foo foo="bar" />)
|
||||
// @ts-expect-error
|
||||
expectError(<Foo baz="bar" />)
|
||||
|
||||
// Explicit signature with props + emits
|
||||
@@ -18,8 +20,11 @@ const Bar: FunctionalComponent<
|
||||
expectType<number>(props.foo)
|
||||
|
||||
emit('update', 123)
|
||||
// @ts-expect-error
|
||||
expectError(emit('nope'))
|
||||
// @ts-expect-error
|
||||
expectError(emit('update'))
|
||||
// @ts-expect-error
|
||||
expectError(emit('update', 'nope'))
|
||||
}
|
||||
|
||||
@@ -27,15 +32,20 @@ const Bar: FunctionalComponent<
|
||||
Bar.props = {
|
||||
foo: Number
|
||||
}
|
||||
// @ts-expect-error
|
||||
expectError((Bar.props = { foo: String }))
|
||||
|
||||
Bar.emits = {
|
||||
update: value => value > 1
|
||||
}
|
||||
// @ts-expect-error
|
||||
expectError((Bar.emits = { baz: () => void 0 }))
|
||||
|
||||
// TSX
|
||||
expectType<JSX.Element>(<Bar foo={1} />)
|
||||
// expectError(<Foo />) // tsd does not catch missing type errors
|
||||
// @ts-expect-error
|
||||
expectError(<Foo />)
|
||||
// @ts-expect-error
|
||||
expectError(<Bar foo="bar" />)
|
||||
// @ts-expect-error
|
||||
expectError(<Foo baz="bar" />)
|
||||
|
||||
Reference in New Issue
Block a user