Skip to content

Oxc transformer miscalculates design:returntype for getter properties #14493

@cjnoname

Description

@cjnoname

Description:
The Oxc parser produces an incorrect design:returntype for getter properties when using type-graphql. Reflection does not work as expected for getter functions.

Example:

import { ObjectType, Field } from "type-graphql";

@ObjectType("Test", { description: "Test" })
export class A {
  @Field()
  line1: string;

  @Field({ nullable: true })
  line2?: string;

  @Field({ nullable: true })
  line3?: string;

  @Field()
  get address(): string {
    let address = this.line1.trim();
    if (this.line2) {
      address = address + " " + this.line2.trim();
    }
    if (this.line3) {
      address = address + " " + this.line3.trim();
    }
    return address;
  }
}

Issue:
Reflection metadata for the address getter is incorrect.

Steps to Reproduce:

Clone the repo: https://github.com/cjnoname/my-issue

Run the project and inspect the reflection metadata for the address property

Expected Behavior:
The design:returntype for the address getter should be String.

Actual Behavior:
The design:returntype does not reflect the correct type for the getter.

Metadata

Metadata

Assignees

Labels

A-transformerArea - Transformer / Transpiler

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions