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

type check not pass #1457

Closed
suanmei opened this issue Mar 27, 2021 · 7 comments
Closed

type check not pass #1457

suanmei opened this issue Mar 27, 2021 · 7 comments

Comments

@suanmei
Copy link

suanmei commented Mar 27, 2021

Describe/explain the bug
When I run tsc in my project,it show the error that

node_modules/@nivo/core/index.d.ts:2:10 - error TS2305: Module '"react-spring"' has no exported member 'OpaqueInterpolation'.

2 import { OpaqueInterpolation, SpringConfig } from 'react-spring'
           ~~~~~~~~~~~~~~~~~~~

node_modules/@nivo/core/index.d.ts:252:12 - error TS1038: A 'declare' modifier cannot be used in an already ambient context.

252     export declare const defaultAnimate = true
               ~~~~~~~

node_modules/@nivo/core/index.d.ts:253:12 - error TS1038: A 'declare' modifier cannot be used in an already ambient context.

253     export declare const defaultMotionStiffness = 90
               ~~~~~~~

node_modules/@nivo/core/index.d.ts:254:12 - error TS1038: A 'declare' modifier cannot be used in an already ambient context.

254     export declare const defaultMotionDamping = 15
               ~~~~~~~

node_modules/@nivo/core/index.d.ts:256:12 - error TS1038: A 'declare' modifier cannot be used in an already ambient context.

256     export declare const motionDefaultProps = {
               ~~~~~~~

node_modules/@nivo/core/index.d.ts:256:47 - error TS1254: A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference.

256     export declare const motionDefaultProps = {
                                                  ~
257         animate: true,
    ~~~~~~~~~~~~~~~~~~~~~~
...
260         config: 'default',
    ~~~~~~~~~~~~~~~~~~~~~~~~~~
261     }
    ~~~~~

node_modules/@nivo/core/index.d.ts:263:12 - error TS1038: A 'declare' modifier cannot be used in an already ambient context.

263     export declare const defaultMargin = {
               ~~~~~~~

node_modules/@nivo/core/index.d.ts:263:42 - error TS1254: A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference.

263     export declare const defaultMargin = {
                                             ~
264         top: 0,
    ~~~~~~~~~~~~~~~
...
267         left: 0,
    ~~~~~~~~~~~~~~~~
268     }
    ~~~~~

node_modules/@nivo/core/index.d.ts:291:31 - error TS1254: A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference.

291     export const SvgWrapper = (
                                  ~
292         props: React.PropsWithChildren<{
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
298         }>
    ~~~~~~~~~~
299     ) => JSX.Element
    ~~~~~~~~~~~~~~~~~~~~

node_modules/@nivo/core/index.d.ts:299:10 - error TS2708: Cannot use namespace 'JSX' as a value.

299     ) => JSX.Element
             ~~~

node_modules/@nivo/core/index.d.ts:311:30 - error TS1254: A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference.

311     export const Container = (props: React.PropsWithChildren<ContainerProps>) => JSX.Element
                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@nivo/core/index.d.ts:311:82 - error TS2708: Cannot use namespace 'JSX' as a value.

311     export const Container = (props: React.PropsWithChildren<ContainerProps>) => JSX.Element
                                                                                     ~~~

node_modules/@nivo/core/index.d.ts:313:38 - error TS1254: A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference.

313     export const ResponsiveWrapper = (props: {
                                         ~~~~~~~~~
314         children: (dimensions: { width: number; height: number }) => JSX.Element
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
315     }) => JSX.Element
    ~~~~~~~~~~~~~~~~~~~~~

node_modules/@nivo/core/index.d.ts:315:11 - error TS2708: Cannot use namespace 'JSX' as a value.

315     }) => JSX.Element
              ~~~

Found 14 errors.

To Reproduce

Steps to reproduce the behavior:

  1. create a vite project
  2. install @nivo/calendar and @nivo/core
  3. import @nivo/calendar
  4. run tsc

