Skip to content

JS RPC not returning option types for TypeScript recipes #6293

@mike-solomon

Description

@mike-solomon

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions