PathValue returns `never` for bracket notation array paths like `items[0].name`
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
defineFieldwith bracket notation:
const [itemName] = defineField('items[0].name');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?
- Firefox
- Chrome
- Safari
- Microsoft Edge
Relevant log output
Code of Conduct
- I agree to follow this project's 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.
Source: logaretm/vee-validate