build: upgrade to TypeScript 5.x

This commit is contained in:
Evan You 2023-03-23 17:11:35 +08:00
parent e60ebd07a4
commit 58e5c51149
8 changed files with 101 additions and 63 deletions

View File

@ -66,7 +66,7 @@
"@rollup/plugin-terser": "^0.1.0",
"@types/hash-sum": "^1.0.0",
"@types/node": "^16.4.7",
"@typescript-eslint/parser": "^5.23.0",
"@typescript-eslint/parser": "^5.56.0",
"@vitest/coverage-istanbul": "^0.29.7",
"@vue/consolidate": "0.17.3",
"brotli": "^1.3.2",
@ -90,7 +90,7 @@
"pug": "^3.0.1",
"puppeteer": "^19.6.3",
"rollup": "^3.20.0",
"rollup-plugin-dts": "^5.1.1",
"rollup-plugin-dts": "^5.3.0",
"rollup-plugin-esbuild": "^5.0.0",
"rollup-plugin-node-builtins": "^2.1.2",
"rollup-plugin-node-globals": "^1.4.0",
@ -100,8 +100,8 @@
"simple-git-hooks": "^2.8.1",
"terser": "^5.15.1",
"todomvc-app-css": "^2.3.0",
"tslib": "^2.4.0",
"typescript": "^4.9.0",
"tslib": "^2.5.0",
"typescript": "^5.0.0",
"vite": "^4.2.0",
"vitest": "^0.29.7"
}

View File

