build(deps): upgrade to TypeScript 4

This commit is contained in:
Evan You
2020-08-20 17:48:28 -04:00
parent 91700fbec2
commit 7454e2a52b
9 changed files with 60 additions and 36 deletions

View File

@@ -176,7 +176,7 @@ export function parse(
`its syntax will be ambiguous outside of the component.`
)
)
delete descriptor.scriptSetup
descriptor.scriptSetup = null
}
if (descriptor.script && descriptor.script.src) {
errors.push(
@@ -185,7 +185,7 @@ export function parse(
`also present because they must be processed together.`
)
)
delete descriptor.script
descriptor.script = null
}
}

View File

@@ -66,6 +66,7 @@ describe('reactivity/effect', () => {
effect(() => (dummy = obj.prop))
expect(dummy).toBe('value')
// @ts-ignore
delete obj.prop
expect(dummy).toBe(undefined)
})
@@ -76,6 +77,7 @@ describe('reactivity/effect', () => {
effect(() => (dummy = 'prop' in obj))
expect(dummy).toBe(true)
// @ts-ignore
delete obj.prop
expect(dummy).toBe(false)
obj.prop = 12
@@ -90,6 +92,7 @@ describe('reactivity/effect', () => {
effect(() => (dummy = counter.num))
expect(dummy).toBe(0)
// @ts-ignore
delete counter.num
expect(dummy).toBe(2)
parentCounter.num = 4
@@ -106,8 +109,10 @@ describe('reactivity/effect', () => {
effect(() => (dummy = 'num' in counter))
expect(dummy).toBe(true)
// @ts-ignore
delete counter.num
expect(dummy).toBe(true)
// @ts-ignore
delete parentCounter.num
expect(dummy).toBe(false)
counter.num = 3
@@ -219,6 +224,7 @@ describe('reactivity/effect', () => {
expect(hasDummy).toBe(true)
obj[key] = 'newValue'
expect(dummy).toBe('newValue')
// @ts-ignore
delete obj[key]
expect(dummy).toBe(undefined)
expect(hasDummy).toBe(false)
@@ -648,6 +654,7 @@ describe('reactivity/effect', () => {
newValue: 2
})
// @ts-ignore
delete obj.foo
expect(dummy).toBeUndefined()
expect(onTrigger).toHaveBeenCalledTimes(2)

View File

@@ -68,18 +68,21 @@ describe('reactivity/readonly', () => {
`Set operation on key "Symbol(qux)" failed: target is readonly.`
).toHaveBeenWarnedLast()
// @ts-ignore
delete wrapped.foo
expect(wrapped.foo).toBe(1)
expect(
`Delete operation on key "foo" failed: target is readonly.`
).toHaveBeenWarnedLast()
// @ts-ignore
delete wrapped.bar.baz
expect(wrapped.bar.baz).toBe(2)
expect(
`Delete operation on key "baz" failed: target is readonly.`
).toHaveBeenWarnedLast()
// @ts-ignore
delete wrapped[qux]
expect(wrapped[qux]).toBe(3)
expect(

View File

@@ -356,6 +356,7 @@ describe('api: lifecycle hooks', () => {
newValue: 2
})
// @ts-ignore
delete obj.bar
await nextTick()
expect(onTrigger).toHaveBeenCalledTimes(2)

View File

@@ -707,6 +707,7 @@ describe('api: watch', () => {
newValue: 2
})
// @ts-ignore
delete obj.foo
await nextTick()
expect(dummy).toBeUndefined()

View File

@@ -258,7 +258,7 @@ export function createAppAPI<HostElement>(
},
provide(key, value) {
if (__DEV__ && key in context.provides) {
if (__DEV__ && (key as string | symbol) in context.provides) {
warn(
`App already provides property with key "${String(key)}". ` +
`It will be overwritten with the new value.`

View File

@@ -37,7 +37,7 @@ export function inject(
const instance = currentInstance || currentRenderingInstance
if (instance) {
const provides = instance.provides
if (key in provides) {
if ((key as string | symbol) in provides) {
// TS doesn't allow symbol as index type
return provides[key as string]
} else if (arguments.length > 1) {