Apollo-client: Apollo boost with TypeScript does not work out of the box and documentation is incomplete

Created on 18 Jul 2018  路  1Comment  路  Source: apollographql/apollo-client

Intended outcome:

Using create-react-app-typescript + installing Apollo Boost, typescript definitions are automatically included.

Actual outcome:

Cannot use 'new' with an expression whose type lacks a call or construct signature.

How to reproduce the issue:

npm install -g create-react-app
create-react-app client --scripts-version=react-scripts-ts

Follow https://www.apollographql.com/docs/react/essentials/get-started.html

Versions

System:
OS: macOS High Sierra 10.13.5
Binaries:
Node: 10.5.0 - /usr/local/bin/node
Yarn: 1.7.0 - /usr/local/bin/yarn
npm: 6.1.0 - /usr/local/bin/npm
Browsers:
Firefox: 57.0.4
Safari: 11.1.1
npmPackages:
apollo-boost: ^0.1.10 => 0.1.10
react-apollo: ^2.1.9 => 2.1.9

Issue Labels

  • [x] docs
  • [x] blocking
  • [x] good first issue
馃摑 documentation

Most helpful comment

Hey!

I was doing it incorrectly. Usually when importing from JS to TS modules, instead of

import ApolloClient from "apollo-boost";
import gql from "graphql-tag";

It is required to write

import * as ApolloClient from "apollo-boost";
import * as gql from "graphql-tag";

This case the syntax is same as in JS for imports, and everything works fine.

Have a nice day!

>All comments

Hey!

I was doing it incorrectly. Usually when importing from JS to TS modules, instead of

import ApolloClient from "apollo-boost";
import gql from "graphql-tag";

It is required to write

import * as ApolloClient from "apollo-boost";
import * as gql from "graphql-tag";

This case the syntax is same as in JS for imports, and everything works fine.

Have a nice day!

Was this page helpful?
0 / 5 - 0 ratings