Skip to content

Commit

Permalink
types: fix tsx dts tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Feb 16, 2020
1 parent 57ee5df commit 77103e1
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"size": "node scripts/build.js vue runtime-dom size-check -p -f global",
"lint": "prettier --write --parser typescript \"packages/**/*.ts?(x)\"",
"test": "node scripts/build.js vue -f global -d && jest",
"test-dts": "node scripts/build.js reactivity runtime-core runtime-dom -t -f esm && tsd",
"test-dts": "node scripts/build.js reactivity runtime-core runtime-dom -dt -f esm-bundler && tsd",
"release": "node scripts/release.js",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
"dev-compiler": "npm-run-all --parallel \"dev template-explorer\" serve",
Expand Down
4 changes: 2 additions & 2 deletions packages/runtime-core/src/components/KeepAlive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
LifecycleHooks,
currentInstance
} from '../component'
import { VNode, cloneVNode, isVNode } from '../vnode'
import { VNode, cloneVNode, isVNode, VNodeProps } from '../vnode'
import { warn } from '../warning'
import { onBeforeUnmount, injectHook, onUnmounted } from '../apiLifecycle'
import { isString, isArray, ShapeFlags } from '@vue/shared'
Expand Down Expand Up @@ -218,7 +218,7 @@ const KeepAliveImpl = {
// also to avoid inline import() in generated d.ts files
export const KeepAlive = (KeepAliveImpl as any) as {
new (): {
$props: KeepAliveProps
$props: VNodeProps & KeepAliveProps
}
}

Expand Down
4 changes: 2 additions & 2 deletions packages/runtime-core/src/components/Portal.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ComponentInternalInstance } from '../component'
import { SuspenseBoundary } from './Suspense'
import { RendererInternals, MoveType } from '../renderer'
import { VNode, VNodeArrayChildren } from '../vnode'
import { VNode, VNodeArrayChildren, VNodeProps } from '../vnode'
import { isString, ShapeFlags, PatchFlags } from '@vue/shared'
import { warn } from '../warning'

Expand Down Expand Up @@ -114,5 +114,5 @@ export const PortalImpl = {
// Force-casted public typing for h and TSX props inference
export const Portal = (PortalImpl as any) as {
__isPortal: true
new (): { $props: PortalProps }
new (): { $props: VNodeProps & PortalProps }
}
4 changes: 2 additions & 2 deletions packages/runtime-core/src/components/Suspense.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { VNode, normalizeVNode, VNodeChild } from '../vnode'
import { VNode, normalizeVNode, VNodeChild, VNodeProps } from '../vnode'
import { isFunction, isArray, ShapeFlags } from '@vue/shared'
import { ComponentInternalInstance, handleSetupResult } from '../component'
import { Slots } from '../componentSlots'
Expand Down Expand Up @@ -67,7 +67,7 @@ export const Suspense = ((__FEATURE_SUSPENSE__
? SuspenseImpl
: null) as any) as {
__isSuspense: true
new (): { $props: SuspenseProps }
new (): { $props: VNodeProps & SuspenseProps }
}

function mountSuspense(
Expand Down
5 changes: 1 addition & 4 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,7 @@ function createConfig(format, output, plugins = []) {
output.name = packageOptions.name
}

const shouldEmitDeclarations =
process.env.TYPES != null &&
process.env.NODE_ENV === 'production' &&
!hasTSChecked
const shouldEmitDeclarations = process.env.TYPES != null && !hasTSChecked

const tsPlugin = ts({
check: process.env.NODE_ENV === 'production' && !hasTSChecked,
Expand Down
5 changes: 4 additions & 1 deletion test-dts/tsx.test-d.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,17 @@ expectType<JSX.Element>(<Fragment />)
expectType<JSX.Element>(<Fragment key="1" />)

expectType<JSX.Element>(<Portal target="#foo" />)
// target is required
expectType<JSX.Element>(<Portal target="#foo" key="1" />)
expectError(<Portal />)
expectError(<Portal target={1} />)

// KeepAlive
expectType<JSX.Element>(<KeepAlive include="foo" exclude={['a']} />)
expectType<JSX.Element>(<KeepAlive key="1" />)
expectError(<KeepAlive include={123} />)

// Suspense
expectType<JSX.Element>(<Suspense />)
expectType<JSX.Element>(<Suspense key="1" />)
expectType<JSX.Element>(<Suspense onResolve={() => {}} onRecede={() => {}} />)
expectError(<Suspense onResolve={123} />)

0 comments on commit 77103e1

Please sign in to comment.