Skip to content

Excluding ResponseEntity produces invalid \any<T>\ TypeScript syntax #24

Description

@Nthalk

Description

When excluding the Spring Framework package (org.springframework.) and an API method returns ResponseEntity<T>, the generator emits any<T> which is invalid TypeScript syntax.

Minimal Reproduction

Java/Kotlin Controller:

@RestController
class MyController {
    @GetMapping("/items/{id}")
    fun getItem(@PathVariable id: String): ResponseEntity<ItemResponse> {
        return ResponseEntity.ok(ItemResponse(id, "name"))
    }
}

data class ItemResponse(val id: String, val name: String)

Generator Configuration (Gradle):

typescriptGenerator {
    config {
        exclude("org.springframework.")  // Blanket exclusion
    }
}

Generated TypeScript (buggy):

getItem(id: string): AbortablePromise<any<ItemResponse>>

Problem: any<T> is invalid TypeScript syntax - generics cannot be applied to any.

Expected Behavior

One of:

  • getItem(id: string): AbortablePromise<ItemResponse> (unwrap the generic)
  • getItem(id: string): AbortablePromise<any> (drop the type parameter if using any)

Workaround

Exclude specific Spring types instead of the whole package:

exclude(
    "org.springframework.util.MimeType",
    "org.springframework.http.HttpMethod",
    "org.springframework.http.HttpStatus"
)
// DO NOT exclude "org.springframework." - generator needs ResponseEntity

Activity

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

Metadata

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