@ -210,13 +210,14 @@ export const transformElement: NodeTransform = (node, context) => {
if (__DEV__) {
if (patchFlag < 0) {
// special flags (negative and mutually exclusive)
vnodePatchFlag = patchFlag + ` /* ${PatchFlagNames[patchFlag]} */`
vnodePatchFlag =
patchFlag + ` /* ${PatchFlagNames[patchFlag as PatchFlags]} */`
} else {
// bitwise flags
const flagNames = Object.keys(PatchFlagNames)
.map(Number)
.filter(n => n > 0 && patchFlag & n)
.map(n => PatchFlagNames[n])
.map(n => PatchFlagNames[n as PatchFlags])
.join(`, `)
vnodePatchFlag = patchFlag + ` /* ${flagNames} */`
}

View File

@ -563,7 +563,7 @@ describe('with mixins', () => {
expectType<string>(props.z)
// props
expectType<((...args: any[]) => any) | undefined>(props.onClick)
// from Base
// from MixinA
expectType<((...args: any[]) => any) | undefined>(props.onBar)
expectType<string>(props.aP1)
expectType<boolean | undefined>(props.aP2)
@ -575,7 +575,7 @@ describe('with mixins', () => {
const props = this.$props
// props
expectType<((...args: any[]) => any) | undefined>(props.onClick)
// from Base
// from MixinA
expectType<((...args: any[]) => any) | undefined>(props.onBar)
expectType<string>(props.aP1)
expectType<boolean | undefined>(props.aP2)

View File

@ -15,8 +15,7 @@ import {
isArray,
NOOP,
isPromise,
LooseRequired,
UnionToIntersection
LooseRequired
} from '@vue/shared'
import { isRef, Ref } from '@vue/reactivity'
import { computed } from './apiComputed'
@ -58,7 +57,9 @@ import { Directive } from './directives'
import {
CreateComponentPublicInstance,
ComponentPublicInstance,
isReservedPrefix
isReservedPrefix,
IntersectionMixin,
UnwrapMixinsType
} from './componentPublicInstance'
import { warn } from './warning'
import { VNodeChild } from './vnode'
@ -93,21 +94,6 @@ export interface ComponentCustomOptions {}
export type RenderFunction = () => VNodeChild
type ExtractOptionProp<T> = T extends ComponentOptionsBase<
infer P, // Props
any, // RawBindings
any, // D
any, // C
any, // M
any, // Mixin
any, // Extends
any // EmitsOptions
>
? unknown extends P
? {}
: P
: {}
export interface ComponentOptionsBase<
Props,
RawBindings,
@ -129,8 +115,10 @@ export interface ComponentOptionsBase<
props: Readonly<
LooseRequired<
Props &
UnionToIntersection<ExtractOptionProp<Mixin>> &
UnionToIntersection<ExtractOptionProp<Extends>>
UnwrapMixinsType<
IntersectionMixin<Mixin> & IntersectionMixin<Extends>,
'P'
>
>
>,
ctx: SetupContext<E>

View File

@ -100,11 +100,11 @@ type ExtractMixin<T> = {
Mixin: MixinToOptionTypes<T>
}[T extends ComponentOptionsMixin ? 'Mixin' : never]
type IntersectionMixin<T> = IsDefaultMixinComponent<T> extends true
export type IntersectionMixin<T> = IsDefaultMixinComponent<T> extends true
? OptionTypesType<{}, {}, {}, {}, {}>
: UnionToIntersection<ExtractMixin<T>>
type UnwrapMixinsType<
export type UnwrapMixinsType<
T,
Type extends OptionTypesKeys
> = T extends OptionTypesType ? T[Type] : never

View File

@ -137,7 +137,7 @@ export function defineCustomElement(
options: any,
hydrate?: RootHydrateFunction
): VueElementConstructor {
const Comp = defineComponent(options as any)
const Comp = defineComponent(options) as any
class VueCustomElement extends VueElement {
static def = Comp
constructor(initialProps?: Record<string, any>) {

View File

@ -125,7 +125,7 @@ export const enum PatchFlags {
/**
* dev only flag -> name mapping
*/
export const PatchFlagNames = {
export const PatchFlagNames: Record<PatchFlags, string> = {
[PatchFlags.TEXT]: `TEXT`,
[PatchFlags.CLASS]: `CLASS`,
[PatchFlags.STYLE]: `STYLE`,

View File

@ -15,7 +15,7 @@ importers:
'@rollup/plugin-terser': ^0.1.0
'@types/hash-sum': ^1.0.0
'@types/node': ^16.4.7
'@typescript-eslint/parser': ^5.23.0
'@typescript-eslint/parser': ^5.56.0
'@vitest/coverage-istanbul': ^0.29.7
'@vue/consolidate': 0.17.3
brotli: ^1.3.2
@ -39,7 +39,7 @@ importers:
pug: ^3.0.1
puppeteer: ^19.6.3
rollup: ^3.20.0
rollup-plugin-dts: ^5.1.1
rollup-plugin-dts: ^5.3.0
rollup-plugin-esbuild: ^5.0.0
rollup-plugin-node-builtins: ^2.1.2
rollup-plugin-node-globals: ^1.4.0
@ -49,8 +49,8 @@ importers:
simple-git-hooks: ^2.8.1
terser: ^5.15.1
todomvc-app-css: ^2.3.0
tslib: ^2.4.0
typescript: ^4.9.0
tslib: ^2.5.0
typescript: ^5.0.0
vite: ^4.2.0
vitest: ^0.29.7
devDependencies:
@ -65,7 +65,7 @@ importers:
'@rollup/plugin-terser': 0.1.0_rollup@3.20.0
'@types/hash-sum': 1.0.0
'@types/node': 16.18.11
'@typescript-eslint/parser': 5.50.0_4vsywjlpuriuw3tl5oq6zy5a64
'@typescript-eslint/parser': 5.56.0_qesohl5arz7pvqyycxtsqomlr4
'@vitest/coverage-istanbul': 0.29.7_vitest@0.29.7
'@vue/consolidate': 0.17.3
brotli: 1.3.3
@ -75,7 +75,7 @@ importers:
enquirer: 2.3.6
esbuild: 0.17.5
eslint: 8.33.0
eslint-plugin-jest: 27.2.1_4vsywjlpuriuw3tl5oq6zy5a64
eslint-plugin-jest: 27.2.1_qesohl5arz7pvqyycxtsqomlr4
estree-walker: 2.0.2
execa: 4.1.0
jsdom: 21.1.0
@ -89,7 +89,7 @@ importers:
pug: 3.0.2
puppeteer: 19.6.3
rollup: 3.20.0
rollup-plugin-dts: 5.1.1_pn5zetjg24cqcolt42iry5qj6a
rollup-plugin-dts: 5.3.0_hy5v2w3xaqxocfx6d2ai5z6ari
rollup-plugin-esbuild: 5.0.0_iczynsknn7ny3sc5doji76wu6a
rollup-plugin-node-builtins: 2.1.2
rollup-plugin-node-globals: 1.4.0
@ -100,7 +100,7 @@ importers:
terser: 5.16.2
todomvc-app-css: 2.4.2
tslib: 2.5.0
typescript: 4.9.5
typescript: 5.0.2
vite: 4.2.1_ghge5pqdvzsmxto52quo4r2say
vitest: 0.29.7_jsdom@21.1.0+terser@5.16.2
@ -1011,8 +1011,8 @@ packages:
dev: true
optional: true
/@typescript-eslint/parser/5.50.0_4vsywjlpuriuw3tl5oq6zy5a64:
resolution: {integrity: sha512-KCcSyNaogUDftK2G9RXfQyOCt51uB5yqC6pkUYqhYh8Kgt+DwR5M0EwEAxGPy/+DH6hnmKeGsNhiZRQxjH71uQ==}
/@typescript-eslint/parser/5.56.0_qesohl5arz7pvqyycxtsqomlr4:
resolution: {integrity: sha512-sn1OZmBxUsgxMmR8a8U5QM/Wl+tyqlH//jTqCg8daTAmhAk26L2PFhcqPLlYBhYUJMZJK276qLXlHN3a83o2cg==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
peerDependencies:
eslint: ^6.0.0 || ^7.0.0 || ^8.0.0
@ -1021,12 +1021,12 @@ packages:
typescript:
optional: true
dependencies:
'@typescript-eslint/scope-manager': 5.50.0
'@typescript-eslint/types': 5.50.0
'@typescript-eslint/typescript-estree': 5.50.0_typescript@4.9.5
'@typescript-eslint/scope-manager': 5.56.0
'@typescript-eslint/types': 5.56.0
'@typescript-eslint/typescript-estree': 5.56.0_typescript@5.0.2
debug: 4.3.4
eslint: 8.33.0
typescript: 4.9.5
typescript: 5.0.2
transitivePeerDependencies:
- supports-color
dev: true
@ -1039,12 +1039,25 @@ packages:
'@typescript-eslint/visitor-keys': 5.50.0
dev: true
/@typescript-eslint/scope-manager/5.56.0:
resolution: {integrity: sha512-jGYKyt+iBakD0SA5Ww8vFqGpoV2asSjwt60Gl6YcO8ksQ8s2HlUEyHBMSa38bdLopYqGf7EYQMUIGdT/Luw+sw==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
dependencies:
'@typescript-eslint/types': 5.56.0
'@typescript-eslint/visitor-keys': 5.56.0
dev: true
/@typescript-eslint/types/5.50.0:
resolution: {integrity: sha512-atruOuJpir4OtyNdKahiHZobPKFvZnBnfDiyEaBf6d9vy9visE7gDjlmhl+y29uxZ2ZDgvXijcungGFjGGex7w==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
dev: true
/@typescript-eslint/typescript-estree/5.50.0_typescript@4.9.5:
/@typescript-eslint/types/5.56.0:
resolution: {integrity: sha512-JyAzbTJcIyhuUhogmiu+t79AkdnqgPUEsxMTMc/dCZczGMJQh1MK2wgrju++yMN6AWroVAy2jxyPcPr3SWCq5w==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
dev: true
/@typescript-eslint/typescript-estree/5.50.0_typescript@5.0.2:
resolution: {integrity: sha512-Gq4zapso+OtIZlv8YNAStFtT6d05zyVCK7Fx3h5inlLBx2hWuc/0465C2mg/EQDDU2LKe52+/jN4f0g9bd+kow==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
peerDependencies:
@ -1059,13 +1072,34 @@ packages:
globby: 11.1.0
is-glob: 4.0.3
semver: 7.3.8
tsutils: 3.21.0_typescript@4.9.5
typescript: 4.9.5
tsutils: 3.21.0_typescript@5.0.2
typescript: 5.0.2
transitivePeerDependencies:
- supports-color
dev: true
/@typescript-eslint/utils/5.50.0_4vsywjlpuriuw3tl5oq6zy5a64:
/@typescript-eslint/typescript-estree/5.56.0_typescript@5.0.2:
resolution: {integrity: sha512-41CH/GncsLXOJi0jb74SnC7jVPWeVJ0pxQj8bOjH1h2O26jXN3YHKDT1ejkVz5YeTEQPeLCCRY0U2r68tfNOcg==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
peerDependencies:
typescript: '*'
peerDependenciesMeta:
typescript:
optional: true
dependencies:
'@typescript-eslint/types': 5.56.0
'@typescript-eslint/visitor-keys': 5.56.0
debug: 4.3.4
globby: 11.1.0
is-glob: 4.0.3
semver: 7.3.8
tsutils: 3.21.0_typescript@5.0.2
typescript: 5.0.2
transitivePeerDependencies:
- supports-color
dev: true
/@typescript-eslint/utils/5.50.0_qesohl5arz7pvqyycxtsqomlr4:
resolution: {integrity: sha512-v/AnUFImmh8G4PH0NDkf6wA8hujNNcrwtecqW4vtQ1UOSNBaZl49zP1SHoZ/06e+UiwzHpgb5zP5+hwlYYWYAw==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
peerDependencies:
@ -1075,7 +1109,7 @@ packages:
'@types/semver': 7.3.13
'@typescript-eslint/scope-manager': 5.50.0
'@typescript-eslint/types': 5.50.0
'@typescript-eslint/typescript-estree': 5.50.0_typescript@4.9.5
'@typescript-eslint/typescript-estree': 5.50.0_typescript@5.0.2
eslint: 8.33.0
eslint-scope: 5.1.1
eslint-utils: 3.0.0_eslint@8.33.0
@ -1093,6 +1127,14 @@ packages:
eslint-visitor-keys: 3.3.0
dev: true
/@typescript-eslint/visitor-keys/5.56.0:
resolution: {integrity: sha512-1mFdED7u5bZpX6Xxf5N9U2c18sb+8EvU3tyOIj6LQZ5OOvnmj8BVeNNP603OFPm5KkS1a7IvCIcwrdHXaEMG/Q==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
dependencies:
'@typescript-eslint/types': 5.56.0
eslint-visitor-keys: 3.3.0
dev: true
/@vitejs/plugin-vue/4.1.0_m7w7ijwolt366p5gn6p5ouqwxe:
resolution: {integrity: sha512-++9JOAFdcXI3lyer9UKUV4rfoQ3T1RN8yDqoCLar86s0xQct5yblxAE+yWgRnU5/0FOlVCpTZpYSBV/bGWrSrQ==}
engines: {node: ^14.18.0 || >=16.0.0}
@ -2474,7 +2516,7 @@ packages:
source-map: 0.6.1
dev: true
/eslint-plugin-jest/27.2.1_4vsywjlpuriuw3tl5oq6zy5a64:
/eslint-plugin-jest/27.2.1_qesohl5arz7pvqyycxtsqomlr4:
resolution: {integrity: sha512-l067Uxx7ZT8cO9NJuf+eJHvt6bqJyz2Z29wykyEdz/OtmcELQl2MQGQLX8J94O1cSJWAwUSEvCjwjA7KEK3Hmg==}
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
peerDependencies:
@ -2487,7 +2529,7 @@ packages:
jest:
optional: true
dependencies:
'@typescript-eslint/utils': 5.50.0_4vsywjlpuriuw3tl5oq6zy5a64
'@typescript-eslint/utils': 5.50.0_qesohl5arz7pvqyycxtsqomlr4
eslint: 8.33.0
transitivePeerDependencies:
- supports-color
@ -3955,6 +3997,13 @@ packages:
dependencies:
'@jridgewell/sourcemap-codec': 1.4.14
/magic-string/0.30.0:
resolution: {integrity: sha512-LA+31JYDJLs82r2ScLrlz1GjSgu66ZV518eyWT+S8VhyQn/JL0u9MeBOvQMGYiPk1DBiSN9DDMOcXvigJZaViQ==}
engines: {node: '>=12'}
dependencies:
'@jridgewell/sourcemap-codec': 1.4.14
dev: true
/make-dir/3.1.0:
resolution: {integrity: sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==}
engines: {node: '>=8'}
@ -5065,16 +5114,16 @@ packages:
inherits: 2.0.4
dev: true
/rollup-plugin-dts/5.1.1_pn5zetjg24cqcolt42iry5qj6a:
resolution: {integrity: sha512-zpgo52XmnLg8w4k3MScinFHZK1+ro6r7uVe34fJ0Ee8AM45FvgvTuvfWWaRgIpA4pQ1BHJuu2ospncZhkcJVeA==}
/rollup-plugin-dts/5.3.0_hy5v2w3xaqxocfx6d2ai5z6ari:
resolution: {integrity: sha512-8FXp0ZkyZj1iU5klkIJYLjIq/YZSwBoERu33QBDxm/1yw5UU4txrEtcmMkrq+ZiKu3Q4qvPCNqc3ovX6rjqzbQ==}
engines: {node: '>=v14'}
peerDependencies:
rollup: ^3.0.0
typescript: ^4.1
typescript: ^4.1 || ^5.0
dependencies:
magic-string: 0.27.0
magic-string: 0.30.0
rollup: 3.20.0
typescript: 4.9.5
typescript: 5.0.2
optionalDependencies:
'@babel/code-frame': 7.18.6
dev: true
@ -5743,14 +5792,14 @@ packages:
resolution: {integrity: sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==}
dev: true
/tsutils/3.21.0_typescript@4.9.5:
/tsutils/3.21.0_typescript@5.0.2:
resolution: {integrity: sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==}
engines: {node: '>= 6'}
peerDependencies:
typescript: '>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta'
dependencies:
tslib: 1.14.1
typescript: 4.9.5
typescript: 5.0.2
dev: true
/type-check/0.3.2:
@ -5813,9 +5862,9 @@ packages:
resolution: {integrity: sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==}
dev: true
/typescript/4.9.5:
resolution: {integrity: sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==}
engines: {node: '>=4.2.0'}
/typescript/5.0.2:
resolution: {integrity: sha512-wVORMBGO/FAs/++blGNeAVdbNKtIh1rbBL2EyQ1+J9lClJ93KiiKe8PmFIVdXhHcyv44SL9oglmfeSsndo0jRw==}
engines: {node: '>=12.20'}
hasBin: true
dev: true