You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As far as I know you can't pass props into variables in TypeScript, so to me this seems like a "gotcha!" that could be mentioned in the documentation perhaps?
I'm not happy with this, but we couldn't find a way make TypeScript infer the types if the generic was specified on only one of the two types. We discussed alternate component syntaxes that got around this, but they all came with other tradeoffs.
We'd gladly accept a PR that fixes this 🙂 I'm indifferent two which of the two types would get the annotation, and which would be inferred.
Am I safe to assume that the type in ForgoNewComponentCtor is directly passed into forgo.Component and if so, is it still necessary to use ForgoNewComponentCtor?
The ForgoNewComponentCtor type solves two needs: the constructor receives the same props that are passed to the component's first render, and it lets TypeScript warn you when you forget to return a Component instance. If you don't care about those, you don't need to use the type.
As far as I know you can't pass props into variables in TypeScript, so to me this seems like a "gotcha!" that could be mentioned in the documentation perhaps?
Good call, I'll update the migration section of the docs to reflect this.
When using TypeScript, prop types are not correctly inferred if the forgo component is not directly returned, see minimal example
The text was updated successfully, but these errors were encountered: