mirror of
https://github.com/vuejs/vue.git
synced 2024-11-22 04:39:46 +00:00
chore: fix type tests
This commit is contained in:
parent
206f8a7f09
commit
ffaf81ba5f
@ -34,10 +34,11 @@
|
||||
"source-map": "0.5.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/webpack": "^4.41.32",
|
||||
"file-loader": "^3.0.1",
|
||||
"memory-fs": "^0.5.0",
|
||||
"vue": "file:../..",
|
||||
"webpack": "^4.46.0",
|
||||
"file-loader": "^3.0.1"
|
||||
"webpack": "^4.46.0"
|
||||
},
|
||||
"homepage": "https://github.com/vuejs/vue/tree/dev/packages/vue-server-renderer#readme"
|
||||
}
|
||||
|
@ -1,12 +1,9 @@
|
||||
import Vue, { VNode, VNodeDirective } from '../index'
|
||||
import VueSSRClientPlugin = require('../../packages/vue-server-renderer/client-plugin')
|
||||
import VueSSRServerPlugin = require('../../packages/vue-server-renderer/server-plugin')
|
||||
import webpack = require('webpack')
|
||||
import Vue, { VNode, VNodeDirective } from '../../../types/index'
|
||||
import VueSSRClientPlugin from '../client-plugin'
|
||||
import VueSSRServerPlugin from '../server-plugin'
|
||||
import webpack from 'webpack'
|
||||
import { readFileSync } from 'fs'
|
||||
import {
|
||||
createRenderer,
|
||||
createBundleRenderer
|
||||
} from '../../packages/vue-server-renderer'
|
||||
import { createRenderer, createBundleRenderer } from '.'
|
||||
|
||||
function createApp(context: any) {
|
||||
return new Vue({
|
@ -5,6 +5,7 @@
|
||||
"moduleResolution": "node",
|
||||
"strict": true,
|
||||
"noEmit": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"paths": {
|
||||
"vue": ["../../../types/index.d.ts"]
|
||||
}
|
||||
|
@ -128,6 +128,7 @@ importers:
|
||||
|
||||
packages/server-renderer:
|
||||
specifiers:
|
||||
'@types/webpack': ^4.41.32
|
||||
chalk: ^4.0.0
|
||||
file-loader: ^3.0.1
|
||||
hash-sum: ^2.0.0
|
||||
@ -150,6 +151,7 @@ importers:
|
||||
serialize-javascript: 6.0.0
|
||||
source-map: 0.5.6
|
||||
devDependencies:
|
||||
'@types/webpack': 4.41.32
|
||||
file-loader: 3.0.1_webpack@4.46.0
|
||||
memory-fs: 0.5.0
|
||||
vue: 'file:'
|
||||
@ -492,6 +494,39 @@ packages:
|
||||
'@types/node': 17.0.36
|
||||
dev: true
|
||||
|
||||
/@types/source-list-map/0.1.2:
|
||||
resolution: {integrity: sha512-K5K+yml8LTo9bWJI/rECfIPrGgxdpeNbj+d53lwN4QjW1MCwlkhUms+gtdzigTeUyBr09+u8BwOIY3MXvHdcsA==}
|
||||
dev: true
|
||||
|
||||
/@types/tapable/1.0.8:
|
||||
resolution: {integrity: sha512-ipixuVrh2OdNmauvtT51o3d8z12p6LtFW9in7U79der/kwejjdNchQC5UMn5u/KxNoM7VHHOs/l8KS8uHxhODQ==}
|
||||
dev: true
|
||||
|
||||
/@types/uglify-js/3.13.2:
|
||||
resolution: {integrity: sha512-/xFrPIo+4zOeNGtVMbf9rUm0N+i4pDf1ynExomqtokIJmVzR3962lJ1UE+MmexMkA0cmN9oTzg5Xcbwge0Ij2Q==}
|
||||
dependencies:
|
||||
source-map: 0.6.1
|
||||
dev: true
|
||||
|
||||
/@types/webpack-sources/3.2.0:
|
||||
resolution: {integrity: sha512-Ft7YH3lEVRQ6ls8k4Ff1oB4jN6oy/XmU6tQISKdhfh+1mR+viZFphS6WL0IrtDOzvefmJg5a0s7ZQoRXwqTEFg==}
|
||||
dependencies:
|
||||
'@types/node': 17.0.36
|
||||
'@types/source-list-map': 0.1.2
|
||||
source-map: 0.7.3
|
||||
dev: true
|
||||
|
||||
/@types/webpack/4.41.32:
|
||||
resolution: {integrity: sha512-cb+0ioil/7oz5//7tZUSwbrSAN/NWHrQylz5cW8G0dWTcF/g+/dSdMlKVZspBYuMAN1+WnwHrkxiRrLcwd0Heg==}
|
||||
dependencies:
|
||||
'@types/node': 17.0.36
|
||||
'@types/tapable': 1.0.8
|
||||
'@types/uglify-js': 3.13.2
|
||||
'@types/webpack-sources': 3.2.0
|
||||
anymatch: 3.1.2
|
||||
source-map: 0.6.1
|
||||
dev: true
|
||||
|
||||
/@types/yauzl/2.10.0:
|
||||
resolution: {integrity: sha512-Cn6WYCm0tXv8p6k+A8PvbDG763EDpBoTzHdA+Q/MF6H3sapGjCm9NzoaJncJS9tUKSuCoDs9XHxYYsQDgxR6kw==}
|
||||
requiresBuild: true
|
||||
@ -4083,7 +4118,7 @@ packages:
|
||||
dev: true
|
||||
|
||||
/normalize-path/2.1.1:
|
||||
resolution: {integrity: sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=}
|
||||
resolution: {integrity: sha512-3pKJwH184Xo/lnH6oyP1q2pMd7HcypqqmRs91/6/i2CGtWwIKGCkOOMTm/zXbgTEWHw1uNpNi/igc3ePOYHb6w==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
dependencies:
|
||||
remove-trailing-separator: 1.1.0
|
||||
@ -5300,6 +5335,11 @@ packages:
|
||||
resolution: {integrity: sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
||||
/source-map/0.7.3:
|
||||
resolution: {integrity: sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==}
|
||||
engines: {node: '>= 8'}
|
||||
dev: true
|
||||
|
||||
/sourcemap-codec/1.4.8:
|
||||
resolution: {integrity: sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==}
|
||||
dev: true
|
||||
@ -6375,7 +6415,7 @@ packages:
|
||||
'file:':
|
||||
resolution: {directory: '', type: directory}
|
||||
name: vue
|
||||
version: 2.6.14
|
||||
version: 2.7.0-alpha.3
|
||||
dependencies:
|
||||
'@vue/compiler-sfc': link:packages/compiler-sfc
|
||||
dev: true
|
||||
|
8
types/index.d.ts
vendored
8
types/index.d.ts
vendored
@ -11,8 +11,8 @@ export {
|
||||
ComponentOptions,
|
||||
FunctionalComponentOptions,
|
||||
RenderContext,
|
||||
// PropType,
|
||||
// PropOptions,
|
||||
PropType,
|
||||
PropOptions,
|
||||
ComputedOptions,
|
||||
WatchHandler,
|
||||
WatchOptions,
|
||||
@ -52,8 +52,8 @@ export {
|
||||
ComponentRenderProxy
|
||||
} from './v3-component-proxy'
|
||||
export {
|
||||
PropType,
|
||||
PropOptions,
|
||||
// PropType,
|
||||
// PropOptions,
|
||||
ExtractPropTypes,
|
||||
ExtractDefaultPropTypes
|
||||
} from './v3-component-props'
|
||||
|
14
types/options.d.ts
vendored
14
types/options.d.ts
vendored
@ -250,10 +250,22 @@ export interface RenderContext<Props = DefaultProps> {
|
||||
injections: any
|
||||
}
|
||||
|
||||
import { PropOptions, PropType } from './v3-component-props'
|
||||
export type Prop<T> =
|
||||
| { (): T }
|
||||
| { new (...args: never[]): T & object }
|
||||
| { new (...args: string[]): Function }
|
||||
|
||||
export type PropType<T> = Prop<T> | Prop<T>[]
|
||||
|
||||
export type PropValidator<T> = PropOptions<T> | PropType<T>
|
||||
|
||||
export interface PropOptions<T = any> {
|
||||
type?: PropType<T>
|
||||
required?: boolean
|
||||
default?: T | null | undefined | (() => T | null | undefined)
|
||||
validator?(value: unknown): boolean
|
||||
}
|
||||
|
||||
export type RecordPropsDefinition<T> = {
|
||||
[K in keyof T]: PropValidator<T[K]>
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import Vue, { defineComponent } from '../../index'
|
||||
import Vue, { defineComponent, PropType } from '../../index'
|
||||
|
||||
// object props
|
||||
Vue.extend({
|
||||
@ -78,3 +78,18 @@ defineComponent({
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
defineComponent({
|
||||
props: {
|
||||
foo: null as any as PropType<{ a: number }>
|
||||
},
|
||||
data() {
|
||||
this.foo?.a
|
||||
},
|
||||
setup(props) {
|
||||
const res = props.foo?.a.toFixed(2)
|
||||
// @ts-expect-error
|
||||
res.charAt(1)
|
||||
res?.charAt(1)
|
||||
}
|
||||
})
|
||||
|
2
types/v3-component-props.d.ts
vendored
2
types/v3-component-props.d.ts
vendored
@ -22,8 +22,8 @@ export interface PropOptions<T = any, D = T> {
|
||||
export type PropType<T> = PropConstructor<T> | PropConstructor<T>[]
|
||||
|
||||
type PropConstructor<T> =
|
||||
| { new (...args: any[]): T & object }
|
||||
| { (): T }
|
||||
| { new (...args: never[]): T & object }
|
||||
| { new (...args: string[]): Function }
|
||||
|
||||
type RequiredKeys<T> = {
|
||||
|
Loading…
Reference in New Issue
Block a user