0

I am currently using Inovua RDG and am trying to center the content of each grid cell, but am getting a frustrating typescript error:

Type '{ name: string; header: string; textAlign: string; defaultFlex: number; defaultVisible?: undefined; }' is not assignable to type 'TypeColWithIdProperty'.
    Types of property 'textAlign' are incompatible.
      Type 'string' is not assignable to type '"end" | "left" | "center" | "right" | "start" | undefined'.

Here is my code, where I define the columns:

{ name: "id", header: "Id", defaultVisible: false },
{ name: "simId", header: "Sim ID", textAlign: "center", defaultFlex: 0.75 },
...

Why is this breaking? I copied directly from their reference docs here: columns.textAlign

Am I just making a stupid syntax error or something?

Thanks!!

tprebenda
  • 389
  • 1
  • 6
  • 17

1 Answers1

1

Okay so this is probably a bug with Inovua RDG, but here's what I did to fix the problem:

Since it's a weird type issue between 'string' and the various possible values of textAlign, I just manually created the correct type:

type TextAlign = "end" | "left" | "center" | "right" | "start" | undefined;

And then in my columns, I just set the textAlign value as such:

{
  name: "simId",
  header: "Sim ID",
  textAlign: "center" as TextAlign,
  defaultFlex: 1
},

And then my error was gone! Hope that helps.

tprebenda
  • 389
  • 1
  • 6
  • 17