@elench/testkit 0.1.130 → 0.1.131

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.
@@ -101,6 +101,7 @@ function writeNextServiceTypecheckConfig({ productDir, cwd, outputDir, serviceNa
101
101
  compilerOptions: buildTypecheckCompilerOptions({
102
102
  tsconfigPath,
103
103
  extendsPath,
104
+ extraPaths: nextRuntimeTypePaths({ tsconfigPath, serviceDir }),
104
105
  }),
105
106
  include: [
106
107
  serviceExists(serviceDir, "next-env.d.ts") ? relativeJsonPath(tsconfigPath, path.join(serviceDir, "next-env.d.ts")) : undefined,
@@ -202,10 +203,11 @@ function packageTypePaths(tsconfigPath) {
202
203
  };
203
204
  }
204
205
 
205
- export function buildTypecheckCompilerOptions({ tsconfigPath, extendsPath, rootDir }) {
206
+ export function buildTypecheckCompilerOptions({ tsconfigPath, extendsPath, rootDir, extraPaths = {} }) {
206
207
  const inheritedPaths = extendsPath ? resolveInheritedPathMappings({ tsconfigPath, extendsPath }) : {};
207
208
  const paths = {
208
209
  ...inheritedPaths,
210
+ ...extraPaths,
209
211
  ...packageTypePaths(tsconfigPath),
210
212
  };
211
213
 
@@ -240,3 +242,31 @@ function resolveInheritedPathMappings({ tsconfigPath, extendsPath }) {
240
242
 
241
243
  return Object.fromEntries(mappedEntries);
242
244
  }
245
+
246
+ export function nextRuntimeTypePaths({ tsconfigPath, serviceDir }) {
247
+ const nextTypesPath = findNodeModuleFileUpward(serviceDir, [
248
+ path.join("next", "types.d.ts"),
249
+ path.join("next", "types.js"),
250
+ ]);
251
+ if (!nextTypesPath) return {};
252
+
253
+ const mappedPath = relativeJsonPath(tsconfigPath, nextTypesPath);
254
+ return {
255
+ "next/types": [mappedPath],
256
+ "next/types.js": [mappedPath],
257
+ };
258
+ }
259
+
260
+ function findNodeModuleFileUpward(startDir, packageRelativePaths) {
261
+ let current = path.resolve(startDir);
262
+ while (true) {
263
+ for (const packageRelativePath of packageRelativePaths) {
264
+ const candidate = path.join(current, "node_modules", packageRelativePath);
265
+ if (fs.existsSync(candidate)) return candidate;
266
+ }
267
+
268
+ const parent = path.dirname(current);
269
+ if (parent === current) return null;
270
+ current = parent;
271
+ }
272
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elench/testkit",
3
- "version": "0.1.130",
3
+ "version": "0.1.131",
4
4
  "description": "Assistant-first CLI for running, inspecting, and debugging local testkit suites",
5
5
  "type": "module",
6
6
  "workspaces": [