@vue/language-core 2.0.10 → 2.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -68,7 +68,7 @@ function* generate(ts, compilerOptions, vueCompilerOptions, template, shouldGene
68
68
  if (expectErrorToken) {
69
69
  const token = expectErrorToken;
70
70
  const data = code[3];
71
- if (data.verification) {
71
+ if (data.verification && (typeof data.verification !== 'object' || !data.verification.shouldReport)) {
72
72
  code[3] = {
73
73
  ...data,
74
74
  verification: {
@@ -102,7 +102,6 @@ function* generate(ts, compilerOptions, vueCompilerOptions, template, shouldGene
102
102
  let hasSlot = false;
103
103
  let ignoreError = false;
104
104
  let expectErrorToken;
105
- let expectedErrorNode;
106
105
  let elementIndex = 0;
107
106
  if (slotsAssignName) {
108
107
  localVars.set(slotsAssignName, 1);
@@ -166,13 +165,13 @@ function* generate(ts, compilerOptions, vueCompilerOptions, template, shouldGene
166
165
  }
167
166
  return tagOffsetsMap;
168
167
  }
169
- function* generateExpectErrorComment() {
170
- if (expectErrorToken && expectedErrorNode) {
168
+ function* resetDirectiveComments(endStr) {
169
+ if (expectErrorToken) {
171
170
  const token = expectErrorToken;
172
171
  yield _ts([
173
172
  '',
174
173
  'template',
175
- expectedErrorNode.loc.start.offset,
174
+ expectErrorToken.node.loc.start.offset,
176
175
  (0, utils_1.disableAllFeatures)({
177
176
  verification: {
178
177
  shouldReport: () => token.errors === 0,
@@ -183,14 +182,17 @@ function* generate(ts, compilerOptions, vueCompilerOptions, template, shouldGene
183
182
  yield _ts([
184
183
  '',
185
184
  'template',
186
- expectedErrorNode.loc.end.offset,
185
+ expectErrorToken.node.loc.end.offset,
187
186
  (0, utils_1.disableAllFeatures)({ __combineLastMapping: true }),
188
187
  ]);
189
188
  yield _ts('\n;\n');
189
+ expectErrorToken = undefined;
190
+ yield _ts(`// @vue-expect-error ${endStr}\n`);
191
+ }
192
+ if (ignoreError) {
193
+ ignoreError = false;
194
+ yield _ts(`// @vue-ignore ${endStr}\n`);
190
195
  }
191
- ignoreError = false;
192
- expectErrorToken = undefined;
193
- expectedErrorNode = undefined;
194
196
  }
195
197
  function* generateCanonicalComponentName(tagText, offset, info) {
196
198
  if (validTsVarReg.test(tagText)) {
@@ -292,18 +294,22 @@ function* generate(ts, compilerOptions, vueCompilerOptions, template, shouldGene
292
294
  }
293
295
  }
294
296
  function* generateAstNode(node, parentEl, prevNode, componentCtxVar) {
295
- yield* generateExpectErrorComment();
296
297
  if (prevNode?.type === CompilerDOM.NodeTypes.COMMENT) {
297
298
  const commentText = prevNode.content.trim().split(' ')[0];
298
299
  if (commentText.match(/^@vue-skip\b[\s\S]*/)) {
300
+ yield _ts('// @vue-skip\n');
299
301
  return;
300
302
  }
301
- else if (commentText.match(/^@vue-ignore\b[\s\S]*/)) {
303
+ else if (commentText.match(/^@vue-ignore\b[\s\S]*/) && !ignoreError) {
302
304
  ignoreError = true;
305
+ yield _ts('// @vue-ignore start\n');
303
306
  }
304
- else if (commentText.match(/^@vue-expect-error\b[\s\S]*/)) {
305
- expectErrorToken = { errors: 0 };
306
- expectedErrorNode = prevNode;
307
+ else if (commentText.match(/^@vue-expect-error\b[\s\S]*/) && !expectErrorToken) {
308
+ expectErrorToken = {
309
+ errors: 0,
310
+ node: prevNode,
311
+ };
312
+ yield _ts('// @vue-expect-error start\n');
307
313
  }
308
314
  }
309
315
  if (node.type === CompilerDOM.NodeTypes.ROOT) {
@@ -312,7 +318,7 @@ function* generate(ts, compilerOptions, vueCompilerOptions, template, shouldGene
312
318
  yield* generateAstNode(childNode, parentEl, prev, componentCtxVar);
313
319
  prev = childNode;
314
320
  }
315
- yield* generateExpectErrorComment();
321
+ yield* resetDirectiveComments('end of root');
316
322
  }
317
323
  else if (node.type === CompilerDOM.NodeTypes.ELEMENT) {
318
324
  const vForNode = getVForNode(node);
@@ -343,6 +349,7 @@ function* generate(ts, compilerOptions, vueCompilerOptions, template, shouldGene
343
349
  // {{ ... }}
344
350
  const [content, start] = parseInterpolationNode(node, template.content);
345
351
  yield* generateInterpolation(content, node.content.loc, start, presetInfos.all, '(', ');\n');
352
+ yield* resetDirectiveComments('end of INTERPOLATION');
346
353
  }
347
354
  else if (node.type === CompilerDOM.NodeTypes.IF) {
348
355
  // v-if / v-else-if / v-else
@@ -374,16 +381,16 @@ function* generate(ts, compilerOptions, vueCompilerOptions, template, shouldGene
374
381
  yield _ts(` `);
375
382
  yield* generateInterpolation(branch.condition.content, branch.condition.loc, branch.condition.loc.start.offset, presetInfos.all, '(', ')');
376
383
  blockConditions.push((0, language_core_1.toString)([...generateInterpolation(branch.condition.content, branch.condition.loc, undefined, undefined, '(', ')')]
377
- .map(code => code[1])));
384
+ .map(([code]) => code)));
378
385
  addedBlockCondition = true;
379
386
  }
380
387
  yield _ts(` {\n`);
388
+ yield* resetDirectiveComments('end of v-if start');
381
389
  let prev;
382
390
  for (const childNode of branch.children) {
383
391
  yield* generateAstNode(childNode, parentEl, prev, componentCtxVar);
384
392
  prev = childNode;
385
393
  }
386
- yield* generateExpectErrorComment();
387
394
  yield* generateExtraAutoImport();
388
395
  yield _ts('}\n');
389
396
  if (addedBlockCondition) {
@@ -411,12 +418,12 @@ function* generate(ts, compilerOptions, vueCompilerOptions, template, shouldGene
411
418
  yield* generateInterpolation(source.content, source.loc, source.loc.start.offset, presetInfos.all, '(', ')');
412
419
  yield _ts('!)'); // #3102
413
420
  yield _ts(') {\n');
421
+ yield* resetDirectiveComments('end of v-for start');
414
422
  let prev;
415
423
  for (const childNode of node.children) {
416
424
  yield* generateAstNode(childNode, parentEl, prev, componentCtxVar);
417
425
  prev = childNode;
418
426
  }
419
- yield* generateExpectErrorComment();
420
427
  yield* generateExtraAutoImport();
421
428
  yield _ts('}\n');
422
429
  }
@@ -608,6 +615,7 @@ function* generate(ts, compilerOptions, vueCompilerOptions, template, shouldGene
608
615
  }
609
616
  const slotBlockVars = [];
610
617
  yield _ts(`{\n`);
618
+ yield* resetDirectiveComments('end of element slot start');
611
619
  let hasProps = false;
612
620
  if (slotDir?.exp?.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION) {
613
621
  const slotAst = createTsAst(ts, slotDir, `(${slotDir.exp.content}) => {}`);
@@ -658,8 +666,6 @@ function* generate(ts, compilerOptions, vueCompilerOptions, template, shouldGene
658
666
  yield* generateAstNode(childNode, parentEl, prev, componentCtxVar);
659
667
  prev = childNode;
660
668
  }
661
- yield* generateExpectErrorComment();
662
- yield* generateExtraAutoImport();
663
669
  slotBlockVars.forEach(varName => {
664
670
  localVars.set(varName, localVars.get(varName) - 1);
665
671
  });
@@ -680,15 +686,16 @@ function* generate(ts, compilerOptions, vueCompilerOptions, template, shouldGene
680
686
  ]);
681
687
  yield _ts(`'/* empty slot name completion */]\n`);
682
688
  }
689
+ yield* generateExtraAutoImport();
683
690
  yield _ts(`}\n`);
684
691
  }
685
692
  else {
693
+ yield* resetDirectiveComments('end of element children start');
686
694
  let prev;
687
695
  for (const childNode of node.children) {
688
696
  yield* generateAstNode(childNode, parentEl, prev, componentCtxVar);
689
697
  prev = childNode;
690
698
  }
691
- yield* generateExpectErrorComment();
692
699
  // fix https://github.com/vuejs/language-tools/issues/932
693
700
  if (!hasSlotElements.has(node) && node.children.length) {
694
701
  yield _ts(`(${componentCtxVar}.slots!).`);
@@ -1187,8 +1194,13 @@ function* generate(ts, compilerOptions, vueCompilerOptions, template, shouldGene
1187
1194
  }
1188
1195
  yield _ts('// @ts-ignore\n'); // #2304
1189
1196
  yield _ts('[');
1197
+ const visited = new Set();
1190
1198
  for (const _vars of tempVars) {
1191
1199
  for (const v of _vars) {
1200
+ if (visited.has(v.offset)) {
1201
+ continue;
1202
+ }
1203
+ visited.add(v.offset);
1192
1204
  yield _ts([
1193
1205
  v.text,
1194
1206
  'template',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/language-core",
3
- "version": "2.0.10",
3
+ "version": "2.0.11",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "**/*.js",
@@ -12,7 +12,7 @@
12
12
  "directory": "packages/language-core"
13
13
  },
14
14
  "dependencies": {
15
- "@volar/language-core": "~2.2.0-alpha.5",
15
+ "@volar/language-core": "~2.2.0-alpha.6",
16
16
  "@vue/compiler-dom": "^3.4.0",
17
17
  "@vue/shared": "^3.4.0",
18
18
  "computeds": "^0.0.1",
@@ -34,5 +34,5 @@
34
34
  "optional": true
35
35
  }
36
36
  },
37
- "gitHead": "a20a2ee950b63a949660b7e8faf0faed0e5bad33"
37
+ "gitHead": "c89f25ffc32c760130adeeac796b9a5d20585bf7"
38
38
  }