From 0dcff653444395edfec60fb3da3fcb3155cdff33 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Thu, 30 Aug 2018 16:43:01 +0200 Subject: [PATCH] Upgrade react-relay types --- package-lock.json | 4 ++-- package.json | 1 + .../client/framework/lib/relay/QueryRenderer.tsx | 12 +++++++----- .../stream/mutations/CreateCommentMutation.ts | 8 ++++---- .../client/stream/queries/PermalinkViewQuery.tsx | 11 ++++------- src/core/client/stream/queries/StreamQuery.tsx | 14 +++++++------- 6 files changed, 25 insertions(+), 25 deletions(-) diff --git a/package-lock.json b/package-lock.json index 452c8c4b8..d347dd3da 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2069,7 +2069,7 @@ } }, "@types/react-relay": { - "version": "github:coralproject/patched#ba4c8d01bb737e5f073534b32d870294e39cc5a8", + "version": "github:coralproject/patched#c8e07adee83418ca04acfc99a3c542e082d70116", "from": "github:coralproject/patched#types/react-relay", "dev": true }, @@ -8617,7 +8617,7 @@ "dependencies": { "chalk": { "version": "1.1.3", - "resolved": "http://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", "dev": true, "requires": { diff --git a/package.json b/package.json index 666743414..9eaedca62 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "lint:scripts": "tslint --project ./tsconfig.json", "lint-fix": "npm run lint:server -- --fix && npm run lint:client -- --fix && npm run lint:client-embed -- --fix && npm run lint:scripts -- --fix", "test": "node scripts/test.js --env=jsdom", + "tscheck": "npm-run-all --parallel tscheck:*", "tscheck:server": "tsc --project ./src/tsconfig.json --noEmit", "tscheck:client": "tsc --project ./src/core/client/tsconfig.json --noEmit", "tscheck:client-embed": "tsc --project ./src/core/client/embed/tsconfig.json --noEmit", diff --git a/src/core/client/framework/lib/relay/QueryRenderer.tsx b/src/core/client/framework/lib/relay/QueryRenderer.tsx index a5845c0b6..cc8acac40 100644 --- a/src/core/client/framework/lib/relay/QueryRenderer.tsx +++ b/src/core/client/framework/lib/relay/QueryRenderer.tsx @@ -3,23 +3,25 @@ import { QueryRenderer, QueryRendererProps as QueryRendererPropsOrig, } from "react-relay"; +import { OperationBase, OperationDefaults } from "relay-runtime"; import { Omit } from "talk-framework/types"; import { TalkContextConsumer } from "../bootstrap/TalkContext"; // Omit environment as we are passing this from the context. -export type QueryRendererProps = Omit< - QueryRendererPropsOrig, - "environment" ->; +export type QueryRendererProps< + T extends OperationBase = OperationDefaults +> = Omit, "environment">; /** * TalkQueryRenderer is a wrappper around Relay's `QueryRenderer`. * It supplies the `environment` from the context and has better * generics type support. */ -class TalkQueryRenderer extends Component> { +class TalkQueryRenderer< + T extends OperationBase = OperationDefaults +> extends Component> { public render() { return ( diff --git a/src/core/client/stream/mutations/CreateCommentMutation.ts b/src/core/client/stream/mutations/CreateCommentMutation.ts index 7be32b3dd..079285b91 100644 --- a/src/core/client/stream/mutations/CreateCommentMutation.ts +++ b/src/core/client/stream/mutations/CreateCommentMutation.ts @@ -9,10 +9,10 @@ import { } from "talk-framework/lib/relay"; import { Omit } from "talk-framework/types"; -import { CreateCommentMutation as CreateCommentType } from "talk-stream/__generated__/CreateCommentMutation.graphql"; +import { CreateCommentMutation as MutationTypes } from "talk-stream/__generated__/CreateCommentMutation.graphql"; export type CreateCommentInput = Omit< - CreateCommentType["variables"]["input"], + MutationTypes["variables"]["input"], "clientMutationId" >; @@ -41,7 +41,7 @@ let clientMutationId = 0; function commit(environment: Environment, input: CreateCommentInput) { const me = getMe(environment)!; const currentDate = new Date().toISOString(); - return commitMutationPromiseNormalized(environment, { + return commitMutationPromiseNormalized(environment, { mutation, variables: { input: { @@ -90,4 +90,4 @@ export const withCreateCommentMutation = createMutationContainer( export type CreateCommentMutation = ( input: CreateCommentInput -) => Promise; +) => Promise; diff --git a/src/core/client/stream/queries/PermalinkViewQuery.tsx b/src/core/client/stream/queries/PermalinkViewQuery.tsx index 3a9b22f71..67bfb98a0 100644 --- a/src/core/client/stream/queries/PermalinkViewQuery.tsx +++ b/src/core/client/stream/queries/PermalinkViewQuery.tsx @@ -7,10 +7,7 @@ import { QueryRenderer, withLocalStateContainer, } from "talk-framework/lib/relay"; -import { - PermalinkViewQueryResponse, - PermalinkViewQueryVariables, -} from "talk-stream/__generated__/PermalinkViewQuery.graphql"; +import { PermalinkViewQuery as QueryTypes } from "talk-stream/__generated__/PermalinkViewQuery.graphql"; import { PermalinkViewQueryLocal as Local } from "talk-stream/__generated__/PermalinkViewQueryLocal.graphql"; import { Spinner } from "talk-ui/components"; @@ -23,7 +20,7 @@ interface InnerProps { export const render = ({ error, props, -}: ReadyState) => { +}: ReadyState) => { if (error) { return
{error.message}
; } @@ -36,7 +33,7 @@ export const render = ({ const PermalinkViewQuery: StatelessComponent = ({ local: { commentID }, }) => ( - + query={graphql` query PermalinkViewQuery($commentID: ID!) { comment(id: $commentID) { @@ -45,7 +42,7 @@ const PermalinkViewQuery: StatelessComponent = ({ } `} variables={{ - commentID, + commentID: commentID!, }} render={render} /> diff --git a/src/core/client/stream/queries/StreamQuery.tsx b/src/core/client/stream/queries/StreamQuery.tsx index 41d262428..1d0830992 100644 --- a/src/core/client/stream/queries/StreamQuery.tsx +++ b/src/core/client/stream/queries/StreamQuery.tsx @@ -5,10 +5,7 @@ import { QueryRenderer, withLocalStateContainer, } from "talk-framework/lib/relay"; -import { - StreamQueryResponse, - StreamQueryVariables, -} from "talk-stream/__generated__/StreamQuery.graphql"; +import { StreamQuery as QueryTypes } from "talk-stream/__generated__/StreamQuery.graphql"; import { StreamQueryLocal as Local } from "talk-stream/__generated__/StreamQueryLocal.graphql"; import { Spinner } from "talk-ui/components"; import StreamContainer from "../containers/StreamContainer"; @@ -17,7 +14,10 @@ interface InnerProps { local: Local; } -export const render = ({ error, props }: ReadyState) => { +export const render = ({ + error, + props, +}: ReadyState) => { if (error) { return
{error.message}
; } @@ -32,7 +32,7 @@ export const render = ({ error, props }: ReadyState) => { const StreamQuery: StatelessComponent = ({ local: { assetID, authRevision }, }) => ( - + query={graphql` query StreamQuery($assetID: ID!, $authRevision: Int!) { asset(id: $assetID) { @@ -47,7 +47,7 @@ const StreamQuery: StatelessComponent = ({ } `} variables={{ - assetID, + assetID: assetID!, authRevision, }} render={render}