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
12 changes: 9 additions & 3 deletions packages/language-core/lib/codegen/template/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export function createTemplateCodegenContext(
) {
let variableId = 0;

function resolveCodeFeatures(features: VueCodeInformation) {
function resolveCodeFeatures(features: VueCodeInformation): VueCodeInformation {
if (features.verification && stack.length) {
const data = stack[stack.length - 1]!;
if (data.ignoreError) {
Expand All @@ -133,8 +133,14 @@ export function createTemplateCodegenContext(
return {
...features,
verification: {
shouldReport: () => {
data.expectError!.token++;
shouldReport: (source, code) => {
if (
typeof features.verification !== 'object'
|| !features.verification.shouldReport
|| features.verification.shouldReport(source, code) === true
) {
data.expectError!.token++;
}
return false;
},
},
Expand Down
7 changes: 4 additions & 3 deletions packages/tsc/tests/typecheck.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ describe(`vue-tsc`, () => {
"test-workspace/tsc/failureFixtures/#4569/main.vue(1,41): error TS4025: Exported variable '__VLS_export' has or is using private name 'Props'.",
"test-workspace/tsc/failureFixtures/#5071/withScript.vue(1,19): error TS1005: ';' expected.",
"test-workspace/tsc/failureFixtures/#5071/withoutScript.vue(2,26): error TS1005: ';' expected.",
"test-workspace/tsc/failureFixtures/directives/main.vue(12,2): error TS2578: Unused '@ts-expect-error' directive.",
"test-workspace/tsc/failureFixtures/directives/main.vue(4,6): error TS2339: Property 'notExist' does not exist on type '{ exist: {}; $: ComponentInternalInstance; $data: {}; $props: {}; $attrs: Data; $refs: Data; $slots: Readonly<InternalSlots>; ... 8 more ...; $watch<T extends string | ((...args: any) => any)>(source: T, cb: T extends (...args: any) => infer R ? (args_0: R, args_1: R, args_2: OnCleanup) => any : (args_0: any, args_1...'.",
"test-workspace/tsc/failureFixtures/directives/main.vue(9,6): error TS2339: Property 'notExist' does not exist on type '{ exist: {}; $: ComponentInternalInstance; $data: {}; $props: {}; $attrs: Data; $refs: Data; $slots: Readonly<InternalSlots>; ... 8 more ...; $watch<T extends string | ((...args: any) => any)>(source: T, cb: T extends (...args: any) => infer R ? (args_0: R, args_1: R, args_2: OnCleanup) => any : (args_0: any, args_1...'.",
"test-workspace/tsc/failureFixtures/directives/main.vue(14,6): error TS2339: Property 'notExist' does not exist on type '{ exist: {}; Comp: () => void; $: ComponentInternalInstance; $data: {}; $props: {}; $attrs: Data; $refs: Data; $slots: Readonly<InternalSlots>; ... 8 more ...; $watch<T extends string | ((...args: any) => any)>(source: T, cb: T extends (...args: any) => infer R ? (args_0: R, args_1: R, args_2: OnCleanup) => any : (a...'.",
"test-workspace/tsc/failureFixtures/directives/main.vue(17,2): error TS2578: Unused '@ts-expect-error' directive.",
"test-workspace/tsc/failureFixtures/directives/main.vue(20,2): error TS2578: Unused '@ts-expect-error' directive.",
"test-workspace/tsc/failureFixtures/directives/main.vue(9,6): error TS2339: Property 'notExist' does not exist on type '{ exist: {}; Comp: () => void; $: ComponentInternalInstance; $data: {}; $props: {}; $attrs: Data; $refs: Data; $slots: Readonly<InternalSlots>; ... 8 more ...; $watch<T extends string | ((...args: any) => any)>(source: T, cb: T extends (...args: any) => infer R ? (args_0: R, args_1: R, args_2: OnCleanup) => any : (a...'.",
]
`);
});
Expand Down
12 changes: 8 additions & 4 deletions test-workspace/tsc/failureFixtures/directives/main.vue
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
<script setup lang="ts">
const exist = {};
const Comp = () => {};
</script>

<template>
<!-- @vue-ignore -->
<div v-if="true">
Expand All @@ -11,8 +16,7 @@

<!-- @vue-expect-error -->
<div v-bind="exist"></div>
</template>

<script setup lang="ts">
const exist = {};
</script>
<!-- @vue-expect-error -->
<Comp unknown="foo" />
</template>
Loading