tstyche 3.0.0-beta.4 → 3.0.0-beta.5

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.
@@ -178,6 +178,10 @@ interface ConfigFileOptions {
178
178
  * The list of glob patterns matching the test files.
179
179
  */
180
180
  testFileMatch?: Array<string>;
181
+ /**
182
+ * The look up strategy to be used to find the TSConfig file.
183
+ */
184
+ tsconfig?: string;
181
185
  }
182
186
 
183
187
  /**
@@ -232,6 +236,10 @@ interface CommandLineOptions {
232
236
  * The list of TypeScript versions to be tested on.
233
237
  */
234
238
  target?: Array<string>;
239
+ /**
240
+ * The look up strategy to be used to find the TSConfig file.
241
+ */
242
+ tsconfig?: string;
235
243
  /**
236
244
  * Fetch the 'typescript' package metadata from the registry and exit.
237
245
  */
@@ -443,10 +451,10 @@ type TargetResultStatus = ResultStatus.Runs | ResultStatus.Passed | ResultStatus
443
451
  declare class TargetResult {
444
452
  results: Map<string | undefined, ProjectResult>;
445
453
  status: TargetResultStatus;
454
+ target: string;
446
455
  tasks: Array<Task>;
447
456
  timing: ResultTiming;
448
- versionTag: string;
449
- constructor(versionTag: string, tasks: Array<Task>);
457
+ constructor(target: string, tasks: Array<Task>);
450
458
  }
451
459
 
452
460
  declare class Result {
@@ -843,7 +851,7 @@ declare class Path {
843
851
 
844
852
  declare class ProjectService {
845
853
  #private;
846
- constructor(compiler: typeof ts);
854
+ constructor(resolvedConfig: ResolvedConfig, compiler: typeof ts);
847
855
  closeFile(filePath: string): void;
848
856
  getDefaultProject(filePath: string): ts.server.Project | undefined;
849
857
  getLanguageService(filePath: string): ts.LanguageService | undefined;
package/build/tstyche.js CHANGED
@@ -850,6 +850,10 @@ class OptionValidator {
850
850
  }
851
851
  async check(optionName, optionValue, optionBrand, origin) {
852
852
  switch (optionName) {
853
+ case "tsconfig":
854
+ if (["findup", "ignore"].includes(optionValue)) {
855
+ break;
856
+ }
853
857
  case "config":
854
858
  case "rootPath":
855
859
  if (!existsSync(optionValue)) {
@@ -1001,6 +1005,12 @@ class Options {
1001
1005
  },
1002
1006
  name: "testFileMatch",
1003
1007
  },
1008
+ {
1009
+ brand: "string",
1010
+ description: "The look up strategy to be used to find the TSConfig file.",
1011
+ group: 2 | 4,
1012
+ name: "tsconfig",
1013
+ },
1004
1014
  {
1005
1015
  brand: "bareTrue",
1006
1016
  description: "Fetch the 'typescript' package metadata from the registry and exit.",
@@ -1117,7 +1127,8 @@ class CommandLineParser {
1117
1127
  break;
1118
1128
  case "string":
1119
1129
  if (optionValue !== "") {
1120
- if (optionDefinition.name === "config") {
1130
+ if (optionDefinition.name === "config" ||
1131
+ (optionDefinition.name === "tsconfig" && !["findup", "ignore"].includes(optionValue))) {
1121
1132
  optionValue = Path.resolve(optionValue);
1122
1133
  }
1123
1134
  await this.#optionValidator.check(optionDefinition.name, optionValue, optionDefinition.brand);
@@ -1311,7 +1322,8 @@ class ConfigFileParser {
1311
1322
  optionValue = pathToFileURL(Path.join(configFilePath, optionValue)).toString();
1312
1323
  }
1313
1324
  }
1314
- if (optionDefinition.name === "rootPath") {
1325
+ if (optionDefinition.name === "rootPath" ||
1326
+ (optionDefinition.name === "tsconfig" && !["findup", "ignore"].includes(optionValue))) {
1315
1327
  optionValue = Path.resolve(Path.dirname(this.#sourceFile.fileName), optionValue);
1316
1328
  }
1317
1329
  await this.#optionValidator.check(optionDefinition.name, optionValue, optionDefinition.brand, jsonNode.origin);
@@ -1420,6 +1432,7 @@ const defaultOptions = {
1420
1432
  rootPath: Path.resolve("./"),
1421
1433
  target: environmentOptions.typescriptPath != null ? ["current"] : ["latest"],
1422
1434
  testFileMatch: ["**/*.tst.*", "**/__typetests__/*.test.*", "**/typetests/*.test.*"],
1435
+ tsconfig: "findup",
1423
1436
  };
1424
1437
 
1425
1438
  class Config {
@@ -1596,11 +1609,11 @@ var ResultStatus;
1596
1609
  class TargetResult {
1597
1610
  results = new Map();
1598
1611
  status = "runs";
1612
+ target;
1599
1613
  tasks;
1600
1614
  timing = new ResultTiming();
1601
- versionTag;
1602
- constructor(versionTag, tasks) {
1603
- this.versionTag = versionTag;
1615
+ constructor(target, tasks) {
1616
+ this.target = target;
1604
1617
  this.tasks = tasks;
1605
1618
  }
1606
1619
  }
@@ -2460,7 +2473,7 @@ class Task {
2460
2473
  filePath;
2461
2474
  position;
2462
2475
  constructor(filePath, position) {
2463
- this.filePath = Path.normalizeSlashes(this.#toPath(filePath));
2476
+ this.filePath = Path.resolve(this.#toPath(filePath));
2464
2477
  this.position = position;
2465
2478
  }
2466
2479
  #toPath(filePath) {
@@ -3087,8 +3100,10 @@ var TestMemberFlags;
3087
3100
 
3088
3101
  class ProjectService {
3089
3102
  #compiler;
3103
+ #resolvedConfig;
3090
3104
  #service;
3091
- constructor(compiler) {
3105
+ constructor(resolvedConfig, compiler) {
3106
+ this.#resolvedConfig = resolvedConfig;
3092
3107
  this.#compiler = compiler;
3093
3108
  const noop = () => undefined;
3094
3109
  const noopLogger = {
@@ -3123,6 +3138,15 @@ class ProjectService {
3123
3138
  useInferredProjectPerProjectRoot: true,
3124
3139
  useSingleInferredProject: false,
3125
3140
  });
3141
+ switch (this.#resolvedConfig.tsconfig) {
3142
+ case "findup":
3143
+ break;
3144
+ case "ignore":
3145
+ this.#service.getConfigFileNameForFile = () => undefined;
3146
+ break;
3147
+ default:
3148
+ this.#service.getConfigFileNameForFile = () => this.#resolvedConfig.tsconfig;
3149
+ }
3126
3150
  this.#service.setCompilerOptionsForInferredProjects(this.#getDefaultCompilerOptions());
3127
3151
  }
3128
3152
  closeFile(filePath) {
@@ -4038,7 +4062,7 @@ class TaskRunner {
4038
4062
  this.#resolvedConfig = resolvedConfig;
4039
4063
  this.#compiler = compiler;
4040
4064
  this.#collectService = new CollectService(compiler);
4041
- this.#projectService = new ProjectService(compiler);
4065
+ this.#projectService = new ProjectService(this.#resolvedConfig, compiler);
4042
4066
  }
4043
4067
  run(task, cancellationToken) {
4044
4068
  if (cancellationToken?.isCancellationRequested === true) {
@@ -4052,6 +4076,13 @@ class TaskRunner {
4052
4076
  this.#projectService.closeFile(task.filePath);
4053
4077
  }
4054
4078
  #run(task, taskResult, cancellationToken) {
4079
+ if (!existsSync(task.filePath)) {
4080
+ EventEmitter.dispatch([
4081
+ "task:error",
4082
+ { diagnostics: [Diagnostic.error(`Test file '${task.filePath}' does not exist.`)], result: taskResult },
4083
+ ]);
4084
+ return;
4085
+ }
4055
4086
  const languageService = this.#projectService.getLanguageService(task.filePath);
4056
4087
  if (!languageService) {
4057
4088
  return;
@@ -4095,7 +4126,7 @@ class TaskRunner {
4095
4126
  class Runner {
4096
4127
  #eventEmitter = new EventEmitter();
4097
4128
  #resolvedConfig;
4098
- static version = "3.0.0-beta.4";
4129
+ static version = "3.0.0-beta.5";
4099
4130
  constructor(resolvedConfig) {
4100
4131
  this.#resolvedConfig = resolvedConfig;
4101
4132
  }
@@ -4143,10 +4174,10 @@ class Runner {
4143
4174
  async #run(tasks, cancellationToken) {
4144
4175
  const result = new Result(this.#resolvedConfig, tasks);
4145
4176
  EventEmitter.dispatch(["run:start", { result }]);
4146
- for (const versionTag of this.#resolvedConfig.target) {
4147
- const targetResult = new TargetResult(versionTag, tasks);
4177
+ for (const target of this.#resolvedConfig.target) {
4178
+ const targetResult = new TargetResult(target, tasks);
4148
4179
  EventEmitter.dispatch(["target:start", { result: targetResult }]);
4149
- const compiler = await Store.load(versionTag);
4180
+ const compiler = await Store.load(target);
4150
4181
  if (compiler) {
4151
4182
  const taskRunner = new TaskRunner(this.#resolvedConfig, compiler);
4152
4183
  for (const task of tasks) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tstyche",
3
- "version": "3.0.0-beta.4",
3
+ "version": "3.0.0-beta.5",
4
4
  "description": "The Essential Type Testing Tool.",
5
5
  "keywords": [
6
6
  "typescript",
@@ -61,12 +61,12 @@
61
61
  "test:unit": "yarn test:run **/__tests__/*.test.js --parallel"
62
62
  },
63
63
  "devDependencies": {
64
- "@biomejs/biome": "1.9.3",
64
+ "@biomejs/biome": "1.9.4",
65
65
  "@rollup/plugin-typescript": "12.1.1",
66
- "@types/node": "20.16.11",
66
+ "@types/node": "20.16.14",
67
67
  "@types/react": "18.3.11",
68
68
  "ajv": "8.17.1",
69
- "cspell": "8.15.3",
69
+ "cspell": "8.15.4",
70
70
  "magic-string": "0.30.12",
71
71
  "monocart-coverage-reports": "2.11.1",
72
72
  "pretty-ansi": "2.0.0",
@@ -83,7 +83,7 @@
83
83
  "optional": true
84
84
  }
85
85
  },
86
- "packageManager": "yarn@4.5.0",
86
+ "packageManager": "yarn@4.5.1",
87
87
  "engines": {
88
88
  "node": ">=18.17"
89
89
  }