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

Spread incoming type in module function

$
0
0

This might be stretching it but can I do something like this

module BaseCollection = (
  T: {
    type data
  },
) => {
  type t

  type extendedData = {
    created: string,
    updated: string,
    // Error on this line
    ...T.data
  }

  @send
  external getList: (t, int, int) => promise<array<'data>> = "getList"

  @send
  external create: (t, 'data) => promise<'data> = "create"
}

Usage:

type notificationSubscription = {
  user: string,
  active?: bool,
  endpoint: string,
  auth: string,
  p256dh: string,
}

module NotificationSubscriptions = {
  include Pocketbase.BaseCollection({
    type data = notificationSubscription
  })
}

Can I somehow tell ReScript type data is a record?


Viewing all articles
Browse latest Browse all 1813

Trending Articles