Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ra-core package does not build due to missing query-string type definitions #5128

Closed
hjr3 opened this issue Aug 10, 2020 · 8 comments
Closed
Labels

Comments

@hjr3
Copy link
Contributor

hjr3 commented Aug 10, 2020

What you were expecting:
The ra-core package to build

What happened instead:

node_modules/ra-core/esm/dataProvider/fetch.d.ts:1:27 - error TS7016: Could not find a declaration file for module 'query-string'. '/Users/herman/Code/ra-postgraphile/node_modules/ra-core/node_modules/query-string/index.js' implicitly has an 'any' type.
  Try `npm install @types/query-string` if it exists or add a new declaration (.d.ts) file containing `declare module 'query-string';`

1 import { stringify } from 'query-string';

Steps to reproduce:

Create a new repository with the following dependency: "ra-core": "^3.7.1"

You can also try to build https://github.com/BowlingX/ra-postgraphile/tree/34962d0837f233cdf19608c3869756b960544de9 to see the error.

Other information:

I am fairly certain this has to do with ra-core having a dependency on @types/query-string, but that npm package is a stub package: https://www.npmjs.com/package/@types/query-string . Also, https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/query-string does not exist.

I noticed #4173 downgraded the version of query-string to a version that does not publish its own types.

I was able to temporarily work around this by including the latest version of query-string as a top-level dependency.

hjr3 added a commit to hjr3/ra-postgraphile that referenced this issue Aug 10, 2020
hjr3 added a commit to hjr3/ra-postgraphile that referenced this issue Aug 10, 2020
BowlingX pushed a commit to BowlingX/ra-postgraphile that referenced this issue Aug 10, 2020
@djhi
Copy link
Collaborator

djhi commented Aug 12, 2020

I just tried to install and build this package using the commit you posted (https://github.com/BowlingX/ra-postgraphile/tree/34962d0837f233cdf19608c3869756b960544de9) and it works fine. I did not see any error

@hjr3
Copy link
Contributor Author

hjr3 commented Aug 12, 2020

Do you have types/query-string cached on your system?

Here is a small repository that reproduces this: https://github.com/hjr3/ra-core-test

If you look at hjr3/ra-core-test#1 you will see that Travis CI is failing that build due to this error.

@Luwangel
Copy link
Contributor

@hjr3 I reproduced your issue. Thanks for the Github repository.

@fzaninotto
Copy link
Member

We're using an older version of query-string because the new one doesn't support IE11.

As far as I understand, the problem comes from the fact that our dependency on "@types/query-string" is a devDependency, so it is not installed when you use ra-core as a dependency.

I see 3 possible solutions:

  1. upgrade query-string to a more recent version, drop IE11 support. Not a big fan.
  2. include "@types/query-string" as a dependency of ra-core instead of devDependency. But then I fail to understand why we don't need to do the same for the other type files
  3. Do nothing, and let users of ra-core add the package themselves.

Any insights?

@Luwangel
Copy link
Contributor

@fzaninotto IE11 has only one year left before Microsoft team stops to support it (https://death-to-ie11.com). We can do the same and migrate query-string to its last version in the next major version of React-Admin.

For the moment, we can let users of ra-core add the package themselves.

@fzaninotto
Copy link
Member

We opt for solution 3. As ra-core isn't documented, and you can get every ra-core component and hook from react-admin, we consider that using ra-core directly is advanced (and unsupported) usage. If you know enough react-admin to do that, you should probably be able to add the right types definition.

@hjr3
Copy link
Contributor Author

hjr3 commented Oct 29, 2020

I was not aware that using ra-core is unsupported. So, in the case of https://github.com/BowlingX/ra-postgraphile we should be depending on react-admin instead of ra-core?

@fzaninotto
Copy link
Member

you can use ra-core, but you should know how to use it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants