@marko/type-check 1.0.6 → 1.0.7

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.
Files changed (2) hide show
  1. package/dist/cli.js +44 -37
  2. package/package.json +2 -2
package/dist/cli.js CHANGED
@@ -354,48 +354,55 @@ function run(opts) {
354
354
  );
355
355
  }
356
356
  function reportDiagnostic(report, diag) {
357
- if (diag.file && diag.start !== void 0) {
358
- const extracted = extractCache.get(diag.file);
357
+ const diagMessage = flattenDiagnosticMessage(
358
+ diag.messageText,
359
+ report.display,
360
+ report.formatSettings.newLineCharacter
361
+ );
362
+ if (diag.file) {
359
363
  let code = diag.file.text;
360
- let loc;
361
- if (extracted) {
362
- loc = extracted.sourceLocationAt(
363
- diag.start,
364
- diag.start + (diag.length || 0)
364
+ let loc = void 0;
365
+ if (diag.start !== void 0) {
366
+ const extracted = extractCache.get(diag.file);
367
+ if (extracted) {
368
+ loc = extracted.sourceLocationAt(
369
+ diag.start,
370
+ diag.start + (diag.length || 0)
371
+ );
372
+ code = extracted.parsed.code;
373
+ } else {
374
+ const start = import_tsserverlibrary.default.getLineAndCharacterOfPosition(diag.file, diag.start);
375
+ const end = diag.length ? import_tsserverlibrary.default.getLineAndCharacterOfPosition(
376
+ diag.file,
377
+ diag.start + diag.length
378
+ ) : start;
379
+ loc = {
380
+ start,
381
+ end
382
+ };
383
+ }
384
+ }
385
+ if (loc) {
386
+ report.out.push(
387
+ `${import_kleur.default.cyan(
388
+ import_path.default.relative(currentDirectory, diag.file.fileName)
389
+ )}:${import_kleur.default.yellow(loc.start.line + 1)}:${import_kleur.default.yellow(
390
+ loc.start.character + 1
391
+ )} - ${coloredDiagnosticCategory(diag.category)} ${import_kleur.default.dim(
392
+ `TS${diag.code}`
393
+ )}${report.formatSettings.newLineCharacter}${report.display === Display.codeframe ? report.formatSettings.newLineCharacter + formatCodeFrameMessage(code, loc, diagMessage) : diagMessage}`
365
394
  );
366
- code = extracted.parsed.code;
367
- if (!loc)
368
- return;
369
395
  } else {
370
- const start = import_tsserverlibrary.default.getLineAndCharacterOfPosition(diag.file, diag.start);
371
- const end = diag.length ? import_tsserverlibrary.default.getLineAndCharacterOfPosition(diag.file, diag.start + diag.length) : start;
372
- loc = {
373
- start,
374
- end
375
- };
396
+ report.out.push(
397
+ `${import_kleur.default.cyan(
398
+ import_path.default.relative(currentDirectory, diag.file.fileName)
399
+ )} - ${coloredDiagnosticCategory(diag.category)} ${import_kleur.default.dim(
400
+ `TS${diag.code}`
401
+ )}${report.formatSettings.newLineCharacter}${diagMessage}`
402
+ );
376
403
  }
377
- const diagMessage = flattenDiagnosticMessage(
378
- diag.messageText,
379
- report.display,
380
- report.formatSettings.newLineCharacter
381
- );
382
- report.out.push(
383
- `${import_kleur.default.cyan(
384
- import_path.default.relative(currentDirectory, diag.file.fileName)
385
- )}:${import_kleur.default.yellow(loc.start.line + 1)}:${import_kleur.default.yellow(
386
- loc.start.character + 1
387
- )} - ${coloredDiagnosticCategory(diag.category)} ${import_kleur.default.dim(
388
- `TS${diag.code}`
389
- )}${report.formatSettings.newLineCharacter}${report.display === Display.codeframe ? report.formatSettings.newLineCharacter + formatCodeFrameMessage(code, loc, diagMessage) : diagMessage}`
390
- );
391
404
  } else {
392
- report.out.push(
393
- flattenDiagnosticMessage(
394
- diag.messageText,
395
- report.display,
396
- report.formatSettings.newLineCharacter
397
- )
398
- );
405
+ report.out.push(diagMessage);
399
406
  }
400
407
  if (!report.hasErrors && diag.category === import_tsserverlibrary.default.DiagnosticCategory.Error) {
401
408
  report.hasErrors = true;
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@marko/type-check",
3
3
  "description": "A CLI to type check Marko projects",
4
- "version": "1.0.6",
4
+ "version": "1.0.7",
5
5
  "bugs": "https://github.com/marko-js/language-server/issues/new?template=Bug_report.md",
6
6
  "dependencies": {
7
7
  "@babel/code-frame": "^7.23.5",
8
- "@marko/language-tools": "^2.1.10",
8
+ "@marko/language-tools": "^2.1.11",
9
9
  "arg": "^5.0.2",
10
10
  "kleur": "^4.1.5",
11
11
  "strip-json-comments": "^3.1.1",