TypeScript Definition Help
See original GitHub issueHi all,
I’m working on a TypeScript definition for withStyle. What I have so far is:
type identity<T> = (arg: T) => T;
//TODO: This could be better, specific type information about the component is lost
export default function withStyles<P, S, T>(style: any): identity<new (...args: T[]) => React.Component<P, S>>
While this is OK, clearly some type information about the component is being lost, and I’m not too sure what type to use for the style object. Any ideas how to make this better?
Note that
export default function withStyles<T extends React.Component>(style: any): identity<T>
only works if you specify the return type (with withStyles<ComponentName>). Trying to avoid explicit generics if possible.
Issue Analytics
- State:
- Created 6 years ago
- Comments:13
Top Results From Across the Web
Documentation - Type Declarations - TypeScript
TypeScript includes declaration files for all of the standardized built-in APIs available in JavaScript runtimes. This includes things like methods and ...
Read more >Documentation - Introduction - TypeScript
The Declaration Files section is designed to teach you how to write a high-quality TypeScript Declaration File. We need to assume basic familiarity...
Read more >Documentation - Declaration Reference - TypeScript
The purpose of this guide is to teach you how to write a high-quality definition file. This guide is structured by showing documentation...
Read more >Documentation - Advanced Types - TypeScript
This page lists some of the more advanced ways in which you can model types, it works in tandem with the Utility Types...
Read more >Handbook - Basic Types - TypeScript
As in JavaScript, all numbers in TypeScript are either floating point values or BigIntegers. These floating point numbers get the type number ,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Hello @danielmhanover, are you still working on the typescript? I am expecting
@types/isomorphic-style-loader. I tried with above suggestions but still seeing issues. Would you or anyone has a working solution?Thanks in advance.
Following the thread, this is a sugestion for
*.[s]cssfiles,useStyleshook andStyledContextinglobal.d.tsfile: