Skip to content

Commit 2d83bfb

Browse files
authored
fix: typings for GraphQLError on the client (#12464)
Signed-off-by: Matt Krick <matt.krick@gmail.com>
1 parent 421f28e commit 2d83bfb

File tree

21 files changed

+75
-154
lines changed

21 files changed

+75
-154
lines changed

packages/client/Atmosphere.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
type NormalizationLinkedField,
1818
Observable,
1919
type OperationType,
20+
type PayloadError,
2021
RecordSource,
2122
RelayFeatureFlags,
2223
type RequestParameters,
@@ -187,10 +188,10 @@ export default class Atmosphere extends Environment {
187188
return Observable.create<GraphQLResponse>((sink) => {
188189
const _next = sink.next
189190
const _error = sink.error
190-
sink.error = (error: Error | Error[] | CloseEvent) => {
191+
sink.error = (error: Error | Error[] | CloseEvent | PayloadError) => {
191192
if (Array.isArray(error)) {
192193
const invalidSessionError = error.find(
193-
(e) => (e as any).extensions?.code === 'SESSION_INVALIDATED'
194+
(e) => (e as PayloadError).extensions?.code === 'SESSION_INVALIDATED'
194195
)
195196
if (invalidSessionError) {
196197
this.invalidateSession(invalidSessionError.message)

packages/client/client.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import {render} from 'react-dom'
22
import Root from './Root'
33
import './scrollIntoViewIfNeeded'
4-
import './types/modules.d'
54

65
render(<Root />, document.getElementById('root'))
76
if (__PRODUCTION__ && 'serviceWorker' in navigator) {

packages/client/modules/pages/PageAccessCombobox.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export const PageAccessCombobox = (props: Props) => {
4545
onCompleted(_res, errors) {
4646
const firstError = errors?.[0]
4747
if (firstError) {
48-
if ((firstError as any).extensions?.code === 'UNAPPROVED_UNLINK') {
48+
if (firstError.extensions?.code === 'UNAPPROVED_UNLINK') {
4949
setAttemptedRole(role)
5050
return
5151
}

packages/client/modules/pages/RequestPageAccess.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export const RequestPageAccess = (props: Props) => {
4040
onCompleted: (_result, errors) => {
4141
const firstError = errors?.[0]
4242
if (firstError) {
43-
const code = (firstError as any).extensions?.code
43+
const code = firstError.extensions?.code
4444
if (code === 'NOT_FOUND') {
4545
atmosphere.eventEmitter.emit('addSnackbar', {
4646
message: 'Page not found',

packages/client/polyfills.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import './types/modules.d'
2-
31
if (__PRODUCTION__) {
42
__webpack_public_path__ = window.__ACTION__.publicPath
53
}

packages/client/serviceWorker/modules.d.ts

Lines changed: 0 additions & 3 deletions
This file was deleted.

packages/client/types/reactHTML4.d.ts

Lines changed: 0 additions & 14 deletions
This file was deleted.

packages/client/types/shared.d.ts

Lines changed: 0 additions & 2 deletions
This file was deleted.

packages/client/utils/relay/getGraphQLError.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type {PayloadError} from 'relay-runtime/lib/network/RelayNetworkTypes'
1+
import type {PayloadError} from 'relay-runtime'
22

33
const getServerError = (errors: ReadonlyArray<PayloadError> | null | undefined) =>
44
(errors && errors[0]) || undefined

packages/embedder/inferLanguage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import franc from 'franc-min'
1+
import {franc} from 'franc-min'
22
import {type ISO6391, iso6393To1} from './iso6393To1'
33
import {URLRegex} from './regex'
44

0 commit comments

Comments
 (0)