]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
types: fix tsx dts tests
authorEvan You <yyx990803@gmail.com>
Sun, 16 Feb 2020 02:48:45 +0000 (21:48 -0500)
committerEvan You <yyx990803@gmail.com>
Sun, 16 Feb 2020 02:48:45 +0000 (21:48 -0500)
package.json
packages/runtime-core/src/components/KeepAlive.ts
packages/runtime-core/src/components/Portal.ts
packages/runtime-core/src/components/Suspense.ts
rollup.config.js
test-dts/tsx.test-d.tsx

index ccdebeb490655d093a30e09f052394180350752c..008b8762e348d4f763939b9a22bbcd56bd8eb9e7 100644 (file)
@@ -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",
index 78bb824f97199df5f81b0eb8c3aa18316e1c0dba..6587e91122c0b337b46ac9a3c98d12071ca24313 100644 (file)
@@ -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'
@@ -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
   }
 }
 
index bbbaaad4c9d2d5a85a152b822081ef70631a44e2..c1e0e5dab876380ed0e7993884b1466166efe4b0 100644 (file)
@@ -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'
 
@@ -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 }
 }
index 56a4d5da383ecd58277ef4bc91711d67b555fdd5..d27c1f29f58e3eb6f81966b6b294cb0759e4ab46 100644 (file)
@@ -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'
@@ -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(
index 18fc0e5aad525d3a863697d894ed289fd7df46ec..ed3e5cd44cc3b747574ef0fd23d8d46b39287961 100644 (file)
@@ -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,
index 387533739c94cc4572444c4f163b0258a0050a01..8c63070e6b48530d1d3ca48997dae3a5baf6b0f6 100644 (file)
@@ -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} />)