Skip to content

[TypeScript] Multiple errors on TableCell components #13372

@JeanBeaurepaire

Description

@JeanBeaurepaire
  • 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    component: tableThis is the name of the generic UI component, not the React module!typescript

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions