Skip to content

Commit a8b161a

Browse files
Merge branch 'main' into chore-collectionHandlers-type
2 parents 1f4fb01 + 788527e commit a8b161a

33 files changed

+764
-336
lines changed

.github/contributing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,4 +330,4 @@ Funds donated via Patreon go directly to support Evan You's full-time work on Vu
330330

331331
Thank you to all the people who have already contributed to Vue.js!
332332

333-
<a href="https://github.com/vuejs/vue/graphs/contributors"><img src="https://opencollective.com/vuejs/contributors.svg?width=890" /></a>
333+
<a href="https://github.com/vuejs/core/graphs/contributors"><img src="https://opencollective.com/vuejs/contributors.svg?width=890" /></a>

BACKERS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ Vue.js is an MIT-licensed open source project with its ongoing development made
44

55
<p align="center">
66
<a target="_blank" href="https://sponsors.vuejs.org/backers.svg">
7-
<img alt="sponsors" src="https://sponsors.vuejs.org/backers.svg">
7+
<img alt="sponsors" src="https://sponsors.vuejs.org/backers.svg?v1">
88
</a>
99
</p>

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"private": true,
33
"version": "3.3.4",
4-
"packageManager": "pnpm@8.4.0",
4+
"packageManager": "pnpm@8.6.2",
55
"type": "module",
66
"scripts": {
77
"dev": "node scripts/dev.js",
@@ -35,7 +35,7 @@
3535
"build-runtime-esm": "node scripts/build.js runtime reactivity shared -af esm-bundler && node scripts/build.js vue -f esm-bundler-runtime && node scripts/build.js vue -f esm-browser-runtime",
3636
"build-ssr-esm": "node scripts/build.js compiler-sfc server-renderer -f esm-browser",
3737
"build-sfc-playground-self": "cd packages/sfc-playground && npm run build",
38-
"preinstall": "node ./scripts/preinstall.js",
38+
"preinstall": "npx only-allow pnpm",
3939
"postinstall": "simple-git-hooks"
4040
},
4141
"simple-git-hooks": {

packages/compiler-core/src/babelUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export function walkIdentifiers(
3232
root.body[0].type === 'ExpressionStatement' &&
3333
root.body[0].expression
3434

35-
;(walk as any)(root, {
35+
walk(root, {
3636
enter(node: Node & { scopeIds?: Set<string> }, parent: Node | undefined) {
3737
parent && parentStack.push(parent)
3838
if (

packages/compiler-sfc/__tests__/compileScript/resolveType.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
} from '../../src/script/resolveType'
1111

1212
import ts from 'typescript'
13-
registerTS(ts)
13+
registerTS(() => ts)
1414

1515
describe('resolveType', () => {
1616
test('type literal', () => {

packages/compiler-sfc/src/compileScript.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -607,8 +607,8 @@ export function compileScript(
607607
node.type.endsWith('Statement')
608608
) {
609609
const scope: Statement[][] = [scriptSetupAst.body]
610-
;(walk as any)(node, {
611-
enter(child: Node, parent: Node) {
610+
walk(node, {
611+
enter(child: Node, parent: Node | undefined) {
612612
if (isFunctionType(child)) {
613613
this.skip()
614614
}
@@ -633,7 +633,7 @@ export function compileScript(
633633
ctx,
634634
child,
635635
needsSemi,
636-
parent.type === 'ExpressionStatement'
636+
parent!.type === 'ExpressionStatement'
637637
)
638638
}
639639
},

packages/compiler-sfc/src/script/definePropsDestructure.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ export function transformDestructuredProps(
238238
// check root scope first
239239
const ast = ctx.scriptSetupAst!
240240
walkScope(ast, true)
241-
;(walk as any)(ast, {
241+
walk(ast, {
242242
enter(node: Node, parent?: Node) {
243243
parent && parentStack.push(parent)
244244

packages/compiler-sfc/src/script/resolveType.ts

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -708,13 +708,14 @@ function resolveGlobalScope(ctx: TypeResolveContext): TypeScope[] | undefined {
708708
}
709709
}
710710

711-
let ts: typeof TS
711+
let ts: typeof TS | undefined
712+
let loadTS: (() => typeof TS) | undefined
712713

713714
/**
714715
* @private
715716
*/
716-
export function registerTS(_ts: any) {
717-
ts = _ts
717+
export function registerTS(_loadTS: () => typeof TS) {
718+
loadTS = _loadTS
718719
}
719720

720721
type FS = NonNullable<SFCScriptCompileOptions['fs']>
@@ -723,7 +724,10 @@ function resolveFS(ctx: TypeResolveContext): FS | undefined {
723724
if (ctx.fs) {
724725
return ctx.fs
725726
}
726-
const fs = ctx.options.fs || ts.sys
727+
if (!ts && loadTS) {
728+
ts = loadTS()
729+
}
730+
const fs = ctx.options.fs || ts?.sys
727731
if (!fs) {
728732
return
729733
}
@@ -779,22 +783,25 @@ function importSourceToScope(
779783
} else {
780784
// module or aliased import - use full TS resolution, only supported in Node
781785
if (!__NODE_JS__) {
782-
ctx.error(
786+
return ctx.error(
783787
`Type import from non-relative sources is not supported in the browser build.`,
784788
node,
785789
scope
786790
)
787791
}
788792
if (!ts) {
789-
ctx.error(
790-
`Failed to resolve import source ${JSON.stringify(source)}. ` +
791-
`typescript is required as a peer dep for vue in order ` +
792-
`to support resolving types from module imports.`,
793-
node,
794-
scope
795-
)
793+
if (loadTS) ts = loadTS()
794+
if (!ts) {
795+
return ctx.error(
796+
`Failed to resolve import source ${JSON.stringify(source)}. ` +
797+
`typescript is required as a peer dep for vue in order ` +
798+
`to support resolving types from module imports.`,
799+
node,
800+
scope
801+
)
802+
}
796803
}
797-
resolved = resolveWithTS(scope.filename, source, fs)
804+
resolved = resolveWithTS(scope.filename, source, ts, fs)
798805
}
799806
if (resolved) {
800807
resolved = scope.resolvedImportSources[source] = normalizePath(resolved)
@@ -839,6 +846,7 @@ const tsConfigRefMap = new Map<string, string>()
839846
function resolveWithTS(
840847
containingFile: string,
841848
source: string,
849+
ts: typeof TS,
842850
fs: FS
843851
): string | undefined {
844852
if (!__NODE_JS__) return
@@ -853,7 +861,7 @@ function resolveWithTS(
853861
const normalizedConfigPath = normalizePath(configPath)
854862
const cached = tsConfigCache.get(normalizedConfigPath)
855863
if (!cached) {
856-
configs = loadTSConfig(configPath, fs).map(config => ({ config }))
864+
configs = loadTSConfig(configPath, ts, fs).map(config => ({ config }))
857865
tsConfigCache.set(normalizedConfigPath, configs)
858866
} else {
859867
configs = cached
@@ -918,7 +926,11 @@ function resolveWithTS(
918926
}
919927
}
920928

921-
function loadTSConfig(configPath: string, fs: FS): TS.ParsedCommandLine[] {
929+
function loadTSConfig(
930+
configPath: string,
931+
ts: typeof TS,
932+
fs: FS
933+
): TS.ParsedCommandLine[] {
922934
// The only case where `fs` is NOT `ts.sys` is during tests.
923935
// parse config host requires an extra `readDirectory` method
924936
// during tests, which is stubbed.
@@ -940,7 +952,7 @@ function loadTSConfig(configPath: string, fs: FS): TS.ParsedCommandLine[] {
940952
if (config.projectReferences) {
941953
for (const ref of config.projectReferences) {
942954
tsConfigRefMap.set(ref.path, configPath)
943-
res.unshift(...loadTSConfig(ref.path, fs))
955+
res.unshift(...loadTSConfig(ref.path, ts, fs))
944956
}
945957
}
946958
return res

packages/global.d.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,17 @@ declare module 'file-saver' {
3333
export function saveAs(blob: any, name: any): void
3434
}
3535

36+
declare module 'estree-walker' {
37+
export function walk<T>(
38+
root: T,
39+
options: {
40+
enter?: (node: T, parent: T | undefined) => any
41+
leave?: (node: T, parent: T | undefined) => any
42+
exit?: (node: T) => any
43+
} & ThisType<{ skip: () => void }>
44+
)
45+
}
46+
3647
declare interface String {
3748
/**
3849
* @deprecated Please use String.prototype.slice instead of String.prototype.substring in the repository.

packages/reactivity-transform/src/reactivityTransform.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ export function transformAST(
636636

637637
// check root scope first
638638
walkScope(ast, true)
639-
;(walk as any)(ast, {
639+
walk(ast, {
640640
enter(node: Node, parent?: Node) {
641641
parent && parentStack.push(parent)
642642

packages/runtime-core/src/apiCreateApp.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
ComponentPublicInstance
1717
} from './componentPublicInstance'
1818
import { Directive, validateDirectiveName } from './directives'
19-
import { RootRenderFunction } from './renderer'
19+
import { RendererElement, RootRenderFunction } from './renderer'
2020
import { InjectionKey } from './apiInject'
2121
import { warn } from './warning'
2222
import { createVNode, cloneVNode, VNode } from './vnode'
@@ -196,7 +196,7 @@ export type CreateAppFunction<HostElement> = (
196196

197197
let uid = 0
198198

199-
export function createAppAPI<HostElement>(
199+
export function createAppAPI<HostElement extends RendererElement>(
200200
render: RootRenderFunction<HostElement>,
201201
hydrate?: RootHydrateFunction
202202
): CreateAppFunction<HostElement> {

packages/runtime-core/src/devtools.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ interface DevtoolsHook {
3030
appRecords: AppRecord[]
3131
/**
3232
* Added at https://github.com/vuejs/devtools/commit/f2ad51eea789006ab66942e5a27c0f0986a257f9
33-
* Returns wether the arg was buffered or not
33+
* Returns whether the arg was buffered or not
3434
*/
3535
cleanupBuffer?: (matchArg: unknown) => boolean
3636
}

packages/runtime-core/src/directives.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { ComponentPublicInstance } from './componentPublicInstance'
2121
import { mapCompatDirectiveHook } from './compat/customDirective'
2222
import { pauseTracking, resetTracking } from '@vue/reactivity'
2323
import { traverse } from './apiWatch'
24+
import { RendererElement } from './renderer'
2425

2526
export interface DirectiveBinding<V = any> {
2627
instance: ComponentPublicInstance | null
@@ -31,7 +32,11 @@ export interface DirectiveBinding<V = any> {
3132
dir: ObjectDirective<any, V>
3233
}
3334

34-
export type DirectiveHook<T = any, Prev = VNode<any, T> | null, V = any> = (
35+
export type DirectiveHook<
36+
T extends RendererElement = any,
37+
Prev = VNode<any, T> | null,
38+
V = any
39+
> = (
3540
el: T,
3641
binding: DirectiveBinding<V>,
3742
vnode: VNode<any, T>,
@@ -43,7 +48,7 @@ export type SSRDirectiveHook = (
4348
vnode: VNode
4449
) => Data | undefined
4550

46-
export interface ObjectDirective<T = any, V = any> {
51+
export interface ObjectDirective<T extends RendererElement = any, V = any> {
4752
created?: DirectiveHook<T, null, V>
4853
beforeMount?: DirectiveHook<T, null, V>
4954
mounted?: DirectiveHook<T, null, V>
@@ -55,9 +60,12 @@ export interface ObjectDirective<T = any, V = any> {
5560
deep?: boolean
5661
}
5762

58-
export type FunctionDirective<T = any, V = any> = DirectiveHook<T, any, V>
63+
export type FunctionDirective<
64+
T extends RendererElement = any,
65+
V = any
66+
> = DirectiveHook<T, any, V>
5967

60-
export type Directive<T = any, V = any> =
68+
export type Directive<T extends RendererElement = any, V = any> =
6169
| ObjectDirective<T, V>
6270
| FunctionDirective<T, V>
6371

packages/runtime-core/src/renderer.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export type RootRenderFunction<HostElement = RendererElement> = (
9090

9191
export interface RendererOptions<
9292
HostNode = RendererNode,
93-
HostElement = RendererElement
93+
HostElement extends RendererElement = RendererElement
9494
> {
9595
patchProp(
9696
el: HostElement,
@@ -145,7 +145,7 @@ export interface RendererElement extends RendererNode {}
145145
// to optimize bundle size.
146146
export interface RendererInternals<
147147
HostNode = RendererNode,
148-
HostElement = RendererElement
148+
HostElement extends RendererElement = RendererElement
149149
> {
150150
p: PatchFn
151151
um: UnmountFn
@@ -295,7 +295,7 @@ export const queuePostRenderEffect = __FEATURE_SUSPENSE__
295295
*/
296296
export function createRenderer<
297297
HostNode = RendererNode,
298-
HostElement = RendererElement
298+
HostElement extends RendererElement = RendererElement
299299
>(options: RendererOptions<HostNode, HostElement>) {
300300
return baseCreateRenderer<HostNode, HostElement>(options)
301301
}
@@ -312,7 +312,7 @@ export function createHydrationRenderer(
312312
// overload 1: no hydration
313313
function baseCreateRenderer<
314314
HostNode = RendererNode,
315-
HostElement = RendererElement
315+
HostElement extends RendererElement = RendererElement
316316
>(options: RendererOptions<HostNode, HostElement>): Renderer<HostElement>
317317

318318
// overload 2: with hydration

packages/runtime-core/src/vnode.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ export type VNodeNormalizedChildren =
133133

134134
export interface VNode<
135135
HostNode = RendererNode,
136-
HostElement = RendererElement,
136+
HostElement extends RendererElement = RendererElement,
137137
ExtraProps = { [key: string]: any }
138138
> {
139139
/**
@@ -613,7 +613,7 @@ export function guardReactiveProps(props: (Data & VNodeProps) | null) {
613613
: props
614614
}
615615

616-
export function cloneVNode<T, U>(
616+
export function cloneVNode<T extends RendererNode, U extends RendererElement>(
617617
vnode: VNode<T, U>,
618618
extraProps?: (Data & VNodeProps) | null,
619619
mergeRef = false

packages/runtime-dom/src/components/Transition.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,8 @@ function getTimeout(delays: string[], durations: string[]): number {
445445
// If comma is not replaced with a dot, the input will be rounded down
446446
// (i.e. acting as a floor function) causing unexpected behaviors
447447
function toMs(s: string): number {
448+
// #8409 default value for CSS durations can be 'auto'
449+
if (s === 'auto') return 0
448450
return Number(s.slice(0, -1).replace(',', '.')) * 1000
449451
}
450452

packages/runtime-dom/src/jsx.ts

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,31 @@ export interface InsHTMLAttributes extends HTMLAttributes {
464464
datetime?: string
465465
}
466466

467+
export type InputTypeHTMLAttribute =
468+
| 'button'
469+
| 'checkbox'
470+
| 'color'
471+
| 'date'
472+
| 'datetime-local'
473+
| 'email'
474+
| 'file'
475+
| 'hidden'
476+
| 'image'
477+
| 'month'
478+
| 'number'
479+
| 'password'
480+
| 'radio'
481+
| 'range'
482+
| 'reset'
483+
| 'search'
484+
| 'submit'
485+
| 'tel'
486+
| 'text'
487+
| 'time'
488+
| 'url'
489+
| 'week'
490+
| (string & {})
491+
467492
export interface InputHTMLAttributes extends HTMLAttributes {
468493
accept?: string
469494
alt?: string
@@ -495,7 +520,7 @@ export interface InputHTMLAttributes extends HTMLAttributes {
495520
size?: Numberish
496521
src?: string
497522
step?: Numberish
498-
type?: string
523+
type?: InputTypeHTMLAttribute
499524
value?: any // we support :value to be bound to anything w/ v-model
500525
width?: Numberish
501526
}
@@ -677,7 +702,7 @@ export interface TextareaHTMLAttributes extends HTMLAttributes {
677702
minlength?: Numberish
678703
name?: string
679704
placeholder?: string
680-
readonly?: boolean
705+
readonly?: Booleanish
681706
required?: Booleanish
682707
rows?: Numberish
683708
value?: string | string[] | number

0 commit comments

Comments
 (0)