vue-tsc 0.35.0 → 0.36.0

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.
package/out/apis.js CHANGED
@@ -56,37 +56,38 @@ function register(ts, context) {
56
56
  }
57
57
  // transform
58
58
  function transformDiagnostics(diagnostics) {
59
- var _a, _b, _c;
59
+ var _a, _b, _c, _d, _e, _f, _g, _h;
60
60
  const result = [];
61
61
  for (const diagnostic of diagnostics) {
62
62
  if (diagnostic.file !== undefined
63
63
  && diagnostic.start !== undefined
64
64
  && diagnostic.length !== undefined) {
65
+ let founded = false;
65
66
  for (const tsOrVueLoc of context.vueFiles.fromEmbeddedLocation(diagnostic.file.fileName, diagnostic.start, diagnostic.start + diagnostic.length, data => !!data.capabilities.diagnostic)) {
66
67
  if (!((_b = (_a = context.vueLsHost).fileExists) === null || _b === void 0 ? void 0 : _b.call(_a, tsOrVueLoc.fileName)))
67
68
  continue;
68
- let file = tsOrVueLoc.fileName === diagnostic.file.fileName
69
- ? diagnostic.file
70
- : undefined;
71
- if (!file) {
72
- let docText = (_c = tsOrVueLoc.mapped) === null || _c === void 0 ? void 0 : _c.vueFile.getContent();
73
- if (docText === undefined) {
74
- const snapshot = context.vueLsHost.getScriptSnapshot(tsOrVueLoc.fileName);
75
- if (snapshot) {
76
- docText = snapshot.getText(0, snapshot.getLength());
77
- }
69
+ onMapping(diagnostic, tsOrVueLoc.fileName, tsOrVueLoc.range.start, tsOrVueLoc.range.end, (_c = tsOrVueLoc.mapped) === null || _c === void 0 ? void 0 : _c.vueFile.getContent());
70
+ founded = true;
71
+ break;
72
+ }
73
+ // fix https://github.com/johnsoncodehk/volar/issues/1372
74
+ if (!founded) {
75
+ for (const start of context.vueFiles.fromEmbeddedLocation(diagnostic.file.fileName, diagnostic.start, diagnostic.start, data => !!data.capabilities.diagnostic)) {
76
+ if (!((_e = (_d = context.vueLsHost).fileExists) === null || _e === void 0 ? void 0 : _e.call(_d, start.fileName)))
77
+ continue;
78
+ for (const end of context.vueFiles.fromEmbeddedLocation(diagnostic.file.fileName, diagnostic.start + diagnostic.length, diagnostic.start + diagnostic.length, data => !!data.capabilities.diagnostic)) {
79
+ if (!((_g = (_f = context.vueLsHost).fileExists) === null || _g === void 0 ? void 0 : _g.call(_f, end.fileName)))
80
+ continue;
81
+ if (start.fileName !== end.fileName)
82
+ continue;
83
+ onMapping(diagnostic, start.fileName, start.range.start, end.range.end, (_h = start.mapped) === null || _h === void 0 ? void 0 : _h.vueFile.getContent());
84
+ founded = true;
85
+ break;
78
86
  }
79
- else {
80
- file = ts.createSourceFile(tsOrVueLoc.fileName, docText, tsOrVueLoc.fileName.endsWith('.vue') ? ts.ScriptTarget.JSON : ts.ScriptTarget.Latest);
87
+ if (founded) {
88
+ break;
81
89
  }
82
90
  }
83
- const newDiagnostic = Object.assign(Object.assign({}, diagnostic), { file, start: tsOrVueLoc.range.start, length: tsOrVueLoc.range.end - tsOrVueLoc.range.start });
84
- const relatedInformation = diagnostic.relatedInformation;
85
- if (relatedInformation) {
86
- newDiagnostic.relatedInformation = transformDiagnostics(relatedInformation);
87
- }
88
- result.push(newDiagnostic);
89
- break;
90
91
  }
91
92
  }
92
93
  else if (diagnostic.file === undefined) {
@@ -94,6 +95,29 @@ function register(ts, context) {
94
95
  }
95
96
  }
96
97
  return result;
98
+ function onMapping(diagnostic, fileName, start, end, docText) {
99
+ var _a;
100
+ let file = fileName === ((_a = diagnostic.file) === null || _a === void 0 ? void 0 : _a.fileName)
101
+ ? diagnostic.file
102
+ : undefined;
103
+ if (!file) {
104
+ if (docText === undefined) {
105
+ const snapshot = context.vueLsHost.getScriptSnapshot(fileName);
106
+ if (snapshot) {
107
+ docText = snapshot.getText(0, snapshot.getLength());
108
+ }
109
+ }
110
+ else {
111
+ file = ts.createSourceFile(fileName, docText, fileName.endsWith('.vue') ? ts.ScriptTarget.JSON : ts.ScriptTarget.Latest);
112
+ }
113
+ }
114
+ const newDiagnostic = Object.assign(Object.assign({}, diagnostic), { file, start: start, length: end - start });
115
+ const relatedInformation = diagnostic.relatedInformation;
116
+ if (relatedInformation) {
117
+ newDiagnostic.relatedInformation = transformDiagnostics(relatedInformation);
118
+ }
119
+ result.push(newDiagnostic);
120
+ }
97
121
  }
98
122
  }
99
123
  exports.register = register;
package/out/proxy.js CHANGED
@@ -35,14 +35,14 @@ _options, _host, _oldProgram, _configFileParsingDiagnostics) {
35
35
  isVueTsc: true,
36
36
  });
37
37
  tsRuntime.update(); // must update before getProgram() to update virtual scripts
38
- const tsProgram = tsRuntime.getTsLs().getProgram();
39
- if (!tsProgram)
40
- throw '!tsProgram';
41
38
  const proxyApis = apis.register(ts, tsRuntime);
42
- const program = new Proxy(tsProgram, {
43
- get: (target, property) => {
39
+ const program = new Proxy({}, {
40
+ get: (_, property) => {
44
41
  tsRuntime.update();
45
- return proxyApis[property] || target[property];
42
+ if (property in proxyApis) {
43
+ return proxyApis[property];
44
+ }
45
+ return tsRuntime.getTsLs().getProgram()[property];
46
46
  },
47
47
  });
48
48
  program.__VLS_tsRuntime = tsRuntime;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-tsc",
3
- "version": "0.35.0",
3
+ "version": "0.36.0",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "bin",
@@ -16,10 +16,10 @@
16
16
  "vue-tsc": "./bin/vue-tsc.js"
17
17
  },
18
18
  "dependencies": {
19
- "@volar/vue-typescript": "0.35.0"
19
+ "@volar/vue-typescript": "0.36.0"
20
20
  },
21
21
  "peerDependencies": {
22
22
  "typescript": "*"
23
23
  },
24
- "gitHead": "463919892eb6419dfd9ffd55c910659faaeddc90"
24
+ "gitHead": "c1bb6990fd2433673923fbf55897a8bf91c03a6f"
25
25
  }