Skip to content

@genType not generating correct TypeScript definitions for module aliases #6112

Closed
@cristianoc

Description

Description:

When using @genType with module aliases, the generated TypeScript definitions are not correctly referencing the aliased modules. This issue occurs when trying to access types and functions through the module alias.

Example:

Consider the following ReScript code:

// MyModule.res
@genType
type t = int

@genType
let add: (t, int) => int = (x, y) => x + y

// Wrapper.res
module MyModuleAlias = MyModule

// Usage.res
open Wrapper

let a = 5
@genType
let b = MyModuleAlias.add(a, 3)

Expected behavior:

The @genType annotations should generate the correct TypeScript type definitions and import paths, even when using module aliases.

Actual behavior:

The generated TypeScript definitions are not correctly referencing the aliased modules, causing issues when trying to use the aliased types and functions in a TypeScript/JavaScript context.

For more discussion see: rescript-lang/rescript-core#128

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