tstyche 3.1.1 → 3.2.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/build/tstyche.d.ts +5 -1
- package/build/tstyche.js +58 -21
- package/package.json +8 -8
package/build/tstyche.d.ts
CHANGED
|
@@ -152,6 +152,10 @@ declare class ConfigDiagnosticText {
|
|
|
152
152
|
* Options loaded from the configuration file.
|
|
153
153
|
*/
|
|
154
154
|
interface ConfigFileOptions {
|
|
155
|
+
/**
|
|
156
|
+
* Enable type error reporting for source files.
|
|
157
|
+
*/
|
|
158
|
+
checkSourceFiles?: boolean;
|
|
155
159
|
/**
|
|
156
160
|
* Stop running tests after the first failed assertion.
|
|
157
161
|
*/
|
|
@@ -867,4 +871,4 @@ declare class WatchService {
|
|
|
867
871
|
watch(cancellationToken: CancellationToken): AsyncIterable<Array<Task>>;
|
|
868
872
|
}
|
|
869
873
|
|
|
870
|
-
export { Assertion, BaseReporter, CancellationHandler, CancellationReason, CancellationToken, Cli, CollectService, Color, type CommandLineOptions, Config, ConfigDiagnosticText, type ConfigFileOptions, DescribeResult, Diagnostic, DiagnosticCategory, DiagnosticOrigin, type DiagnosticsHandler, type EnvironmentOptions, type Event, EventEmitter, type EventHandler, ExitCodeHandler, ExpectResult, ExpectService, type FileWatchHandler, FileWatcher, type InputHandler, InputService, type ItemDefinition, Line, ListReporter, type MatchResult, OptionBrand, type OptionDefinition, OptionGroup, Options, OutputService, Path, type Plugin, PluginService, ProjectResult, ProjectService, type Reporter, type ReporterEvent, type ResolvedConfig, Result, ResultCount, ResultHandler, ResultStatus, ResultTiming, Runner, Scribbler, ScribblerJsx, type ScribblerOptions, Select, SelectDiagnosticText, SetupReporter, SourceFile, Store, SummaryReporter, TargetResult, type TargetResultStatus, Task, TaskResult, type TaskResultStatus, TestMember, TestMemberBrand, TestMemberFlags, TestResult, TestTree, Text, type TypeChecker, Version, type WatchHandler, WatchReporter, WatchService, Watcher, type WatcherOptions, addsPackageText, defaultOptions, describeNameText, diagnosticText, environmentOptions, fileViewText, formattedText, helpText, summaryText, taskStatusText, testNameText, usesCompilerText, waitingForFileChangesText, watchUsageText };
|
|
874
|
+
export { Assertion, BaseReporter, CancellationHandler, CancellationReason, CancellationToken, Cli, CollectService, Color, type CommandLineOptions, Config, ConfigDiagnosticText, type ConfigFileOptions, DescribeResult, Diagnostic, DiagnosticCategory, DiagnosticOrigin, type DiagnosticsHandler, type EnvironmentOptions, type Event, EventEmitter, type EventHandler, ExitCodeHandler, ExpectResult, ExpectService, type FileWatchHandler, FileWatcher, type InputHandler, InputService, type ItemDefinition, Line, ListReporter, type MatchResult, OptionBrand, type OptionDefinition, OptionGroup, Options, OutputService, Path, type Plugin, PluginService, ProjectResult, ProjectService, type Reporter, type ReporterEvent, type ResolvedConfig, Result, ResultCount, ResultHandler, ResultStatus, ResultTiming, Runner, Scribbler, ScribblerJsx, type ScribblerOptions, Select, SelectDiagnosticText, type SelectHookContext, SetupReporter, SourceFile, Store, SummaryReporter, TargetResult, type TargetResultStatus, Task, TaskResult, type TaskResultStatus, TestMember, TestMemberBrand, TestMemberFlags, TestResult, TestTree, Text, type TypeChecker, Version, type WatchHandler, WatchReporter, WatchService, Watcher, type WatcherOptions, addsPackageText, defaultOptions, describeNameText, diagnosticText, environmentOptions, fileViewText, formattedText, helpText, summaryText, taskStatusText, testNameText, usesCompilerText, waitingForFileChangesText, watchUsageText };
|
package/build/tstyche.js
CHANGED
|
@@ -869,6 +869,12 @@ class Options {
|
|
|
869
869
|
group: 4,
|
|
870
870
|
name: "$schema",
|
|
871
871
|
},
|
|
872
|
+
{
|
|
873
|
+
brand: "boolean",
|
|
874
|
+
description: "Enable type error reporting for source files.",
|
|
875
|
+
group: 4,
|
|
876
|
+
name: "checkSourceFiles",
|
|
877
|
+
},
|
|
872
878
|
{
|
|
873
879
|
brand: "string",
|
|
874
880
|
description: "The path to a TSTyche configuration file.",
|
|
@@ -1474,6 +1480,7 @@ class ConfigFileParser {
|
|
|
1474
1480
|
}
|
|
1475
1481
|
|
|
1476
1482
|
const defaultOptions = {
|
|
1483
|
+
checkSourceFiles: false,
|
|
1477
1484
|
failFast: false,
|
|
1478
1485
|
plugins: [],
|
|
1479
1486
|
rejectAnyType: false,
|
|
@@ -2335,12 +2342,11 @@ class FileView {
|
|
|
2335
2342
|
}
|
|
2336
2343
|
|
|
2337
2344
|
class ListReporter extends BaseReporter {
|
|
2338
|
-
#currentCompilerVersion;
|
|
2339
|
-
#currentProjectConfigFilePath;
|
|
2340
2345
|
#fileCount = 0;
|
|
2341
2346
|
#fileView = new FileView();
|
|
2342
2347
|
#hasReportedAdds = false;
|
|
2343
2348
|
#hasReportedError = false;
|
|
2349
|
+
#hasReportedUses = false;
|
|
2344
2350
|
#isFileViewExpanded = false;
|
|
2345
2351
|
#seenDeprecations = new Set();
|
|
2346
2352
|
get #isLastFile() {
|
|
@@ -2371,21 +2377,14 @@ class ListReporter extends BaseReporter {
|
|
|
2371
2377
|
break;
|
|
2372
2378
|
case "target:start":
|
|
2373
2379
|
this.#fileCount = payload.result.tasks.length;
|
|
2374
|
-
|
|
2375
|
-
case "target:end":
|
|
2376
|
-
this.#currentCompilerVersion = undefined;
|
|
2377
|
-
this.#currentProjectConfigFilePath = undefined;
|
|
2380
|
+
this.#hasReportedUses = false;
|
|
2378
2381
|
break;
|
|
2379
2382
|
case "project:uses":
|
|
2380
|
-
|
|
2381
|
-
this.#
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
this.#hasReportedAdds = false;
|
|
2386
|
-
this.#currentCompilerVersion = payload.compilerVersion;
|
|
2387
|
-
this.#currentProjectConfigFilePath = payload.projectConfigFilePath;
|
|
2388
|
-
}
|
|
2383
|
+
OutputService.writeMessage(usesCompilerText(payload.compilerVersion, payload.projectConfigFilePath, {
|
|
2384
|
+
prependEmptyLine: this.#hasReportedUses && !this.#hasReportedAdds && !this.#hasReportedError,
|
|
2385
|
+
}));
|
|
2386
|
+
this.#hasReportedAdds = false;
|
|
2387
|
+
this.#hasReportedUses = true;
|
|
2389
2388
|
break;
|
|
2390
2389
|
case "project:error":
|
|
2391
2390
|
for (const diagnostic of payload.diagnostics) {
|
|
@@ -3162,7 +3161,9 @@ var TestMemberFlags;
|
|
|
3162
3161
|
|
|
3163
3162
|
class ProjectService {
|
|
3164
3163
|
#compiler;
|
|
3164
|
+
#lastSeenProject = "";
|
|
3165
3165
|
#resolvedConfig;
|
|
3166
|
+
#seenPrograms = new WeakSet();
|
|
3166
3167
|
#service;
|
|
3167
3168
|
constructor(resolvedConfig, compiler) {
|
|
3168
3169
|
this.#resolvedConfig = resolvedConfig;
|
|
@@ -3237,7 +3238,12 @@ class ProjectService {
|
|
|
3237
3238
|
return defaultCompilerOptions;
|
|
3238
3239
|
}
|
|
3239
3240
|
getDefaultProject(filePath) {
|
|
3240
|
-
|
|
3241
|
+
const project = this.#service.getDefaultProjectForFile(this.#compiler.server.toNormalizedPath(filePath), true);
|
|
3242
|
+
const compilerOptions = project?.getCompilerOptions();
|
|
3243
|
+
if (this.#resolvedConfig.checkSourceFiles && compilerOptions?.skipLibCheck) {
|
|
3244
|
+
project?.setCompilerOptions({ ...compilerOptions, skipLibCheck: false });
|
|
3245
|
+
}
|
|
3246
|
+
return project;
|
|
3241
3247
|
}
|
|
3242
3248
|
getLanguageService(filePath) {
|
|
3243
3249
|
const project = this.getDefaultProject(filePath);
|
|
@@ -3245,16 +3251,47 @@ class ProjectService {
|
|
|
3245
3251
|
}
|
|
3246
3252
|
openFile(filePath, sourceText, projectRootPath) {
|
|
3247
3253
|
const { configFileErrors, configFileName } = this.#service.openClientFile(filePath, sourceText, undefined, projectRootPath);
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3254
|
+
if (configFileName !== this.#lastSeenProject) {
|
|
3255
|
+
this.#lastSeenProject = configFileName;
|
|
3256
|
+
EventEmitter.dispatch([
|
|
3257
|
+
"project:uses",
|
|
3258
|
+
{ compilerVersion: this.#compiler.version, projectConfigFilePath: configFileName },
|
|
3259
|
+
]);
|
|
3260
|
+
}
|
|
3252
3261
|
if (configFileErrors && configFileErrors.length > 0) {
|
|
3253
3262
|
EventEmitter.dispatch([
|
|
3254
3263
|
"project:error",
|
|
3255
3264
|
{ diagnostics: Diagnostic.fromDiagnostics(configFileErrors, this.#compiler) },
|
|
3256
3265
|
]);
|
|
3257
3266
|
}
|
|
3267
|
+
if (this.#resolvedConfig.checkSourceFiles) {
|
|
3268
|
+
const languageService = this.getLanguageService(filePath);
|
|
3269
|
+
const program = languageService?.getProgram();
|
|
3270
|
+
if (!program || this.#seenPrograms.has(program)) {
|
|
3271
|
+
return;
|
|
3272
|
+
}
|
|
3273
|
+
this.#seenPrograms.add(program);
|
|
3274
|
+
const filesToCheck = [];
|
|
3275
|
+
for (const sourceFile of program.getSourceFiles()) {
|
|
3276
|
+
if (program.isSourceFileFromExternalLibrary(sourceFile) || program.isSourceFileDefaultLibrary(sourceFile)) {
|
|
3277
|
+
continue;
|
|
3278
|
+
}
|
|
3279
|
+
if (!Select.isTestFile(sourceFile.fileName, { ...this.#resolvedConfig, pathMatch: [] })) {
|
|
3280
|
+
filesToCheck.push(sourceFile);
|
|
3281
|
+
}
|
|
3282
|
+
}
|
|
3283
|
+
const diagnostics = [];
|
|
3284
|
+
for (const sourceFile of filesToCheck) {
|
|
3285
|
+
diagnostics.push(...program.getSyntacticDiagnostics(sourceFile), ...program.getSemanticDiagnostics(sourceFile));
|
|
3286
|
+
}
|
|
3287
|
+
if (diagnostics.length > 0) {
|
|
3288
|
+
EventEmitter.dispatch([
|
|
3289
|
+
"project:error",
|
|
3290
|
+
{ diagnostics: Diagnostic.fromDiagnostics(diagnostics, this.#compiler) },
|
|
3291
|
+
]);
|
|
3292
|
+
return;
|
|
3293
|
+
}
|
|
3294
|
+
}
|
|
3258
3295
|
}
|
|
3259
3296
|
}
|
|
3260
3297
|
|
|
@@ -4270,7 +4307,7 @@ class TaskRunner {
|
|
|
4270
4307
|
class Runner {
|
|
4271
4308
|
#eventEmitter = new EventEmitter();
|
|
4272
4309
|
#resolvedConfig;
|
|
4273
|
-
static version = "3.
|
|
4310
|
+
static version = "3.2.0";
|
|
4274
4311
|
constructor(resolvedConfig) {
|
|
4275
4312
|
this.#resolvedConfig = resolvedConfig;
|
|
4276
4313
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tstyche",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"description": "The Essential Type Testing Tool.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -62,15 +62,15 @@
|
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
64
|
"@biomejs/biome": "1.9.4",
|
|
65
|
-
"@rollup/plugin-typescript": "12.1.
|
|
66
|
-
"@types/node": "22.10.
|
|
67
|
-
"@types/react": "
|
|
65
|
+
"@rollup/plugin-typescript": "12.1.2",
|
|
66
|
+
"@types/node": "22.10.2",
|
|
67
|
+
"@types/react": "19.0.2",
|
|
68
68
|
"ajv": "8.17.1",
|
|
69
|
-
"cspell": "8.
|
|
70
|
-
"magic-string": "0.30.
|
|
71
|
-
"monocart-coverage-reports": "2.11.
|
|
69
|
+
"cspell": "8.17.1",
|
|
70
|
+
"magic-string": "0.30.17",
|
|
71
|
+
"monocart-coverage-reports": "2.11.5",
|
|
72
72
|
"pretty-ansi": "3.0.0",
|
|
73
|
-
"rollup": "4.
|
|
73
|
+
"rollup": "4.29.1",
|
|
74
74
|
"rollup-plugin-dts": "6.1.1",
|
|
75
75
|
"tslib": "2.8.1",
|
|
76
76
|
"typescript": "5.7.2"
|