Comments (23)
The problem is likely related to contextual types for children
used through the JSX children (and not through the explicit children
prop on the component). We can see that it fails in 5.0.4 in this TS playground but it already works in the latest nightlies of TypeScript, see the playground here. I think that this has been fixed by one of my TypeScript PRs (see this one).
Since this was a bug in TypeScript itself... I'm not sure if I can figure out a library-land fix for this but gonna take another look at this some time later today.
On the flip side... this should start working in TS 5.1 which is supposed to get released... today π (according to the timeline posted here)
from react-virtualized-auto-sizer.
Fixed in 63c6c8e. Will release in a bit.
from react-virtualized-auto-sizer.
Yeah sure. Here it is: https://github.com/V-Mann-Nick/react-virtualized-auto-sizer-typing-bug
git clone https://github.com/V-Mann-Nick/react-virtualized-auto-sizer-typing-bug.git
cd react-virtualized-auto-sizer-typing-bug
pnpm install
pnpm tsc
from react-virtualized-auto-sizer.
You will either need to upgrade Typescript to the latest (5.1) or pass children as a. Explicit prop rather than JSX children. I canβt help/fix this otherwise.
from react-virtualized-auto-sizer.
That's interesting. The types are good enough to warn about a mismatch if you add e.g. disableHeight={true}
but they're reporting any
for the values π€
from react-virtualized-auto-sizer.
If I pass children
as an explicit prop it seems to work
from react-virtualized-auto-sizer.
I'm not sure why TypeScript is distinguishing between a function passed as JSX child vs a children
prop.
from react-virtualized-auto-sizer.
from react-virtualized-auto-sizer.
I still have the same problem with 1.0.19
. Types are any if passed as jsx child. Passing explicitly as children
prop works though.
https://codesandbox.io/s/react-virtualized-auto-sizer-any-type-ny0l6l
from react-virtualized-auto-sizer.
Maybe there's an issue with the TypeScript version being used on Code Sandbox. I'm not sure.
TypeScript properly handles the types for the latest release, so I don't know what I can further do about this:
https://www.typescriptlang.org/play?#code/JYWwDg9gTgLgBAJQKYEMDG8BmUIjgIilQ3wG4AoUSWOAQQFcYIBlYALySjm1wKPRgBaAG7BY9FABt2SACaCUjCIIDOMqGXLkA9NrgAVJCpgqtACnJw4AHgZNWHLmgAWwSbKIA7ALwBvM75wzkjAAObOMAA0cADuwLIwznAAvgCUcN4AfHAWVlbWssDCcMYAnpJIfoHBYRHRcQlJyclw2pmWcKktbeSpFLk2dizqcC5uHkg+-oENiSnpWTkd+YXFZRVVsfFzza3tVl1whSooAEYVABIh4TB+MFD0SN3tfeQDtkoOnKOu7l5+ASC1wi8wy2QGKyKJRg5UqvmqwPgux6BxaxzOFQA6ttnHcHk89r1+h1dHAAAImQRIAAeYCQGCpUBwUA6H3sIzGf0mAIRtSiW0aoMWEJsq2hsM2NRu9RxKWeHUO6POSCufLxj3lrwGpIpKiptPpQk4zNZQy+Tl+EymgKldQFOwW4OWoqh6zhvOl9qa8tRR2AJ2V2Ma6oJPVeQA
from react-virtualized-auto-sizer.
I'm using the latest version of typescript in my editor (5.0.4) and I have the same issue there.
from react-virtualized-auto-sizer.
@V-Mann-Nick could u prepare a repository that would showcase the problem?
from react-virtualized-auto-sizer.
FWIW opening that repo locally picks up the correct types for me.
from react-virtualized-auto-sizer.
Thanks Andarist!
from react-virtualized-auto-sizer.
Ok. I guess I'll just use the children prop for now and look at it again when TS 5.1 released. Perhaps worth reopening this issue until it has been resolved?
Thanks for the quick responses π
from react-virtualized-auto-sizer.
@bvaughn I think that somehow you are using a different TS version locally, ain't sure how though. Could you recheck with cmd+P: "Select TypeScript Version..."? I tested this repro and can observe the problem as expected
I tried a couple of things locally (different variations based on height?: never
as similar) and can't make it work with TS 5.0. So if you intend to keep this shape of the API, I would advise just waiting for the 5.1 release which should come really soon.
from react-virtualized-auto-sizer.
Seems like I'm using a pre-release TS version (5.2 dev from a few days ago). Don't know why.
I'm sorry for the confusion this is causing folks, but I don't want to spend time reverting this change (the past couple of releases really) because of a TypeScript issue if it's being fixed/released today. This is a side side project for me.
from react-virtualized-auto-sizer.
To be clear, there is no "fix" really. The previous types were inaccurate. (They didn't have this "any" type issue, but they did incorrect report height/width when one had been disabled.)
I don't know of a good way type this that satisfies TypeScript, at least not without rewriting this component to be a function component (which may help but would also be a breaking change and raise the min React version).
from react-virtualized-auto-sizer.
The issue is in the TS version. It's this issue, which exits in Typescript v4 and is fixed in v5:
from react-virtualized-auto-sizer.
The issue is in the TS version. It's this issue, which exits in Typescript v4 and is fixed in v5:
@shiftyp Interesting. Why is @V-Mann-Nick seeing this problem with TypeScript 5.0.4?
from react-virtualized-auto-sizer.
from react-virtualized-auto-sizer.
I am using TS 5.1.3 and auto-sizer 1.0.20 and the problem stills happen. :(
from react-virtualized-auto-sizer.
Try this ({ width, height }: VerticalSize): ReactElement
from react-virtualized-auto-sizer.
Related Issues (20)
- Missing class properties transform HOT 3
- The container's width (or the resize event) does not update if the parent has a scaling animation HOT 10
- The AutoSizer does not have correct width in a popover. HOT 1
- AutoSizer height and width changed from type `number` to `number | undefined` in 1.0.8 HOT 5
- `Module parse failed: Unexpected token` error HOT 3
- ResizeObserver loop limit exceeded HOT 6
- AutoSizer cannot be used as a JSX component typescript error HOT 4
- Reporting an integer size when the available space has decimals HOT 6
- "react-virtualized-auto-sizer ζ°ηζ¬ιε€ζΈ²ζεη»δ»ΆοΌε antd tabs ε²ηͺ HOT 2
- API change in return type HOT 2
- "Can't perform a React state update on an unmounted component" console error HOT 5
- 1.0.19 does not render anything HOT 1
- Is it possible to test AutoSizer-powered components in unit tests? HOT 8
- Types of disableHeight and disableWidth are incorrect HOT 6
- TypeScript: Incorrect typing of AutoSize height and width HOT 2
- Typings for conditional `disableHeight` and `disableWidth` HOT 2
- 'AutoSizer' cannot be used as a JSX component. HOT 1
- Is it possible to render content inside auto sizer callback on server? HOT 1
- AutoSizer not rendering initially with consistent height for fixed height components HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-virtualized-auto-sizer.