feat(types): update to Typescript 3.9 (#1106)
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
import { expectError, expectType } from 'tsd'
|
||||
import {
|
||||
describe,
|
||||
defineComponent,
|
||||
PropType,
|
||||
ref,
|
||||
reactive,
|
||||
createApp
|
||||
createApp,
|
||||
expectError,
|
||||
expectType
|
||||
} from './index'
|
||||
|
||||
describe('with object props', () => {
|
||||
@@ -83,7 +84,7 @@ describe('with object props', () => {
|
||||
expectType<ExpectedProps['eee']>(props.eee)
|
||||
expectType<ExpectedProps['fff']>(props.fff)
|
||||
|
||||
// props should be readonly
|
||||
// @ts-expect-error props should be readonly
|
||||
expectError((props.a = 1))
|
||||
|
||||
// setup context
|
||||
@@ -112,7 +113,7 @@ describe('with object props', () => {
|
||||
expectType<ExpectedProps['eee']>(props.eee)
|
||||
expectType<ExpectedProps['fff']>(props.fff)
|
||||
|
||||
// props should be readonly
|
||||
// @ts-expect-error props should be readonly
|
||||
expectError((props.a = 1))
|
||||
|
||||
// should also expose declared props on `this`
|
||||
@@ -129,7 +130,7 @@ describe('with object props', () => {
|
||||
expectType<ExpectedProps['eee']>(this.eee)
|
||||
expectType<ExpectedProps['fff']>(this.fff)
|
||||
|
||||
// props on `this` should be readonly
|
||||
// @ts-expect-error props on `this` should be readonly
|
||||
expectError((this.a = 1))
|
||||
|
||||
// assert setup context unwrapping
|
||||
@@ -167,13 +168,14 @@ describe('with object props', () => {
|
||||
/>
|
||||
)
|
||||
|
||||
// missing required props
|
||||
// @ts-expect-error missing required props
|
||||
expectError(<MyComponent />)
|
||||
|
||||
// wrong prop types
|
||||
expectError(
|
||||
// @ts-expect-error wrong prop types
|
||||
<MyComponent a={'wrong type'} b="foo" dd={{ n: 1 }} ddd={['foo']} />
|
||||
)
|
||||
// @ts-expect-error
|
||||
expectError(<MyComponent b="foo" dd={{ n: 'string' }} ddd={['foo']} />)
|
||||
})
|
||||
|
||||
@@ -211,7 +213,7 @@ describe('type inference w/ array props declaration', () => {
|
||||
defineComponent({
|
||||
props: ['a', 'b'],
|
||||
setup(props) {
|
||||
// props should be readonly
|
||||
// @ts-expect-error props should be readonly
|
||||
expectError((props.a = 1))
|
||||
expectType<any>(props.a)
|
||||
expectType<any>(props.b)
|
||||
@@ -222,6 +224,7 @@ describe('type inference w/ array props declaration', () => {
|
||||
render() {
|
||||
expectType<any>(this.$props.a)
|
||||
expectType<any>(this.$props.b)
|
||||
// @ts-expect-error
|
||||
expectError((this.$props.a = 1))
|
||||
expectType<any>(this.a)
|
||||
expectType<any>(this.b)
|
||||
@@ -340,19 +343,29 @@ describe('emits', () => {
|
||||
setup(props, { emit }) {
|
||||
emit('click', 1)
|
||||
emit('input', 'foo')
|
||||
// @ts-expect-error
|
||||
expectError(emit('nope'))
|
||||
// @ts-expect-error
|
||||
expectError(emit('click'))
|
||||
// @ts-expect-error
|
||||
expectError(emit('click', 'foo'))
|
||||
// @ts-expect-error
|
||||
expectError(emit('input'))
|
||||
// @ts-expect-error
|
||||
expectError(emit('input', 1))
|
||||
},
|
||||
created() {
|
||||
this.$emit('click', 1)
|
||||
this.$emit('input', 'foo')
|
||||
// @ts-expect-error
|
||||
expectError(this.$emit('nope'))
|
||||
// @ts-expect-error
|
||||
expectError(this.$emit('click'))
|
||||
// @ts-expect-error
|
||||
expectError(this.$emit('click', 'foo'))
|
||||
// @ts-expect-error
|
||||
expectError(this.$emit('input'))
|
||||
// @ts-expect-error
|
||||
expectError(this.$emit('input', 1))
|
||||
}
|
||||
})
|
||||
@@ -364,12 +377,14 @@ describe('emits', () => {
|
||||
emit('foo')
|
||||
emit('foo', 123)
|
||||
emit('bar')
|
||||
// @ts-expect-error
|
||||
expectError(emit('nope'))
|
||||
},
|
||||
created() {
|
||||
this.$emit('foo')
|
||||
this.$emit('foo', 123)
|
||||
this.$emit('bar')
|
||||
// @ts-expect-error
|
||||
expectError(this.$emit('nope'))
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user