Skip to content

Commit 77103e1

Browse files
committed
types: fix tsx dts tests
1 parent 57ee5df commit 77103e1

File tree

6 files changed

+12
-12
lines changed

6 files changed

+12
-12
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"size": "node scripts/build.js vue runtime-dom size-check -p -f global",
1111
"lint": "prettier --write --parser typescript \"packages/**/*.ts?(x)\"",
1212
"test": "node scripts/build.js vue -f global -d && jest",
13-
"test-dts": "node scripts/build.js reactivity runtime-core runtime-dom -t -f esm && tsd",
13+
"test-dts": "node scripts/build.js reactivity runtime-core runtime-dom -dt -f esm-bundler && tsd",
1414
"release": "node scripts/release.js",
1515
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
1616
"dev-compiler": "npm-run-all --parallel \"dev template-explorer\" serve",

packages/runtime-core/src/components/KeepAlive.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
LifecycleHooks,
88
currentInstance
99
} from '../component'
10-
import { VNode, cloneVNode, isVNode } from '../vnode'
10+
import { VNode, cloneVNode, isVNode, VNodeProps } from '../vnode'
1111
import { warn } from '../warning'
1212
import { onBeforeUnmount, injectHook, onUnmounted } from '../apiLifecycle'
1313
import { isString, isArray, ShapeFlags } from '@vue/shared'
@@ -218,7 +218,7 @@ const KeepAliveImpl = {
218218
// also to avoid inline import() in generated d.ts files
219219
export const KeepAlive = (KeepAliveImpl as any) as {
220220
new (): {
221-
$props: KeepAliveProps
221+
$props: VNodeProps & KeepAliveProps
222222
}
223223
}
224224

packages/runtime-core/src/components/Portal.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { ComponentInternalInstance } from '../component'
22
import { SuspenseBoundary } from './Suspense'
33
import { RendererInternals, MoveType } from '../renderer'
4-
import { VNode, VNodeArrayChildren } from '../vnode'
4+
import { VNode, VNodeArrayChildren, VNodeProps } from '../vnode'
55
import { isString, ShapeFlags, PatchFlags } from '@vue/shared'
66
import { warn } from '../warning'
77

@@ -114,5 +114,5 @@ export const PortalImpl = {
114114
// Force-casted public typing for h and TSX props inference
115115
export const Portal = (PortalImpl as any) as {
116116
__isPortal: true
117-
new (): { $props: PortalProps }
117+
new (): { $props: VNodeProps & PortalProps }
118118
}

packages/runtime-core/src/components/Suspense.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { VNode, normalizeVNode, VNodeChild } from '../vnode'
1+
import { VNode, normalizeVNode, VNodeChild, VNodeProps } from '../vnode'
22
import { isFunction, isArray, ShapeFlags } from '@vue/shared'
33
import { ComponentInternalInstance, handleSetupResult } from '../component'
44
import { Slots } from '../componentSlots'
@@ -67,7 +67,7 @@ export const Suspense = ((__FEATURE_SUSPENSE__
6767
? SuspenseImpl
6868
: null) as any) as {
6969
__isSuspense: true
70-
new (): { $props: SuspenseProps }
70+
new (): { $props: VNodeProps & SuspenseProps }
7171
}
7272

7373
function mountSuspense(

rollup.config.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,7 @@ function createConfig(format, output, plugins = []) {
8888
output.name = packageOptions.name
8989
}
9090

91-
const shouldEmitDeclarations =
92-
process.env.TYPES != null &&
93-
process.env.NODE_ENV === 'production' &&
94-
!hasTSChecked
91+
const shouldEmitDeclarations = process.env.TYPES != null && !hasTSChecked
9592

9693
const tsPlugin = ts({
9794
check: process.env.NODE_ENV === 'production' && !hasTSChecked,

test-dts/tsx.test-d.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,17 @@ expectType<JSX.Element>(<Fragment />)
2828
expectType<JSX.Element>(<Fragment key="1" />)
2929

3030
expectType<JSX.Element>(<Portal target="#foo" />)
31-
// target is required
31+
expectType<JSX.Element>(<Portal target="#foo" key="1" />)
3232
expectError(<Portal />)
33+
expectError(<Portal target={1} />)
3334

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

3840
// Suspense
3941
expectType<JSX.Element>(<Suspense />)
42+
expectType<JSX.Element>(<Suspense key="1" />)
4043
expectType<JSX.Element>(<Suspense onResolve={() => {}} onRecede={() => {}} />)
4144
expectError(<Suspense onResolve={123} />)

0 commit comments

Comments
 (0)