mercredi 3 août 2016

Can you check if an object conforms to a Flow type at runtime?

I have a JSON object that is being parsed, and I'm writing tests for the output and I wan't to be able to check if a specific object conforms to a flow type, at runtime.

const object = {/**/}

type SomeType = {
    foo: string,
    bar: bool,
    baz: Object,
}

describe('object', () => {
    describe('.subfield', () => {
        it('conforms to SomeType', () => {
            // Here I want to write an 'expect'
            // that checks if object.subfield
            // conforms to the SomeType flow type?
        })
    });
});

Is there any way this is achievable?

Aucun commentaire:

Enregistrer un commentaire