@graphql-codegen/testing 5.0.2 → 5.0.3-alpha-20260920112236-61210c9e19c41cd401b641c8894e4eebaa08e96e
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 +23 -3
- package/esm/typescript.js +24 -4
- package/package.json +1 -1
package/cjs/typescript.js
CHANGED
|
@@ -6,6 +6,26 @@ 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
|
+
// A `typeRoots` entry is a *container* directory, not a type package: TypeScript resolves
|
|
23
|
+
// every name in `types` as `<typeRoot>/<name>`, so `types: ['node']` looks for
|
|
24
|
+
// `<typeRoot>/node`. Hence two steps up from the manifest -- to the package, then to the
|
|
25
|
+
// `@types` directory holding it.
|
|
26
|
+
const nodeTypesPackageDir = (0, path_1.dirname)(require.resolve('@types/node/package.json')); // <..>/@types/node
|
|
27
|
+
return [(0, path_1.dirname)(nodeTypesPackageDir)]; // <..>/@types
|
|
28
|
+
}
|
|
9
29
|
function validateTs(pluginOutput, options = {
|
|
10
30
|
noEmitOnError: true,
|
|
11
31
|
noImplicitAny: true,
|
|
@@ -13,7 +33,7 @@ function validateTs(pluginOutput, options = {
|
|
|
13
33
|
experimentalDecorators: true,
|
|
14
34
|
emitDecoratorMetadata: true,
|
|
15
35
|
target: typescript_1.ScriptTarget.ES5,
|
|
16
|
-
typeRoots:
|
|
36
|
+
typeRoots: resolveTypeRoots(),
|
|
17
37
|
jsx: typescript_1.JsxEmit.React,
|
|
18
38
|
allowJs: true,
|
|
19
39
|
skipLibCheck: true,
|
|
@@ -40,7 +60,7 @@ function validateTs(pluginOutput, options = {
|
|
|
40
60
|
}
|
|
41
61
|
if (typescript_1.version.startsWith('6.')) {
|
|
42
62
|
options.ignoreDeprecations ||= '6.0';
|
|
43
|
-
|
|
63
|
+
options.types ||= ['node'];
|
|
44
64
|
}
|
|
45
65
|
const contents = typeof pluginOutput === 'string'
|
|
46
66
|
? pluginOutput
|
|
@@ -134,7 +154,7 @@ function compileTs(contents, options = {
|
|
|
134
154
|
experimentalDecorators: true,
|
|
135
155
|
emitDecoratorMetadata: true,
|
|
136
156
|
target: typescript_1.ScriptTarget.ES5,
|
|
137
|
-
typeRoots:
|
|
157
|
+
typeRoots: resolveTypeRoots(),
|
|
138
158
|
jsx: typescript_1.JsxEmit.Preserve,
|
|
139
159
|
allowJs: true,
|
|
140
160
|
lib: [
|
package/esm/typescript.js
CHANGED
|
@@ -1,6 +1,26 @@
|
|
|
1
|
-
import { dirname, join
|
|
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
|
+
// A `typeRoots` entry is a *container* directory, not a type package: TypeScript resolves
|
|
18
|
+
// every name in `types` as `<typeRoot>/<name>`, so `types: ['node']` looks for
|
|
19
|
+
// `<typeRoot>/node`. Hence two steps up from the manifest -- to the package, then to the
|
|
20
|
+
// `@types` directory holding it.
|
|
21
|
+
const nodeTypesPackageDir = dirname(require.resolve('@types/node/package.json')); // <..>/@types/node
|
|
22
|
+
return [dirname(nodeTypesPackageDir)]; // <..>/@types
|
|
23
|
+
}
|
|
4
24
|
export function validateTs(pluginOutput, options = {
|
|
5
25
|
noEmitOnError: true,
|
|
6
26
|
noImplicitAny: true,
|
|
@@ -8,7 +28,7 @@ export function validateTs(pluginOutput, options = {
|
|
|
8
28
|
experimentalDecorators: true,
|
|
9
29
|
emitDecoratorMetadata: true,
|
|
10
30
|
target: ScriptTarget.ES5,
|
|
11
|
-
typeRoots:
|
|
31
|
+
typeRoots: resolveTypeRoots(),
|
|
12
32
|
jsx: JsxEmit.React,
|
|
13
33
|
allowJs: true,
|
|
14
34
|
skipLibCheck: true,
|
|
@@ -35,7 +55,7 @@ export function validateTs(pluginOutput, options = {
|
|
|
35
55
|
}
|
|
36
56
|
if (tsVersion.startsWith('6.')) {
|
|
37
57
|
options.ignoreDeprecations ||= '6.0';
|
|
38
|
-
|
|
58
|
+
options.types ||= ['node'];
|
|
39
59
|
}
|
|
40
60
|
const contents = typeof pluginOutput === 'string'
|
|
41
61
|
? pluginOutput
|
|
@@ -129,7 +149,7 @@ export function compileTs(contents, options = {
|
|
|
129
149
|
experimentalDecorators: true,
|
|
130
150
|
emitDecoratorMetadata: true,
|
|
131
151
|
target: ScriptTarget.ES5,
|
|
132
|
-
typeRoots:
|
|
152
|
+
typeRoots: resolveTypeRoots(),
|
|
133
153
|
jsx: JsxEmit.Preserve,
|
|
134
154
|
allowJs: true,
|
|
135
155
|
lib: [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-codegen/testing",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.3-alpha-20260920112236-61210c9e19c41cd401b641c8894e4eebaa08e96e",
|
|
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",
|