Skip to content

Commit

Permalink
build: upgrade to TypeScript 5.x
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Mar 23, 2023
1 parent e60ebd0 commit 58e5c51
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 63 deletions.
8 changes: 4 additions & 4 deletions package.json
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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"
}
Expand Down
5 changes: 3 additions & 2 deletions packages/compiler-core/src/transforms/transformElement.ts
Expand Up @@ -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} */`
}
Expand Down
4 changes: 2 additions & 2 deletions packages/dts-test/defineComponent.test-d.tsx
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
28 changes: 8 additions & 20 deletions packages/runtime-core/src/componentOptions.ts
Expand Up @@ -15,8 +15,7 @@ import {
isArray,
NOOP,
isPromise,
LooseRequired,
UnionToIntersection
LooseRequired
} from '@vue/shared'
import { isRef, Ref } from '@vue/reactivity'
import { computed } from './apiComputed'
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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,
Expand All @@ -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>
Expand Down
4 changes: 2 additions & 2 deletions packages/runtime-core/src/componentPublicInstance.ts
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime-dom/src/apiCustomElement.ts
Expand Up @@ -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>) {
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/src/patchFlags.ts
Expand Up @@ -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`,
Expand Down

0 comments on commit 58e5c51

Please sign in to comment.