Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"@types/estree": "^0.0.42",
"@types/jest": "^24.9.1",
"@types/node": "12.12.35",
"@vue/compiler-sfc": "^3.0.0-beta.20",
"@vue/compiler-sfc": "^3.0.0-rc.5",
"babel-jest": "^25.2.3",
"babel-preset-jest": "^25.2.1",
"dom-event-types": "^1.0.0",
Expand All @@ -38,7 +38,7 @@
"ts-jest": "^25.0.0",
"tsd": "0.11.0",
"typescript": "^3.7.5",
"vue": "^3.0.0-beta.20",
"vue": "^3.0.0-rc.5",
"vue-jest": "vuejs/vue-jest#next",
"vue-router": "^4.0.0-alpha.14",
"vuex": "^4.0.0-beta.1"
Expand Down
2 changes: 1 addition & 1 deletion src/utils/find.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function matches(node: VNode, selector: FindAllComponentsSelector): boolean {

// if a name is missing, then check the locally registered components in the parent
if (node.component.parent) {
const registry = (node.component.parent as any).components
const registry = (node.component.parent as any).type.components
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, do we need a check to see if type is not null?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question but it is not marked as nullable in the TS definition of ComponentInternalInstance, so I think we're good (but I do agree we would feel safer if we had strict: true)

for (const key in registry) {
// is it the selector
if (!selectorName && registry[key] === selector) {
Expand Down
15 changes: 7 additions & 8 deletions test-dts/mount.d-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const AppWithDefine = defineComponent({
template: ''
})

// accept props- vm is properly typed
// accept props - vm is properly typed
expectType<string>(
mount(AppWithDefine, {
props: { a: 'Hello', b: 2 }
Expand All @@ -31,13 +31,12 @@ expectError(
})
)

// can receive extra props
// ideally, it should not
// but the props have type { a: string } & VNodeProps
// which allows any property
mount(AppWithDefine, {
props: { a: 'Hello', c: 2 }
})
// can not receive extra props
expectError(
mount(AppWithDefine, {
props: { a: 'Hello', c: 2 }
})
)

// wrong prop type should not compile
expectError(
Expand Down
13 changes: 6 additions & 7 deletions test-dts/shallowMount.d-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,12 @@ let wrapper = shallowMount(AppWithDefine, {
// vm is properly typed
expectType<string>(wrapper.vm.a)

// can receive extra props
// ideally, it should not
// but the props have type { a: string } & VNodeProps
// which allows any property
shallowMount(AppWithDefine, {
props: { a: 'Hello', c: 2 }
})
// can not receive extra props
expectError(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

shallowMount(AppWithDefine, {
props: { a: 'Hello', c: 2 }
})
)

// wrong prop type should not compile
expectError(
Expand Down
1 change: 0 additions & 1 deletion tests/features/async-components.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { defineAsyncComponent, defineComponent, h, AppConfig } from 'vue'
import { mount, flushPromises } from '../../src'

const config: AppConfig = {
devtools: false,
optionMergeStrategies: {},
globalProperties: {},
isCustomElement: (tag: string) => false,
Expand Down
7 changes: 3 additions & 4 deletions tests/mountingOptions/props.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,11 @@ describe('mountingOptions.props', () => {
})

test('assigns extra properties as attributes on components', () => {
// the recommended way is to use `attrs` though
// and ideally it should not even compile, but props is too loosely typed
// for components defined with `defineComponent`
const wrapper = mount(Component, {
props: {
message: 'Hello World',
message: 'Hello World'
},
attrs: {
class: 'HelloFromTheOtherSide',
id: 'hello',
disabled: true
Expand Down
155 changes: 89 additions & 66 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,11 @@
dependencies:
"@babel/types" "^7.8.3"

"@babel/helper-validator-identifier@^7.10.4":
version "7.10.4"
resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.10.4.tgz#a78c7a7251e01f616512d31b10adcf52ada5e0d2"
integrity sha512-3U9y+43hz7ZM+rzG24Qe2mufW5KhvFg/NhnNph+i9mgCtdTCtMJuI1TMkrIUiK7Ix4PYlRF9I5dhqaLYA/ADXw==

"@babel/helper-validator-identifier@^7.9.0", "@babel/helper-validator-identifier@^7.9.5":
version "7.9.5"
resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.9.5.tgz#90977a8e6fbf6b431a7dc31752eee233bf052d80"
Expand Down Expand Up @@ -245,6 +250,11 @@
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.9.4.tgz#68a35e6b0319bbc014465be43828300113f2f2e8"
integrity sha512-bC49otXX6N0/VYhgOMh4gnP26E9xnDZK3TmbNpxYzzz9BQLBosQwfyOe9/cXUU3txYhTzLCbcqd5c8y/OmCjHA==

"@babel/parser@^7.10.4":
version "7.10.5"
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.10.5.tgz#e7c6bf5a7deff957cec9f04b551e2762909d826b"
integrity sha512-wfryxy4bE1UivvQKSQDU4/X6dr+i8bctjUjj8Zyt3DQy7NtPizJXT8M52nqpNKL+nq2PW8lxk4ZqLj0fD4B4hQ==

"@babel/plugin-proposal-async-generator-functions@^7.8.3":
version "7.8.3"
resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-async-generator-functions/-/plugin-proposal-async-generator-functions-7.8.3.tgz#bad329c670b382589721b27540c7d288601c6e6f"
Expand Down Expand Up @@ -764,6 +774,15 @@
lodash "^4.17.13"
to-fast-properties "^2.0.0"

"@babel/types@^7.10.4":
version "7.10.5"
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.10.5.tgz#d88ae7e2fde86bfbfe851d4d81afa70a997b5d15"
integrity sha512-ixV66KWfCI6GKoA/2H9v6bQdbfXEwwpOdQ8cRvb4F+eyvhlaHxWFMQB4+3d9QFJXZsiiiqVrewNV0DFEQpyT4Q==
dependencies:
"@babel/helper-validator-identifier" "^7.10.4"
lodash "^4.17.19"
to-fast-properties "^2.0.0"

"@bcoe/v8-coverage@^0.2.3":
version "0.2.3"
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
Expand Down Expand Up @@ -1188,79 +1207,83 @@
dependencies:
"@types/yargs-parser" "*"

"@vue/compiler-core@3.0.0-beta.20":
version "3.0.0-beta.20"
resolved "https://registry.yarnpkg.com/@vue/compiler-core/-/compiler-core-3.0.0-beta.20.tgz#66c085e23d5420088074bec73291fbd8151caff3"
integrity sha512-ZMMMD4GMZXrwJFBzdn3v+VcrrGofqrP7gfJ5ie/3p2sIEVAfsI0qwIb/DCezWt/Cm3viMJiTpv4SINPGK4xM8Q==
"@vue/compiler-core@3.0.0-rc.5":
version "3.0.0-rc.5"
resolved "https://registry.yarnpkg.com/@vue/compiler-core/-/compiler-core-3.0.0-rc.5.tgz#dd4f1816fcae34a81bc60e584f97993cad284d54"
integrity sha512-dNz5AObEYg0Oglw3emIsBhTAOVfObrfxDaAzR0UTRDDq+Ohfr6KTSaVQAH88Ym+oa08ZlLZBFc6ARe9doAOIxg==
dependencies:
"@babel/parser" "^7.8.6"
"@babel/types" "^7.8.6"
"@vue/shared" "3.0.0-beta.20"
estree-walker "^0.8.1"
"@babel/parser" "^7.10.4"
"@babel/types" "^7.10.4"
"@vue/shared" "3.0.0-rc.5"
estree-walker "^2.0.1"
source-map "^0.6.1"

"@vue/compiler-dom@3.0.0-beta.20":
version "3.0.0-beta.20"
resolved "https://registry.yarnpkg.com/@vue/compiler-dom/-/compiler-dom-3.0.0-beta.20.tgz#9d305d566da28222db4a0f7cd349e3e603a42872"
integrity sha512-vtkvL8OOcIMdZn8oLKTVRqKLcpRBivhR6xz2sS8mfRA+NNh+QDpBFip5Zjl//FD6mRvv2wiJoWWqe0MgXUChbg==
dependencies:
"@vue/compiler-core" "3.0.0-beta.20"
"@vue/shared" "3.0.0-beta.20"

"@vue/compiler-sfc@^3.0.0-beta.20":
version "3.0.0-beta.20"
resolved "https://registry.yarnpkg.com/@vue/compiler-sfc/-/compiler-sfc-3.0.0-beta.20.tgz#8ffe1a31e709713708fb625cae62e7efdae90b14"
integrity sha512-n5bNvZCxvzGJqH2EXsurmzJDHnimOi93ezoeJTOguqNG2XYiiN+IOwzoOy+eYGem945FtKcgvawPhUMr5vPFug==
dependencies:
"@vue/compiler-core" "3.0.0-beta.20"
"@vue/compiler-dom" "3.0.0-beta.20"
"@vue/compiler-ssr" "3.0.0-beta.20"
"@vue/shared" "3.0.0-beta.20"
"@vue/compiler-dom@3.0.0-rc.5":
version "3.0.0-rc.5"
resolved "https://registry.yarnpkg.com/@vue/compiler-dom/-/compiler-dom-3.0.0-rc.5.tgz#83905e8601123a3654b90fbd80708a16530ce21a"
integrity sha512-z8n+R1GhFnWuKURLYxfVSEfP7nSNM91qteobxwys55fhlZZuReouMnUwgrn+ois/IL6RdFlT9H+n4+N6yLrdJA==
dependencies:
"@vue/compiler-core" "3.0.0-rc.5"
"@vue/shared" "3.0.0-rc.5"

"@vue/compiler-sfc@^3.0.0-rc.5":
version "3.0.0-rc.5"
resolved "https://registry.yarnpkg.com/@vue/compiler-sfc/-/compiler-sfc-3.0.0-rc.5.tgz#374e52a6fbf8fb9aee1213026050a0f1c496fecf"
integrity sha512-huoIFEfFCJxHcpoByAUQti7CIwJdHPLJXKuy2HG7J1B+IEKugtBdF50CLH35ZD8dWM0nyOMFFqTbO7i6CCjL3Q==
dependencies:
"@babel/parser" "^7.10.4"
"@babel/types" "^7.10.4"
"@vue/compiler-core" "3.0.0-rc.5"
"@vue/compiler-dom" "3.0.0-rc.5"
"@vue/compiler-ssr" "3.0.0-rc.5"
"@vue/shared" "3.0.0-rc.5"
consolidate "^0.15.1"
estree-walker "^2.0.1"
hash-sum "^2.0.0"
lru-cache "^5.1.1"
magic-string "^0.25.7"
merge-source-map "^1.1.0"
postcss "^7.0.27"
postcss-modules "^3.1.0"
postcss-selector-parser "^6.0.2"
source-map "^0.6.1"

"@vue/compiler-ssr@3.0.0-beta.20":
version "3.0.0-beta.20"
resolved "https://registry.yarnpkg.com/@vue/compiler-ssr/-/compiler-ssr-3.0.0-beta.20.tgz#f605836a09b9bcd3ca66193e4984081aa1408825"
integrity sha512-j2XS2NX/skYxuMPG4T4sk3JUm4LYmonGNBXT5YWUX8G8+KlVTI7/9iPg+8FhZR2jIerhzHj/34MSKxytTItffA==
"@vue/compiler-ssr@3.0.0-rc.5":
version "3.0.0-rc.5"
resolved "https://registry.yarnpkg.com/@vue/compiler-ssr/-/compiler-ssr-3.0.0-rc.5.tgz#878406c59daff362ecdcb199fb9467a769ca8de5"
integrity sha512-OU5Vl2+bCDMImS9OeCVnl4lfxZ3/sopdwX2SrUWVKQvCxmmmlyWvoVkC6nNGCs/MrOmIMhKmL6etgzLTWyCkUg==
dependencies:
"@vue/compiler-dom" "3.0.0-beta.20"
"@vue/shared" "3.0.0-beta.20"
"@vue/compiler-dom" "3.0.0-rc.5"
"@vue/shared" "3.0.0-rc.5"

"@vue/reactivity@3.0.0-beta.20":
version "3.0.0-beta.20"
resolved "https://registry.yarnpkg.com/@vue/reactivity/-/reactivity-3.0.0-beta.20.tgz#8a16f089394a29a8509e4c8e515f5ec84b26cc13"
integrity sha512-X59+ZENE1sFRW56vcyb3eTGwqGwRpBJIkau0/NMv86hBbtWUigG4+r4thoCNKQAX3iyMQBlk5dQvxUxopjn5pg==
"@vue/reactivity@3.0.0-rc.5":
version "3.0.0-rc.5"
resolved "https://registry.yarnpkg.com/@vue/reactivity/-/reactivity-3.0.0-rc.5.tgz#45cff8d839d7ad130b1e499239090050fdecff13"
integrity sha512-oe9C+1jtWUdYL/iNc0OPWbwgOk2rOW2uQ+exx3I6Jo6PKOmnAiPkMElalf9vRnO53rnUphVecMp8BlTJvcNgDw==
dependencies:
"@vue/shared" "3.0.0-beta.20"
"@vue/shared" "3.0.0-rc.5"

"@vue/runtime-core@3.0.0-beta.20":
version "3.0.0-beta.20"
resolved "https://registry.yarnpkg.com/@vue/runtime-core/-/runtime-core-3.0.0-beta.20.tgz#33d090a18ae86899ffdc571e19cfa8a5523b4a4f"
integrity sha512-X5mM44vKVi9YC963McJ2m3siKdAAXS0s+LaWnnVH4IjkrlJFcaqQBMhfkJt8mI2SCv5tICBDgmIIkIkJzZ2tTw==
"@vue/runtime-core@3.0.0-rc.5":
version "3.0.0-rc.5"
resolved "https://registry.yarnpkg.com/@vue/runtime-core/-/runtime-core-3.0.0-rc.5.tgz#dd59af3a5fc089d1cdc05a657320c0dc17e5c362"
integrity sha512-MRIWreFigxdRuI2moFociUL5rVBfgYPrT7rWfQ0XfOyW46b+AiuCJyZvgbsRXwkAERfW1Tb/mY5forYjX2thOg==
dependencies:
"@vue/reactivity" "3.0.0-beta.20"
"@vue/shared" "3.0.0-beta.20"
"@vue/reactivity" "3.0.0-rc.5"
"@vue/shared" "3.0.0-rc.5"

"@vue/runtime-dom@3.0.0-beta.20":
version "3.0.0-beta.20"
resolved "https://registry.yarnpkg.com/@vue/runtime-dom/-/runtime-dom-3.0.0-beta.20.tgz#7588341e7304ae5a695ea1dd86bbe86c8df96e55"
integrity sha512-L8G9O34TuUUWMA06kZBSGfc44vHPpy+d3K8bM5qXiocdSCyjvikb9McXJsTZesLZZksRAyr1G05u/ikxCERCWQ==
"@vue/runtime-dom@3.0.0-rc.5":
version "3.0.0-rc.5"
resolved "https://registry.yarnpkg.com/@vue/runtime-dom/-/runtime-dom-3.0.0-rc.5.tgz#2fd75a1f29b23abf0ffe5ccdedabda11721c5b5b"
integrity sha512-0jwpO3MBqMToq7qC816Z8Y6G8aN4ZKbv7MupgRaepzxhiK0sXcjLQmOATP3g/NyX52UCBJS4wAwsxidqGnAabA==
dependencies:
"@vue/runtime-core" "3.0.0-beta.20"
"@vue/shared" "3.0.0-beta.20"
"@vue/runtime-core" "3.0.0-rc.5"
"@vue/shared" "3.0.0-rc.5"
csstype "^2.6.8"

"@vue/shared@3.0.0-beta.20":
version "3.0.0-beta.20"
resolved "https://registry.yarnpkg.com/@vue/shared/-/shared-3.0.0-beta.20.tgz#022b7aac09669d6ca79ff2cd38418853b2ffc8be"
integrity sha512-Ttuh2Kib8aelCm0J0M31z7ajHYWI3DOj59sbAh8ZuwIn8l5sKUmDUkxry2n3gYJ5s3uV3xhFCLQs1THtsg1/qA==
"@vue/shared@3.0.0-rc.5":
version "3.0.0-rc.5"
resolved "https://registry.yarnpkg.com/@vue/shared/-/shared-3.0.0-rc.5.tgz#cea2378e3e37363ddc1f5dd158edc9c9b5b3fff0"
integrity sha512-ZhcgGzBpp+pUzisZgQpM4ctIGgLpYjBj7/rZfbhEPxFHF/BuTV2jmhXvAl8aF9xDAejIcw85xCy92gDSwKtPag==

abab@^2.0.0, abab@^2.0.3:
version "2.0.3"
Expand Down Expand Up @@ -2310,16 +2333,16 @@ estree-walker@^0.6.1:
resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-0.6.1.tgz#53049143f40c6eb918b23671d1fe3219f3a1b362"
integrity sha512-SqmZANLWS0mnatqbSfRP5g8OXZC12Fgg1IwNtLsyHDzJizORW4khDfjPqJZsemPWBB2uqykUah5YpQ6epsqC/w==

estree-walker@^0.8.1:
version "0.8.1"
resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-0.8.1.tgz#6230ce2ec9a5cb03888afcaf295f97d90aa52b79"
integrity sha512-H6cJORkqvrNziu0KX2hqOMAlA2CiuAxHeGJXSIoKA/KLv229Dw806J3II6mKTm5xiDX1At1EXCfsOQPB+tMB+g==

estree-walker@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-1.0.1.tgz#31bc5d612c96b704106b477e6dd5d8aa138cb700"
integrity sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg==

estree-walker@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-2.0.1.tgz#f8e030fb21cefa183b44b7ad516b747434e7a3e0"
integrity sha512-tF0hv+Yi2Ot1cwj9eYHtxC0jB9bmjacjQs6ZBTj82H8JwUywFuc+7E83NWfNMwHXZc11mjfFcVXPe9gEP4B8dg==

esutils@^2.0.2:
version "2.0.3"
resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64"
Expand Down Expand Up @@ -3983,7 +4006,7 @@ lodash.sortby@^4.7.0:
resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438"
integrity sha1-7dFMgk4sycHgsKG0K7UhBRakJDg=

lodash@^4.17.13, lodash@^4.17.15:
lodash@^4.17.13, lodash@^4.17.15, lodash@^4.17.19:
version "4.17.19"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.19.tgz#e48ddedbe30b3321783c5b4301fbd353bc1e4a4b"
integrity sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ==
Expand Down Expand Up @@ -4060,7 +4083,7 @@ lru-cache@^5.1.1:
dependencies:
yallist "^3.0.2"

magic-string@^0.25.2, magic-string@^0.25.5:
magic-string@^0.25.2, magic-string@^0.25.5, magic-string@^0.25.7:
version "0.25.7"
resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.25.7.tgz#3f497d6fd34c669c6798dcb821f2ef31f5445051"
integrity sha512-4CrMT5DOHTDk4HYDlzmwu4FVCcIYI8gauveasrdCu2IKIFOJ3f0v/8MDGJCDL9oD2ppz/Av1b0Nj345H9M+XIA==
Expand Down Expand Up @@ -5945,14 +5968,14 @@ vue-router@^4.0.0-alpha.14:
resolved "https://registry.yarnpkg.com/vue-router/-/vue-router-4.0.0-alpha.14.tgz#4bc5fed1db61b8d04fd95ad9c499c7428f039a0e"
integrity sha512-ydWSXxXAsTCiJ31V4x4ZAKI1CdpPMhf7b2LPi4AmG5SCgduu1zf+LhzWWHXmgbmheEiJpfecigVIZp4ABpZJmw==

vue@^3.0.0-beta.20:
version "3.0.0-beta.20"
resolved "https://registry.yarnpkg.com/vue/-/vue-3.0.0-beta.20.tgz#34a7907cfbdc65b6b8c61fb4d7656f4aa6bf1fff"
integrity sha512-JmfvMwZQ/bsEF5YBDdYqZzpp4M8dSninyGxG2bHUlpS4Y66X/pduw2GpGE61xxgfrp2KM5cI9ryRpsNHrsf9HA==
vue@^3.0.0-rc.5:
version "3.0.0-rc.5"
resolved "https://registry.yarnpkg.com/vue/-/vue-3.0.0-rc.5.tgz#973175d45a892b3bd23ef5de7faa4add9c66275f"
integrity sha512-8t8Y4sHMBGD5iLZ7JfBGmKBJlzesPoL+/nW9EV8s+4LwnKC4rGlRp+Lj2rcign4iQaj0GFaL7DrQ8IoOfVX6+w==
dependencies:
"@vue/compiler-dom" "3.0.0-beta.20"
"@vue/runtime-dom" "3.0.0-beta.20"
"@vue/shared" "3.0.0-beta.20"
"@vue/compiler-dom" "3.0.0-rc.5"
"@vue/runtime-dom" "3.0.0-rc.5"
"@vue/shared" "3.0.0-rc.5"

vuex@^4.0.0-beta.1:
version "4.0.0-beta.1"
Expand Down