Skip to content

Commit

Permalink
Prefer import * as for imports whose types are re-exported
Browse files Browse the repository at this point in the history
Fixes #7741

Using `import React from 'react'` causes issues when the import makes
its way into the d.ts file. Users without `esModuleInterop: true` or
`allowSyntheticDefaultImports: true` (or `skipLibCheck: true`) in
their tsconfig files will get errors from typescript about not being
able to default-import using that syntax.

This PR fixes the specific imports that would cause issues due to
their types being re-exported in `@apollo/client`'s types.
  • Loading branch information
Mike Deverell authored and benjamn committed Mar 5, 2021
1 parent fd93923 commit 2709331
Show file tree
Hide file tree
Showing 15 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/link/persisted-queries/__tests__/react.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import ReactDOM from 'react-dom/server';
import * as React from 'react';
import * as ReactDOM from 'react-dom/server';
import gql from 'graphql-tag';
import { print } from 'graphql';
import { sha256 } from 'crypto-hash';
Expand Down
2 changes: 1 addition & 1 deletion src/react/components/Mutation.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import PropTypes from 'prop-types';
import * as PropTypes from 'prop-types';

import { OperationVariables } from '../../core';
import { MutationComponentOptions } from './types';
Expand Down
2 changes: 1 addition & 1 deletion src/react/components/Query.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import PropTypes from 'prop-types';
import * as PropTypes from 'prop-types';

import { OperationVariables } from '../../core';
import { QueryComponentOptions } from './types';
Expand Down
2 changes: 1 addition & 1 deletion src/react/components/Subscription.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import PropTypes from 'prop-types';
import * as PropTypes from 'prop-types';

import { OperationVariables } from '../../core';
import { SubscriptionComponentOptions } from './types';
Expand Down
2 changes: 1 addition & 1 deletion src/react/context/ApolloConsumer.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import * as React from 'react';
import { invariant } from 'ts-invariant';

import { ApolloClient } from '../../core';
Expand Down
2 changes: 1 addition & 1 deletion src/react/context/ApolloContext.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import * as React from 'react';
import { ApolloClient } from '../../core';
import { canUseWeakMap } from '../../utilities';

Expand Down
2 changes: 1 addition & 1 deletion src/react/context/ApolloProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import * as React from 'react';
import { invariant } from 'ts-invariant';

import { ApolloClient } from '../../core';
Expand Down
2 changes: 1 addition & 1 deletion src/react/hoc/hoc-utils.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import * as React from 'react';
import { invariant } from 'ts-invariant';
import { OperationVariables } from '../../core';
import { IDocumentDefinition } from '../parser';
Expand Down
2 changes: 1 addition & 1 deletion src/react/hoc/mutation-hoc.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import * as React from 'react';
import { DocumentNode } from 'graphql';
import hoistNonReactStatics from 'hoist-non-react-statics';

Expand Down
2 changes: 1 addition & 1 deletion src/react/hoc/query-hoc.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import * as React from 'react';
import { DocumentNode } from 'graphql';
import hoistNonReactStatics from 'hoist-non-react-statics';

Expand Down
2 changes: 1 addition & 1 deletion src/react/hoc/subscription-hoc.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import * as React from 'react';
import { DocumentNode } from 'graphql';
import hoistNonReactStatics from 'hoist-non-react-statics';

Expand Down
2 changes: 1 addition & 1 deletion src/react/hoc/withApollo.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import * as React from 'react';
import hoistNonReactStatics from 'hoist-non-react-statics';
import { invariant } from 'ts-invariant';

Expand Down
2 changes: 1 addition & 1 deletion src/react/hooks/useApolloClient.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import * as React from 'react';
import { invariant } from 'ts-invariant';

import { ApolloClient } from '../../core';
Expand Down
2 changes: 1 addition & 1 deletion src/react/ssr/getDataFromTree.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import * as React from 'react';
import { getApolloContext } from '../context';
import { RenderPromises } from './RenderPromises';

Expand Down
2 changes: 1 addition & 1 deletion src/utilities/testing/mocking/MockedProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import * as React from 'react';

import { ApolloClient, DefaultOptions } from '../../../core';
import { InMemoryCache as Cache } from '../../../cache';
Expand Down

0 comments on commit 2709331

Please sign in to comment.