【问题标题】:Type in typescript that is equivalent to "record" type in C# 9.0键入相当于 C# 9.0 中“记录”类型的打字稿
【发布时间】:2021-05-25 11:22:56
【问题描述】:

我的项目中的一个数据模型在 C# 9.0 中使用 "record" type。 是这样的:

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

  1. 我不知道 typescript 中对应模型应该使用什么类型(我的前端代码)。

  2. 下一个问题是我应该如何处理TypeWriter 来处理这种数据类型。

非常感谢。

【问题讨论】:

标签: typescript c#-9.0 typewriter


【解决方案1】:

我已经尝试过github.com/frhagn/Typewriter/issues/337 中的解决方案 (感谢 Aleksey L.),此后我们可以配置它以便生成它:

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

由于我们使用的是非官方的 TypeWriter 版本,所以每次关闭并重新启动 Visual Studio 后都需要手动安装(我的版本是 VS 2019)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-26
    • 1970-01-01
    • 1970-01-01
    • 2021-03-09
    • 2019-09-28
    • 2021-06-10
    相关资源
    最近更新 更多