Skip to content
This repository has been archived by the owner on Sep 27, 2023. It is now read-only.

Commit

Permalink
chore: add missing test typings; configure tsconfig.json to also incl…
Browse files Browse the repository at this point in the history
…ude the tests; add tsconfig.build.json for the actual lib only build.
  • Loading branch information
n1ru4l committed Feb 11, 2021
1 parent 71e44a3 commit b5872b4
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 14 deletions.
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -32,7 +32,7 @@
"lib"
],
"scripts": {
"build": "rm -rf lib && tsc",
"build": "rm -rf lib && tsc --project tsconfig.build.json",
"lint": "tslint -c tslint.json --project tsconfig.json",
"pr-check": "scripts/pr-check.sh",
"prettier": "prettier --write '{src,types,test}/**/*.ts'",
Expand All @@ -41,7 +41,7 @@
"sync-fixtures": "ts-node ./syncFixtures.ts",
"test": "npm run type-check && jest",
"type-check": "tsc --noEmit --pretty",
"watch": "concurrently 'tsc --watch' 'chokidar \"lib/**/*.js\" -c \"yalc publish --force --push\"'"
"watch": "concurrently 'tsc --watch --project tsconfig.build.json' 'chokidar \"lib/**/*.js\" -c \"yalc publish --force --push\"'"
},
"husky": {
"hooks": {
Expand Down
2 changes: 1 addition & 1 deletion test/FindGraphQLTags-test.ts
Expand Up @@ -21,7 +21,7 @@ describe("FindGraphQLTags", () => {
).toEqual([
{
keyName: null,
template: `
template: /* GraphQL */ `
fragment TestModule_artist on Artist {
name
}
Expand Down
10 changes: 3 additions & 7 deletions test/TypeScriptGenerator-test.ts
@@ -1,13 +1,9 @@
import { CompilerContext, IRTransforms, Root } from "relay-compiler";
// @ts-ignore
import { CompilerContext, IRTransforms, Root, } from "relay-compiler";
import { TypeGeneratorOptions } from "relay-compiler/lib/language/RelayLanguagePluginInterface";
// @ts-ignore
import { generateTestsFromFixtures } from "relay-test-utils-internal/lib/generateTestsFromFixtures";
// @ts-ignore
import * as parseGraphQLText from "relay-test-utils-internal/lib/parseGraphQLText";
// @ts-ignore
import { TestSchema } from "relay-test-utils-internal/lib/TestSchema";
import * as TypeScriptGenerator from "../src/TypeScriptGenerator";
import parseGraphQLText = require("relay-test-utils-internal/lib/parseGraphQLText");

function generate(
text: string,
Expand All @@ -16,7 +12,7 @@ function generate(
) {
const schema = TestSchema.extend([
...IRTransforms.schemaExtensions,
`
/* GraphQL */ `
scalar Color
extend type User {
color: Color
Expand Down
17 changes: 17 additions & 0 deletions test/ambient.d.ts
Expand Up @@ -4,3 +4,20 @@ declare namespace jest {
toMatchFile(width: string): void;
}
}


declare module "relay-test-utils-internal/lib/generateTestsFromFixtures" {

export function generateTestsFromFixtures(path: string, callback: (text: string) => void): void
}

declare module "relay-test-utils-internal/lib/parseGraphQLText" {
import type {Fragment, Root, Schema} from 'relay-compiler';
function parseGraphQLText(schema: Schema, text: string): { definitions: ReadonlyArray<Fragment | Root>, schema: Schema }
export = parseGraphQLText
}

declare module "relay-test-utils-internal/lib/TestSchema" {
import type {Schema} from 'relay-compiler';
export const TestSchema: Schema
}
3 changes: 0 additions & 3 deletions test/formatGeneratedModule-test.ts
Expand Up @@ -50,7 +50,6 @@ describe("formatGeneratedModule", () => {
relayRuntimeModule: "relay-runtime",
sourceHash: "edcba"
})
// @ts-ignore
).toMatchFile(
join(__dirname, "fixtures/generated-module/complete-example.ts")
);
Expand All @@ -69,7 +68,6 @@ describe("formatGeneratedModule", () => {
hash: "@relayHash abcde",
sourceHash: "edcba"
})
// @ts-ignore
).toMatchFile(
join(__dirname, "fixtures/generated-module/complete-example.ts")
);
Expand All @@ -88,7 +86,6 @@ describe("formatGeneratedModule", () => {
hash: null,
sourceHash: "edcba"
})
// @ts-ignore
).toMatchFile(
join(__dirname, "fixtures/generated-module/complete-example-no-cast.ts")
);
Expand Down
4 changes: 4 additions & 0 deletions tsconfig.build.json
@@ -0,0 +1,4 @@
{
"extends": "./tsconfig.json",
"exclude": ["./test/**/*"]
}
2 changes: 1 addition & 1 deletion tsconfig.json
Expand Up @@ -53,5 +53,5 @@
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
},
"include": ["./src/**/*", "./types/**/*"]
"include": ["./src/**/*", "./types/**/*", "./test/**/*"]
}

0 comments on commit b5872b4

Please sign in to comment.