Skip to content

Commit 5ec9377

Browse files
committed
chore: Merge branch 'main' into minor
2 parents 7aa3f25 + a8d0b1b commit 5ec9377

File tree

10 files changed

+305
-245
lines changed

10 files changed

+305
-245
lines changed

.github/contributing.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Hi! I'm really excited that you are interested in contributing to Vue.js. Before
6363

6464
You will need [Node.js](https://nodejs.org) **version 18.12+**, and [PNPM](https://pnpm.io) **version 8+**.
6565

66-
We also recommend installing [ni](https://github.com/antfu/ni) to help switching between repos using different package managers. `ni` also provides the handy `nr` command which running npm scripts easier.
66+
We also recommend installing [@antfu/ni](https://github.com/antfu/ni) to help switching between repos using different package managers. `ni` also provides the handy `nr` command which running npm scripts easier.
6767

6868
After cloning the repo, run:
6969

@@ -90,7 +90,7 @@ The project uses [simple-git-hooks](https://github.com/toplenboren/simple-git-ho
9090

9191
## Scripts
9292

93-
**The examples below will be using the `nr` command from the [ni](https://github.com/antfu/ni) package.** You can also use plain `npm run`, but you will need to pass all additional arguments after the command after an extra `--`. For example, `nr build runtime --all` is equivalent to `npm run build -- runtime --all`.
93+
**The examples below will be using the `nr` command from the [@antfu/ni](https://github.com/antfu/ni) package.** You can also use plain `npm run`, but you will need to pass all additional arguments after the command after an extra `--`. For example, `nr build runtime --all` is equivalent to `npm run build -- runtime --all`.
9494

9595
The `run-s` and `run-p` commands found in some scripts are from [npm-run-all](https://github.com/mysticatea/npm-run-all) for orchestrating multiple scripts. `run-s` means "run in sequence" while `run-p` means "run in parallel".
9696

package.json

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"private": true,
33
"version": "3.4.0-beta.4",
4-
"packageManager": "[email protected].0",
4+
"packageManager": "[email protected].1",
55
"type": "module",
66
"scripts": {
77
"dev": "node scripts/dev.js",
@@ -59,8 +59,8 @@
5959
"node": ">=18.12.0"
6060
},
6161
"devDependencies": {
62-
"@babel/parser": "^7.23.5",
63-
"@babel/types": "^7.23.5",
62+
"@babel/parser": "^7.23.6",
63+
"@babel/types": "^7.23.6",
6464
"@codspeed/vitest-plugin": "^2.3.1",
6565
"@rollup/plugin-alias": "^5.0.1",
6666
"@rollup/plugin-commonjs": "^25.0.7",
@@ -70,16 +70,16 @@
7070
"@rollup/plugin-terser": "^0.4.4",
7171
"@types/hash-sum": "^1.0.2",
7272
"@types/minimist": "^1.2.5",
73-
"@types/node": "^20.10.4",
73+
"@types/node": "^20.10.5",
7474
"@types/semver": "^7.5.5",
75-
"@typescript-eslint/parser": "^6.13.2",
76-
"@vitest/coverage-istanbul": "^1.0.4",
75+
"@typescript-eslint/parser": "^6.15.0",
76+
"@vitest/coverage-istanbul": "^1.1.0",
7777
"@vue/consolidate": "0.17.3",
7878
"conventional-changelog-cli": "^4.1.0",
7979
"enquirer": "^2.4.1",
8080
"esbuild": "^0.19.5",
8181
"esbuild-plugin-polyfill-node": "^0.3.0",
82-
"eslint": "^8.55.0",
82+
"eslint": "^8.56.0",
8383
"eslint-define-config": "^1.24.1",
8484
"eslint-plugin-jest": "^27.6.0",
8585
"estree-walker": "^2.0.2",
@@ -89,14 +89,14 @@
8989
"lodash": "^4.17.21",
9090
"magic-string": "^0.30.5",
9191
"markdown-table": "^3.0.3",
92-
"marked": "^11.0.1",
92+
"marked": "^11.1.0",
9393
"minimist": "^1.2.8",
9494
"npm-run-all": "^4.1.5",
9595
"picocolors": "^1.0.0",
9696
"prettier": "^3.1.1",
9797
"pretty-bytes": "^6.1.1",
9898
"pug": "^3.0.2",
99-
"puppeteer": "~21.6.0",
99+
"puppeteer": "~21.6.1",
100100
"rimraf": "^5.0.5",
101101
"rollup": "^4.1.4",
102102
"rollup-plugin-dts": "^6.1.0",
@@ -108,9 +108,9 @@
108108
"terser": "^5.22.0",
109109
"todomvc-app-css": "^2.4.3",
110110
"tslib": "^2.6.2",
111-
"tsx": "^4.6.2",
111+
"tsx": "^4.7.0",
112112
"typescript": "^5.2.2",
113113
"vite": "^5.0.5",
114-
"vitest": "^1.0.4"
114+
"vitest": "^1.1.0"
115115
}
116116
}

packages/compiler-core/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@
3232
},
3333
"homepage": "https://github.com/vuejs/core/tree/main/packages/compiler-core#readme",
3434
"dependencies": {
35-
"@babel/parser": "^7.23.5",
35+
"@babel/parser": "^7.23.6",
3636
"@vue/shared": "workspace:*",
3737
"entities": "^4.5.0",
3838
"estree-walker": "^2.0.2",
3939
"source-map-js": "^1.0.2"
4040
},
4141
"devDependencies": {
42-
"@babel/types": "^7.23.5"
42+
"@babel/types": "^7.23.6"
4343
}
4444
}

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

+34-3
Original file line numberDiff line numberDiff line change
@@ -939,6 +939,34 @@ describe('resolveType', () => {
939939
manufacturer: ['Object']
940940
})
941941
})
942+
943+
// #9871
944+
test('shared generics with different args', () => {
945+
const files = {
946+
'/foo.ts': `export interface Foo<T> { value: T }`
947+
}
948+
const { props } = resolve(
949+
`import type { Foo } from './foo'
950+
defineProps<Foo<string>>()`,
951+
files,
952+
undefined,
953+
`/One.vue`
954+
)
955+
expect(props).toStrictEqual({
956+
value: ['String']
957+
})
958+
const { props: props2 } = resolve(
959+
`import type { Foo } from './foo'
960+
defineProps<Foo<number>>()`,
961+
files,
962+
undefined,
963+
`/Two.vue`,
964+
false /* do not invalidate cache */
965+
)
966+
expect(props2).toStrictEqual({
967+
value: ['Number']
968+
})
969+
})
942970
})
943971

