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

Error: Field value has a type which is less general than the (defined) scoped polymorphic type

$
0
0

I get an error when I try to use a record type, a field of which is defined with a scoped polymorphic type.

Code:

module ColumnDef = {
  type cellProps<'tData, 'cellData> = {getValue: unit => 'cellData}

  type t<'tData> = {
    id: string,
    // The types of accessorFn and cell fields uses a scoped polymorphic type 'cellData: https://rescript-lang.org/docs/manual/latest/scoped-polymorphic-types
    accessorFn: 'cellData. 'tData => 'cellData,
    cell?: 'cellData. cellProps<'tData, 'cellData> => React.element,
    enableSorting?: bool,
  }
}

type t = {
  id: string,
  rank: int,
}

let columnDefs: array<ColumnDef.t<t>> = [
  {
    id: "ID",
    accessorFn: t => t.id,
  },
  {
    id: "Rank",
    accessorFn: t => t.rank,
  },
]

Error:

[E] Line 21, column 16:

This field value has type t => string
  which is less general than 'cellData. 'tData => 'cellData

Link to playground

Can someone help me solve it?


Viewing all articles
Browse latest Browse all 1969

Trending Articles