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

Release 2.2 depends on SyntheticDefaultImports for ts definitions #2433

Closed
daugsbi opened this issue Sep 28, 2018 · 3 comments
Closed

Release 2.2 depends on SyntheticDefaultImports for ts definitions #2433

daugsbi opened this issue Sep 28, 2018 · 3 comments
Assignees

Comments

@daugsbi
Copy link

daugsbi commented Sep 28, 2018

Intended outcome:
The published library should not depend on any additional configuration. The types of the wrapped components need to be inferred correctly.

Actual outcome:
The published release has the following typings throughout the project i. e. in graphql.d.ts
import React from 'react';
This only works, if the tsconfig.json has the following compiler options defined.
"allowSyntheticDefaultImports": true

The typings in previous released defined it as
import * as React from 'react'

The wrapped components are typed as any.

How to reproduce the issue:
Set allowSyntheticDefaultImports: false.
Try to use graphql HOC. The types are any, although stronlgy typed.
apolloissue

With the allowSyntheticDefaultImports the types are inferred.
apolloissueresolved

Version

@danilobuerger
Copy link
Contributor

danilobuerger commented Sep 28, 2018

Caused by #2045

@meyer
Copy link

meyer commented Sep 28, 2018

The Query component is broken by this change as well:

screenshot 2018-09-28 14 12 13

@danilobuerger
Copy link
Contributor

@hwillson any insight into this? you changed this in 9a96519

@hwillson hwillson self-assigned this Sep 29, 2018
hwillson added a commit that referenced this issue Sep 29, 2018
Typescript's `allowSyntheticDefaultImports` compiler option
is something we'd like to start using, but I jumped the gun a
bit by introducing it in 9a96519.
Including it means that anyone who wants to use Typescript with
React Apollo would have to also include it in their own local
`tsconfig.json`, to be able to handle default imports
properly. This is because we're also using Typescript's `es2015`
module option, which means `allowSyntheticDefaultImports` has
to be enabled explicitly.

This commit removes `allowSyntheticDefaultImports` use, switching
back to using a combination of `import * as X` and `require`
syntax, to work with default imports. We'll re-introduce
`allowSyntheticDefaultImports` use in React Apollo 3.

Fixes #2433.
hwillson added a commit that referenced this issue Sep 29, 2018
Typescript's `allowSyntheticDefaultImports` compiler option
is something we'd like to start using, but I jumped the gun a
bit by introducing it in 9a96519.
Including it means that anyone who wants to use Typescript with
React Apollo would have to also include it in their own local
`tsconfig.json`, to be able to handle default imports
properly. This is because we're also using Typescript's `es2015`
module option, which means `allowSyntheticDefaultImports` has
to be enabled explicitly.

This commit removes `allowSyntheticDefaultImports` use, switching
back to using a combination of `import * as X` and `require`
syntax, to work with default imports. We'll re-introduce
`allowSyntheticDefaultImports` use in React Apollo 3.

Fixes #2433.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants