Closed thchia closed 6 years ago
same here
I tried to do a quick fix, but I ran into problems because (I think) the type declaration file for react-transition-group specifies a wildcard dependency for React. I am still on React v15.x so there's a collision with the latest (v16.x) version.
How can I validate my definition file? I'm a beginner with typescript
The gist of it is you need to
import React from 'react'
import { Transition } from 'react-transition-group'
And make sure that both of these type files are listed as dependencies (@types/react
@types/react-transition-group
).
The problem I had was that although this fixes this package, I got errors because @types/react-transition-group
referenced @types/react: "*"
, which caused the types for v16 to be included in my project when I am using v15.x still.
Ok thanks.
But I think @types/react @types/react-transition-group
need to be listed as devDependencies instead of dependencies.
When I look at other packages most of the time @types/*
is listed as DevDependencies.
Sorry yes I meant as devDependencies.
Thanks for your help !
Just pushed a new version. Can you tell me if it fix the issue please.
Thank you.
last bug fuxed, but new error occuring now:
ERROR in [at-loader] ./node_modules/react-toastify/index.d.ts:1:8 TS1192: Module '"C:/Projekte/DAP/DAP/Webkomponenten/node_modules/(at)types/react/index"' has no default export.
Really weird.
ERROR in [at-loader] ./node_modules/react-toastify/index.d.ts:2:24
TS7016: Could not find a declaration file for module 'react-transition-group/Transition'. '/Users/thomaschia/argomi/node_modules/react-transition-group/Transition.js' implicitly has an 'any' type.
Try `npm install @types/react-transition-group/Transition` if it exists or add a new declaration (.d.ts) file containing `declare module 'react-transition-group/Transition';`
I think this is because @types/react-transition-group
is a devDependency. It doesn't get included when installing this library.
-- EDIT Actually that doesn't make sense. Non-TS users will get it too if it is specified in dependencies.
Hmm. I'm wondering why it's not happening for React.
-- EDIT So I must leave it as devDependencies, right ?
That's because I already have the type file for react. I do not have it for the transition library.
I'm wondering if it's not due to a cache issue
no, because react.index.ts doesn´t have a default export. So you have to import it either using "*" or single components in {}
Maybe I need to turn import React from "react"
to import React = require("react")
or
import * as React from "react"
Can you check if it works for you when doing import * as React from "react"
inside the node_modules/react-toastify/index.d.ts.
I saw in definitlyTypes that `import React = require('React') is used
import * ....
works
require might work too. but i think it is recommended to avoid require if possible
Sure. Thank you for the test. I fix it now.
Fix pushed. Anything is ok for you now ?
works now @me
I think there need to be imports for React and Transition.