diff --git a/package.json b/package.json index b288edf82..045f1c174 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "rollup-plugin-terser": "^5.1.1", "rollup-plugin-typescript2": "^0.24.0", "ts-jest": "^24.0.2", - "tsd": "^0.10.0", + "tsd": "^0.11.0", "typescript": "^3.7.0", "yorkie": "^2.0.0" } diff --git a/packages/runtime-core/src/components/Transition.ts b/packages/runtime-core/src/components/Transition.ts index 34d9e5f19..1d4d3febf 100644 --- a/packages/runtime-core/src/components/Transition.ts +++ b/packages/runtime-core/src/components/Transition.ts @@ -168,6 +168,8 @@ export interface TransitionHooks { delayLeave?(performLeave: () => void): void } +// The transition hooks are attached to the vnode as vnode.transition +// and will be called at appropriate timing in the renderer. function resolveTransitionHooks( { appear, diff --git a/packages/runtime-dom/src/components/CSSTransition.ts b/packages/runtime-dom/src/components/CSSTransition.ts index 09862ec4b..c3a858f82 100644 --- a/packages/runtime-dom/src/components/CSSTransition.ts +++ b/packages/runtime-dom/src/components/CSSTransition.ts @@ -2,8 +2,8 @@ import { Transition as BaseTransition, TransitionProps, h, - SetupContext, - warn + warn, + FunctionalComponent } from '@vue/runtime-core' import { isObject } from '@vue/shared' @@ -14,19 +14,22 @@ export interface CSSTransitionProps extends TransitionProps { name?: string type?: typeof TRANSITION | typeof ANIMATION duration?: number | { enter: number; leave: number } - + // custom transition classes enterFromClass?: string enterActiveClass?: string enterToClass?: string leaveFromClass?: string leaveActiveClass?: string leaveToClass?: string + // if present, indicates this is a v-show transition by toggling the + // CSS display property instead of actually removing the element. + show?: boolean } -export const CSSTransition = ( +export const CSSTransition: FunctionalComponent = ( props: CSSTransitionProps, - { slots }: SetupContext -) => h(BaseTransition, resolveCSSTransitionData(props), slots) + { slots } +) => h(BaseTransition, resolveCSSTransitionProps(props), slots) if (__DEV__) { CSSTransition.props = { @@ -43,7 +46,7 @@ if (__DEV__) { } } -function resolveCSSTransitionData({ +function resolveCSSTransitionProps({ name = 'v', type, duration, @@ -176,7 +179,10 @@ function whenTransitionEnds( cb: () => void ) { const { type, timeout, propCount } = getTransitionInfo(el, expectedType) - if (!type) return cb() + if (!type) { + return cb() + } + const endEvent = type + 'end' let ended = 0 const end = () => { diff --git a/packages/runtime-dom/src/index.ts b/packages/runtime-dom/src/index.ts index f093ac505..ea736067f 100644 --- a/packages/runtime-dom/src/index.ts +++ b/packages/runtime-dom/src/index.ts @@ -71,8 +71,3 @@ export { CSSTransition } from './components/CSSTransition' // re-export everything from core // h, Component, reactivity API, nextTick, flags & types export * from '@vue/runtime-core' - -// Type augmentations -export interface ComponentPublicInstance { - $el: Element -} diff --git a/test-dts/createComponent.test-d.tsx b/test-dts/createComponent.test-d.tsx index ce15c7042..aba58c718 100644 --- a/test-dts/createComponent.test-d.tsx +++ b/test-dts/createComponent.test-d.tsx @@ -1,6 +1,5 @@ -import { describe } from './util' import { expectError, expectType } from 'tsd' -import { createComponent, PropType, ref } from './index' +import { describe, createComponent, PropType, ref } from './index' describe('with object props', () => { interface ExpectedProps { diff --git a/test-dts/h.test-d.ts b/test-dts/h.test-d.ts index a017dafc6..7998a6c55 100644 --- a/test-dts/h.test-d.ts +++ b/test-dts/h.test-d.ts @@ -1,6 +1,13 @@ -import { describe } from './util' import { expectError } from 'tsd' -import { h, createComponent, ref, Fragment, Portal, Suspense } from './index' +import { + describe, + h, + createComponent, + ref, + Fragment, + Portal, + Suspense +} from './index' describe('h inference w/ element', () => { // key diff --git a/test-dts/index.d.ts b/test-dts/index.d.ts index f61c077a5..757dfb407 100644 --- a/test-dts/index.d.ts +++ b/test-dts/index.d.ts @@ -5,3 +5,5 @@ // that would suppress the errors that should be caught. export * from '@vue/runtime-dom' + +export function describe(_name: string, _fn: () => void): void diff --git a/test-dts/util.ts b/test-dts/util.ts deleted file mode 100644 index 774538247..000000000 --- a/test-dts/util.ts +++ /dev/null @@ -1,4 +0,0 @@ -// aesthetic utility for making test-d.ts look more like actual tests -// and makes it easier to navigate test cases with folding -// it's a noop since test-d.ts files are not actually run. -export function describe(_name: string, _fn: () => void) {} diff --git a/yarn.lock b/yarn.lock index 85677f78d..420060714 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7203,13 +7203,12 @@ ts-jest@^24.0.2: semver "^5.5" yargs-parser "10.x" -tsd@^0.10.0: - version "0.10.0" - resolved "https://registry.yarnpkg.com/tsd/-/tsd-0.10.0.tgz#092e5dbfdccaab89fd31e75a43a2e67411bcfff9" - integrity sha512-Gj/GoGBoskUJHZnja8V936sMAs3daHjZDQCqYQWMWEm4kNZLzYHvAAdV+apeg3mjsxMmvt8FByOM1AnYDdo+6g== +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" - execa "^2.0.4" globby "^9.1.0" meow "^5.0.0" path-exists "^3.0.0"