selfrefactor / rambdax

Extended version of Rambda
https://selfrefactor.github.io/rambdax
MIT License
221 stars 26 forks source link

Importing rambdax into React with typescript breaks the app. #60

Closed dusanbass closed 4 years ago

dusanbass commented 4 years ago

Hi,

I'm trying to learn to use rambdax and I'm importing it in an Create React App starter kit with a TypeScript template. However I cannot proceed with rambdax usage because of this error:

Failed to compile.

.../training-app/node_modules/rambdax/_ts-toolbelt/src/List/Append.ts
TypeScript error in .../training-app/node_modules/rambdax/_ts-toolbelt/src/List/Append.ts(13,6):
A rest element must be last in a tuple type.  TS1256

    11 | */
    12 | export type Append<L extends List, A extends any> =
  > 13 |     [...L, A]
       |      ^
    14 |

My code looks like this:

import React from 'react';
... 
import { filter, range } from 'rambdax'
...

The line with imports breaks the app. I cannot figure out why. I'm brand new to rambdax so it might be and my miss-use.

Thanks!

selfrefactor commented 4 years ago

I just created a new CRA app and I couldn't reproduce your bug. It may be related to Typescript version. Do you mind sharing package.json that you have?

dusanbass commented 4 years ago

Hello,

I'm sorry for a long delay before my answer, here it is, my package.json file:

{
  "name": "training-app",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@material-ui/core": "^4.11.0",
    "@material-ui/lab": "^4.0.0-alpha.56",
    "@reduxjs/toolkit": "^1.4.0",
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.5.0",
    "@testing-library/user-event": "^7.2.1",
    "@types/jest": "^24.9.1",
    "@types/node": "^12.19.3",
    "@types/react": "^16.9.55",
    "@types/react-dom": "^16.9.9",
    "@types/react-redux": "^7.1.9",
    "i18next": "^19.8.3",
    "rambdax": "^7.0.1",
    "react": "^17.0.1",
    "react-dom": "^17.0.1",
    "react-i18next": "^11.7.3",
    "react-redux": "^7.2.2",
    "react-scripts": "4.0.0",
    "typescript": "^3.8.3"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}
selfrefactor commented 4 years ago

This is older Typescript version than the current CRA tool. If you use the newest version, then you should be fine. Still, I realize that I need a tool to test which TS versions are supported.

dusanbass commented 4 years ago

Alright so some TypeScript update I will try. Do you know maybe in advance what is the minimum Typescript version for rambdax? And will you maybe include it in docs on the main GitHub page for the project?

p.s. EDIT I've just updated the TypeScript:

from "typescript": "^3.8.3" to "typescript": "^4.0.5"

And everything just works! Thank you @selfrefactor very much for your time and effort!

selfrefactor commented 4 years ago

I test it with latest TS. Information about supported TS version is coming for both Rambda and Rambdax.