The type error appeared after we added app.config.idPrefix in 3.5.0-alpha.3, due to an interesting constraint in TypeScript:
declare const x: {
a: boolean // required primitive type
b?: string // optional, different primitive type
}
declare var k: keyof typeof x
x[k] = true as any
// ^ type error!
However, this works:
declare const x: {
a: {} // required non-primitive type
b?: string // optional, different primitive type
}
declare var k: keyof typeof x
x[k] = true as any // somehow works
The code in test-utils was previously working because it was case 2. After app.config.idPrefix was added it became case 1.
I don't think Vue core needs to change anything as it's mostly a usage issue in test-utils. Not sure if there's even a good workaround for this. Maybe this case should just be // @ts-expect-error...
Discovered when running latest ecosystem-ci on
minor
branch in Vue core: https://github.com/vuejs/ecosystem-ci/actions/runs/10194241059/job/28200426892The relevant line here: https://github.com/vuejs/test-utils/blob/main/src/createInstance.ts#L263
The type error appeared after we added
app.config.idPrefix
in 3.5.0-alpha.3, due to an interesting constraint in TypeScript:However, this works:
The code in
test-utils
was previously working because it was case 2. Afterapp.config.idPrefix
was added it became case 1.I don't think Vue core needs to change anything as it's mostly a usage issue in
test-utils
. Not sure if there's even a good workaround for this. Maybe this case should just be// @ts-expect-error
...