What happened?
When using defineField or any typed path API with bracket notation for array access (e.g., items[0].name), the PathValue type incorrectly resolves to never instead of the actual type.
The path is correctly accepted as valid (autocomplete works), but the return type is wrong.
Expected:
const [name] = defineField('items[0].name'); // name should be Ref<string>
Actual:
const [name] = defineField('items[0].name'); // name is Ref<never>
This happens because PathValue in types/paths.ts doesn't handle the key[index] pattern (e.g., items[0]) - it only handles dot notation (items.0).
Reproduction steps
- Create a form with a typed array field:
interface MyForm {
items: { name: string }[];
}
const { defineField } = useForm<MyForm>();
- Use
defineField with bracket notation:
const [itemName] = defineField('items[0].name');
-
Hover over itemName - it shows Ref<never> instead of Ref<string>
-
The same issue occurs with items[0] (should be { name: string }, but returns never)
Version
Vue.js 3.x and vee-validate 4.x
What browsers are you seeing the problem on?
Relevant log output
Code of Conduct
Additional context
I've identified the root cause in packages/vee-validate/src/types/paths.ts - the PathValue type doesn't parse the key[index] bracket notation pattern. I have a fix ready and would be happy to submit a PR if this issue is confirmed.
What happened?
When using
defineFieldor any typed path API with bracket notation for array access (e.g.,items[0].name), thePathValuetype incorrectly resolves toneverinstead of the actual type.The path is correctly accepted as valid (autocomplete works), but the return type is wrong.
Expected:
Actual:
This happens because
PathValueintypes/paths.tsdoesn't handle thekey[index]pattern (e.g.,items[0]) - it only handles dot notation (items.0).Reproduction steps
defineFieldwith bracket notation:Hover over
itemName- it showsRef<never>instead ofRef<string>The same issue occurs with
items[0](should be{ name: string }, but returnsnever)Version
Vue.js 3.x and vee-validate 4.x
What browsers are you seeing the problem on?
Relevant log output
Code of Conduct
Additional context
I've identified the root cause in
packages/vee-validate/src/types/paths.ts- thePathValuetype doesn't parse thekey[index]bracket notation pattern. I have a fix ready and would be happy to submit a PR if this issue is confirmed.