我继承了代码,我正在尝试将其转译并最终运行。在 components/TableAsset.tsx
中,我发现了以下几行
import { Table } from "antd";
const { Column, ColumnGroup } = Table;
class MyTable extends Table<Interfaces.ViewEntry> { }
这给出了各种 typescript errors, which I do not understand 。但这段代码的实际用途可能是什么?您会如何在今天的 Typescript 3.x 中编写它?
最佳答案
But what might have actually be intended with this piece of code?
该代码:
1. Imports 来自 "antd"
的名为 Table
的命名导出:
import { Table } from "antd";
2.使用 destructuring 将 Table.Column
和 Table.ColumnGroup
分别分配给常量 Column
和 ColumnGroup
:
const { Column, ColumnGroup } = Table;
3.创建一个扩展Table
的类,为Table
的通用参数提供Interfaces.ViewEntry
(更多:generics) :
class MyTable extends Table<Interfaces.ViewEntry> { }
How would you write it in today's Typescript 3.x?
该代码适用于 TypeScript 3.x。
关于javascript - 如何正确创建类成员?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58488732/