Expected behavior
no error

Screenshots
image

@nostalgiaz
Copy link

Hello!
Same if you install @nivo/core and @nivo/bar

versions:

  • @nivo/core @ 0.67.0
  • @nivo/bar @ 0.67.0
  • react-spring @ 9.0.0
ERROR in node_modules/@nivo/core/index.d.ts(2,10):
TS2305: Module '"./node_modules/react-spring/web"' has no exported member 'OpaqueInterpolation'.
ERROR in node_modules/@nivo/core/index.d.ts(280,46):
TS2536: Type 'T' cannot be used to index type 'U'.
ERROR in node_modules/@nivo/core/index.d.ts(308,10):
TS2708: Cannot use namespace 'JSX' as a value.
ERROR in node_modules/@nivo/core/index.d.ts(320,82):
TS2708: Cannot use namespace 'JSX' as a value.
ERROR in node_modules/@nivo/core/index.d.ts(324,11):
TS2708: Cannot use namespace 'JSX' as a value.

@mrmartineau
Copy link

mrmartineau commented Mar 31, 2021

For what it's worth, I have the same issue and tried fixing it by using Yarn's dependency resolutions. I added this to my package.json and the errors are still there 😞

  "resolutions": {
    "react-spring": "^9.0.0"
  }

Versions:

  • "@nivo/core": "^0.67.0"
  • "@nivo/radar": "^0.67.0"
  • "react-spring": "^9.0.0"
  • "@react-spring/types": "^9.0.0"
  • "typescript": "^4.2.3"

And I had to also install @types/react-motion, @types/d3-scale-chromatic, @types/d3-color

Also in case it's useful, here are the errors that I get:

node_modules/@nivo/core/index.d.ts:2:10 - error TS2305: Module '"react-spring"' has no exported member 'OpaqueInterpolation'.

2 import { OpaqueInterpolation, SpringConfig } from 'react-spring'
           ~~~~~~~~~~~~~~~~~~~

node_modules/@nivo/core/index.d.ts:253:12 - error TS1038: A 'declare' modifier cannot be used in an already ambient context.

253     export declare const defaultAnimate = true
               ~~~~~~~

node_modules/@nivo/core/index.d.ts:254:12 - error TS1038: A 'declare' modifier cannot be used in an already ambient context.

254     export declare const defaultMotionStiffness = 90
               ~~~~~~~

node_modules/@nivo/core/index.d.ts:255:12 - error TS1038: A 'declare' modifier cannot be used in an already ambient context.

255     export declare const defaultMotionDamping = 15
               ~~~~~~~

node_modules/@nivo/core/index.d.ts:257:12 - error TS1038: A 'declare' modifier cannot be used in an already ambient context.

257     export declare const motionDefaultProps = {
               ~~~~~~~

node_modules/@nivo/core/index.d.ts:257:47 - error TS1254: A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference.

257     export declare const motionDefaultProps = {
                                                  ~
258         animate: true,
    ~~~~~~~~~~~~~~~~~~~~~~
...
261         config: 'default',
    ~~~~~~~~~~~~~~~~~~~~~~~~~~
262     }
    ~~~~~

node_modules/@nivo/core/index.d.ts:264:12 - error TS1038: A 'declare' modifier cannot be used in an already ambient context.

264     export declare const defaultMargin = {
               ~~~~~~~

node_modules/@nivo/core/index.d.ts:264:42 - error TS1254: A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference.

264     export declare const defaultMargin = {
                                             ~
265         top: 0,
    ~~~~~~~~~~~~~~~
...
268         left: 0,
    ~~~~~~~~~~~~~~~~
269     }
    ~~~~~

node_modules/@nivo/core/index.d.ts:280:46 - error TS2536: Type 'T' cannot be used to index type 'U'.

280     type Accessor<T, U> = T extends string ? U[T] : never
                                                 ~~~~

node_modules/@nivo/core/index.d.ts:300:31 - error TS1254: A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference.

300     export const SvgWrapper = (
                                  ~
301         props: React.PropsWithChildren<{
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
307         }>
    ~~~~~~~~~~
308     ) => JSX.Element
    ~~~~~~~~~~~~~~~~~~~~

node_modules/@nivo/core/index.d.ts:308:10 - error TS2708: Cannot use namespace 'JSX' as a value.

308     ) => JSX.Element
             ~~~

node_modules/@nivo/core/index.d.ts:320:30 - error TS1254: A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference.

320     export const Container = (props: React.PropsWithChildren<ContainerProps>) => JSX.Element
                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@nivo/core/index.d.ts:320:82 - error TS2708: Cannot use namespace 'JSX' as a value.

320     export const Container = (props: React.PropsWithChildren<ContainerProps>) => JSX.Element
                                                                                     ~~~

node_modules/@nivo/core/index.d.ts:322:38 - error TS1254: A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference.

322     export const ResponsiveWrapper = (props: {
                                         ~~~~~~~~~
323         children: (dimensions: { width: number; height: number }) => JSX.Element
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
324     }) => JSX.Element
    ~~~~~~~~~~~~~~~~~~~~~

node_modules/@nivo/core/index.d.ts:324:11 - error TS2708: Cannot use namespace 'JSX' as a value.

324     }) => JSX.Element
              ~~~

node_modules/@nivo/radar/index.d.ts:22:16 - error TS2314: Generic type 'InheritedColorConfig' requires 1 type argument(s).

22         color: InheritedColorConfig
                  ~~~~~~~~~~~~~~~~~~~~

node_modules/@nivo/radar/index.d.ts:24:22 - error TS2314: Generic type 'InheritedColorConfig' requires 1 type argument(s).

24         borderColor: InheritedColorConfig
                        ~~~~~~~~~~~~~~~~~~~~

node_modules/@nivo/radar/index.d.ts:44:23 - error TS2314: Generic type 'InheritedColorConfig' requires 1 type argument(s).

44         borderColor?: InheritedColorConfig
                         ~~~~~~~~~~~~~~~~~~~~

node_modules/@nivo/radar/index.d.ts:54:20 - error TS2314: Generic type 'InheritedColorConfig' requires 1 type argument(s).

54         dotColor?: InheritedColorConfig
                      ~~~~~~~~~~~~~~~~~~~~

node_modules/@nivo/radar/index.d.ts:56:26 - error TS2314: Generic type 'InheritedColorConfig' requires 1 type argument(s).

56         dotBorderColor?: InheritedColorConfig

@mrmartineau
Copy link

mrmartineau commented Mar 31, 2021

I just found a PR that might fix some/all of our issues: #1386

Not sure what needs to happen to get it released though..

Also of note, from the above PR, if you set skipLibCheck: true in your tsconfig, these errors magically disappear /s

@suanmei
Copy link
Author

suanmei commented Mar 31, 2021

I just found a PR that might fix some/all of our issues: #1386

Not sure what needs to happen to get it released though..

Also of note, from the above PR, if you set skipLibCheck: true in your tsconfig, these errors magically disappear /s

If u set skipLibCheck,tsc will ignore all .d.ts files, so there is no error message

@nostalgiaz
Copy link

Go to #1386 and give some ❤️ , hopefully it will be merged as soon as possible :)

@mrmartineau
Copy link

If u set skipLibCheck,tsc will ignore all .d.ts files, so there is no error message

My /s was meant to denote sarcasm..

I also notice that react-spring was recently updated to v9.0.0 and moved out of release candidate stage. A PR for that change in this library should also be created. If I get time, I will do that.

@wyze
Copy link
Contributor

wyze commented Apr 26, 2021

This is fixed in the latest version.

@wyze wyze closed this as completed Apr 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants