Skip to content

Cannot use Dict.t<json> #6388

Closed
Closed
@Exegetech

Description

@Exegetech

Using rescript@11.0.0-rc.3 and @rescript/core@0.4.0 with bsconfig.json

{
  "name": "playground",
  "sources": {
    "dir": "src",
    "subdirs": true
  },
  "package-specs": {
    "module": "commonjs",
    "in-source": true
  },
  "suffix": ".bs.js",
  "bsc-flags": ["-open RescriptCore"],
  "bs-dependencies": ["@rescript/core"]
}

Below works

@unboxed
type rec json =
  | @as(false) False
  | @as(true) True
  | @as(null) Null
  | String(string)
  | Number(float)
  | Object(Js.Dict.t<json>)
  | Array(array<json>)

But below doesn't work

@unboxed
type rec json =
  | @as(false) False
  | @as(true) True
  | @as(null) Null
  | String(string)
  | Number(float)
  | Object(Dict.t<json>) // <--- here
  | Array(array<json>)

The compiler gives error

This untagged variant definition is invalid: Case Object has a payload that is not of one of the recognized shapes (object, array, etc). Then it must be the only case with payloads.

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