diff --git a/packages/language-core/lib/codegen/template/context.ts b/packages/language-core/lib/codegen/template/context.ts index 0ff9e4b016..c6b5d90c48 100644 --- a/packages/language-core/lib/codegen/template/context.ts +++ b/packages/language-core/lib/codegen/template/context.ts @@ -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) { @@ -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; }, }, diff --git a/packages/tsc/tests/typecheck.spec.ts b/packages/tsc/tests/typecheck.spec.ts index 198591bac1..6433e8f6dd 100644 --- a/packages/tsc/tests/typecheck.spec.ts +++ b/packages/tsc/tests/typecheck.spec.ts @@ -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; ... 8 more ...; $watch 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; ... 8 more ...; $watch 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; ... 8 more ...; $watch 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; ... 8 more ...; $watch any)>(source: T, cb: T extends (...args: any) => infer R ? (args_0: R, args_1: R, args_2: OnCleanup) => any : (a...'.", ] `); }); diff --git a/test-workspace/tsc/failureFixtures/directives/main.vue b/test-workspace/tsc/failureFixtures/directives/main.vue index 2dcf19bfb7..44231eae31 100644 --- a/test-workspace/tsc/failureFixtures/directives/main.vue +++ b/test-workspace/tsc/failureFixtures/directives/main.vue @@ -1,3 +1,8 @@ + + - + + +