Skip to content

JSXv4: First-class module prop can't be destrutured directly #5976

Closed
@glennsl

Description

@glennsl

Repro

module type Comp = {
  @react.component
  let make: () => React.element
}

@react.component
let make = (~comp as module(Comp: Comp)) =>
  <Comp />

causes the error:

The module or file Comp can't be found.

This used to work with JSXv3.

ETA:

Actually doesn't need to be used as a component. Simpler repro:

module type T = {
  let render: unit => React.element
}

@react.component
let make = (~foo as module(T: T)) => T.render()

Workaround

Destructure the module outside the argument:

@react.component
let make = (~foo) => {
  module T = unpack(foo: T)
  T.render()
}

or

@react.component
let make = (~foo: module(T)) => {
  module T = unpack(foo)
  T.render()
}

(unfortunately neither of these work with locally abstract types, see #5978)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions