Quantcast
Channel: ReScript Forum - Latest posts
Viewing all articles
Browse latest Browse all 1848

Type duplication between interface file and implementation

$
0
0

In my opinion it’s an issue that should be solved by a better IDE support, but if you’re looking for a solution nevertheless, there’s an easy way, define the types of your file
A.res in a third file (called A_Types.res for example), and then you can include it both in your implementation and interface files:

module A_Types = {
  type entitlement = {
    purchased: array<string>,
    source: string,
    failedAvailabilityChecks: array<string>,
  }
  type tokenType = | @as("bearer") Bearer
  type authResponse = {
    entitlement: entitlement,
    emailVerified: bool,
    tokenType: tokenType,
    accessToken: string,
    refreshToken: string,
    profileToken: string,
  }
}

module A: {
  include module type of A_Types
  let default: (string, string) => promise<authResponse>
} = {
  include A_Types
  let default = (a, b) => // your implementation here
}

playground link


Viewing all articles
Browse latest Browse all 1848

Trending Articles