@graphql-codegen/testing 5.0.2 → 5.0.3-alpha-20260920103222-fbebccebe4eca34e33e380cffc09e1d43618acbe

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/cjs/typescript.js CHANGED
@@ -6,6 +6,21 @@ const tslib_1 = require("tslib");
6
6
  const path_1 = require("path");
7
7
  const LZString = tslib_1.__importStar(require("lz-string")); // lz-string is a package which has CJS/ESM issues. So, we cannot do `import { something } from 'lz-string'`
8
8
  const typescript_1 = require("typescript");
9
+ /**
10
+ * Resolve the `@types` directory that actually contains `@types/node`.
11
+ *
12
+ * This used to be derived from `require.resolve('typescript')` as
13
+ * `<ts>/lib/../../../@types`, which only lands on `node_modules/@types` in a flat
14
+ * (npm/yarn) layout. Under pnpm's default isolated layout `require.resolve` returns the
15
+ * realpath inside the virtual store, so it pointed at
16
+ * `node_modules/.pnpm/typescript@<version>/node_modules/@types` -- a directory that does
17
+ * not exist -- and no ambient typings were ever loaded.
18
+ *
19
+ * Locating the directory from `@types/node` itself keeps it correct under every layout.
20
+ */
21
+ function resolveTypeRoots() {
22
+ return [(0, path_1.dirname)((0, path_1.dirname)(require.resolve('@types/node/package.json')))];
23
+ }
9
24
  function validateTs(pluginOutput, options = {
10
25
  noEmitOnError: true,
11
26
  noImplicitAny: true,
@@ -13,7 +28,7 @@ function validateTs(pluginOutput, options = {
13
28
  experimentalDecorators: true,
14
29
  emitDecoratorMetadata: true,
15
30
  target: typescript_1.ScriptTarget.ES5,
16
- typeRoots: [(0, path_1.resolve)(require.resolve('typescript'), '../../../@types/')],
31
+ typeRoots: resolveTypeRoots(),
17
32
  jsx: typescript_1.JsxEmit.React,
18
33
  allowJs: true,
19
34
  skipLibCheck: true,
@@ -40,7 +55,7 @@ function validateTs(pluginOutput, options = {
40
55
  }
41
56
  if (typescript_1.version.startsWith('6.')) {
42
57
  options.ignoreDeprecations ||= '6.0';
43
- // options.types ||= ['node']; FIXME(pnpm-update): causing errors about missing node. Maybe resolving at the wrong location?
58
+ options.types ||= ['node'];
44
59
  }
45
60
  const contents = typeof pluginOutput === 'string'
46
61
  ? pluginOutput
@@ -134,7 +149,7 @@ function compileTs(contents, options = {
134
149
  experimentalDecorators: true,
135
150
  emitDecoratorMetadata: true,
136
151
  target: typescript_1.ScriptTarget.ES5,
137
- typeRoots: [(0, path_1.resolve)(require.resolve('typescript'), '../../../@types/')],
152
+ typeRoots: resolveTypeRoots(),
138
153
  jsx: typescript_1.JsxEmit.Preserve,
139
154
  allowJs: true,
140
155
  lib: [
package/esm/typescript.js CHANGED
@@ -1,6 +1,21 @@
1
- import { dirname, join, resolve } from 'path';
1
+ import { dirname, join } from 'path';
2
2
  import * as LZString from 'lz-string'; // lz-string is a package which has CJS/ESM issues. So, we cannot do `import { something } from 'lz-string'`
3
3
  import { createCompilerHost, createProgram, createSourceFile, flattenDiagnosticMessageText, JsxEmit, ModuleKind, ModuleResolutionKind, ScriptKind, ScriptTarget, version as tsVersion, } from 'typescript';
4
+ /**
5
+ * Resolve the `@types` directory that actually contains `@types/node`.
6
+ *
7
+ * This used to be derived from `require.resolve('typescript')` as
8
+ * `<ts>/lib/../../../@types`, which only lands on `node_modules/@types` in a flat
9
+ * (npm/yarn) layout. Under pnpm's default isolated layout `require.resolve` returns the
10
+ * realpath inside the virtual store, so it pointed at
11
+ * `node_modules/.pnpm/typescript@<version>/node_modules/@types` -- a directory that does
12
+ * not exist -- and no ambient typings were ever loaded.
13
+ *
14
+ * Locating the directory from `@types/node` itself keeps it correct under every layout.
15
+ */
16
+ function resolveTypeRoots() {
17
+ return [dirname(dirname(require.resolve('@types/node/package.json')))];
18
+ }
4
19
  export function validateTs(pluginOutput, options = {
5
20
  noEmitOnError: true,
6
21
  noImplicitAny: true,
@@ -8,7 +23,7 @@ export function validateTs(pluginOutput, options = {
8
23
  experimentalDecorators: true,
9
24
  emitDecoratorMetadata: true,
10
25
  target: ScriptTarget.ES5,
11
- typeRoots: [resolve(require.resolve('typescript'), '../../../@types/')],
26
+ typeRoots: resolveTypeRoots(),
12
27
  jsx: JsxEmit.React,
13
28
  allowJs: true,
14
29
  skipLibCheck: true,
@@ -35,7 +50,7 @@ export function validateTs(pluginOutput, options = {
35
50
  }
36
51
  if (tsVersion.startsWith('6.')) {
37
52
  options.ignoreDeprecations ||= '6.0';
38
- // options.types ||= ['node']; FIXME(pnpm-update): causing errors about missing node. Maybe resolving at the wrong location?
53
+ options.types ||= ['node'];
39
54
  }
40
55
  const contents = typeof pluginOutput === 'string'
41
56
  ? pluginOutput
@@ -129,7 +144,7 @@ export function compileTs(contents, options = {
129
144
  experimentalDecorators: true,
130
145
  emitDecoratorMetadata: true,
131
146
  target: ScriptTarget.ES5,
132
- typeRoots: [resolve(require.resolve('typescript'), '../../../@types/')],
147
+ typeRoots: resolveTypeRoots(),
133
148
  jsx: JsxEmit.Preserve,
134
149
  allowJs: true,
135
150
  lib: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-codegen/testing",
3
- "version": "5.0.2",
3
+ "version": "5.0.3-alpha-20260920103222-fbebccebe4eca34e33e380cffc09e1d43618acbe",
4
4
  "description": "GraphQL Codegen Testing Utils",
5
5
  "peerDependencies": {
6
6
  "jest-diff": "^23.0.0 || ^24.0.0 || ^25.0.0 || ^26.0.0 || ^27.0.0 || ^28.0.0 || ^29.0.0 || ^30.0.0",