Skip to content
This repository was archived by the owner on Nov 13, 2023. It is now read-only.
This repository was archived by the owner on Nov 13, 2023. It is now read-only.

@gentype annotation is required for .gen.tsx creation; using functors not sufficient #582

@jmagaram

Description

@jmagaram

Consider this file. GenType creates everything I expect, including a constant for the whole NegativeInt module. BUT comment out the @genType let bozo = 0 and NOTHING gets generated. This seems really odd. Why would the inclusion of the bozo line affect generation of anything else?

Separately, I'm finding some inconsistent behavior with trying to generate those wrapped up constant exports like NegativeInt that include all the defined module functions. Sometimes it creates the constant with everything wrapped up, and sometimes it only creates the pieces inside NegativeInt without a wrapper. Can't pin this down. I was actually surprised it ever works since you can't put a genType annotation on the module itself and I thought it only worked with first class modules.

module type Validated = { type t type domain @genType let make: domain => option<t> @genType let makeExn: domain => t @genType let value: t => domain } module type Config = { type domain let validate: domain => option<domain> } module type MakeValidated = (P: Config) => (Validated with type domain := P.domain) module Make: MakeValidated = (P: Config) => { type t = P.domain let make = v => v->P.validate let makeExn = v => v->make->Option.getExn external value: t => P.domain = "%identity" } module NegativeInt = Make({ type domain = int let validate = n => switch n < 0 { | true => Some(n) | false => None } }) // Comment out these lines and nothing is generated @genType let bozo = 0 

Part of what gets generated...

export const NegativeInt: { makeExn: (_1: number) => NegativeInt_t; value: (_1: NegativeInt_t) => number; make: (_1: number) => null | undefined | NegativeInt_t; } = ExperimentBS.NegativeInt; 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions