openrewrite / openrewrite/rewrite

JS RPC not returning option types for TypeScript recipes

Open
#6,293 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug javascript
Dominant language
Java
Stars
3.7k
Forks
570
Avg merge
13h 12m
Merged PRs (30d)
261

Description

Details

  • Library: org.openrewrite:rewrite-javascript:8.66.2
  • Class: org.openrewrite.javascript.rpc.JavaScriptRewriteRpc
  • Method: getRecipes()

Problem

When loading TypeScript recipes via RPC, the type field of OptionDescriptor is always null, even though the TypeScript source code explicitly defines a type.

Example

From https://github.com/openrewrite/rewrite/blob/main/rewrite-javascript/rewrite/src/javascript/migrate/es6/modernize-octal-escape-sequences.ts#L35 :

  export class ModernizeOctalEscapeSequences extends Recipe {
    @Option({
      displayName: "Use Unicode escapes",
      description: "Use Unicode escape sequences...",
      required: false,
      example: "true",
    })
    useUnicodeEscapes: boolean;  // ← TYPE IS "boolean"
  }

What my RPC calls returns:

  Recipe: org.openrewrite.javascript.migrate.es6.modernize-octal-escape-sequences
    Option name: useUnicodeEscapes
      type: null                    ← Should be "boolean"
      description: Use Unicode escape sequences (`\uXXXX`)...
      example: true
      required: false

How I'm calling it:

  val rpc = JavaScriptRewriteRpc.builder().get()
  rpc.installRecipes("@openrewrite/rewrite", "8.66.2")
  val descriptors: List<RecipeDescriptor> = rpc.recipes
  for (descriptor in descriptors) {
      for (option in descriptor.options) {
          println("type: ${option.type}")  // Prints "null"
      }
  }

Expected behavior

option.type should be a non-null type such as "boolean" (as a String representation of the TypeScript type)

Actual behavior

option.type is null

Impact

  • Documentation generation shows null instead of proper types
  • Users cannot tell what type of value to provide for recipe options without checking the source code itself

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in rewrite-javascript/rewrite/src/main/java/org/openrewrite/javascript/rpc/JavaScriptRewriteRpc.java at getRecipes(), then compare its option handling with modernize-octal-escape-sequences.ts, especially the useUnicodeEscapes declaration. Verify the resulting RecipeDescriptor options expose the TypeScript type as a string rather than null, while preserving the existing description, example, and required fields.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, typescript
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.