Skip to content

Conversation

@cometkim
Copy link
Member

@cometkim cometkim commented Dec 27, 2025

See #6196 (comment) for context.

I tried to implement all the features we need, including those not supported by genType today.

Currently, it is somewhat complex to support both .ts and .d.ts outputs. Eventually, it could simplify the codegen process by unifying the codebase after deprecating genType and by organizing the context and config structures.

Config

For dts:

{
  "sources": "src",
  "package-specs": [
    {
      "module": "esmodule",
      "in-source": true,
+     "dts": true
    }
  ]
}

For TypeScript
(config schema would be changed)

{
  "sources": "src",
+ "language": "typescript",
  "package-specs": [
    {
      "module": "esmodule",
      "in-source": true
    }
  ]
}

Attributes

  • @as: Rename the generated types.

    type user // => interface user
    
    @as("User")
    type user // => interface User
  • @external("TypeName"): Use external (global) type

  • @external(("package-name", "Name", true)): named type import

  • @external(("package-name", "default", true)): default import as type

  • @external(("package-name", "*", true)): namespace import as type

  • @opaque: Force the type to be opaque

    type t 
    // abstract types will automatically be opaque
    
    type t<'a, 'b> = 'b
    // opaque type because 'a is phantom type
    
    @opaque
    type t = string
    // branded string type

@cometkim cometkim requested review from cristianoc and zth December 27, 2025 07:31
@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 27, 2025

Open in StackBlitz

rescript

npm i https://pkg.pr.new/rescript-lang/rescript@8118

@rescript/darwin-arm64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/darwin-arm64@8118

@rescript/darwin-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/darwin-x64@8118

@rescript/linux-arm64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/linux-arm64@8118

@rescript/linux-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/linux-x64@8118

@rescript/runtime

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/runtime@8118

@rescript/win32-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/win32-x64@8118

commit: 2f90e46

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant