2016-12-22 7 views
2

私はRecordが新しいクラスを作成することを理解しています。なぜ、ない流れで次のようです。TypeCheck:レコードクラスとインスタンスの入力方法

コントラスト普通のクラスを使用している場合(予想通り)、次はです。TypeCheckしないで
const Person = Record({fname  : null, lname: null}); 
const Person2 = Record({fnameMANGLED: null, lname: null});   
const p : Person2 = new Person({fname: 'joe', lname: 'doe'}); // shouldn't Flow complain? 

class A{constructor() {}}; 
class B{constructor() {}};   
const a: A = new A(); 

答えて

1

v4.0.0-rc.5からは、タイプRecordOf<T>RecordFactory<T>が追加されました。

ここでは、これらのフロータイプの使用方法に関するdocsのスニペットを示します。

import type { RecordFactory, RecordOf } from 'immutable'; 

// Use RecordFactory<TProps> for defining new Record factory functions. 
type Point3DProps = { x: number, y: number, z: number }; 
const makePoint3D: RecordFactory<Point3DProps> = Record({ x: 0, y: 0, z: 0 }); 
export makePoint3D; 

// Use RecordOf<T> for defining new instances of that Record. 
export type Point3D = RecordOf<Point3DProps>; 
const some3DPoint: Point3D = makePoint3D({ x: 10, y: 20, z: 30 }); 
関連する問題