Skip to content

Commit

Permalink
fix: generate valid syntax when noPropertyAccessFromIndexSignature is…
Browse files Browse the repository at this point in the history
… not enabled (#3575)

Co-authored-by: Johnson Chu <johnsoncodehk@gmail.com>
  • Loading branch information
so1ve and johnsoncodehk committed Sep 20, 2023
1 parent a065fd7 commit 80b4782
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/vue-language-core/src/generators/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1000,7 +1000,7 @@ export function generate(
const eventVar = `__VLS_${elementIndex++}`;
codes.push(
`let ${eventVar} = { '${prop.arg.loc.source}': `,
`__VLS_pickEvent(${componentCtxVar}.emit!, '${prop.arg.loc.source}' as const, {} as __VLS_FunctionalComponentProps<typeof ${componentVar}, typeof ${componentInstanceVar}>`,
`__VLS_pickEvent(${componentCtxVar}.emit!, '${prop.arg.loc.source}' as const, ({} as __VLS_FunctionalComponentProps<typeof ${componentVar}, typeof ${componentInstanceVar}>)`,
...createPropertyAccessCode([
camelize('on-' + prop.arg.loc.source), // onClickOutside
'template',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<script lang="ts" setup>
defineEmits<{
(event: 'change', value: string): void
}>()
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<template>
<Comp @change="(value) => console.log(value)" />
<!-- ^^^^^ is inferred as `any` now, should be `string` -->
</template>

<script lang="ts" setup>
import Comp from './Comp.vue'
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "../tsconfig.json",
"include": [ "**/*" ],
"compilerOptions": {
"noPropertyAccessFromIndexSignature": false
}
}

0 comments on commit 80b4782

Please sign in to comment.