Преглед на файлове

wip: warn work with v-for

daiwei преди 1 година
родител
ревизия
4dbcd896a1
променени са 3 файла, в които са добавени 8 реда и са изтрити 1 реда
  1. 1 1
      packages/compiler-core/src/ast.ts
  2. 2 0
      packages/compiler-core/src/errors.ts
  3. 5 0
      packages/compiler-core/src/transforms/vSkip.ts

+ 1 - 1
packages/compiler-core/src/ast.ts

@@ -556,7 +556,7 @@ export interface DynamicSlotFnProperty extends Property {
 export type BlockCodegenNode = VNodeCall | RenderSlotCall
 
 export interface IfConditionalExpression extends ConditionalExpression {
-  consequent: BlockCodegenNode | MemoExpression | ConditionalExpression
+  consequent: BlockCodegenNode | MemoExpression
   alternate: BlockCodegenNode | IfConditionalExpression | MemoExpression
 }
 

+ 2 - 0
packages/compiler-core/src/errors.ts

@@ -93,6 +93,7 @@ export enum ErrorCodes {
   X_V_SKIP_NO_EXPRESSION,
   X_V_SKIP_ON_TEMPLATE,
   X_V_SKIP_UNEXPECTED_SLOT,
+  X_V_SKIP_WITH_V_FOR,
 
   // generic errors
   X_PREFIX_ID_NOT_SUPPORTED,
@@ -185,6 +186,7 @@ export const errorMessages: Record<ErrorCodes, string> = {
   [ErrorCodes.X_V_SKIP_NO_EXPRESSION]: `v-skip is missing expression.`,
   [ErrorCodes.X_V_SKIP_ON_TEMPLATE]: `v-skip cannot be used on <template> or <slot> tags.`,
   [ErrorCodes.X_V_SKIP_UNEXPECTED_SLOT]: `v-skip directive requires the component to have a default slot without slot props`,
+  [ErrorCodes.X_V_SKIP_WITH_V_FOR]: `v-skip with v-for is not supported.`,
 
   // generic errors
   [ErrorCodes.X_PREFIX_ID_NOT_SUPPORTED]: `"prefixIdentifiers" option is not supported in this build of compiler.`,

+ 5 - 0
packages/compiler-core/src/transforms/vSkip.ts

@@ -15,6 +15,7 @@ import {
 import {
   ErrorCodes,
   createCompilerError,
+  findDir,
   findProp,
   isSlotOutlet,
   isTemplateNode,
@@ -32,6 +33,10 @@ export const transformSkip: NodeTransform = createStructuralDirectiveTransform(
       return
     }
 
+    if (findDir(node, 'for')) {
+      context.onWarn(createCompilerError(ErrorCodes.X_V_SKIP_WITH_V_FOR, loc))
+    }
+
     if (!dir.exp || !(dir.exp as SimpleExpressionNode).content.trim()) {
       context.onError(
         createCompilerError(ErrorCodes.X_V_SKIP_NO_EXPRESSION, loc),