@marko/type-check 2.0.2 → 2.1.1
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/dist/cli.js +47 -8
- package/dist/run.d.ts +1 -0
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -49,7 +49,7 @@ var modulePartsReg = /^((?:@(?:[^/]+)\/)?(?:[^/]+))(.*)$/;
|
|
|
49
49
|
var isRemapExtensionReg = /\.ts$/;
|
|
50
50
|
var isSourceMapExtensionReg = /\.map$/;
|
|
51
51
|
var skipRemapExtensionsReg = /\.(?:[cm]?jsx?|json|marko|css|less|sass|scss|styl|stylus|pcss|postcss|sss|a?png|jpe?g|jfif|pipeg|pjp|gif|svg|ico|web[pm]|avif|mp4|ogg|mp3|wav|flac|aac|opus|woff2?|eot|[ot]tf|webmanifest|pdf|txt)$/;
|
|
52
|
-
var extractCache = /* @__PURE__ */ new
|
|
52
|
+
var extractCache = /* @__PURE__ */ new Map();
|
|
53
53
|
var requiredTSCompilerOptions = {
|
|
54
54
|
allowJs: true,
|
|
55
55
|
composite: true,
|
|
@@ -60,12 +60,47 @@ var requiredTSCompilerOptions = {
|
|
|
60
60
|
allowNonTsExtensions: true
|
|
61
61
|
};
|
|
62
62
|
function run(opts) {
|
|
63
|
+
var _a, _b;
|
|
63
64
|
const {
|
|
64
65
|
display = Display.codeframe,
|
|
65
66
|
project: configFile = findRootConfigFile("tsconfig.json") || findRootConfigFile("jsconfig.json")
|
|
66
67
|
} = opts;
|
|
67
|
-
if (!configFile)
|
|
68
|
+
if (!configFile) {
|
|
68
69
|
throw new Error("Could not find tsconfig.json or jsconfig.json");
|
|
70
|
+
}
|
|
71
|
+
if (opts.generateTrace) {
|
|
72
|
+
(_b = (_a = import_tsserverlibrary.default).startTracing) == null ? void 0 : _b.call(
|
|
73
|
+
_a,
|
|
74
|
+
"build",
|
|
75
|
+
import_path.default.resolve(opts.generateTrace),
|
|
76
|
+
configFile
|
|
77
|
+
);
|
|
78
|
+
const tracing = import_tsserverlibrary.default.tracing;
|
|
79
|
+
if (!tracing) {
|
|
80
|
+
throw new Error("generateTrace not available in TypeScript compiler.");
|
|
81
|
+
}
|
|
82
|
+
const { push } = tracing;
|
|
83
|
+
tracing.push = (phase, name, args2, separateBeginAndEnd) => {
|
|
84
|
+
if (args2 && typeof args2 === "object" && "pos" in args2 && typeof args2.pos === "number" && "end" in args2 && typeof args2.end === "number") {
|
|
85
|
+
const fileName = "path" in args2 ? args2.path : "fileName" in args2 ? args2.fileName : void 0;
|
|
86
|
+
if (typeof fileName === "string") {
|
|
87
|
+
const extracted = extractCache.get(getCanonicalFileName(fileName));
|
|
88
|
+
if (extracted) {
|
|
89
|
+
const sourceRange = extracted.sourceRangeAt(args2.pos, args2.end);
|
|
90
|
+
if (sourceRange) {
|
|
91
|
+
args2.pos = sourceRange.start;
|
|
92
|
+
args2.end = sourceRange.end;
|
|
93
|
+
} else {
|
|
94
|
+
args2.pos = args2.end = void 0;
|
|
95
|
+
}
|
|
96
|
+
args2.generatedPos = args2.pos;
|
|
97
|
+
args2.generatedEnd = args2.end;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return push.call(tracing, phase, name, args2, separateBeginAndEnd);
|
|
102
|
+
};
|
|
103
|
+
}
|
|
69
104
|
const formatSettings = import_tsserverlibrary.default.getDefaultFormatCodeSettings(
|
|
70
105
|
import_tsserverlibrary.default.sys.newLine
|
|
71
106
|
);
|
|
@@ -255,7 +290,7 @@ function run(opts) {
|
|
|
255
290
|
processor.getScriptKind(fileName)
|
|
256
291
|
);
|
|
257
292
|
sourceFile.version = import_crypto.default.createHash("md5").update(extractedCode).digest("hex");
|
|
258
|
-
extractCache.set(
|
|
293
|
+
extractCache.set(getCanonicalFileName(fileName), extracted);
|
|
259
294
|
return sourceFile;
|
|
260
295
|
}
|
|
261
296
|
return getSourceFile(
|
|
@@ -317,7 +352,7 @@ function run(opts) {
|
|
|
317
352
|
outFileName = fileName.slice(0, -inExt.length) + (isDts ? ".d" : "") + processorExt;
|
|
318
353
|
}
|
|
319
354
|
const extracted = extractCache.get(
|
|
320
|
-
|
|
355
|
+
getCanonicalFileName(sourceFile.fileName)
|
|
321
356
|
);
|
|
322
357
|
const printContext = {
|
|
323
358
|
extracted,
|
|
@@ -368,7 +403,7 @@ function run(opts) {
|
|
|
368
403
|
return ext ? processors[ext] : void 0;
|
|
369
404
|
};
|
|
370
405
|
solutionHost.getParsedCommandLine = (fileName) => {
|
|
371
|
-
var
|
|
406
|
+
var _a2, _b2;
|
|
372
407
|
const parsedCommandLine = import_tsserverlibrary.default.getParsedCommandLineOfConfigFile(
|
|
373
408
|
fileName,
|
|
374
409
|
requiredTSCompilerOptions,
|
|
@@ -385,7 +420,7 @@ function run(opts) {
|
|
|
385
420
|
if (!parsedCommandLine) return;
|
|
386
421
|
const finalRootNames = new Set(parsedCommandLine.fileNames);
|
|
387
422
|
for (const name in processors) {
|
|
388
|
-
const rootNames = (
|
|
423
|
+
const rootNames = (_b2 = (_a2 = processors[name]).getRootNames) == null ? void 0 : _b2.call(_a2);
|
|
389
424
|
if (rootNames) {
|
|
390
425
|
for (const rootName of rootNames) {
|
|
391
426
|
finalRootNames.add(rootName);
|
|
@@ -413,7 +448,9 @@ function reportDiagnostic(report, diag) {
|
|
|
413
448
|
let code = diag.file.text;
|
|
414
449
|
let loc = void 0;
|
|
415
450
|
if (diag.start !== void 0) {
|
|
416
|
-
const extracted = extractCache.get(
|
|
451
|
+
const extracted = extractCache.get(
|
|
452
|
+
getCanonicalFileName(diag.file.fileName)
|
|
453
|
+
);
|
|
417
454
|
if (extracted) {
|
|
418
455
|
loc = extracted.sourceLocationAt(
|
|
419
456
|
diag.start,
|
|
@@ -515,6 +552,7 @@ var args = (0, import_arg.default)(
|
|
|
515
552
|
{
|
|
516
553
|
"--project": String,
|
|
517
554
|
"--display": String,
|
|
555
|
+
"--generateTrace": String,
|
|
518
556
|
"--help": Boolean,
|
|
519
557
|
"--version": Boolean,
|
|
520
558
|
"-p": "--project",
|
|
@@ -575,6 +613,7 @@ For more information, visit ${import_kleur2.default.blue(
|
|
|
575
613
|
);
|
|
576
614
|
} else {
|
|
577
615
|
const {
|
|
616
|
+
"--generateTrace": generateTrace,
|
|
578
617
|
"--display": display = process.env.CI ? Display.condensed : Display.codeframe
|
|
579
618
|
} = args;
|
|
580
619
|
let { "--project": project } = args;
|
|
@@ -585,7 +624,7 @@ For more information, visit ${import_kleur2.default.blue(
|
|
|
585
624
|
}
|
|
586
625
|
}
|
|
587
626
|
checkDisplay(display);
|
|
588
|
-
run({ project, display });
|
|
627
|
+
run({ generateTrace, project, display });
|
|
589
628
|
}
|
|
590
629
|
function checkDisplay(display) {
|
|
591
630
|
if (display && Display[display] === void 0) {
|
package/dist/run.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@marko/type-check",
|
|
3
3
|
"description": "A CLI to type check Marko projects",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.1.1",
|
|
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.27.1",
|
|
8
8
|
"@luxass/strip-json-comments": "^1.4.0",
|
|
9
|
-
"@marko/language-tools": "^2.5.
|
|
9
|
+
"@marko/language-tools": "^2.5.28",
|
|
10
10
|
"arg": "^5.0.2",
|
|
11
11
|
"kleur": "^4.1.5",
|
|
12
12
|
"typescript": "^5.8.3"
|