[TypeScript] Multiple errors on TableCell components
See original GitHub issue- This is not a v0.x issue.
- I have searched the issues of this repository and believe that this is not a duplicate.
Expected Behavior
No typescript errors.
Current Behavior
Hello, I’m having some typescript issues with TableCell props direction and sortDirection
TS2322: Type 'string' is not assignable to type 'SortDirection'.
TS2322: Type 'string' is not assignable to type 'asc' | 'desc'.
I experienced those errors on an other library and the fixed was by passing it with an Enum instead of a type for ‘asc’ or ‘dsc’. Example :
export type SortDirection = Direction | false; export const enum Direction { ASC = 'asc', DSC='desc' }
Steps to Reproduce
I’m not able to reproduce on the codesanbox, it’s weird.
Link : https://codesandbox.io/s/jz25ov7p5w
Context
I can’t compile.
Your Environment
tsconfig.json and tslint.json files are in the codesanbox
Tech | Version |
---|---|
Material-UI | 3.1.1 |
React | 16.5.2 |
Browser | |
TypeScript | 3.1.3 |
etc. |
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
[TypeScript] Multiple errors on TableCell components #13372
No typescript errors. Current Behavior. Hello, I'm having some typescript issues with TableCell props direction and sortDirection. TS2322: Type ...
Read more >Something went wrong with react table using typescript
It is possible that you are missing the @types/react-table package. If the package is installed already, there is another step to follow to ......
Read more >Grid - How do I resolve these typescript errors relating to type ...
a) I think this works in JS as restProps contain these elements and they are passed through. Typescript wants them explicitly.
Read more >HTML DOM Table cells Collection - W3Schools
The cells collection returns a collection of all <td> or <th> elements in a table. Note: The elements in the collection are sorted...
Read more >Data Grid - Editing - MUI X
To let your users edit all cells in a given row simultaneously, set the editMode prop to "row" . For more information, see...
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 FreeTop 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
Top GitHub Comments
You encountered typescripts type widening.
Possible fix:
codesandbox’ typechecking is currently not working. That’s why you couldn’t reproduce this.
Yes which is caused by typescript. I provided you with the proper documentation about that typescript behavior. It has nothing to do with this library.