react-native-gifted-charts icon indicating copy to clipboard operation
react-native-gifted-charts copied to clipboard

Typescript errors

Open christophby opened this issue 1 year ago • 16 comments

Describe the bug

Found 187 errors in 22 files.

If you run yarn tsc you'll get 187 typescript errors in this project. Most of them are Parameter 'xyz' implicitly has an 'any' type.

To Reproduce Steps to reproduce the behavior:

  1. Add a tsconfig.json in the root with {"extends": "@tsconfig/react-native/tsconfig.json"}
  2. Add @tsconfig/react-native to the dev dependencies (is a default in react native typescript projects)
  3. Run typecheck yarn tsc or npm run tsc
  4. See errors

Expected behavior There shouldn't be any errors.

christophby avatar Dec 18 '23 12:12 christophby

@christophby whats the best way to get around this temporarily?

1kDustin avatar Dec 27 '23 20:12 1kDustin

@1kDustin I'm using patch-package to put a // @ts-nocheck on top of (almost) each file

christophby avatar Dec 27 '23 21:12 christophby

First time trying out gifted charts. Are these errors new in the latest version, or have they always been there? Is it worse using an older version?

Since I'm not yet invested in this particular package, it just look nice for what I want, I don't really want to do some hacks of adding 'nocheck' to a bunch of files.

Any chance this will be fixed soon?

digitalthjarta avatar Jan 03 '24 21:01 digitalthjarta

Hi @digitalthjarta These typescript errors have always been there. I'll try to fix them in coming 1 or 2 weeks.

Abhinandan-Kushwaha avatar Jan 03 '24 21:01 Abhinandan-Kushwaha

Thank you!

digitalthjarta avatar Jan 03 '24 21:01 digitalthjarta

Nice @Abhinandan-Kushwaha

christophby avatar Jan 18 '24 11:01 christophby

One temporary fix, that is not ideal, is to add the noimplicitAny option to your tsconfig:

"compilerOptions": {
    "noImplicitAny": false,
    ...
  },

To enforce some of the rules enforced by that config option, you can utilize this typscript-eslint rule. Note that their docs say to prefer noImplicitAny over this rule. Hopefully when types for this package are fixed, we can revert this rule.

jasonleibowitz avatar Jan 28 '24 18:01 jasonleibowitz

what is the best way to workaround this?

bryanprimus avatar Jan 29 '24 11:01 bryanprimus

Any updates here? We can not get a build with tsc build

dogancancelik12 avatar Feb 12 '24 11:02 dogancancelik12

This repo exports direct typescript code without bundling it, all typescript errors from this package (and gifted-core) will be reported in your downstream user's projects.

Regardless of a user's tsconfig settings, these errors prevent teams from building or checking types on their own code.

This can be fixed if decide to either:

  • Compile and bundle this package into JS
    • PR: #559
    • This will allow users to simply use skipLibCheck: true to ignore these issues
  • Or keep serving pure typescript and fix types on this repo & react-gifted-core
    • PR for react-gifted-core: https://github.com/Abhinandan-Kushwaha/gifted-charts-core/pull/5
  • Or add // @ts-nocheck on all the files in this repo & react-gifted-core

araphiel-nf avatar Feb 29 '24 16:02 araphiel-nf

Hi @digitalthjarta These typescript errors have always been there. I'll try to fix them in coming 1 or 2 weeks.

Any updates to this? Starting to feel like "Elon Musk two weeks" now. :)

Painful to see all github actions fail because of the missing types from this package.

tfsjohan avatar Mar 03 '24 19:03 tfsjohan

Sorry @tfsjohan @dogancancelik12 for the delay. I could have released a new version with type fixes, but here's an update.

The web counterpart of this library is almost ready. So I wanted to add types in such a way that it satisfies both- react-native and reactJS.

Check my new repo- https://github.com/Abhinandan-Kushwaha/react-gifted-charts

Expect this all to be ready by this weekend.

Abhinandan-Kushwaha avatar Mar 04 '24 21:03 Abhinandan-Kushwaha

Here's a workaround for this issue: https://gist.github.com/araphiel/b3d13ade7f9fe69e99c3d053196557d2

Hope this can help 👋

araphiel avatar Mar 10 '24 22:03 araphiel

Any updates on this @Abhinandan-Kushwaha ? :)

christophby avatar Apr 02 '24 14:04 christophby

It seems expo eas build failed because of this type error.

// Saying this because npx tsc --noEmit throw error on this library. Removing all the charts from the app , then build again did pass.

cjmling avatar Apr 08 '24 07:04 cjmling

Here's a workaround for this issue: https://gist.github.com/araphiel/b3d13ade7f9fe69e99c3d053196557d2

Hope this can help 👋

Windows 10 - I got some troubles running command to update every file from this guide, so I used this command in my cmd in order to add // @ts-nocheck line to every file:

  1. First I navigated to the module folder from project root:
cd ./node_modules/react-native-gifted-charts/src
  1. Then I ran this command to add // @ts-nocheck line to every file:
for /R %i in (*.ts *.tsx) do (echo // @ts-nocheck > temp & type %i >> temp & move /Y temp %i)
  1. After that I ran patch-package for updated module from my project root
npx patch-package react-native-gifted-charts

rodnoycry avatar Jun 06 '24 23:06 rodnoycry

Any updates on this ?

kuldip-simform avatar Jul 19 '24 10:07 kuldip-simform

Hi @christophby @1kDustin @digitalthjarta @jasonleibowitz @bryanltobing @dogancancelik12 @araphiel @tfsjohan @cjmling @rodnoycry @kuldip-simform 👋

react-native-gifted-charts is now shipping compiled js files instead of ts files from version 1.4.22 onwards. This should fix all type related issues. 🎉

Abhinandan-Kushwaha avatar Jul 28 '24 19:07 Abhinandan-Kushwaha