From c073dbf53513b4bbec146e4281cc3d1b96baeccd Mon Sep 17 00:00:00 2001 From: dolymood Date: Tue, 14 Jan 2020 17:15:15 +0800 Subject: [PATCH 01/23] feat(runtime-core): support mixins and extends for TS ThisType --- .../runtime-core/src/apiDefineComponent.ts | 86 ++++++++++++------- packages/runtime-core/src/apiOptions.ts | 64 +++++++++++--- packages/runtime-core/src/componentProxy.ts | 79 ++++++++++++++--- 3 files changed, 175 insertions(+), 54 deletions(-) diff --git a/packages/runtime-core/src/apiDefineComponent.ts b/packages/runtime-core/src/apiDefineComponent.ts index 9244a8161ab..3d9054fda5a 100644 --- a/packages/runtime-core/src/apiDefineComponent.ts +++ b/packages/runtime-core/src/apiDefineComponent.ts @@ -1,12 +1,16 @@ import { ComputedOptions, MethodOptions, + LegacyComponent, ComponentOptionsWithoutProps, ComponentOptionsWithArrayProps, ComponentOptionsWithObjectProps } from './apiOptions' import { SetupContext, RenderFunction } from './component' -import { ComponentPublicInstance } from './componentProxy' +import { + ComponentPublicInstance, + ComponentPublicInstanceConstructor +} from './componentProxy' import { ExtractPropTypes, ComponentPropsOptions } from './componentProps' import { isFunction } from '@vue/shared' import { VNodeProps } from './vnode' @@ -23,39 +27,40 @@ export function defineComponent( props: Readonly, ctx: SetupContext ) => RawBindings | RenderFunction -): { - new (): ComponentPublicInstance< +): ComponentPublicInstanceConstructor< + ComponentPublicInstance< Props, RawBindings, {}, {}, {}, + LegacyComponent, // public props VNodeProps & Props > -} +> -// overload 2: object format with no props -// (uses user defined props interface) -// return type is for Vetur and TSX support export function defineComponent< Props, RawBindings, D, C extends ComputedOptions = {}, - M extends MethodOptions = {} + M extends MethodOptions = {}, + Mixin extends LegacyComponent = LegacyComponent >( - options: ComponentOptionsWithoutProps -): { - new (): ComponentPublicInstance< - Props, - RawBindings, - D, - C, - M, - VNodeProps & Props + options: ComponentOptionsWithoutProps +): typeof options & + ComponentPublicInstanceConstructor< + ComponentPublicInstance< + Props, + RawBindings, + D, + C, + M, + Mixin, + VNodeProps & Props + > > -} // overload 3: object format with array props declaration // props inferred as { [key in PropNames]?: any } @@ -65,13 +70,22 @@ export function defineComponent< RawBindings, D, C extends ComputedOptions = {}, - M extends MethodOptions = {} + M extends MethodOptions = {}, + Mixin extends LegacyComponent = LegacyComponent >( - options: ComponentOptionsWithArrayProps -): { - // array props technically doesn't place any contraints on props in TSX - new (): ComponentPublicInstance -} + options: ComponentOptionsWithArrayProps< + PropNames, + RawBindings, + D, + C, + M, + Mixin + > +): typeof options & + ComponentPublicInstanceConstructor< + // array props technically doesn't place any contraints on props in TSX + ComponentPublicInstance + > // overload 4: object format with object props declaration // see `ExtractPropTypes` in ./componentProps.ts @@ -82,19 +96,29 @@ export function defineComponent< RawBindings, D, C extends ComputedOptions = {}, - M extends MethodOptions = {} + M extends MethodOptions = {}, + Mixin extends LegacyComponent = LegacyComponent >( - options: ComponentOptionsWithObjectProps -): { - new (): ComponentPublicInstance< - ExtractPropTypes, + options: ComponentOptionsWithObjectProps< + PropsOptions, RawBindings, D, C, M, - VNodeProps & ExtractPropTypes + Mixin + > +): typeof options & + ComponentPublicInstanceConstructor< + ComponentPublicInstance< + ExtractPropTypes, + RawBindings, + D, + C, + M, + Mixin, + VNodeProps & ExtractPropTypes + > > -} // implementation, close to no-op export function defineComponent(options: unknown) { diff --git a/packages/runtime-core/src/apiOptions.ts b/packages/runtime-core/src/apiOptions.ts index b306943f855..3a17523d229 100644 --- a/packages/runtime-core/src/apiOptions.ts +++ b/packages/runtime-core/src/apiOptions.ts @@ -48,8 +48,11 @@ export interface ComponentOptionsBase< RawBindings, D, C extends ComputedOptions, - M extends MethodOptions -> extends LegacyOptions, SFCInternalOptions { + M extends MethodOptions, + Mixin +> + extends LegacyOptions, + SFCInternalOptions { setup?: ( this: null, props: Props, @@ -81,10 +84,13 @@ export type ComponentOptionsWithoutProps< RawBindings = {}, D = {}, C extends ComputedOptions = {}, - M extends MethodOptions = {} -> = ComponentOptionsBase & { + M extends MethodOptions = {}, + Mixin = LegacyComponent +> = ComponentOptionsBase & { props?: undefined -} & ThisType>> +} & ThisType< + ComponentPublicInstance<{}, RawBindings, D, C, M, Mixin, Readonly> + > export type ComponentOptionsWithArrayProps< PropNames extends string = string, @@ -92,10 +98,11 @@ export type ComponentOptionsWithArrayProps< D = {}, C extends ComputedOptions = {}, M extends MethodOptions = {}, + Mixin = LegacyComponent, Props = Readonly<{ [key in PropNames]?: any }> -> = ComponentOptionsBase & { +> = ComponentOptionsBase & { props: PropNames[] -} & ThisType> +} & ThisType> export type ComponentOptionsWithObjectProps< PropsOptions = ComponentObjectPropsOptions, @@ -103,18 +110,32 @@ export type ComponentOptionsWithObjectProps< D = {}, C extends ComputedOptions = {}, M extends MethodOptions = {}, + Mixin = LegacyComponent, Props = Readonly> -> = ComponentOptionsBase & { +> = ComponentOptionsBase & { props: PropsOptions -} & ThisType> +} & ThisType> export type ComponentOptions = | ComponentOptionsWithoutProps | ComponentOptionsWithObjectProps | ComponentOptionsWithArrayProps +// IComponentOptionsXXX is used to resolve circularly references +export interface IComponentOptionsWithoutProps + extends ComponentOptionsWithoutProps {} +export interface IComponentOptionsWithObjectProps + extends ComponentOptionsWithObjectProps {} +export interface IComponentOptionsWithArrayProps + extends ComponentOptionsWithArrayProps {} + // TODO legacy component definition also supports constructors with .options -type LegacyComponent = ComponentOptions +export type LegacyComponent = + | IComponentOptionsWithoutProps + | IComponentOptionsWithObjectProps + | IComponentOptionsWithArrayProps + +export type MixinsOptions = LegacyComponent[] export type ComputedOptions = Record< string, @@ -152,7 +173,8 @@ export interface LegacyOptions< RawBindings, D, C extends ComputedOptions, - M extends MethodOptions + M extends MethodOptions, + Mixin > { el?: any @@ -168,8 +190,8 @@ export interface LegacyOptions< inject?: ComponentInjectOptions // composition - mixins?: LegacyComponent[] - extends?: LegacyComponent + mixins?: Mixin[] + extends?: Mixin // lifecycle beforeCreate?(): void @@ -187,6 +209,22 @@ export interface LegacyOptions< errorCaptured?: ErrorCapturedHook } +export type OptionTypesKeys = 'P' | 'B' | 'D' | 'C' | 'M' + +export type OptionTypesType< + P = {}, + B = {}, + D = {}, + C extends ComputedOptions = {}, + M extends MethodOptions = {} +> = { + P: P + B: B + D: D + C: C + M: M +} + const enum OptionTypes { PROPS = 'Props', DATA = 'Data', diff --git a/packages/runtime-core/src/componentProxy.ts b/packages/runtime-core/src/componentProxy.ts index dbdbe894060..8b29b1afb71 100644 --- a/packages/runtime-core/src/componentProxy.ts +++ b/packages/runtime-core/src/componentProxy.ts @@ -4,9 +4,15 @@ import { instanceWatch } from './apiWatch' import { EMPTY_OBJ, hasOwn, isGloballyWhitelisted } from '@vue/shared' import { ExtractComputedReturns, + LegacyComponent, ComponentOptionsBase, + IComponentOptionsWithoutProps, + IComponentOptionsWithArrayProps, + IComponentOptionsWithObjectProps, ComputedOptions, - MethodOptions + MethodOptions, + OptionTypesType, + OptionTypesKeys } from './apiOptions' import { UnwrapRef, ReactiveEffect } from '@vue/reactivity' import { warn } from './warning' @@ -16,6 +22,46 @@ import { markAttrsAccessed } from './componentRenderUtils' +type UnionToIntersection = (U extends any + ? (k: U) => void + : never) extends ((k: infer I) => void) + ? I + : never + +type MixinToOptionTypes = T extends ComponentOptionsBase< + infer P, + infer B, + infer D, + infer C, + infer M, + infer Mixin +> + ? OptionTypesType

& + IntersectionMixin + : never + +// MixinMapToOptionTypes is used to resolve circularly references +type MixinMapToOptionTypes = { + withoutProps: MixinToOptionTypes + objectProps: MixinToOptionTypes + arrayProps: MixinToOptionTypes +}[T extends IComponentOptionsWithArrayProps + ? 'arrayProps' + : T extends IComponentOptionsWithObjectProps + ? 'objectProps' + : T extends IComponentOptionsWithoutProps ? 'withoutProps' : never] + +type ExtractMixin = T extends LegacyComponent + ? MixinMapToOptionTypes + : never + +type IntersectionMixin = UnionToIntersection> + +type UnwrapMixinsType< + T, + Type extends OptionTypesKeys +> = T extends OptionTypesType ? T[Type] : never + // public properties exposed on the proxy, which is used as the render context // in templates (as `this` in the render option) export type ComponentPublicInstance< @@ -24,10 +70,17 @@ export type ComponentPublicInstance< D = {}, C extends ComputedOptions = {}, M extends MethodOptions = {}, - PublicProps = P + Mixin extends LegacyComponent = LegacyComponent, + PublicProps = P, + PublicMixin = IntersectionMixin, + PublicP = UnwrapMixinsType & P & PublicProps, + PublicB = UnwrapMixinsType & B, + PublicD = UnwrapMixinsType & D, + PublicC extends ComputedOptions = UnwrapMixinsType & C, + PublicM extends MethodOptions = UnwrapMixinsType & M > = { - $data: D - $props: PublicProps + $data: PublicD + $props: PublicP $attrs: Data $refs: Data $slots: Slots @@ -35,15 +88,21 @@ export type ComponentPublicInstance< $parent: ComponentInternalInstance | null $emit: Emit $el: any - $options: ComponentOptionsBase + $options: ComponentOptionsBase $forceUpdate: ReactiveEffect $nextTick: typeof nextTick $watch: typeof instanceWatch -} & P & - UnwrapRef & - D & - ExtractComputedReturns & - M +} & PublicP & + UnwrapRef & + PublicD & + ExtractComputedReturns & + PublicM + +export type ComponentPublicInstanceConstructor< + T extends ComponentPublicInstance +> = { + new (): T +} const publicPropertiesMap: Record< string, From 7e32c2fb5c40e271fcd7893b725bce997bdaeef5 Mon Sep 17 00:00:00 2001 From: dolymood Date: Tue, 14 Jan 2020 17:16:58 +0800 Subject: [PATCH 02/23] test(runtime-core): add mixins and extends --- .../runtime-core/__tests__/apiOptions.spec.ts | 68 ++++++++++++++----- 1 file changed, 50 insertions(+), 18 deletions(-) diff --git a/packages/runtime-core/__tests__/apiOptions.spec.ts b/packages/runtime-core/__tests__/apiOptions.spec.ts index 8a0199e3ffb..40d894e4bb1 100644 --- a/packages/runtime-core/__tests__/apiOptions.spec.ts +++ b/packages/runtime-core/__tests__/apiOptions.spec.ts @@ -440,13 +440,13 @@ describe('api: options', () => { test('mixins', () => { const calls: string[] = [] - const mixinA = { + const mixinA = defineComponent({ data() { return { a: 1 } }, - created(this: any) { + created() { calls.push('mixinA created') expect(this.a).toBe(1) expect(this.b).toBe(2) @@ -455,68 +455,100 @@ describe('api: options', () => { mounted() { calls.push('mixinA mounted') } - } - const mixinB = { + }) + const mixinB = defineComponent({ + props: { + bP: { + type: String + } + }, data() { return { b: 2 } }, - created(this: any) { + created() { calls.push('mixinB created') expect(this.a).toBe(1) expect(this.b).toBe(2) + expect(this.bP).toBeUndefined() expect(this.c).toBe(3) }, mounted() { calls.push('mixinB mounted') } - } - const Comp = { - mixins: [mixinA, mixinB], + }) + const mixinC = defineComponent({ + props: ['cP1', 'cP2'], data() { return { c: 3 } }, - created(this: any) { + created() { + calls.push('mixinC created') + expect(this.a).toBe(1) + expect(this.b).toBe(2) + expect(this.bP).toBeUndefined() + expect(this.c).toBe(3) + expect(this.cP1).toBeUndefined() + }, + mounted() { + calls.push('mixinC mounted') + } + }) + const Comp = defineComponent({ + mixins: [mixinA, mixinB, mixinC], + data() { + return { + z: 4 + } + }, + created() { calls.push('comp created') expect(this.a).toBe(1) expect(this.b).toBe(2) + expect(this.bP).toBeUndefined() expect(this.c).toBe(3) + expect(this.cP2).toBeUndefined() + expect(this.z).toBe(4) }, mounted() { calls.push('comp mounted') }, - render(this: any) { + render() { return `${this.a}${this.b}${this.c}` } - } - + }) expect(renderToString(h(Comp))).toBe(`123`) expect(calls).toEqual([ 'mixinA created', 'mixinB created', + 'mixinC created', 'comp created', 'mixinA mounted', 'mixinB mounted', + 'mixinC mounted', 'comp mounted' ]) }) test('extends', () => { const calls: string[] = [] - const Base = { + const Base = defineComponent({ data() { return { a: 1 } }, + methods: { + sayA() {} + }, mounted() { calls.push('base') } - } - const Comp = { + }) + const Comp = defineComponent({ extends: Base, data() { return { @@ -526,10 +558,10 @@ describe('api: options', () => { mounted() { calls.push('comp') }, - render(this: any) { + render() { return `${this.a}${this.b}` } - } + }) expect(renderToString(h(Comp))).toBe(`12`) expect(calls).toEqual(['base', 'comp']) @@ -544,7 +576,7 @@ describe('api: options', () => { }, data() { return { - plusOne: (this as any).count + 1 + plusOne: this.count + 1 } }, computed: { From 11f5b30eb3caa80393fa07ec4adfb2dd26b98ed8 Mon Sep 17 00:00:00 2001 From: dolymood Date: Tue, 14 Jan 2020 17:19:18 +0800 Subject: [PATCH 03/23] test(defineComponent): add mixins and extends --- test-dts/defineComponent.test-d.tsx | 173 ++++++++++++++++++++++++++++ 1 file changed, 173 insertions(+) diff --git a/test-dts/defineComponent.test-d.tsx b/test-dts/defineComponent.test-d.tsx index 5ae79cfefc9..d4266adabfb 100644 --- a/test-dts/defineComponent.test-d.tsx +++ b/test-dts/defineComponent.test-d.tsx @@ -241,6 +241,179 @@ describe('type inference w/ options API', () => { }) }) +describe('with mixins', () => { + const MixinA = defineComponent({ + props: { + aP1: { + type: String, + default: 'aP1' + }, + aP2: Boolean + }, + data() { + return { + a: 1 + } + } + }) + const MixinB = defineComponent({ + props: ['bP1', 'bP2'], + data() { + return { + b: 2 + } + } + }) + const MixinC = defineComponent({ + data() { + return { + c: 3 + } + } + }) + const MixinD = defineComponent({ + mixins: [MixinA], + data() { + return { + d: 4 + } + }, + computed: { + dC1(): number { + return this.d + this.a + }, + dC2(): string { + return this.aP1 + 'dC2' + } + } + }) + const MyComponent = defineComponent({ + mixins: [MixinA, MixinB, MixinC, MixinD], + props: { + // required should make property non-void + z: { + type: String, + required: true + } + }, + render() { + const props = this.$props + // props + expectType(props.aP1) + expectType(props.aP2) + expectType(props.bP1) + expectType(props.bP2) + expectType(props.z) + + const data = this.$data + expectType(data.a) + expectType(data.b) + expectType(data.c) + expectType(data.d) + + // should also expose declared props on `this` + expectType(this.a) + expectType(this.aP1) + expectType(this.aP2) + expectType(this.b) + expectType(this.bP1) + expectType(this.c) + expectType(this.d) + expectType(this.dC1) + expectType(this.dC2) + + // props should be readonly + expectError((this.aP1 = 'new')) + expectError((this.z = 1)) + + // props on `this` should be readonly + expectError((this.bP1 = 1)) + + // string value can not assigned to number type value + expectError((this.c = '1')) + + // setup context properties should be mutable + this.d = 5 + + return null + } + }) + + // Test TSX + expectType( + + ) + + // missing required props + expectError() + + // wrong prop types + expectError() + expectError() +}) + +describe('with extends', () => { + const Base = defineComponent({ + props: { + aP1: Boolean, + aP2: { + type: Number, + default: 2 + } + }, + data() { + return { + a: 1 + } + }, + computed: { + c(): number { + return this.aP2 + this.a + } + } + }) + const MyComponent = defineComponent({ + extends: Base, + props: { + // required should make property non-void + z: { + type: String, + required: true + } + }, + render() { + const props = this.$props + // props + expectType(props.aP1) + expectType(props.aP2) + expectType(props.z) + + const data = this.$data + expectType(data.a) + + // should also expose declared props on `this` + expectType(this.a) + expectType(this.aP1) + expectType(this.aP2) + + // setup context properties should be mutable + this.a = 5 + + return null + } + }) + + // Test TSX + expectType() + + // missing required props + expectError() + + // wrong prop types + expectError() + expectError() +}) + describe('compatibility w/ createApp', () => { const comp = defineComponent({}) createApp().mount(comp, '#hello') From 058e6c7eafb486d595b1d3b561d6eade73c0c352 Mon Sep 17 00:00:00 2001 From: dolymood Date: Tue, 14 Jan 2020 17:37:43 +0800 Subject: [PATCH 04/23] fix(runtime-core): apiExtractor can not support typeof "options" --- packages/runtime-core/src/apiDefineComponent.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/runtime-core/src/apiDefineComponent.ts b/packages/runtime-core/src/apiDefineComponent.ts index 3d9054fda5a..2c399c23de2 100644 --- a/packages/runtime-core/src/apiDefineComponent.ts +++ b/packages/runtime-core/src/apiDefineComponent.ts @@ -49,7 +49,7 @@ export function defineComponent< Mixin extends LegacyComponent = LegacyComponent >( options: ComponentOptionsWithoutProps -): typeof options & +): ComponentOptionsWithoutProps & ComponentPublicInstanceConstructor< ComponentPublicInstance< Props, @@ -81,7 +81,7 @@ export function defineComponent< M, Mixin > -): typeof options & +): ComponentOptionsWithArrayProps & ComponentPublicInstanceConstructor< // array props technically doesn't place any contraints on props in TSX ComponentPublicInstance @@ -107,7 +107,7 @@ export function defineComponent< M, Mixin > -): typeof options & +): ComponentOptionsWithObjectProps & ComponentPublicInstanceConstructor< ComponentPublicInstance< ExtractPropTypes, From bfd35a162f34fbb2daa5e62efb5152ae1d3087e6 Mon Sep 17 00:00:00 2001 From: dolymood Date: Thu, 16 Jan 2020 13:48:28 +0800 Subject: [PATCH 05/23] fix(runtime-core): compatible with before h & defineComponent --- .../runtime-core/__tests__/apiOptions.spec.ts | 24 ++++--- .../runtime-core/src/apiDefineComponent.ts | 26 ++++--- packages/runtime-core/src/apiOptions.ts | 28 +++++--- packages/runtime-core/src/componentProxy.ts | 72 +++++++++++++------ packages/runtime-core/src/h.ts | 13 +++- test-dts/defineComponent.test-d.tsx | 8 ++- test-dts/h.test-d.ts | 1 + 7 files changed, 122 insertions(+), 50 deletions(-) diff --git a/packages/runtime-core/__tests__/apiOptions.spec.ts b/packages/runtime-core/__tests__/apiOptions.spec.ts index 40d894e4bb1..a9ee06d31a0 100644 --- a/packages/runtime-core/__tests__/apiOptions.spec.ts +++ b/packages/runtime-core/__tests__/apiOptions.spec.ts @@ -334,6 +334,9 @@ describe('api: options', () => { } const Mid = { + props: { + count: Number + }, beforeCreate() { calls.push('mid beforeCreate') }, @@ -364,6 +367,9 @@ describe('api: options', () => { } const Child = { + props: { + count: Number + }, beforeCreate() { calls.push('child beforeCreate') }, @@ -449,8 +455,10 @@ describe('api: options', () => { created() { calls.push('mixinA created') expect(this.a).toBe(1) - expect(this.b).toBe(2) - expect(this.c).toBe(3) + // should not visit other props/data... in one mixin + // only test current mixin props/data ? + // expect(this.b).toBe(2) + // expect(this.c).toBe(3) }, mounted() { calls.push('mixinA mounted') @@ -469,10 +477,10 @@ describe('api: options', () => { }, created() { calls.push('mixinB created') - expect(this.a).toBe(1) + // expect(this.a).toBe(1) expect(this.b).toBe(2) expect(this.bP).toBeUndefined() - expect(this.c).toBe(3) + // expect(this.c).toBe(3) }, mounted() { calls.push('mixinB mounted') @@ -487,9 +495,9 @@ describe('api: options', () => { }, created() { calls.push('mixinC created') - expect(this.a).toBe(1) - expect(this.b).toBe(2) - expect(this.bP).toBeUndefined() + // expect(this.a).toBe(1) + // expect(this.b).toBe(2) + // expect(this.bP).toBeUndefined() expect(this.c).toBe(3) expect(this.cP1).toBeUndefined() }, @@ -576,7 +584,7 @@ describe('api: options', () => { }, data() { return { - plusOne: this.count + 1 + plusOne: (this as any).count + 1 } }, computed: { diff --git a/packages/runtime-core/src/apiDefineComponent.ts b/packages/runtime-core/src/apiDefineComponent.ts index 2c399c23de2..c91e8b8c826 100644 --- a/packages/runtime-core/src/apiDefineComponent.ts +++ b/packages/runtime-core/src/apiDefineComponent.ts @@ -8,7 +8,7 @@ import { } from './apiOptions' import { SetupContext, RenderFunction } from './component' import { - ComponentPublicInstance, + CreateComponentPublicInstance, ComponentPublicInstanceConstructor } from './componentProxy' import { ExtractPropTypes, ComponentPropsOptions } from './componentProps' @@ -28,7 +28,7 @@ export function defineComponent( ctx: SetupContext ) => RawBindings | RenderFunction ): ComponentPublicInstanceConstructor< - ComponentPublicInstance< + CreateComponentPublicInstance< Props, RawBindings, {}, @@ -46,12 +46,12 @@ export function defineComponent< D, C extends ComputedOptions = {}, M extends MethodOptions = {}, - Mixin extends LegacyComponent = LegacyComponent + Mixin = LegacyComponent >( options: ComponentOptionsWithoutProps ): ComponentOptionsWithoutProps & ComponentPublicInstanceConstructor< - ComponentPublicInstance< + CreateComponentPublicInstance< Props, RawBindings, D, @@ -71,7 +71,7 @@ export function defineComponent< D, C extends ComputedOptions = {}, M extends MethodOptions = {}, - Mixin extends LegacyComponent = LegacyComponent + Mixin = LegacyComponent >( options: ComponentOptionsWithArrayProps< PropNames, @@ -83,8 +83,16 @@ export function defineComponent< > ): ComponentOptionsWithArrayProps & ComponentPublicInstanceConstructor< - // array props technically doesn't place any contraints on props in TSX - ComponentPublicInstance + // array props technically doesn't place any contraints on props in TSX before, + // but now we can export array props in TSX + CreateComponentPublicInstance< + Readonly<{ [key in PropNames]?: any }>, + RawBindings, + D, + C, + M, + Mixin + > > // overload 4: object format with object props declaration @@ -97,7 +105,7 @@ export function defineComponent< D, C extends ComputedOptions = {}, M extends MethodOptions = {}, - Mixin extends LegacyComponent = LegacyComponent + Mixin = LegacyComponent >( options: ComponentOptionsWithObjectProps< PropsOptions, @@ -109,7 +117,7 @@ export function defineComponent< > ): ComponentOptionsWithObjectProps & ComponentPublicInstanceConstructor< - ComponentPublicInstance< + CreateComponentPublicInstance< ExtractPropTypes, RawBindings, D, diff --git a/packages/runtime-core/src/apiOptions.ts b/packages/runtime-core/src/apiOptions.ts index 8703a29ff70..14101ee483f 100644 --- a/packages/runtime-core/src/apiOptions.ts +++ b/packages/runtime-core/src/apiOptions.ts @@ -40,7 +40,10 @@ import { } from '@vue/reactivity' import { ComponentObjectPropsOptions, ExtractPropTypes } from './componentProps' import { Directive } from './directives' -import { ComponentPublicInstance } from './componentProxy' +import { + CreateComponentPublicInstance, + ComponentPublicInstance +} from './componentProxy' import { warn } from './warning' export interface ComponentOptionsBase< @@ -49,7 +52,7 @@ export interface ComponentOptionsBase< D, C extends ComputedOptions, M extends MethodOptions, - Mixin + Mixin extends LegacyComponent > extends LegacyOptions, SFCInternalOptions { @@ -68,7 +71,8 @@ export interface ComponentOptionsBase< render?: Function components?: Record< string, - Component | { new (): ComponentPublicInstance } + | Component + | { new (): CreateComponentPublicInstance } > directives?: Record inheritAttrs?: boolean @@ -92,7 +96,15 @@ export type ComponentOptionsWithoutProps< > = ComponentOptionsBase, RawBindings, D, C, M, Mixin> & { props?: undefined } & ThisType< - ComponentPublicInstance<{}, RawBindings, D, C, M, Mixin, Readonly> + CreateComponentPublicInstance< + {}, + RawBindings, + D, + C, + M, + Mixin, + Readonly + > > export type ComponentOptionsWithArrayProps< @@ -105,7 +117,7 @@ export type ComponentOptionsWithArrayProps< Props = Readonly<{ [key in PropNames]?: any }> > = ComponentOptionsBase & { props: PropNames[] -} & ThisType> +} & ThisType> export type ComponentOptionsWithObjectProps< PropsOptions = ComponentObjectPropsOptions, @@ -117,7 +129,7 @@ export type ComponentOptionsWithObjectProps< Props = Readonly> > = ComponentOptionsBase & { props: PropsOptions -} & ThisType> +} & ThisType> export type ComponentOptions = | ComponentOptionsWithoutProps @@ -177,7 +189,7 @@ export interface LegacyOptions< D, C extends ComputedOptions, M extends MethodOptions, - Mixin + Mixin extends LegacyComponent > { el?: any @@ -185,7 +197,7 @@ export interface LegacyOptions< // Limitation: we cannot expose RawBindings on the `this` context for data // since that leads to some sort of circular inference and breaks ThisType // for the entire component. - data?: D | ((this: ComponentPublicInstance) => D) + data?: D | ((this: CreateComponentPublicInstance) => D) computed?: C methods?: M watch?: ComponentWatchOptions diff --git a/packages/runtime-core/src/componentProxy.ts b/packages/runtime-core/src/componentProxy.ts index 8b29b1afb71..092f6f7897f 100644 --- a/packages/runtime-core/src/componentProxy.ts +++ b/packages/runtime-core/src/componentProxy.ts @@ -28,6 +28,10 @@ type UnionToIntersection = (U extends any ? I : never +type IsLegacyComponent = T extends LegacyComponent + ? LegacyComponent extends T ? true : false + : false + type MixinToOptionTypes = T extends ComponentOptionsBase< infer P, infer B, @@ -40,47 +44,75 @@ type MixinToOptionTypes = T extends ComponentOptionsBase< IntersectionMixin : never +const enum OptionsPropsTypes { + WITHOUT = 'OptionsWithoutPropsType', + ARRAY = 'OptionsWithArrayPropsType', + OBJECT = 'OptionsWithObjectPropsType' +} + // MixinMapToOptionTypes is used to resolve circularly references type MixinMapToOptionTypes = { - withoutProps: MixinToOptionTypes - objectProps: MixinToOptionTypes - arrayProps: MixinToOptionTypes + [OptionsPropsTypes.ARRAY]: MixinToOptionTypes + [OptionsPropsTypes.OBJECT]: MixinToOptionTypes + [OptionsPropsTypes.WITHOUT]: MixinToOptionTypes }[T extends IComponentOptionsWithArrayProps - ? 'arrayProps' + ? OptionsPropsTypes.ARRAY : T extends IComponentOptionsWithObjectProps - ? 'objectProps' - : T extends IComponentOptionsWithoutProps ? 'withoutProps' : never] + ? OptionsPropsTypes.OBJECT + : T extends IComponentOptionsWithoutProps + ? OptionsPropsTypes.WITHOUT + : never] type ExtractMixin = T extends LegacyComponent ? MixinMapToOptionTypes : never -type IntersectionMixin = UnionToIntersection> +type IntersectionMixin = IsLegacyComponent extends true + ? OptionTypesType<{}, {}, {}, {}, {}> + : UnionToIntersection> type UnwrapMixinsType< T, Type extends OptionTypesKeys > = T extends OptionTypesType ? T[Type] : never -// public properties exposed on the proxy, which is used as the render context -// in templates (as `this` in the render option) -export type ComponentPublicInstance< +export type CreateComponentPublicInstance< P = {}, B = {}, D = {}, C extends ComputedOptions = {}, M extends MethodOptions = {}, - Mixin extends LegacyComponent = LegacyComponent, + Mixin = LegacyComponent, PublicProps = P, PublicMixin = IntersectionMixin, - PublicP = UnwrapMixinsType & P & PublicProps, + PublicP = UnwrapMixinsType & P, PublicB = UnwrapMixinsType & B, PublicD = UnwrapMixinsType & D, PublicC extends ComputedOptions = UnwrapMixinsType & C, PublicM extends MethodOptions = UnwrapMixinsType & M +> = ComponentPublicInstance< + PublicP, + PublicB, + PublicD, + PublicC, + PublicM, + PublicProps, + ComponentOptionsBase +> + +// public properties exposed on the proxy, which is used as the render context +// in templates (as `this` in the render option) +export type ComponentPublicInstance< + P = {}, + B = {}, + D = {}, + C extends ComputedOptions = {}, + M extends MethodOptions = {}, + PublicProps = P, + Options = ComponentOptionsBase > = { - $data: PublicD - $props: PublicP + $data: D + $props: P & PublicProps $attrs: Data $refs: Data $slots: Slots @@ -88,15 +120,15 @@ export type ComponentPublicInstance< $parent: ComponentInternalInstance | null $emit: Emit $el: any - $options: ComponentOptionsBase + $options: Options $forceUpdate: ReactiveEffect $nextTick: typeof nextTick $watch: typeof instanceWatch -} & PublicP & - UnwrapRef & - PublicD & - ExtractComputedReturns & - PublicM +} & P & + UnwrapRef & + D & + ExtractComputedReturns & + M export type ComponentPublicInstanceConstructor< T extends ComponentPublicInstance diff --git a/packages/runtime-core/src/h.ts b/packages/runtime-core/src/h.ts index 2137be2df1a..0119543b079 100644 --- a/packages/runtime-core/src/h.ts +++ b/packages/runtime-core/src/h.ts @@ -118,8 +118,17 @@ export function h

( // stateful component export function h(type: ComponentOptions, children?: RawChildren): VNode export function h( - type: ComponentOptionsWithoutProps | ComponentOptionsWithArrayProps, - props?: RawProps | null, + type: ComponentOptionsWithoutProps, + // props should be undefined, because + // ComponentOptionsWithArrayProps/ComponentOptionsWithObjectProps extends ComponentOptionsWithoutProps + props?: undefined, + children?: RawChildren | RawSlots +): VNode +export function h( + type: ComponentOptionsWithArrayProps, + props?: + | (RawProps & Readonly<{ [key in S]?: any }>) + | ({} extends Readonly<{ [key in S]?: any }> ? null : never), children?: RawChildren | RawSlots ): VNode export function h( diff --git a/test-dts/defineComponent.test-d.tsx b/test-dts/defineComponent.test-d.tsx index 1bc46f269a9..21d206ab6da 100644 --- a/test-dts/defineComponent.test-d.tsx +++ b/test-dts/defineComponent.test-d.tsx @@ -156,7 +156,7 @@ describe('type inference w/ direct setup function', () => { }) describe('type inference w/ array props declaration', () => { - defineComponent({ + const MyComponent = defineComponent({ props: ['a', 'b'], setup(props) { // props should be readonly @@ -176,6 +176,8 @@ describe('type inference w/ array props declaration', () => { expectType(this.c) } }) + expectType() + expectError() }) describe('type inference w/ options API', () => { @@ -410,8 +412,8 @@ describe('with extends', () => { expectError() // wrong prop types - expectError() - expectError() + expectError() + expectError() }) describe('compatibility w/ createApp', () => { diff --git a/test-dts/h.test-d.ts b/test-dts/h.test-d.ts index 99af6ba5fd2..8f96081c71d 100644 --- a/test-dts/h.test-d.ts +++ b/test-dts/h.test-d.ts @@ -86,6 +86,7 @@ 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 expectError(h(Foo, {})) expectError(h(Foo, { foo: 'ok' })) From fdfb31e3146c92d32a45e13d8f2e25f001cac07b Mon Sep 17 00:00:00 2001 From: dolymood Date: Thu, 16 Jan 2020 14:41:50 +0800 Subject: [PATCH 06/23] fix(runtime-core): h cases for setup --- packages/runtime-core/src/h.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/runtime-core/src/h.ts b/packages/runtime-core/src/h.ts index 0119543b079..ef4a7214d9d 100644 --- a/packages/runtime-core/src/h.ts +++ b/packages/runtime-core/src/h.ts @@ -10,7 +10,7 @@ import { import { Suspense, SuspenseProps } from './components/Suspense' import { isObject, isArray } from '@vue/shared' import { RawSlots } from './componentSlots' -import { FunctionalComponent } from './component' +import { FunctionalComponent, SetupContext, RenderFunction } from './component' import { ComponentOptionsWithoutProps, ComponentOptionsWithArrayProps, @@ -138,6 +138,13 @@ export function h( | ({} extends ExtractPropTypes ? null : never), children?: RawChildren | RawSlots ): VNode +export function h

( + type: { + setup: (props: Readonly

, ctx: SetupContext) => {} | RenderFunction + }, + props?: (RawProps & P) | ({} extends P ? null : never), + children?: RawChildren | RawSlots +): VNode // fake constructor type returned by `defineComponent` export function h(type: Constructor, children?: RawChildren): VNode From 1f5bf5a1e4064b2c09e38f6d4d85218541840eb2 Mon Sep 17 00:00:00 2001 From: dolymood Date: Thu, 16 Jan 2020 14:59:02 +0800 Subject: [PATCH 07/23] fix(runtime-core): h cases for ComponentOptionsBase --- packages/runtime-core/__tests__/apiOptions.spec.ts | 6 ------ packages/runtime-core/src/h.ts | 9 ++++----- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/packages/runtime-core/__tests__/apiOptions.spec.ts b/packages/runtime-core/__tests__/apiOptions.spec.ts index a9ee06d31a0..e266e286b14 100644 --- a/packages/runtime-core/__tests__/apiOptions.spec.ts +++ b/packages/runtime-core/__tests__/apiOptions.spec.ts @@ -334,9 +334,6 @@ describe('api: options', () => { } const Mid = { - props: { - count: Number - }, beforeCreate() { calls.push('mid beforeCreate') }, @@ -367,9 +364,6 @@ describe('api: options', () => { } const Child = { - props: { - count: Number - }, beforeCreate() { calls.push('child beforeCreate') }, diff --git a/packages/runtime-core/src/h.ts b/packages/runtime-core/src/h.ts index ef4a7214d9d..8489a886980 100644 --- a/packages/runtime-core/src/h.ts +++ b/packages/runtime-core/src/h.ts @@ -10,12 +10,13 @@ import { import { Suspense, SuspenseProps } from './components/Suspense' import { isObject, isArray } from '@vue/shared' import { RawSlots } from './componentSlots' -import { FunctionalComponent, SetupContext, RenderFunction } from './component' +import { FunctionalComponent } from './component' import { ComponentOptionsWithoutProps, ComponentOptionsWithArrayProps, ComponentOptionsWithObjectProps, - ComponentOptions + ComponentOptions, + ComponentOptionsBase } from './apiOptions' import { ExtractPropTypes } from './componentProps' @@ -139,9 +140,7 @@ export function h( children?: RawChildren | RawSlots ): VNode export function h

( - type: { - setup: (props: Readonly

, ctx: SetupContext) => {} | RenderFunction - }, + type: ComponentOptionsBase, props?: (RawProps & P) | ({} extends P ? null : never), children?: RawChildren | RawSlots ): VNode From 3b7971e1df6c3accf4e8739a69e23a1fd253f0bb Mon Sep 17 00:00:00 2001 From: dolymood Date: Thu, 16 Jan 2020 15:10:37 +0800 Subject: [PATCH 08/23] fix(runtime-core): withoutprops use union define - null --- packages/runtime-core/src/apiOptions.ts | 2 +- packages/runtime-core/src/h.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/runtime-core/src/apiOptions.ts b/packages/runtime-core/src/apiOptions.ts index 14101ee483f..c8169402c08 100644 --- a/packages/runtime-core/src/apiOptions.ts +++ b/packages/runtime-core/src/apiOptions.ts @@ -94,7 +94,7 @@ export type ComponentOptionsWithoutProps< M extends MethodOptions = {}, Mixin = LegacyComponent > = ComponentOptionsBase, RawBindings, D, C, M, Mixin> & { - props?: undefined + props?: null } & ThisType< CreateComponentPublicInstance< {}, diff --git a/packages/runtime-core/src/h.ts b/packages/runtime-core/src/h.ts index 8489a886980..8637d9e26ae 100644 --- a/packages/runtime-core/src/h.ts +++ b/packages/runtime-core/src/h.ts @@ -120,9 +120,9 @@ export function h

( export function h(type: ComponentOptions, children?: RawChildren): VNode export function h( type: ComponentOptionsWithoutProps, - // props should be undefined, because + // props should be null, because // ComponentOptionsWithArrayProps/ComponentOptionsWithObjectProps extends ComponentOptionsWithoutProps - props?: undefined, + props?: null, children?: RawChildren | RawSlots ): VNode export function h( From df580c076aa04db77d3f0769ca8d06ccbebca0c7 Mon Sep 17 00:00:00 2001 From: dolymood Date: Thu, 16 Jan 2020 15:27:11 +0800 Subject: [PATCH 09/23] fix(runtime-core): props options can be null #3b7971e --- packages/runtime-core/src/componentProps.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/runtime-core/src/componentProps.ts b/packages/runtime-core/src/componentProps.ts index a0acd982f2a..d5457096af8 100644 --- a/packages/runtime-core/src/componentProps.ts +++ b/packages/runtime-core/src/componentProps.ts @@ -95,7 +95,7 @@ type NormalizedPropsOptions = [Record, string[]] export function resolveProps( instance: ComponentInternalInstance, rawProps: Data | null, - _options: ComponentPropsOptions | void + _options: ComponentPropsOptions | void | null ) { const hasDeclaredProps = _options != null if (!rawProps && !hasDeclaredProps) { @@ -214,7 +214,7 @@ const normalizationMap = new WeakMap< >() function normalizePropsOptions( - raw: ComponentPropsOptions | void + raw: ComponentPropsOptions | void | null ): NormalizedPropsOptions { if (!raw) { return [] as any From d2250b984e8898cbd6b8915d53353e45d4120509 Mon Sep 17 00:00:00 2001 From: dolymood Date: Thu, 30 Apr 2020 15:47:49 +0800 Subject: [PATCH 10/23] test(types): add extends with mixins case --- test-dts/defineComponent.test-d.tsx | 83 +++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/test-dts/defineComponent.test-d.tsx b/test-dts/defineComponent.test-d.tsx index 7a22689b511..bcf3b98ca14 100644 --- a/test-dts/defineComponent.test-d.tsx +++ b/test-dts/defineComponent.test-d.tsx @@ -477,6 +477,89 @@ describe('with extends', () => { expectError() }) +describe('extends with mixins', () => { + const Mixin = defineComponent({ + props: { + mP1: { + type: String, + default: 'mP1' + }, + mP2: Boolean + }, + data() { + return { + a: 1 + } + } + }) + const Base = defineComponent({ + props: { + p1: Boolean, + p2: { + type: Number, + default: 2 + } + }, + data() { + return { + b: 2 + } + }, + computed: { + c(): number { + return this.p2 + this.b + } + } + }) + const MyComponent = defineComponent({ + extends: Base, + mixins: [Mixin], + props: { + // required should make property non-void + z: { + type: String, + required: true + } + }, + render() { + const props = this.$props + // props + expectType(props.p1) + expectType(props.p2) + expectType(props.z) + expectType(props.mP1) + expectType(props.mP2) + + const data = this.$data + expectType(data.a) + expectType(data.b) + + // should also expose declared props on `this` + expectType(this.a) + expectType(this.b) + expectType(this.p1) + expectType(this.p2) + expectType(this.mP1) + expectType(this.mP2) + + // setup context properties should be mutable + this.a = 5 + + return null + } + }) + + // Test TSX + expectType() + + // missing required props + expectError() + + // wrong prop types + expectError() + expectError() +}) + describe('compatibility w/ createApp', () => { const comp = defineComponent({}) createApp(comp).mount('#hello') From 3251dcf4c071f346e438715b90318a91962d7397 Mon Sep 17 00:00:00 2001 From: dolymood Date: Thu, 30 Apr 2020 15:54:55 +0800 Subject: [PATCH 11/23] fix(runtime-core): remove PropMethod type useless code --- packages/runtime-core/src/componentProps.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/runtime-core/src/componentProps.ts b/packages/runtime-core/src/componentProps.ts index 5a2578dfc3f..25c5537e171 100644 --- a/packages/runtime-core/src/componentProps.ts +++ b/packages/runtime-core/src/componentProps.ts @@ -48,7 +48,7 @@ type PropConstructor = | PropMethod type PropMethod = T extends (...args: any) => any // if is function with args - ? { new (): T & {}; (): T; readonly proptotype: Function } // Create Function like contructor + ? { new (): T; (): T; readonly proptotype: Function } // Create Function like contructor : never type RequiredKeys = { @@ -67,9 +67,8 @@ type OptionalKeys = Exclude< type InferPropType = T extends null ? any // null & true would fail to infer : T extends { type: null | true } - ? any // As TS issue https://github.com/Microsoft/TypeScript/issues/14829 // somehow `ObjectConstructor` when inferred from { (): T } becomes `any` - : // `BooleanConstructor` when inferred from PropConstructor(with PropMethod) becomes `Boolean` - T extends ObjectConstructor | { type: ObjectConstructor } + ? any // As TS issue https://github.com/Microsoft/TypeScript/issues/14829 // somehow `ObjectConstructor` when inferred from { (): T } becomes `any` // `BooleanConstructor` when inferred from PropConstructor(with PropMethod) becomes `Boolean` + : T extends ObjectConstructor | { type: ObjectConstructor } ? { [key: string]: any } : T extends BooleanConstructor | { type: BooleanConstructor } ? boolean From 3e0eb03a6cceab2198aa7c16b4ba98cf1f6fda87 Mon Sep 17 00:00:00 2001 From: dolymood Date: Thu, 30 Apr 2020 18:03:39 +0800 Subject: [PATCH 12/23] test(runtime-core): ensure mixin can access parent context --- .../runtime-core/__tests__/apiOptions.spec.ts | 72 +++++++++++-------- 1 file changed, 41 insertions(+), 31 deletions(-) diff --git a/packages/runtime-core/__tests__/apiOptions.spec.ts b/packages/runtime-core/__tests__/apiOptions.spec.ts index e1555004dc3..eec46597777 100644 --- a/packages/runtime-core/__tests__/apiOptions.spec.ts +++ b/packages/runtime-core/__tests__/apiOptions.spec.ts @@ -426,25 +426,23 @@ describe('api: options', () => { test('mixins', () => { const calls: string[] = [] - const mixinA = defineComponent({ + const mixinA = { data() { return { a: 1 } }, - created() { + created(this: any) { calls.push('mixinA created') expect(this.a).toBe(1) - // should not visit other props/data... in one mixin - // ????? only test current mixin props/data - // expect(this.b).toBe(2) - // expect(this.c).toBe(3) + expect(this.b).toBe(2) + expect(this.c).toBe(3) }, mounted() { calls.push('mixinA mounted') } - }) - const mixinB = defineComponent({ + } + const mixinB = { props: { bP: { type: String @@ -455,38 +453,42 @@ describe('api: options', () => { b: 2 } }, - created() { + created(this: any) { calls.push('mixinB created') - // expect(this.a).toBe(1) + expect(this.a).toBe(1) expect(this.b).toBe(2) expect(this.bP).toBeUndefined() - // expect(this.c).toBe(3) + expect(this.c).toBe(3) }, mounted() { calls.push('mixinB mounted') } - }) - const mixinC = defineComponent({ + } + const mixinC = { props: ['cP1', 'cP2'], data() { return { c: 3 } }, - created() { + created(this: any) { calls.push('mixinC created') - // expect(this.a).toBe(1) - // expect(this.b).toBe(2) - // expect(this.bP).toBeUndefined() + expect(this.a).toBe(1) + expect(this.b).toBe(2) + expect(this.bP).toBeUndefined() expect(this.c).toBe(3) expect(this.cP1).toBeUndefined() }, mounted() { calls.push('mixinC mounted') } - }) + } const Comp = defineComponent({ - mixins: [mixinA, mixinB, mixinC], + mixins: [ + defineComponent(mixinA), + defineComponent(mixinB), + defineComponent(mixinC) + ], data() { return { z: 4 @@ -523,7 +525,7 @@ describe('api: options', () => { test('extends', () => { const calls: string[] = [] - const Base = defineComponent({ + const Base = { data() { return { a: 1 @@ -532,12 +534,14 @@ describe('api: options', () => { methods: { sayA() {} }, - mounted() { + mounted(this: any) { + expect(this.a).toBe(1) + expect(this.b).toBe(2) calls.push('base') } - }) + } const Comp = defineComponent({ - extends: Base, + extends: defineComponent(Base), data() { return { b: 2 @@ -557,7 +561,7 @@ describe('api: options', () => { test('extends with mixins', () => { const calls: string[] = [] - const Base = defineComponent({ + const Base = { data() { return { a: 1 @@ -566,23 +570,29 @@ describe('api: options', () => { methods: { sayA() {} }, - mounted() { + mounted(this: any) { + expect(this.a).toBe(1) + expect(this.b).toBeTruthy() + expect(this.c).toBe(2) calls.push('base') } - }) - const Base2 = defineComponent({ + } + const Base2 = { data() { return { b: true } }, - mounted() { + mounted(this: any) { + expect(this.a).toBe(1) + expect(this.b).toBeTruthy() + expect(this.c).toBe(2) calls.push('base2') } - }) + } const Comp = defineComponent({ - extends: Base, - mixins: [Base2], + extends: defineComponent(Base), + mixins: [defineComponent(Base2)], data() { return { c: 2 From 3193816b8dda2f461dcb77df475fc3217d583a7f Mon Sep 17 00:00:00 2001 From: pikax Date: Fri, 1 May 2020 08:39:19 +0100 Subject: [PATCH 13/23] feat: update to typescript@3.9rc and type fixes --- package.json | 2 +- packages/runtime-core/src/componentOptions.ts | 6 +++--- packages/runtime-core/src/components/Suspense.ts | 2 +- packages/vue/src/devCheck.ts | 2 +- yarn.lock | 8 ++++---- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 706cedc6f0c..13244341175 100644 --- a/package.json +++ b/package.json @@ -71,7 +71,7 @@ "serve": "^11.3.0", "ts-jest": "^25.2.1", "tsd": "^0.11.0", - "typescript": "^3.8.3", + "typescript": "^3.9.1-rc", "yorkie": "^2.0.0" } } diff --git a/packages/runtime-core/src/componentOptions.ts b/packages/runtime-core/src/componentOptions.ts index 78ef9c3d735..c9ad623d738 100644 --- a/packages/runtime-core/src/componentOptions.ts +++ b/packages/runtime-core/src/componentOptions.ts @@ -178,9 +178,9 @@ export interface MethodOptions { } export type ExtractComputedReturns = { - [key in keyof T]: T[key] extends { get: Function } - ? ReturnType - : ReturnType + [key in keyof T]: T[key] extends { get: (...args: any[]) => infer TReturn } + ? TReturn + : T[key] extends (...args: any[]) => infer TReturn ? TReturn : never } type WatchOptionItem = diff --git a/packages/runtime-core/src/components/Suspense.ts b/packages/runtime-core/src/components/Suspense.ts index cf0e281a646..53a62014de3 100644 --- a/packages/runtime-core/src/components/Suspense.ts +++ b/packages/runtime-core/src/components/Suspense.ts @@ -244,7 +244,7 @@ function createSuspenseBoundary( /* istanbul ignore if */ if (__DEV__ && !__TEST__ && !hasWarned) { hasWarned = true - console[console.info ? 'info' : 'log']( + console[(console as any).info ? 'info' : 'log']( ` is an experimental feature and its API will likely change.` ) } diff --git a/packages/vue/src/devCheck.ts b/packages/vue/src/devCheck.ts index 10bd99ff448..bfaab1e29df 100644 --- a/packages/vue/src/devCheck.ts +++ b/packages/vue/src/devCheck.ts @@ -1,5 +1,5 @@ if (__BROWSER__ && __DEV__) { - console[console.info ? 'info' : 'log']( + console[(console as any).info ? 'info' : 'log']( `You are running a development build of Vue.\n` + `Make sure to use the production build (*.prod.js) when deploying for production.` ) diff --git a/yarn.lock b/yarn.lock index 3a1a6312be4..46695a72486 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7420,10 +7420,10 @@ typedarray@^0.0.6: resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c= -typescript@^3.8.3: - version "3.8.3" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.8.3.tgz#409eb8544ea0335711205869ec458ab109ee1061" - integrity sha512-MYlEfn5VrLNsgudQTVJeNaQFUAI7DkhnOjdpAp4T+ku1TfQClewlbSuTVHiA+8skNBgaf02TL/kLOvig4y3G8w== +typescript@^3.9.1-rc: + version "3.9.1-rc" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.1-rc.tgz#81d5a5a0a597e224b6e2af8dffb46524b2eaf5f3" + integrity sha512-+cPv8L2Vd4KidCotqi2wjegBZ5n47CDRUu/QiLVu2YbeXAz78hIfcai9ziBiNI6JTGTVwUqXRug2UZxDcxhvFw== typescript@~3.7.2: version "3.7.5" From 11cd53daaf5d9cc60997fde79c6a527e2a5dd996 Mon Sep 17 00:00:00 2001 From: pikax Date: Fri, 1 May 2020 14:22:56 +0100 Subject: [PATCH 14/23] types: fix defineComponent return type --- packages/runtime-core/src/apiDefineComponent.ts | 13 +++++++++---- packages/runtime-core/src/component.ts | 12 +++++++++++- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/packages/runtime-core/src/apiDefineComponent.ts b/packages/runtime-core/src/apiDefineComponent.ts index c235e30c388..d5cde0874fb 100644 --- a/packages/runtime-core/src/apiDefineComponent.ts +++ b/packages/runtime-core/src/apiDefineComponent.ts @@ -5,7 +5,12 @@ import { ComponentOptionsWithArrayProps, ComponentOptionsWithObjectProps } from './componentOptions' -import { SetupContext, RenderFunction, FunctionalComponent } from './component' +import { + SetupContext, + RenderFunction, + FunctionalComponent, + DefineComponent +} from './component' import { ComponentPublicInstance } from './componentProxy' import { ExtractPropTypes, ComponentPropsOptions } from './componentProps' import { EmitsOptions } from './componentEmits' @@ -59,7 +64,7 @@ export function defineComponent< E, VNodeProps & Props > -} & ComponentOptionsWithoutProps +} & DefineComponent //& ComponentOptionsWithoutProps // overload 3: object format with array props declaration // props inferred as { [key in PropNames]?: any } @@ -85,7 +90,7 @@ export function defineComponent< ): { // array props technically doesn't place any contraints on props in TSX new (): ComponentPublicInstance -} & ComponentOptionsWithArrayProps +} & DefineComponent //& ComponentOptionsWithArrayProps // overload 4: object format with object props declaration // see `ExtractPropTypes` in ./componentProps.ts @@ -119,7 +124,7 @@ export function defineComponent< E, VNodeProps & ExtractPropTypes > -} & ComponentOptionsWithObjectProps +} & DefineComponent //& ComponentOptionsBase // implementation, close to no-op export function defineComponent(options: unknown) { diff --git a/packages/runtime-core/src/component.ts b/packages/runtime-core/src/component.ts index 2136ae791c6..32d5a4da9ce 100644 --- a/packages/runtime-core/src/component.ts +++ b/packages/runtime-core/src/component.ts @@ -71,7 +71,17 @@ export interface ClassComponent { __vccOpts: ComponentOptions } -export type Component = ComponentOptions | FunctionalComponent +// Allow typescript deferenciate DefineComponent from other interfaces +declare const DefineComponentSymbol: unique symbol +export interface DefineComponent { + [DefineComponentSymbol]: true + [key: string]: any +} + +export type Component = + | ComponentOptions + | FunctionalComponent + | DefineComponent // A type used in public APIs where a component type is expected. // The constructor type is an artificial type returned by defineComponent(). From 42387b945313e70a4fc2f12c811fcf00e39162ce Mon Sep 17 00:00:00 2001 From: pikax Date: Mon, 4 May 2020 16:40:06 +0100 Subject: [PATCH 15/23] Revert "types: fix defineComponent return type" This reverts commit 11cd53daaf5d9cc60997fde79c6a527e2a5dd996. # Conflicts: # packages/runtime-core/src/apiDefineComponent.ts --- packages/runtime-core/src/apiDefineComponent.ts | 8 ++++---- packages/runtime-core/src/component.ts | 12 +----------- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/packages/runtime-core/src/apiDefineComponent.ts b/packages/runtime-core/src/apiDefineComponent.ts index e1402a82eb6..fb945bcb437 100644 --- a/packages/runtime-core/src/apiDefineComponent.ts +++ b/packages/runtime-core/src/apiDefineComponent.ts @@ -6,7 +6,7 @@ import { ComponentOptionsWithObjectProps, RenderFunction } from './componentOptions' -import { SetupContext, FunctionalComponent, DefineComponent } from './component' +import { SetupContext, FunctionalComponent } from './component' import { ComponentPublicInstance } from './componentProxy' import { ExtractPropTypes, ComponentPropsOptions } from './componentProps' import { EmitsOptions } from './componentEmits' @@ -60,7 +60,7 @@ export function defineComponent< E, VNodeProps & Props > -} & DefineComponent //& ComponentOptionsWithoutProps +} & ComponentOptionsWithoutProps // overload 3: object format with array props declaration // props inferred as { [key in PropNames]?: any } @@ -86,7 +86,7 @@ export function defineComponent< ): { // array props technically doesn't place any constraints on props in TSX new (): ComponentPublicInstance -} & DefineComponent //& ComponentOptionsWithArrayProps +} & ComponentOptionsWithArrayProps // overload 4: object format with object props declaration // see `ExtractPropTypes` in ./componentProps.ts @@ -120,7 +120,7 @@ export function defineComponent< E, VNodeProps & ExtractPropTypes > -} & DefineComponent //& ComponentOptionsBase +} & ComponentOptionsWithObjectProps // implementation, close to no-op export function defineComponent(options: unknown) { diff --git a/packages/runtime-core/src/component.ts b/packages/runtime-core/src/component.ts index a9c7ea4054c..a26837bc869 100644 --- a/packages/runtime-core/src/component.ts +++ b/packages/runtime-core/src/component.ts @@ -89,17 +89,7 @@ export interface ClassComponent { __vccOpts: ComponentOptions } -// Allow typescript deferenciate DefineComponent from other interfaces -declare const DefineComponentSymbol: unique symbol -export interface DefineComponent { - [DefineComponentSymbol]: true - [key: string]: any -} - -export type Component = - | ComponentOptions - | FunctionalComponent - | DefineComponent +export type Component = ComponentOptions | FunctionalComponent // A type used in public APIs where a component type is expected. // The constructor type is an artificial type returned by defineComponent(). From bf3e586950f052f1b532a985f5a9778373809411 Mon Sep 17 00:00:00 2001 From: pikax Date: Mon, 4 May 2020 16:51:06 +0100 Subject: [PATCH 16/23] types: apply @ktsn :tada: --- packages/runtime-core/src/componentOptions.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/runtime-core/src/componentOptions.ts b/packages/runtime-core/src/componentOptions.ts index 8bff6b0cdaa..a3f3df7cc3e 100644 --- a/packages/runtime-core/src/componentOptions.ts +++ b/packages/runtime-core/src/componentOptions.ts @@ -134,7 +134,7 @@ export interface ComponentOptionsBase< // type-only differentiator to separate OptionWithoutProps from a constructor // type returned by defineComponent() or FunctionalComponent - call?: never + call?: (this: unknown, ...args: unknown[]) => never // type-only differentiators for built-in Vnode types __isFragment?: never __isTeleport?: never From 6ae01d54bdc1ee61cc3fb980d2bf25ec8ecc06fc Mon Sep 17 00:00:00 2001 From: dolymood Date: Thu, 7 May 2020 16:06:42 +0800 Subject: [PATCH 17/23] fix(runtime-core): compatible with TS 3.9 --- .../runtime-core/__tests__/apiOptions.spec.ts | 19 ++++---- .../runtime-core/src/apiDefineComponent.ts | 14 +++--- packages/runtime-core/src/componentOptions.ts | 43 +++++++++---------- packages/runtime-core/src/componentProxy.ts | 42 +++++------------- 4 files changed, 46 insertions(+), 72 deletions(-) diff --git a/packages/runtime-core/__tests__/apiOptions.spec.ts b/packages/runtime-core/__tests__/apiOptions.spec.ts index eec46597777..0107848ec68 100644 --- a/packages/runtime-core/__tests__/apiOptions.spec.ts +++ b/packages/runtime-core/__tests__/apiOptions.spec.ts @@ -459,36 +459,33 @@ describe('api: options', () => { expect(this.b).toBe(2) expect(this.bP).toBeUndefined() expect(this.c).toBe(3) + expect(this.cP1).toBeUndefined() }, mounted() { calls.push('mixinB mounted') } } - const mixinC = { + const mixinC = defineComponent({ props: ['cP1', 'cP2'], data() { return { c: 3 } }, - created(this: any) { + created() { calls.push('mixinC created') - expect(this.a).toBe(1) - expect(this.b).toBe(2) - expect(this.bP).toBeUndefined() expect(this.c).toBe(3) expect(this.cP1).toBeUndefined() }, mounted() { calls.push('mixinC mounted') } - } + }) const Comp = defineComponent({ - mixins: [ - defineComponent(mixinA), - defineComponent(mixinB), - defineComponent(mixinC) - ], + props: { + aaa: String + }, + mixins: [defineComponent(mixinA), defineComponent(mixinB), mixinC], data() { return { z: 4 diff --git a/packages/runtime-core/src/apiDefineComponent.ts b/packages/runtime-core/src/apiDefineComponent.ts index d5e58318f7c..959b10bdf1b 100644 --- a/packages/runtime-core/src/apiDefineComponent.ts +++ b/packages/runtime-core/src/apiDefineComponent.ts @@ -4,7 +4,7 @@ import { ComponentOptionsWithoutProps, ComponentOptionsWithArrayProps, ComponentOptionsWithObjectProps, - IComponentOptions, + ComponentOptionsMixin, RenderFunction } from './componentOptions' import { SetupContext, FunctionalComponent } from './component' @@ -54,8 +54,8 @@ export function defineComponent< D = {}, C extends ComputedOptions = {}, M extends MethodOptions = {}, - Mixin extends IComponentOptions = {}, - Extends extends IComponentOptions = {}, + Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, + Extends extends ComponentOptionsMixin = ComponentOptionsMixin, E extends EmitsOptions = Record, EE extends string = string >( @@ -104,8 +104,8 @@ export function defineComponent< D, C extends ComputedOptions = {}, M extends MethodOptions = {}, - Mixin extends IComponentOptions = {}, - Extends extends IComponentOptions = {}, + Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, + Extends extends ComponentOptionsMixin = ComponentOptionsMixin, E extends EmitsOptions = Record, EE extends string = string >( @@ -156,8 +156,8 @@ export function defineComponent< D, C extends ComputedOptions = {}, M extends MethodOptions = {}, - Mixin extends IComponentOptions = {}, - Extends extends IComponentOptions = {}, + Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, + Extends extends ComponentOptionsMixin = ComponentOptionsMixin, E extends EmitsOptions = Record, EE extends string = string >( diff --git a/packages/runtime-core/src/componentOptions.ts b/packages/runtime-core/src/componentOptions.ts index 46a2fe66d47..a998aa032e9 100644 --- a/packages/runtime-core/src/componentOptions.ts +++ b/packages/runtime-core/src/componentOptions.ts @@ -81,8 +81,8 @@ export interface ComponentOptionsBase< D, C extends ComputedOptions, M extends MethodOptions, - Mixin extends IComponentOptions, - Extends extends IComponentOptions, + Mixin extends ComponentOptionsMixin, + Extends extends ComponentOptionsMixin, E extends EmitsOptions, EE extends string = string > @@ -152,8 +152,8 @@ export type ComponentOptionsWithoutProps< D = {}, C extends ComputedOptions = {}, M extends MethodOptions = {}, - Mixin extends IComponentOptions = IComponentOptions, - Extends extends IComponentOptions = IComponentOptions, + Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, + Extends extends ComponentOptionsMixin = ComponentOptionsMixin, E extends EmitsOptions = EmitsOptions, EE extends string = string > = ComponentOptionsBase & { @@ -178,8 +178,8 @@ export type ComponentOptionsWithArrayProps< D = {}, C extends ComputedOptions = {}, M extends MethodOptions = {}, - Mixin extends IComponentOptions = IComponentOptions, - Extends extends IComponentOptions = IComponentOptions, + Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, + Extends extends ComponentOptionsMixin = ComponentOptionsMixin, E extends EmitsOptions = EmitsOptions, EE extends string = string, Props = Readonly<{ [key in PropNames]?: any }> @@ -204,8 +204,8 @@ export type ComponentOptionsWithObjectProps< D = {}, C extends ComputedOptions = {}, M extends MethodOptions = {}, - Mixin extends IComponentOptions = IComponentOptions, - Extends extends IComponentOptions = IComponentOptions, + Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, + Extends extends ComponentOptionsMixin = ComponentOptionsMixin, E extends EmitsOptions = EmitsOptions, EE extends string = string, Props = Readonly> @@ -229,18 +229,17 @@ export type ComponentOptions = | ComponentOptionsWithObjectProps | ComponentOptionsWithArrayProps -// IComponentOptionsXXX is used to resolve circularly references -export interface IComponentOptionsWithoutProps - extends ComponentOptionsWithoutProps {} -export interface IComponentOptionsWithObjectProps - extends ComponentOptionsWithObjectProps {} -export interface IComponentOptionsWithArrayProps - extends ComponentOptionsWithArrayProps {} - -export type IComponentOptions = - | IComponentOptionsWithoutProps - | IComponentOptionsWithObjectProps - | IComponentOptionsWithArrayProps +export type ComponentOptionsMixin = ComponentOptionsBase< + any, + any, + any, + any, + any, + any, + any, + any, + any +> export type ComputedOptions = Record< string, @@ -278,8 +277,8 @@ export interface LegacyOptions< D, C extends ComputedOptions, M extends MethodOptions, - Mixin extends IComponentOptions, - Extends extends IComponentOptions + Mixin extends ComponentOptionsMixin, + Extends extends ComponentOptionsMixin > { // allow any custom options [key: string]: any diff --git a/packages/runtime-core/src/componentProxy.ts b/packages/runtime-core/src/componentProxy.ts index 50250d61e3d..01c31897546 100644 --- a/packages/runtime-core/src/componentProxy.ts +++ b/packages/runtime-core/src/componentProxy.ts @@ -14,10 +14,7 @@ import { ComponentOptionsBase, ComputedOptions, MethodOptions, - IComponentOptions, - IComponentOptionsWithoutProps, - IComponentOptionsWithArrayProps, - IComponentOptionsWithObjectProps, + ComponentOptionsMixin, OptionTypesType, OptionTypesKeys, resolveMergedOptions @@ -59,8 +56,8 @@ import { UnionToIntersection } from './helpers/typeUtils' */ export interface ComponentCustomProperties {} -type IsLegacyComponent = T extends IComponentOptions - ? IComponentOptions extends T ? true : false +type IsDefaultMixinComponent = T extends ComponentOptionsMixin + ? ComponentOptionsMixin extends T ? true : false : false type MixinToOptionTypes = T extends ComponentOptionsBase< @@ -78,30 +75,12 @@ type MixinToOptionTypes = T extends ComponentOptionsBase< IntersectionMixin : never -const enum OptionsPropsTypes { - WITHOUT = 'OptionsWithoutPropsType', - ARRAY = 'OptionsWithArrayPropsType', - OBJECT = 'OptionsWithObjectPropsType' -} - -// MixinMapToOptionTypes is used to resolve circularly references -type MixinMapToOptionTypes = { - [OptionsPropsTypes.ARRAY]: MixinToOptionTypes - [OptionsPropsTypes.OBJECT]: MixinToOptionTypes - [OptionsPropsTypes.WITHOUT]: MixinToOptionTypes -}[T extends IComponentOptionsWithArrayProps - ? OptionsPropsTypes.ARRAY - : T extends IComponentOptionsWithObjectProps - ? OptionsPropsTypes.OBJECT - : T extends IComponentOptionsWithoutProps - ? OptionsPropsTypes.WITHOUT - : never] +// ExtractMixin(map type) is used to resolve circularly references +type ExtractMixin = { + Mixin: MixinToOptionTypes +}[T extends ComponentOptionsMixin ? 'Mixin' : never] -type ExtractMixin = T extends IComponentOptions - ? MixinMapToOptionTypes - : never - -type IntersectionMixin = IsLegacyComponent extends true +type IntersectionMixin = IsDefaultMixinComponent extends true ? OptionTypesType<{}, {}, {}, {}, {}> : UnionToIntersection> @@ -118,8 +97,8 @@ export type CreateComponentPublicInstance< D = {}, C extends ComputedOptions = {}, M extends MethodOptions = {}, - Mixin extends IComponentOptions = IComponentOptions, - Extends extends IComponentOptions = IComponentOptions, + Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, + Extends extends ComponentOptionsMixin = ComponentOptionsMixin, E extends EmitsOptions = {}, PublicProps = P, PublicMixin = IntersectionMixin & IntersectionMixin, @@ -140,7 +119,6 @@ export type CreateComponentPublicInstance< PublicProps, ComponentOptionsBase > - // public properties exposed on the proxy, which is used as the render context // in templates (as `this` in the render option) export type ComponentPublicInstance< From ced460364b38a289d66977ebb07224aaeb8ffdd6 Mon Sep 17 00:00:00 2001 From: pikax Date: Fri, 8 May 2020 09:32:57 +0100 Subject: [PATCH 18/23] test: removed dts and use tsc --noEmit, added built types testing --- package.json | 3 +- packages/runtime-dom/types/jsx.d.ts | 1 + test-dts/componentTypeExtensions.test-d.ts | 5 +- test-dts/defineComponent.test-d.tsx | 31 +- test-dts/functionalComponent.test-d.tsx | 18 +- test-dts/h.test-d.ts | 34 +- test-dts/index.d.ts | 4 + test-dts/ref.test-d.ts | 3 +- test-dts/tsconfig.build.json | 10 + test-dts/tsconfig.json | 8 + test-dts/tsx.test-d.tsx | 18 +- test-dts/watch.test-d.ts | 3 +- yarn.lock | 417 +-------------------- 13 files changed, 116 insertions(+), 439 deletions(-) create mode 100644 test-dts/tsconfig.build.json create mode 100644 test-dts/tsconfig.json diff --git a/package.json b/package.json index 06f69dcb872..f4da43456cc 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "lint": "prettier --write --parser typescript \"packages/**/*.ts?(x)\"", "ls-lint": "ls-lint", "test": "node scripts/build.js vue -f global -d && jest", - "test-dts": "node scripts/build.js shared reactivity runtime-core runtime-dom -dt -f esm-bundler && tsd", + "test-dts": "node scripts/build.js shared reactivity runtime-core runtime-dom -dt -f esm-bundler && tsc -p ./test-dts/tsconfig.json && tsc -p ./test-dts/tsconfig.build.json", "release": "node scripts/release.js", "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s", "dev-compiler": "npm-run-all --parallel \"dev template-explorer\" serve", @@ -70,7 +70,6 @@ "semver": "^6.3.0", "serve": "^11.3.0", "ts-jest": "^25.2.1", - "tsd": "^0.11.0", "typescript": "^3.9.1-rc", "yorkie": "^2.0.0" } diff --git a/packages/runtime-dom/types/jsx.d.ts b/packages/runtime-dom/types/jsx.d.ts index 8e7ed1cd968..7b9d625cff7 100644 --- a/packages/runtime-dom/types/jsx.d.ts +++ b/packages/runtime-dom/types/jsx.d.ts @@ -1331,6 +1331,7 @@ declare global { } interface IntrinsicElements extends NativeElements { // allow arbitrary elements + // @ts-ignore supress ts:2374 = Duplicate string index signature. [name: string]: any } } diff --git a/test-dts/componentTypeExtensions.test-d.ts b/test-dts/componentTypeExtensions.test-d.ts index 5066f0b9717..1d543ac9168 100644 --- a/test-dts/componentTypeExtensions.test-d.ts +++ b/test-dts/componentTypeExtensions.test-d.ts @@ -1,5 +1,4 @@ -import { expectError, expectType } from 'tsd' -import { defineComponent } from './index' +import { defineComponent, expectError, expectType } from './index' declare module '@vue/runtime-core' { interface ComponentCustomOptions { @@ -20,9 +19,11 @@ export const Custom = defineComponent({ methods: { aMethod() { + // @ts-expect-error expectError(this.notExisting) this.counter++ this.state = 'running' + // @ts-expect-error expectError((this.state = 'not valid')) } } diff --git a/test-dts/defineComponent.test-d.tsx b/test-dts/defineComponent.test-d.tsx index 05023e1681e..7254bdd67b0 100644 --- a/test-dts/defineComponent.test-d.tsx +++ b/test-dts/defineComponent.test-d.tsx @@ -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(props.eee) expectType(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(props.eee) expectType(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(this.eee) expectType(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() - // wrong prop types + // @ts-expect-error wrong prop types expectError( ) + // @ts-expect-error expectError() }) @@ -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(props.a) expectType(props.b) @@ -222,6 +224,7 @@ describe('type inference w/ array props declaration', () => { render() { expectType(this.$props.a) expectType(this.$props.b) + // @ts-expect-error expectError((this.$props.a = 1)) expectType(this.a) expectType(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')) } }) diff --git a/test-dts/functionalComponent.test-d.tsx b/test-dts/functionalComponent.test-d.tsx index c95ae4a59ea..ea6e1b601b6 100644 --- a/test-dts/functionalComponent.test-d.tsx +++ b/test-dts/functionalComponent.test-d.tsx @@ -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() -// expectError() // tsd does not catch missing type errors +// @ts-expect-error +expectError() +// @ts-expect-error expectError() +// @ts-expect-error expectError() // Explicit signature with props + emits @@ -18,8 +20,11 @@ const Bar: FunctionalComponent< expectType(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() -// expectError() // tsd does not catch missing type errors +// @ts-expect-error +expectError() +// @ts-expect-error expectError() +// @ts-expect-error expectError() diff --git a/test-dts/h.test-d.ts b/test-dts/h.test-d.ts index 88b1a025247..7f7ec3c35ed 100644 --- a/test-dts/h.test-d.ts +++ b/test-dts/h.test-d.ts @@ -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 })) }) diff --git a/test-dts/index.d.ts b/test-dts/index.d.ts index 757dfb40791..be3143f4773 100644 --- a/test-dts/index.d.ts +++ b/test-dts/index.d.ts @@ -7,3 +7,7 @@ export * from '@vue/runtime-dom' export function describe(_name: string, _fn: () => void): void + +export function expectType(value: T): void +export function expectError(value: T): void +export function expectAssignable(value: T2): void diff --git a/test-dts/ref.test-d.ts b/test-dts/ref.test-d.ts index e2454e035c8..b08b1ca96cb 100644 --- a/test-dts/ref.test-d.ts +++ b/test-dts/ref.test-d.ts @@ -1,5 +1,4 @@ -import { expectType } from 'tsd' -import { Ref, ref, isRef, unref, reactive } from './index' +import { Ref, ref, isRef, unref, reactive, expectType } from './index' function plainType(arg: number | Ref) { // ref coercing diff --git a/test-dts/tsconfig.build.json b/test-dts/tsconfig.build.json new file mode 100644 index 00000000000..0ed6e46e00c --- /dev/null +++ b/test-dts/tsconfig.build.json @@ -0,0 +1,10 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "paths": { + "@vue/*": ["../packages/*/dist"], + "vue": ["../packages/vue/dist"] + } + }, + "exclude": ["../packages/*/__tests__", "../packages/*/src"] +} diff --git a/test-dts/tsconfig.json b/test-dts/tsconfig.json new file mode 100644 index 00000000000..01732c5e753 --- /dev/null +++ b/test-dts/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../tsconfig.json", + "compilerOptions": { + "noEmit": true, + "declaration": true + }, + "exclude": ["../packages/*/__tests__"] +} diff --git a/test-dts/tsx.test-d.tsx b/test-dts/tsx.test-d.tsx index c79c1fd42c7..51657636208 100644 --- a/test-dts/tsx.test-d.tsx +++ b/test-dts/tsx.test-d.tsx @@ -1,13 +1,18 @@ // TSX w/ defineComponent is tested in defineComponent.test-d.tsx - -import { expectError, expectType } from 'tsd' -import { KeepAlive, Suspense, Fragment, Teleport } from '@vue/runtime-dom' +import { + KeepAlive, + Suspense, + Fragment, + Teleport, + expectError, + expectType +} from './index' expectType(

) expectType(
) expectType() -// unknown prop +// @ts-expect-error unknown prop expectError(
) // allow key/ref on arbitrary element @@ -29,16 +34,21 @@ expectType() expectType() expectType() + +// @ts-expect-error expectError() +// @ts-expect-error expectError() // KeepAlive expectType() expectType() +// @ts-expect-error expectError() // Suspense expectType() expectType() expectType( {}} onRecede={() => {}} />) +// @ts-expect-error expectError() diff --git a/test-dts/watch.test-d.ts b/test-dts/watch.test-d.ts index c532bc2b7ea..84c6e542b5a 100644 --- a/test-dts/watch.test-d.ts +++ b/test-dts/watch.test-d.ts @@ -1,5 +1,4 @@ -import { ref, computed, watch } from './index' -import { expectType } from 'tsd' +import { ref, computed, watch, expectType } from './index' const source = ref('foo') const source2 = computed(() => source.value) diff --git a/yarn.lock b/yarn.lock index 8e4f445508a..a2994e55754 100644 --- a/yarn.lock +++ b/yarn.lock @@ -599,14 +599,6 @@ resolved "https://registry.yarnpkg.com/@microsoft/tsdoc/-/tsdoc-0.12.19.tgz#2173ccb92469aaf62031fa9499d21b16d07f9b57" integrity sha512-IpgPxHrNxZiMNUSXqR1l/gePKPkfAmIKoDRP9hp7OwjU29ZR8WCJsOJ8iBKgw0Qk+pFwR+8Y1cy8ImLY6e9m4A== -"@mrmlnc/readdir-enhanced@^2.2.1": - version "2.2.1" - resolved "https://registry.yarnpkg.com/@mrmlnc/readdir-enhanced/-/readdir-enhanced-2.2.1.tgz#524af240d1a360527b730475ecfa1344aa540dde" - integrity sha512-bPHp6Ji8b41szTOcaP63VlnbbO5Ny6dwAATtY6JTjh5N2OLrb5Qk/Th5cRkRQhkWCt+EJsYrNB0MiL+Gpn6e3g== - dependencies: - call-me-maybe "^1.0.1" - glob-to-regexp "^0.3.0" - "@nodelib/fs.scandir@2.1.1": version "2.1.1" resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.1.tgz#7fa8fed654939e1a39753d286b48b4836d00e0eb" @@ -620,11 +612,6 @@ resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-2.0.1.tgz#814f71b1167390cfcb6a6b3d9cdeb0951a192c14" integrity sha512-+RqhBlLn6YRBGOIoVYthsG0J9dfpO79eJyN7BYBkZJtfqrBwf2KK+rD/M/yjZR6WBmIhAgOV7S60eCgaSWtbFw== -"@nodelib/fs.stat@^1.1.2": - version "1.1.3" - resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-1.1.3.tgz#2b5a3ab3f918cca48a8c754c08168e3f03eba61b" - integrity sha512-shAmDyaQC4H92APFoIaVDHCx5bStIocgvbwQyxPRrbUY20V1EYTbSDchWbuwlMG3V17cprZhA6+78JfB+3DTPw== - "@nodelib/fs.walk@^1.2.1": version "1.2.2" resolved "https://registry.yarnpkg.com/@nodelib/fs.walk/-/fs.walk-1.2.2.tgz#6a6450c5e17012abd81450eb74949a4d970d2807" @@ -1037,11 +1024,6 @@ ansi-colors@^3.2.1: resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-3.2.4.tgz#e3a3da4bfbae6c86a9c285625de124a234026fbf" integrity sha512-hHUXGagefjN2iRrID63xckIvotOXOojhQKWIPUZ4mNUZ9nLZW+7FMNoE1lOkEhNWYsx/7ysGIuJYCiMAA9FnrA== -ansi-escapes@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-2.0.0.tgz#5bae52be424878dd9783e8910e3fc2922e83c81b" - integrity sha1-W65SvkJIeN2Xg+iRDj/Cki6DyBs= - ansi-escapes@^3.0.0: version "3.1.0" resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-3.1.0.tgz#f73207bb81207d75fd6c83f125af26eea378ca30" @@ -1162,23 +1144,11 @@ array-ify@^1.0.0: resolved "https://registry.yarnpkg.com/array-ify/-/array-ify-1.0.0.tgz#9e528762b4a9066ad163a6962a364418e9626ece" integrity sha1-nlKHYrSpBmrRY6aWKjZEGOlibs4= -array-union@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/array-union/-/array-union-1.0.2.tgz#9a34410e4f4e3da23dea375be5be70f24778ec39" - integrity sha1-mjRBDk9OPaI96jdb5b5w8kd47Dk= - dependencies: - array-uniq "^1.0.1" - array-union@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/array-union/-/array-union-2.1.0.tgz#b798420adbeb1de828d84acd8a2e23d3efe85e8d" integrity sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw== -array-uniq@^1.0.1: - version "1.0.3" - resolved "https://registry.yarnpkg.com/array-uniq/-/array-uniq-1.0.3.tgz#af6ac877a25cc7f74e058894753858dfdb24fdb6" - integrity sha1-r2rId6Jcx/dOBYiUdThY39sk/bY= - array-unique@^0.3.2: version "0.3.2" resolved "https://registry.yarnpkg.com/array-unique/-/array-unique-0.3.2.tgz#a894b75d4bc4f6cd679ef3244a9fd8f46ae2d428" @@ -1383,7 +1353,7 @@ bn.js@^4.0.0, bn.js@^4.1.0, bn.js@^4.1.1, bn.js@^4.4.0: resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.11.8.tgz#2cde09eb5ee341f484746bb0309b3253b1b1442f" integrity sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA== -boxen@1.3.0, boxen@^1.2.1: +boxen@1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/boxen/-/boxen-1.3.0.tgz#55c6c39a8ba58d9c61ad22cd877532deb665a20b" integrity sha512-TNPjfTr432qx7yOjQyaXm3dSR0MH9vXp7eT1BFSl/C51g+EFnOR9hTg1IreahGBmDNCehscshe45f+C1TBZbLw== @@ -1571,11 +1541,6 @@ cache-base@^1.0.1: union-value "^1.0.0" unset-value "^1.0.0" -call-me-maybe@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/call-me-maybe/-/call-me-maybe-1.0.1.tgz#26d208ea89e37b5cbde60250a15f031c16a4d66b" - integrity sha1-JtII6onje1y95gJQoV8DHBak1ms= - caller-callsite@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/caller-callsite/-/caller-callsite-2.0.0.tgz#847e0fce0a223750a9a027c54b33731ad3154134" @@ -1644,11 +1609,6 @@ capture-exit@^2.0.0: dependencies: rsvp "^4.8.4" -capture-stack-trace@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/capture-stack-trace/-/capture-stack-trace-1.0.1.tgz#a6c0bbe1f38f3aa0b92238ecb6ff42c344d4135d" - integrity sha512-mYQLZnx5Qt1JgB1WEiMCf2647plpGeQ2NMR/5L0HNZzGQo4fuSPnK+wjfPnKZV0aiJDgzmWqqkV/g7JD+DW0qw== - caseless@~0.12.0: version "0.12.0" resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc" @@ -1682,7 +1642,7 @@ chalk@^1.0.0, chalk@^1.1.3: strip-ansi "^3.0.0" supports-color "^2.0.0" -chalk@^2.0.0, chalk@^2.0.1, chalk@^2.1.0, chalk@^2.4.1, chalk@^2.4.2: +chalk@^2.0.0, chalk@^2.0.1, chalk@^2.4.1, chalk@^2.4.2: version "2.4.2" resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== @@ -1921,18 +1881,6 @@ concat-stream@1.6.2, concat-stream@^1.4.4: readable-stream "^2.2.2" typedarray "^0.0.6" -configstore@^3.0.0: - version "3.1.2" - resolved "https://registry.yarnpkg.com/configstore/-/configstore-3.1.2.tgz#c6f25defaeef26df12dd33414b001fe81a543f8f" - integrity sha512-vtv5HtGjcYUgFrXc6Kx747B83MRRVS5R1VTEQoXvuP+kMI+if6uywV0nDGoiydJRy4yk7h9od5Og0kxx4zUXmw== - dependencies: - dot-prop "^4.1.0" - graceful-fs "^4.1.2" - make-dir "^1.0.0" - unique-string "^1.0.0" - write-file-atomic "^2.0.0" - xdg-basedir "^3.0.0" - consolidate@^0.15.1: version "0.15.1" resolved "https://registry.yarnpkg.com/consolidate/-/consolidate-0.15.1.tgz#21ab043235c71a07d45d9aad98593b0dba56bab7" @@ -2159,13 +2107,6 @@ create-ecdh@^4.0.0: bn.js "^4.1.0" elliptic "^6.0.0" -create-error-class@^3.0.0: - version "3.0.2" - resolved "https://registry.yarnpkg.com/create-error-class/-/create-error-class-3.0.2.tgz#06be7abef947a3f14a30fd610671d401bca8b7b6" - integrity sha1-Br56vvlHo/FKMP1hBnHUAbyot7Y= - dependencies: - capture-stack-trace "^1.0.0" - create-hash@^1.1.0, create-hash@^1.1.2: version "1.2.0" resolved "https://registry.yarnpkg.com/create-hash/-/create-hash-1.2.0.tgz#889078af11a63756bcfb59bd221996be3a9ef196" @@ -2235,11 +2176,6 @@ crypto-browserify@^3.11.0: randombytes "^2.0.0" randomfill "^1.0.3" -crypto-random-string@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/crypto-random-string/-/crypto-random-string-1.0.0.tgz#a230f64f568310e1498009940790ec99545bca7e" - integrity sha1-ojD2T1aDEOFJgAmUB5DsmVRbyn4= - css-modules-loader-core@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/css-modules-loader-core/-/css-modules-loader-core-1.1.0.tgz#5908668294a1becd261ae0a4ce21b0b551f21d16" @@ -2459,13 +2395,6 @@ diffie-hellman@^5.0.0: miller-rabin "^4.0.0" randombytes "^2.0.0" -dir-glob@^2.2.2: - version "2.2.2" - resolved "https://registry.yarnpkg.com/dir-glob/-/dir-glob-2.2.2.tgz#fa09f0694153c8918b18ba0deafae94769fc50c4" - integrity sha512-f9LBi5QWzIW3I6e//uxZoLBlUt9kcp66qo0sSCxL6YZKc75R1c4MFCoe/LaZiBGmgujvQdxc5Bn3QhfyvK5Hsw== - dependencies: - path-type "^3.0.0" - dir-glob@^3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/dir-glob/-/dir-glob-3.0.1.tgz#56dbf73d992a4a93ba1584f4534063fd2e41717f" @@ -2492,18 +2421,6 @@ dot-prop@^3.0.0: dependencies: is-obj "^1.0.0" -dot-prop@^4.1.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/dot-prop/-/dot-prop-4.2.0.tgz#1f19e0c2e1aa0e32797c49799f2837ac6af69c57" - integrity sha512-tUMXrxlExSW6U2EXiiKGSBVdYgtV8qlHL+C10TsW4PURY/ic+eaysnSkwB4kA/mBlCyy/IKDJ+Lc3wbWeaXtuQ== - dependencies: - is-obj "^1.0.0" - -duplexer3@^0.1.4: - version "0.1.4" - resolved "https://registry.yarnpkg.com/duplexer3/-/duplexer3-0.1.4.tgz#ee01dd1cac0ed3cbc7fdbea37dc0a8f1ce002ce2" - integrity sha1-7gHdHKwO08vH/b6jfcCo8c4ALOI= - ecc-jsbn@~0.1.1: version "0.1.2" resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz#3a83a904e54353287874c564b7549386849a98c9" @@ -2611,17 +2528,6 @@ escodegen@^1.11.1: optionalDependencies: source-map "~0.6.1" -eslint-formatter-pretty@^1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/eslint-formatter-pretty/-/eslint-formatter-pretty-1.3.0.tgz#985d9e41c1f8475f4a090c5dbd2dfcf2821d607e" - integrity sha512-5DY64Y1rYCm7cfFDHEGUn54bvCnK+wSUVF07N8oXeqUJFSd+gnYOTXbzelQ1HurESluY6gnEQPmXOIkB4Wa+gA== - dependencies: - ansi-escapes "^2.0.0" - chalk "^2.1.0" - log-symbols "^2.0.0" - plur "^2.1.2" - string-width "^2.0.0" - esprima@^4.0.0, esprima@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71" @@ -2834,18 +2740,6 @@ fast-deep-equal@^3.1.1: resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.1.tgz#545145077c501491e33b15ec408c294376e94ae4" integrity sha512-8UEa58QDLauDNfpbrX55Q9jrGHThw2ZMdOky5Gl1CDtVeJDPVrG4Jxx1N8jw2gkWaff5UUuX1KJd+9zGe2B+ZA== -fast-glob@^2.2.6: - version "2.2.7" - resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-2.2.7.tgz#6953857c3afa475fff92ee6015d52da70a4cd39d" - integrity sha512-g1KuQwHOZAmOZMuBtHdxDtju+T2RT8jgCC9aANsbpdiDDTSnjgfuVsIBNKbUeJI3oKMRExcfNDtJl4OhbffMsw== - dependencies: - "@mrmlnc/readdir-enhanced" "^2.2.1" - "@nodelib/fs.stat" "^1.1.2" - glob-parent "^3.1.0" - is-glob "^4.0.0" - merge2 "^1.2.3" - micromatch "^3.1.10" - fast-glob@^3.0.3: version "3.0.4" resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.0.4.tgz#d484a41005cb6faeb399b951fd1bd70ddaebb602" @@ -2957,13 +2851,6 @@ find-up@^2.0.0: dependencies: locate-path "^2.0.0" -find-up@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/find-up/-/find-up-3.0.0.tgz#49169f1d7993430646da61ecc5ae355c21c97b73" - integrity sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg== - dependencies: - locate-path "^3.0.0" - find-up@^4.0.0, find-up@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/find-up/-/find-up-4.1.0.tgz#97afe7d6cdc0bc5928584b7c8d7b16e8a9aa5d19" @@ -3146,14 +3033,6 @@ gitconfiglocal@^1.0.0: dependencies: ini "^1.3.2" -glob-parent@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-3.1.0.tgz#9e6af6299d8d3bd2bd40430832bd113df906c5ae" - integrity sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4= - dependencies: - is-glob "^3.1.0" - path-dirname "^1.0.0" - glob-parent@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.0.0.tgz#1dc99f0f39b006d3e92c2c284068382f0c20e954" @@ -3161,11 +3040,6 @@ glob-parent@^5.0.0: dependencies: is-glob "^4.0.1" -glob-to-regexp@^0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/glob-to-regexp/-/glob-to-regexp-0.3.0.tgz#8c5a1494d2066c570cc3bfe4496175acc4d502ab" - integrity sha1-jFoUlNIGbFcMw7/kSWF1rMTVAqs= - glob@^7.1.1, glob@^7.1.2, glob@^7.1.3, glob@^7.1.4: version "7.1.6" resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.6.tgz#141f33b81a7c2492e125594307480c46679278a6" @@ -3178,13 +3052,6 @@ glob@^7.1.1, glob@^7.1.2, glob@^7.1.3, glob@^7.1.4: once "^1.3.0" path-is-absolute "^1.0.0" -global-dirs@^0.1.0: - version "0.1.1" - resolved "https://registry.yarnpkg.com/global-dirs/-/global-dirs-0.1.1.tgz#b319c0dd4607f353f3be9cca4c72fc148c49f445" - integrity sha1-sxnA3UYH81PzvpzKTHL8FIxJ9EU= - dependencies: - ini "^1.3.4" - globals@^11.1.0: version "11.12.0" resolved "https://registry.yarnpkg.com/globals/-/globals-11.12.0.tgz#ab8795338868a0babd8525758018c2a7eb95c42e" @@ -3204,38 +3071,7 @@ globby@^10.0.0: merge2 "^1.2.3" slash "^3.0.0" -globby@^9.1.0: - version "9.2.0" - resolved "https://registry.yarnpkg.com/globby/-/globby-9.2.0.tgz#fd029a706c703d29bdd170f4b6db3a3f7a7cb63d" - integrity sha512-ollPHROa5mcxDEkwg6bPt3QbEf4pDQSNtd6JPL1YvOvAo/7/0VAm9TccUeoTmarjPw4pfUthSCqcyfNB1I3ZSg== - dependencies: - "@types/glob" "^7.1.1" - array-union "^1.0.2" - dir-glob "^2.2.2" - fast-glob "^2.2.6" - glob "^7.1.3" - ignore "^4.0.3" - pify "^4.0.1" - slash "^2.0.0" - -got@^6.7.1: - version "6.7.1" - resolved "https://registry.yarnpkg.com/got/-/got-6.7.1.tgz#240cd05785a9a18e561dc1b44b41c763ef1e8db0" - integrity sha1-JAzQV4WpoY5WHcG0S0HHY+8ejbA= - dependencies: - create-error-class "^3.0.0" - duplexer3 "^0.1.4" - get-stream "^3.0.0" - is-redirect "^1.0.0" - is-retry-allowed "^1.0.0" - is-stream "^1.0.0" - lowercase-keys "^1.0.0" - safe-buffer "^5.0.1" - timed-out "^4.0.0" - unzip-response "^2.0.1" - url-parse-lax "^1.0.0" - -graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.6: +graceful-fs@^4.1.2, graceful-fs@^4.1.6: version "4.1.11" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658" integrity sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg= @@ -3437,11 +3273,6 @@ idb-wrapper@^1.5.0: resolved "https://registry.yarnpkg.com/idb-wrapper/-/idb-wrapper-1.7.2.tgz#8251afd5e77fe95568b1c16152eb44b396767ea2" integrity sha512-zfNREywMuf0NzDo9mVsL0yegjsirJxHpKHvWcyRozIqQy89g0a3U+oBPOCN4cc0oCiOuYgZHimzaW/R46G1Mpg== -ignore@^4.0.3: - version "4.0.6" - resolved "https://registry.yarnpkg.com/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc" - integrity sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg== - ignore@^5.1.1: version "5.1.4" resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.1.4.tgz#84b7b3dbe64552b6ef0eca99f6743dbec6d97adf" @@ -3455,11 +3286,6 @@ import-fresh@^2.0.0: caller-path "^2.0.0" resolve-from "^3.0.0" -import-lazy@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/import-lazy/-/import-lazy-2.1.0.tgz#05698e3d45c88e8d7e9d92cb0584e77f096f3e43" - integrity sha1-BWmOPUXIjo1+nZLLBYTnfwlvPkM= - import-local@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/import-local/-/import-local-3.0.2.tgz#a8cfd0431d1de4a2199703d003e3e62364fa6db6" @@ -3513,7 +3339,7 @@ inherits@^2.0.1, inherits@~2.0.1: resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== -ini@^1.3.2, ini@^1.3.4, ini@~1.3.0: +ini@^1.3.2, ini@~1.3.0: version "1.3.5" resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.5.tgz#eee25f56db1c9ec6085e0c22778083f596abf927" integrity sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw== @@ -3523,11 +3349,6 @@ ip-regex@^2.1.0: resolved "https://registry.yarnpkg.com/ip-regex/-/ip-regex-2.1.0.tgz#fa78bf5d2e6913c911ce9f819ee5146bb6d844e9" integrity sha1-+ni/XS5pE8kRzp+BnuUUa7bYROk= -irregular-plurals@^1.0.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/irregular-plurals/-/irregular-plurals-1.4.0.tgz#2ca9b033651111855412f16be5d77c62a458a766" - integrity sha1-LKmwM2UREYVUEvFr5dd8YqRYp2Y= - is-accessor-descriptor@^0.1.6: version "0.1.6" resolved "https://registry.yarnpkg.com/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz#a9e12cb3ae8d876727eeef3843f8a0897b5c98d6" @@ -3640,7 +3461,7 @@ is-extendable@^1.0.1: dependencies: is-plain-object "^2.0.4" -is-extglob@^2.1.0, is-extglob@^2.1.1: +is-extglob@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" integrity sha1-qIwCU1eR8C7TfHahueqXc8gz+MI= @@ -3674,20 +3495,6 @@ is-generator-fn@^2.0.0: resolved "https://registry.yarnpkg.com/is-generator-fn/-/is-generator-fn-2.1.0.tgz#7d140adc389aaf3011a8f2a2a4cfa6faadffb118" integrity sha512-cTIB4yPYL/Grw0EaSzASzg6bBy9gqCofvWN8okThAYIxKJZC+udlRAmGbM0XLeniEJSs8uEgHPGuHSe1XsOLSQ== -is-glob@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-3.1.0.tgz#7ba5ae24217804ac70707b96922567486cc3e84a" - integrity sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo= - dependencies: - is-extglob "^2.1.0" - -is-glob@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.0.tgz#9521c76845cc2610a85203ddf080a958c2ffabc0" - integrity sha1-lSHHaEXMJhCoUgPd8ICpWML/q8A= - dependencies: - is-extglob "^2.1.1" - is-glob@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.1.tgz#7567dbe9f2f5e2467bc77ab83c4a29482407a5dc" @@ -3695,24 +3502,11 @@ is-glob@^4.0.1: dependencies: is-extglob "^2.1.1" -is-installed-globally@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/is-installed-globally/-/is-installed-globally-0.1.0.tgz#0dfd98f5a9111716dd535dda6492f67bf3d25a80" - integrity sha1-Df2Y9akRFxbdU13aZJL2e/PSWoA= - dependencies: - global-dirs "^0.1.0" - is-path-inside "^1.0.0" - is-module@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-module/-/is-module-1.0.0.tgz#3258fb69f78c14d5b815d664336b4cffb6441591" integrity sha1-Mlj7afeMFNW4FdZkM2tM/7ZEFZE= -is-npm@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-npm/-/is-npm-1.0.0.tgz#f2fb63a65e4905b406c86072765a1a4dc793b9f4" - integrity sha1-8vtjpl5JBbQGyGBydloaTceTufQ= - is-number@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/is-number/-/is-number-3.0.0.tgz#24fd6201a4782cf50561c810276afc7d12d71195" @@ -3754,13 +3548,6 @@ is-path-in-cwd@^2.0.0: dependencies: is-path-inside "^2.1.0" -is-path-inside@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/is-path-inside/-/is-path-inside-1.0.1.tgz#8ef5b7de50437a3fdca6b4e865ef7aa55cb48036" - integrity sha1-jvW33lBDej/cprToZe96pVy0gDY= - dependencies: - path-is-inside "^1.0.1" - is-path-inside@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/is-path-inside/-/is-path-inside-2.1.0.tgz#7c9810587d659a40d27bcdb4d5616eab059494b2" @@ -3785,11 +3572,6 @@ is-promise@^2.0.0, is-promise@^2.1.0: resolved "https://registry.yarnpkg.com/is-promise/-/is-promise-2.1.0.tgz#79a2a9ece7f096e80f36d2b2f3bc16c1ff4bf3fa" integrity sha1-eaKp7OfwlugPNtKy87wWwf9L8/o= -is-redirect@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-redirect/-/is-redirect-1.0.0.tgz#1d03dded53bd8db0f30c26e4f95d36fc7c87dc24" - integrity sha1-HQPd7VO9jbDzDCbk+V02/HyH3CQ= - is-reference@^1.1.2: version "1.1.4" resolved "https://registry.yarnpkg.com/is-reference/-/is-reference-1.1.4.tgz#3f95849886ddb70256a3e6d062b1a68c13c51427" @@ -3816,12 +3598,7 @@ is-regexp@^1.0.0: resolved "https://registry.yarnpkg.com/is-regexp/-/is-regexp-1.0.0.tgz#fd2d883545c46bac5a633e7b9a09e87fa2cb5069" integrity sha1-/S2INUXEa6xaYz57mgnof6LLUGk= -is-retry-allowed@^1.0.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/is-retry-allowed/-/is-retry-allowed-1.2.0.tgz#d778488bd0a4666a3be8a1482b9f2baafedea8b4" - integrity sha512-RUbUeKwvm3XG2VYamhJL1xFktgjvPzL0Hq8C+6yrWIswDy3BIXGqCxhxkc30N9jqK311gVU137K8Ei55/zVJRg== - -is-stream@^1.0.0, is-stream@^1.1.0: +is-stream@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44" integrity sha1-EtSj3U5o4Lec6428hBc66A2RykQ= @@ -4496,13 +4273,6 @@ kleur@^3.0.3: resolved "https://registry.yarnpkg.com/kleur/-/kleur-3.0.3.tgz#a79c9ecc86ee1ce3fa6206d1216c501f147fc07e" integrity sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w== -latest-version@^3.0.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/latest-version/-/latest-version-3.1.0.tgz#a205383fea322b33b5ae3b18abee0dc2f356ee15" - integrity sha1-ogU4P+oyKzO1rjsYq+4NwvNW7hU= - dependencies: - package-json "^4.0.0" - lazy-cache@^1.0.3: version "1.0.4" resolved "https://registry.yarnpkg.com/lazy-cache/-/lazy-cache-1.0.4.tgz#a1d78fc3a50474cb80845d3b3b6e1da49a446e8e" @@ -4713,14 +4483,6 @@ locate-path@^2.0.0: p-locate "^2.0.0" path-exists "^3.0.0" -locate-path@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-3.0.0.tgz#dbec3b3ab759758071b58fe59fc41871af21400e" - integrity sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A== - dependencies: - p-locate "^3.0.0" - path-exists "^3.0.0" - locate-path@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-5.0.0.tgz#1afba396afd676a6d42504d0a67a3a7eb9f62aa0" @@ -4790,13 +4552,6 @@ log-symbols@^1.0.2: dependencies: chalk "^1.0.0" -log-symbols@^2.0.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-2.2.0.tgz#5740e1c5d6f0dfda4ad9323b5332107ef6b4c40a" - integrity sha512-VeIAFslyIerEJLXHziedo2basKbMKtTw3vfn5IzG0XTjhAVEJyNHnL2p7vc+wBDSdQuUpNw3M2u6xb9QsAY5Eg== - dependencies: - chalk "^2.0.1" - log-symbols@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-3.0.0.tgz#f3a08516a5dea893336a7dee14d18a1cfdab77c4" @@ -4833,11 +4588,6 @@ loud-rejection@^1.0.0: currently-unhandled "^0.4.1" signal-exit "^3.0.0" -lowercase-keys@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/lowercase-keys/-/lowercase-keys-1.0.1.tgz#6f9e30b47084d971a7c820ff15a6c5167b74c26f" - integrity sha512-G2Lj61tXDnVFFOi8VZds+SoQjtQC3dgokKdDG2mTm1tx4m50NUHBOZSBwQQHyy0V12A0JTG4icfZQH+xPyh8VA== - lru-cache@^4.0.1: version "4.1.3" resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.1.3.tgz#a1175cf3496dfc8436c156c334b4955992bce69c" @@ -4872,13 +4622,6 @@ magic-string@^0.25.2, magic-string@^0.25.5: dependencies: sourcemap-codec "^1.4.4" -make-dir@^1.0.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-1.3.0.tgz#79c1033b80515bd6d24ec9933e860ca75ee27f0c" - integrity sha512-2w31R7SJtieJJnQtGc7RVL2StM2vGYVfqUOvUDxH6bC6aJTxPxTF0GnIgCyu7tjockiUWAYQRbxa7vKn34s5sQ== - dependencies: - pify "^3.0.0" - make-dir@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-3.0.0.tgz#1b5f39f6b9270ed33f9f054c5c0f84304989f801" @@ -5017,7 +4760,7 @@ micromatch@4.x, micromatch@^4.0.2: braces "^3.0.1" picomatch "^2.0.5" -micromatch@^3.1.10, micromatch@^3.1.4: +micromatch@^3.1.4: version "3.1.10" resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-3.1.10.tgz#70859bc95c9840952f359a068a3fc49f9ecfac23" integrity sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg== @@ -5449,13 +5192,6 @@ p-limit@^1.1.0: dependencies: p-try "^1.0.0" -p-limit@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.0.0.tgz#e624ed54ee8c460a778b3c9f3670496ff8a57aec" - integrity sha512-fl5s52lI5ahKCernzzIyAP0QAZbGIovtVHGwpcu1Jr/EpzLVDI2myISHwGqK7m8uQFugVWSrbxH7XnhGtvEc+A== - dependencies: - p-try "^2.0.0" - p-limit@^2.2.0: version "2.2.1" resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.2.1.tgz#aa07a788cc3151c939b5131f63570f0dd2009537" @@ -5470,13 +5206,6 @@ p-locate@^2.0.0: dependencies: p-limit "^1.1.0" -p-locate@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-3.0.0.tgz#322d69a05c0264b25997d9f40cd8a891ab0064a4" - integrity sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ== - dependencies: - p-limit "^2.0.0" - p-locate@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-4.1.0.tgz#a3428bb7088b3a60292f66919278b7c297ad4f07" @@ -5499,16 +5228,6 @@ p-try@^2.0.0: resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.0.0.tgz#85080bb87c64688fa47996fe8f7dfbe8211760b1" integrity sha512-hMp0onDKIajHfIkdRk3P4CdCmErkYAxxDtP3Wx/4nZ3aGlau2VKh3mZpcuFkH27WQkL/3WBCPOktzA9ZOAnMQQ== -package-json@^4.0.0: - version "4.0.1" - resolved "https://registry.yarnpkg.com/package-json/-/package-json-4.0.1.tgz#8869a0401253661c4c4ca3da6c2121ed555f5eed" - integrity sha1-iGmgQBJTZhxMTKPabCEh7VVfXu0= - dependencies: - got "^6.7.1" - registry-auth-token "^3.0.1" - registry-url "^3.0.3" - semver "^5.1.0" - parse-asn1@^5.0.0: version "5.1.5" resolved "https://registry.yarnpkg.com/parse-asn1/-/parse-asn1-5.1.5.tgz#003271343da58dc94cace494faef3d2147ecea0e" @@ -5561,11 +5280,6 @@ pascalcase@^0.1.1: resolved "https://registry.yarnpkg.com/pascalcase/-/pascalcase-0.1.1.tgz#b363e55e8006ca6fe21784d2db22bd15d7917f14" integrity sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ= -path-dirname@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/path-dirname/-/path-dirname-1.0.2.tgz#cc33d24d525e099a5388c0336c6e32b9160609e0" - integrity sha1-zDPSTVJeCZpTiMAzbG4yuRYGCeA= - path-exists@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-2.1.0.tgz#0feb6c64f0fc518d9a754dd5efb62c7022761f4b" @@ -5588,7 +5302,7 @@ path-is-absolute@^1.0.0: resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18= -path-is-inside@1.0.2, path-is-inside@^1.0.1, path-is-inside@^1.0.2: +path-is-inside@1.0.2, path-is-inside@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/path-is-inside/-/path-is-inside-1.0.2.tgz#365417dede44430d1c11af61027facf074bdfc53" integrity sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM= @@ -5680,11 +5394,6 @@ pify@^3.0.0: resolved "https://registry.yarnpkg.com/pify/-/pify-3.0.0.tgz#e5a4acd2c101fdf3d9a4d07f0dbc4db49dd28176" integrity sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY= -pify@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/pify/-/pify-4.0.1.tgz#4b2cd25c50d598735c50292224fd8c6df41e3231" - integrity sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g== - pinkie-promise@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/pinkie-promise/-/pinkie-promise-2.0.1.tgz#2135d6dfa7a358c069ac9b178776288228450ffa" @@ -5718,13 +5427,6 @@ please-upgrade-node@^3.1.1: dependencies: semver-compare "^1.0.0" -plur@^2.1.2: - version "2.1.2" - resolved "https://registry.yarnpkg.com/plur/-/plur-2.1.2.tgz#7482452c1a0f508e3e344eaec312c91c29dc655a" - integrity sha1-dIJFLBoPUI4+NE6uwxLJHCncZVo= - dependencies: - irregular-plurals "^1.0.0" - pn@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/pn/-/pn-1.1.0.tgz#e2f4cef0e219f463c179ab37463e4e1ecdccbafb" @@ -5818,11 +5520,6 @@ prelude-ls@~1.1.2: resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" integrity sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ= -prepend-http@^1.0.1: - version "1.0.4" - resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-1.0.4.tgz#d4f4562b0ce3696e41ac52d0e002e57a635dc6dc" - integrity sha1-1PRWKwzjaW5BrFLQ4ALlemNdxtw= - prettier@~1.14.0: version "1.14.3" resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.14.3.tgz#90238dd4c0684b7edce5f83b0fb7328e48bd0895" @@ -6120,14 +5817,6 @@ read-pkg-up@^3.0.0: find-up "^2.0.0" read-pkg "^3.0.0" -read-pkg-up@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-4.0.0.tgz#1b221c6088ba7799601c808f91161c66e58f8978" - integrity sha512-6etQSH7nJGsK0RbG/2TeDzZFa8shjQ1um+SwQQ5cwKy0dhSXdOncEhb1CPpvQG4h7FyOV6EB6YlV0yJvZQNAkA== - dependencies: - find-up "^3.0.0" - read-pkg "^3.0.0" - read-pkg-up@^7.0.1: version "7.0.1" resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-7.0.1.tgz#f3a6135758459733ae2b95638056e1854e7ef507" @@ -6273,15 +5962,7 @@ registry-auth-token@3.3.2: rc "^1.1.6" safe-buffer "^5.0.1" -registry-auth-token@^3.0.1: - version "3.4.0" - resolved "https://registry.yarnpkg.com/registry-auth-token/-/registry-auth-token-3.4.0.tgz#d7446815433f5d5ed6431cd5dca21048f66b397e" - integrity sha512-4LM6Fw8eBQdwMYcES4yTnn2TqIasbXuwDx3um+QRs7S55aMKCBKBxvPXl2RiUjHwuJLTyYfxSpmfSAjQpcuP+A== - dependencies: - rc "^1.1.6" - safe-buffer "^5.0.1" - -registry-url@3.1.0, registry-url@^3.0.3: +registry-url@3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/registry-url/-/registry-url-3.1.0.tgz#3d4ef870f73dde1d77f0cf9a381432444e174942" integrity sha1-PU74cPc93h138M+aOBQyRE4XSUI= @@ -6593,14 +6274,7 @@ semver-compare@^1.0.0: resolved "https://registry.yarnpkg.com/semver-compare/-/semver-compare-1.0.0.tgz#0dee216a1c941ab37e9efb1788f6afc5ff5537fc" integrity sha1-De4hahyUGrN+nvsXiPavxf9VN/w= -semver-diff@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/semver-diff/-/semver-diff-2.1.0.tgz#4bbb8437c8d37e4b0cf1a68fd726ec6d645d6d36" - integrity sha1-S7uEN8jTfksM8aaP1ybsbWRdbTY= - dependencies: - semver "^5.0.3" - -"semver@2 || 3 || 4 || 5", semver@^5.0.3, semver@^5.1.0, semver@^5.4.1, semver@^5.5.0: +"semver@2 || 3 || 4 || 5", semver@^5.4.1, semver@^5.5.0: version "5.7.1" resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== @@ -6731,11 +6405,6 @@ sisteransi@^1.0.3: resolved "https://registry.yarnpkg.com/sisteransi/-/sisteransi-1.0.3.tgz#98168d62b79e3a5e758e27ae63c4a053d748f4eb" integrity sha512-SbEG75TzH8G7eVXFSN5f9EExILKfly7SUvVY5DhhYLvfhKqhDFY0OzevWa/zwak0RLRfWS5AvfMWpd9gJvr5Yg== -slash@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/slash/-/slash-2.0.0.tgz#de552851a1759df3a8f206535442f5ec4ddeab44" - integrity sha512-ZYKh3Wh2z1PpEXWr0MpSBZ0V6mZHAQfYevttO11c51CaWjGTaadiKZ+wVt1PbMlDV5qhMFslpZCemhwOK7C89A== - slash@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634" @@ -7214,11 +6883,6 @@ through@2, "through@>=2.2.7 <3": resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" integrity sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU= -timed-out@^4.0.0: - version "4.0.1" - resolved "https://registry.yarnpkg.com/timed-out/-/timed-out-4.0.1.tgz#f32eacac5a175bea25d7fab565ab3ed8741ef56f" - integrity sha1-8y6srFoXW+ol1/q1Zas+2HQe9W8= - timsort@~0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/timsort/-/timsort-0.3.0.tgz#405411a8e7e6339fe64db9a234de11dc31e02bd4" @@ -7342,18 +7006,6 @@ ts-jest@^25.2.1: semver "6.x" yargs-parser "18.x" -tsd@^0.11.0: - version "0.11.0" - resolved "https://registry.yarnpkg.com/tsd/-/tsd-0.11.0.tgz#ede8b8e85850845b753fff7eaaf68dbd3673700b" - integrity sha512-klKMNC0KRzUIaLJG8XqkvH/9rKwYX74xpqJBN8spWjYUDojAesd6AfDCT5dray+yhLfTGkem7O3nU6i4KwzNDw== - dependencies: - eslint-formatter-pretty "^1.3.0" - globby "^9.1.0" - meow "^5.0.0" - path-exists "^3.0.0" - read-pkg-up "^4.0.0" - update-notifier "^2.5.0" - tslib@1.11.1: version "1.11.1" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.11.1.tgz#eb15d128827fbee2841549e171f45ed338ac7e35" @@ -7491,13 +7143,6 @@ uniq@^1.0.1: resolved "https://registry.yarnpkg.com/uniq/-/uniq-1.0.1.tgz#b31c5ae8254844a3a8281541ce2b04b865a734ff" integrity sha1-sxxa6CVIRKOoKBVBzisEuGWnNP8= -unique-string@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/unique-string/-/unique-string-1.0.0.tgz#9e1057cca851abb93398f8b33ae187b99caec11a" - integrity sha1-nhBXzKhRq7kzmPizOuGHuZyuwRo= - dependencies: - crypto-random-string "^1.0.0" - universalify@^0.1.0: version "0.1.2" resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66" @@ -7511,11 +7156,6 @@ unset-value@^1.0.0: has-value "^0.3.1" isobject "^3.0.0" -unzip-response@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/unzip-response/-/unzip-response-2.0.1.tgz#d2f0f737d16b0615e72a6935ed04214572d56f97" - integrity sha1-0vD3N9FrBhXnKmk17QQhRXLVb5c= - update-check@1.5.2: version "1.5.2" resolved "https://registry.yarnpkg.com/update-check/-/update-check-1.5.2.tgz#2fe09f725c543440b3d7dabe8971f2d5caaedc28" @@ -7524,22 +7164,6 @@ update-check@1.5.2: registry-auth-token "3.3.2" registry-url "3.1.0" -update-notifier@^2.5.0: - version "2.5.0" - resolved "https://registry.yarnpkg.com/update-notifier/-/update-notifier-2.5.0.tgz#d0744593e13f161e406acb1d9408b72cad08aff6" - integrity sha512-gwMdhgJHGuj/+wHJJs9e6PcCszpxR1b236igrOkUofGhqJuG+amlIKwApH1IW1WWl7ovZxsX49lMBWLxSdm5Dw== - dependencies: - boxen "^1.2.1" - chalk "^2.0.1" - configstore "^3.0.0" - import-lazy "^2.1.0" - is-ci "^1.0.10" - is-installed-globally "^0.1.0" - is-npm "^1.0.0" - latest-version "^3.0.0" - semver-diff "^2.0.0" - xdg-basedir "^3.0.0" - uri-js@^4.2.2: version "4.2.2" resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.2.2.tgz#94c540e1ff772956e2299507c010aea6c8838eb0" @@ -7552,13 +7176,6 @@ urix@^0.1.0: resolved "https://registry.yarnpkg.com/urix/-/urix-0.1.0.tgz#da937f7a62e21fec1fd18d49b35c2935067a6c72" integrity sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI= -url-parse-lax@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/url-parse-lax/-/url-parse-lax-1.0.0.tgz#7af8f303645e9bd79a272e7a14ac68bc0609da73" - integrity sha1-evjzA2Rem9eaJy56FKxovAYJ2nM= - dependencies: - prepend-http "^1.0.1" - use@^3.1.0: version "3.1.1" resolved "https://registry.yarnpkg.com/use/-/use-3.1.1.tgz#d50c8cac79a19fbc20f2911f56eb973f4e10070f" @@ -7759,15 +7376,6 @@ wrappy@1: resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= -write-file-atomic@^2.0.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/write-file-atomic/-/write-file-atomic-2.3.0.tgz#1ff61575c2e2a4e8e510d6fa4e243cce183999ab" - integrity sha512-xuPeK4OdjWqtfi59ylvVL0Yn35SF3zgcAcv7rBPFHVaEapaDr4GdGgm3j7ckTwH9wHL7fGmgfAnb0+THrHb8tA== - dependencies: - graceful-fs "^4.1.11" - imurmurhash "^0.1.4" - signal-exit "^3.0.2" - write-file-atomic@^3.0.0: version "3.0.3" resolved "https://registry.yarnpkg.com/write-file-atomic/-/write-file-atomic-3.0.3.tgz#56bd5c5a5c70481cd19c571bd39ab965a5de56e8" @@ -7790,11 +7398,6 @@ ws@^7.0.0: resolved "https://registry.yarnpkg.com/ws/-/ws-7.2.3.tgz#a5411e1fb04d5ed0efee76d26d5c46d830c39b46" integrity sha512-HTDl9G9hbkNDk98naoR/cHDws7+EyYMOdL1BmjsZXRUjf7d+MficC4B7HLUPlSiho0vg+CWKrGIt/VJBd1xunQ== -xdg-basedir@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/xdg-basedir/-/xdg-basedir-3.0.0.tgz#496b2cc109eca8dbacfe2dc72b603c17c5870ad4" - integrity sha1-SWsswQnsqNus/i3HK2A8F8WHCtQ= - xml-name-validator@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/xml-name-validator/-/xml-name-validator-3.0.0.tgz#6ae73e06de4d8c6e47f9fb181f78d648ad457c6a" From 6e47393dc08744640652d18b5f9ba491f4483297 Mon Sep 17 00:00:00 2001 From: dolymood Date: Fri, 8 May 2020 18:31:41 +0800 Subject: [PATCH 19/23] fix(test-dts): add ts-expect-error --- test-dts/defineComponent.test-d.tsx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test-dts/defineComponent.test-d.tsx b/test-dts/defineComponent.test-d.tsx index 9e80868463e..20ffaa93a09 100644 --- a/test-dts/defineComponent.test-d.tsx +++ b/test-dts/defineComponent.test-d.tsx @@ -241,6 +241,7 @@ describe('type inference w/ array props declaration', () => { } }) expectType() + // @ts-expect-error expectError() }) @@ -389,13 +390,17 @@ describe('with mixins', () => { expectType(this.dC2) // props should be readonly + // @ts-expect-error expectError((this.aP1 = 'new')) + // @ts-expect-error expectError((this.z = 1)) // props on `this` should be readonly + // @ts-expect-error expectError((this.bP1 = 1)) // string value can not assigned to number type value + // @ts-expect-error expectError((this.c = '1')) // setup context properties should be mutable @@ -411,10 +416,13 @@ describe('with mixins', () => { ) // missing required props + // @ts-expect-error expectError() // wrong prop types + // @ts-expect-error expectError() + // @ts-expect-error expectError() }) @@ -473,10 +481,13 @@ describe('with extends', () => { expectType() // missing required props + // @ts-expect-error expectError() // wrong prop types + // @ts-expect-error expectError() + // @ts-expect-error expectError() }) @@ -556,10 +567,13 @@ describe('extends with mixins', () => { expectType() // missing required props + // @ts-expect-error expectError() // wrong prop types + // @ts-expect-error expectError() + // @ts-expect-error expectError() }) From acebedf9cfcf728665a8e44bbf1b584b5711757e Mon Sep 17 00:00:00 2001 From: pikax Date: Fri, 8 May 2020 10:18:34 +0100 Subject: [PATCH 20/23] chore: add readme --- test-dts/README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 test-dts/README.md diff --git a/test-dts/README.md b/test-dts/README.md new file mode 100644 index 00000000000..c9a4338072f --- /dev/null +++ b/test-dts/README.md @@ -0,0 +1,13 @@ +# Test-ts + +Tests Typescript types to ensure the types remain as expected. + +## Configuration + +### tsconfig.json + +Config used to test against the package source + +### tsconfig.json + +Replaces the `vue` and `@vue/*` dependencies with the built Typescript to ensure the published types are correct. From 3aa35b847ed6c6f34567145ec8d7b87ed6dde5d8 Mon Sep 17 00:00:00 2001 From: pikax Date: Wed, 13 May 2020 08:21:51 +0100 Subject: [PATCH 21/23] chore: update typescript to 3.9.2 --- package.json | 2 +- test-dts/defineComponent.test-d.tsx | 2 +- yarn.lock | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index f4da43456cc..c1095e9e96f 100644 --- a/package.json +++ b/package.json @@ -70,7 +70,7 @@ "semver": "^6.3.0", "serve": "^11.3.0", "ts-jest": "^25.2.1", - "typescript": "^3.9.1-rc", + "typescript": "^3.9.2", "yorkie": "^2.0.0" } } diff --git a/test-dts/defineComponent.test-d.tsx b/test-dts/defineComponent.test-d.tsx index 7254bdd67b0..542634e0f4a 100644 --- a/test-dts/defineComponent.test-d.tsx +++ b/test-dts/defineComponent.test-d.tsx @@ -171,8 +171,8 @@ describe('with object props', () => { // @ts-expect-error missing required props expectError() - // @ts-expect-error wrong prop types expectError( + // @ts-expect-error wrong prop types ) // @ts-expect-error diff --git a/yarn.lock b/yarn.lock index 563f4d45e54..6b41c53d867 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7163,10 +7163,10 @@ typedarray@^0.0.6: resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c= -typescript@^3.9.1-rc: - version "3.9.1-rc" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.1-rc.tgz#81d5a5a0a597e224b6e2af8dffb46524b2eaf5f3" - integrity sha512-+cPv8L2Vd4KidCotqi2wjegBZ5n47CDRUu/QiLVu2YbeXAz78hIfcai9ziBiNI6JTGTVwUqXRug2UZxDcxhvFw== +typescript@^3.9.2: + version "3.9.2" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.2.tgz#64e9c8e9be6ea583c54607677dd4680a1cf35db9" + integrity sha512-q2ktq4n/uLuNNShyayit+DTobV2ApPEo/6so68JaD5ojvc/6GClBipedB9zNWYxRSAlZXAe405Rlijzl6qDiSw== typescript@~3.7.2: version "3.7.5" From ac4ec0a45db5c5834c6842eaa4998a882ee5539b Mon Sep 17 00:00:00 2001 From: pikax Date: Wed, 13 May 2020 17:30:07 +0100 Subject: [PATCH 22/23] chore: using @ts-ignore instead of `as any` on console.info --- packages/runtime-core/src/components/Suspense.ts | 3 ++- packages/vue/src/devCheck.ts | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/runtime-core/src/components/Suspense.ts b/packages/runtime-core/src/components/Suspense.ts index 1cd656c3498..c0467acc117 100644 --- a/packages/runtime-core/src/components/Suspense.ts +++ b/packages/runtime-core/src/components/Suspense.ts @@ -244,7 +244,8 @@ function createSuspenseBoundary( /* istanbul ignore if */ if (__DEV__ && !__TEST__ && !hasWarned) { hasWarned = true - console[(console as any).info ? 'info' : 'log']( + // @ts-ignore `console.info` cannot be null error + console[console.info ? 'info' : 'log']( ` is an experimental feature and its API will likely change.` ) } diff --git a/packages/vue/src/devCheck.ts b/packages/vue/src/devCheck.ts index bfaab1e29df..07aaab4a58d 100644 --- a/packages/vue/src/devCheck.ts +++ b/packages/vue/src/devCheck.ts @@ -1,5 +1,6 @@ if (__BROWSER__ && __DEV__) { - console[(console as any).info ? 'info' : 'log']( + // @ts-ignore `console.info` cannot be null error + console[console.info ? 'info' : 'log']( `You are running a development build of Vue.\n` + `Make sure to use the production build (*.prod.js) when deploying for production.` ) From 526c9fd7947e7d478efea0ee56d9c133bfab9ddc Mon Sep 17 00:00:00 2001 From: pikax Date: Wed, 20 May 2020 09:48:43 +0100 Subject: [PATCH 23/23] build(deps): bump typescript 3.9.3 --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 554ca13b08d..25f6c2f17cf 100644 --- a/package.json +++ b/package.json @@ -70,7 +70,7 @@ "semver": "^6.3.0", "serve": "^11.3.0", "ts-jest": "^25.2.1", - "typescript": "^3.9.2", + "typescript": "^3.9.3", "yorkie": "^2.0.0" } } diff --git a/yarn.lock b/yarn.lock index 559e60c3847..7e922b42863 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7153,10 +7153,10 @@ typedarray@^0.0.6: resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c= -typescript@^3.9.2: - version "3.9.2" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.2.tgz#64e9c8e9be6ea583c54607677dd4680a1cf35db9" - integrity sha512-q2ktq4n/uLuNNShyayit+DTobV2ApPEo/6so68JaD5ojvc/6GClBipedB9zNWYxRSAlZXAe405Rlijzl6qDiSw== +typescript@^3.9.3: + version "3.9.3" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.3.tgz#d3ac8883a97c26139e42df5e93eeece33d610b8a" + integrity sha512-D/wqnB2xzNFIcoBG9FG8cXRDjiqSTbG2wd8DMZeQyJlP1vfTkIxH4GKveWaEBYySKIg+USu+E+EDIR47SqnaMQ== typescript@~3.7.2: version "3.7.5"