How to extract interface from class, exact match
未关闭
feature request
Typing: destructors
- 主要语言
- Rust
- 星标
- 22.3k
- 派生
- 1.9k
- PR 合并指标
- 30 天内没有已合并 PR
描述
How to extract properties interface from class and do exact match?
```js
class A {
a: string
}
const likeA: $ShapeWithExactMatch = {} // need a: string
```
I try $Shape, but it do not exact match.
EDIT: Full example
```js
export default class A {
some: string
constructor]: string}>(rec?: K, old?: K) {
Object.assign(this, this.constructor.defaults, rec, old)
}
copy(rec: {[_: $Keys]: string}): this {
return new this.constructor(rec, this)
}
static defaults = {
some: 'default'
}
}
const a = new A({some: 'test'})
const b = a.copy({info: 'qq'})
```
贡献指南
评估
这个 Issue 还没有评估数据。