Skip to content

Commit b5872b4

Browse files
committed
chore: add missing test typings; configure tsconfig.json to also include the tests; add tsconfig.build.json for the actual lib only build.
1 parent 71e44a3 commit b5872b4

7 files changed

+28
-14
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"lib"
3333
],
3434
"scripts": {
35-
"build": "rm -rf lib && tsc",
35+
"build": "rm -rf lib && tsc --project tsconfig.build.json",
3636
"lint": "tslint -c tslint.json --project tsconfig.json",
3737
"pr-check": "scripts/pr-check.sh",
3838
"prettier": "prettier --write '{src,types,test}/**/*.ts'",
@@ -41,7 +41,7 @@
4141
"sync-fixtures": "ts-node ./syncFixtures.ts",
4242
"test": "npm run type-check && jest",
4343
"type-check": "tsc --noEmit --pretty",
44-
"watch": "concurrently 'tsc --watch' 'chokidar \"lib/**/*.js\" -c \"yalc publish --force --push\"'"
44+
"watch": "concurrently 'tsc --watch --project tsconfig.build.json' 'chokidar \"lib/**/*.js\" -c \"yalc publish --force --push\"'"
4545
},
4646
"husky": {
4747
"hooks": {

test/FindGraphQLTags-test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ describe("FindGraphQLTags", () => {
2121
).toEqual([
2222
{
2323
keyName: null,
24-
template: `
24+
template: /* GraphQL */ `
2525
fragment TestModule_artist on Artist {
2626
name
2727
}

test/TypeScriptGenerator-test.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
import { CompilerContext, IRTransforms, Root } from "relay-compiler";
2-
// @ts-ignore
1+
import { CompilerContext, IRTransforms, Root, } from "relay-compiler";
32
import { TypeGeneratorOptions } from "relay-compiler/lib/language/RelayLanguagePluginInterface";
4-
// @ts-ignore
53
import { generateTestsFromFixtures } from "relay-test-utils-internal/lib/generateTestsFromFixtures";
6-
// @ts-ignore
7-
import * as parseGraphQLText from "relay-test-utils-internal/lib/parseGraphQLText";
8-
// @ts-ignore
94
import { TestSchema } from "relay-test-utils-internal/lib/TestSchema";
105
import * as TypeScriptGenerator from "../src/TypeScriptGenerator";
6+
import parseGraphQLText = require("relay-test-utils-internal/lib/parseGraphQLText");
117

128
function generate(
139
text: string,
@@ -16,7 +12,7 @@ function generate(
1612
) {
1713
const schema = TestSchema.extend([
1814
...IRTransforms.schemaExtensions,
19-
`
15+
/* GraphQL */ `
2016
scalar Color
2117
extend type User {
2218
color: Color

test/ambient.d.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,20 @@ declare namespace jest {
44
toMatchFile(width: string): void;
55
}
66
}
7+
8+
9+
declare module "relay-test-utils-internal/lib/generateTestsFromFixtures" {
10+
11+
export function generateTestsFromFixtures(path: string, callback: (text: string) => void): void
12+
}
13+
14+
declare module "relay-test-utils-internal/lib/parseGraphQLText" {
15+
import type {Fragment, Root, Schema} from 'relay-compiler';
16+
function parseGraphQLText(schema: Schema, text: string): { definitions: ReadonlyArray<Fragment | Root>, schema: Schema }
17+
export = parseGraphQLText
18+
}
19+
20+
declare module "relay-test-utils-internal/lib/TestSchema" {
21+
import type {Schema} from 'relay-compiler';
22+
export const TestSchema: Schema
23+
}

test/formatGeneratedModule-test.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ describe("formatGeneratedModule", () => {
5050
relayRuntimeModule: "relay-runtime",
5151
sourceHash: "edcba"
5252
})
53-
// @ts-ignore
5453
).toMatchFile(
5554
join(__dirname, "fixtures/generated-module/complete-example.ts")
5655
);
@@ -69,7 +68,6 @@ describe("formatGeneratedModule", () => {
6968
hash: "@relayHash abcde",
7069
sourceHash: "edcba"
7170
})
72-
// @ts-ignore
7371
).toMatchFile(
7472
join(__dirname, "fixtures/generated-module/complete-example.ts")
7573
);
@@ -88,7 +86,6 @@ describe("formatGeneratedModule", () => {
8886
hash: null,
8987
sourceHash: "edcba"
9088
})
91-
// @ts-ignore
9289
).toMatchFile(
9390
join(__dirname, "fixtures/generated-module/complete-example-no-cast.ts")
9491
);

tsconfig.build.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"exclude": ["./test/**/*"]
4+
}

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,5 @@
5353
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
5454
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
5555
},
56-
"include": ["./src/**/*", "./types/**/*"]
56+
"include": ["./src/**/*", "./types/**/*", "./test/**/*"]
5757
}

0 commit comments

Comments
 (0)