944972
describe('errors', () => {
@@ -1012,7 +1040,8 @@ function resolve(
10121040
code: string,
10131041
files: Record<string, string> = {},
10141042
options?: Partial<SFCScriptCompileOptions>,
1015-
sourceFileName: string = '/Test.vue'
1043+
sourceFileName: string = '/Test.vue',
1044+
invalidateCache = true
10161045
) {
10171046
const { descriptor } = parse(`<script setup lang="ts">\n${code}\n</script>`, {
10181047
filename: sourceFileName
@@ -1030,8 +1059,10 @@ function resolve(
10301059
...options
10311060
})
10321061

1033-
for (const file in files) {
1034-
invalidateTypeCache(file)
1062+
if (invalidateCache) {
1063+
for (const file in files) {
1064+
invalidateTypeCache(file)
1065+
}
10351066
}
10361067

10371068
// ctx.userImports is collected when calling compileScript(), but we are

packages/compiler-sfc/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
},
3333
"homepage": "https://github.com/vuejs/core/tree/main/packages/compiler-sfc#readme",
3434
"dependencies": {
35-
"@babel/parser": "^7.23.5",
35+
"@babel/parser": "^7.23.6",
3636
"@vue/compiler-core": "workspace:*",
3737
"@vue/compiler-dom": "workspace:*",
3838
"@vue/compiler-ssr": "workspace:*",
@@ -43,7 +43,7 @@
4343
"source-map-js": "^1.0.2"
4444
},
4545
"devDependencies": {
46-
"@babel/types": "^7.23.5",
46+
"@babel/types": "^7.23.6",
4747
"@vue/consolidate": "^0.17.3",
4848
"hash-sum": "^2.0.0",
4949
"lru-cache": "^10.1.0",

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

+15-9
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export class TypeScope {
115115
public types: Record<string, ScopeTypeNode> = Object.create(null),
116116
public declares: Record<string, ScopeTypeNode> = Object.create(null)
117117
) {}
118-
118+
isGenericScope = false
119119
resolvedImportSources: Record<string, string> = Object.create(null)
120120
exportedTypes: Record<string, ScopeTypeNode> = Object.create(null)
121121
exportedDeclares: Record<string, ScopeTypeNode> = Object.create(null)
@@ -146,15 +146,17 @@ export function resolveTypeElements(
146146
scope?: TypeScope,
147147
typeParameters?: Record<string, Node>
148148
): ResolvedElements {
149-
if (node._resolvedElements) {
149+
const canCache = !typeParameters
150+
if (canCache && node._resolvedElements) {
150151
return node._resolvedElements
151152
}
152-
return (node._resolvedElements = innerResolveTypeElements(
153+
const resolved = innerResolveTypeElements(
153154
ctx,
154155
node,
155156
node._ownerScope || scope || ctxToScope(ctx),
156157
typeParameters
157-
))
158+
)
159+
return canCache ? (node._resolvedElements = resolved) : resolved
158160
}
159161

160162
function innerResolveTypeElements(
@@ -215,17 +217,18 @@ function innerResolveTypeElements(
215217
}
216218
const resolved = resolveTypeReference(ctx, node, scope)
217219
if (resolved) {
218-
const typeParams: Record<string, Node> = Object.create(null)
220+
let typeParams: Record<string, Node> | undefined
219221
if (
220222
(resolved.type === 'TSTypeAliasDeclaration' ||
221223
resolved.type === 'TSInterfaceDeclaration') &&
222224
resolved.typeParameters &&
223225
node.typeParameters
224226
) {
227+
typeParams = Object.create(null)
225228
resolved.typeParameters.params.forEach((p, i) => {
226229
let param = typeParameters && typeParameters[p.name]
227230
if (!param) param = node.typeParameters!.params[i]
228-
typeParams[p.name] = param
231+
typeParams![p.name] = param
229232
})
230233
}
231234
return resolveTypeElements(
@@ -322,6 +325,7 @@ function typeElementsToMap(
322325
// capture generic parameters on node's scope
323326
if (typeParameters) {
324327
scope = createChildScope(scope)
328+
scope.isGenericScope = true
325329
Object.assign(scope.types, typeParameters)
326330
}
327331
;(e as MaybeWithScope)._ownerScope = scope
@@ -694,16 +698,18 @@ function resolveTypeReference(
694698
name?: string,
695699
onlyExported = false
696700
): ScopeTypeNode | undefined {
697-
if (node._resolvedReference) {
701+
const canCache = !scope?.isGenericScope
702+
if (canCache && node._resolvedReference) {
698703
return node._resolvedReference
699704
}
700-
return (node._resolvedReference = innerResolveTypeReference(
705+
const resolved = innerResolveTypeReference(
701706
ctx,
702707
scope || ctxToScope(ctx),
703708
name || getReferenceName(node),
704709
node,
705710
onlyExported
706-
))
711+
)
712+
return canCache ? (node._resolvedReference = resolved) : resolved
707713
}
708714

709715
function innerResolveTypeReference(

packages/runtime-dom/__tests__/customizedBuiltIn.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { type SpyInstance } from 'vitest'
1+
import { type MockInstance } from 'vitest'
22
import { render, h } from '@vue/runtime-dom'
33

44
describe('customized built-in elements support', () => {
5-
let createElement: SpyInstance
5+
let createElement: MockInstance
66
afterEach(() => {
77
createElement.mockRestore()
88
})

packages/vue-compat/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
},
3939
"homepage": "https://github.com/vuejs/core/tree/main/packages/vue-compat#readme",
4040
"dependencies": {
41-
"@babel/parser": "^7.23.5",
41+
"@babel/parser": "^7.23.6",
4242
"estree-walker": "^2.0.2",
4343
"source-map-js": "^1.0.2"
4444
},

0 commit comments

Comments
 (0)