BarA, IEnumerable " /> BarA, IEnumerable " /> BarA, IEnumerable "/>

Type in typescript that is equivalent to "record" type in C# 9.0

1k Views Asked by At

A data model in my project is using the "record" type in C# 9.0. It's something like:

public record Foo(IEnumerable<string> BarA, IEnumerable<string> BarB);

  1. I don't know what type should be used in the correspond model in typescript (my frontend code).

  2. The next question is what should I do with the TypeWriter to deal with this data type.

Many thanks.

1

There are 1 best solutions below

0
Dzun Ho On BEST ANSWER

I've tried the solution in github.com/frhagn/Typewriter/issues/337 (thanks Aleksey L.) and hereafter is what we can configure so that it can be generated:

export interface Foo {
  BarA: string[];
  BarB: string[];
}

The thing is due to we are using the unofficial TypeWriter version so that we need to install it manually every time after we close and start the Visual Studio again (my version is VS 2019).