Skip to content

[TS] Preserve superclass type arguments in EtsIR #400

Description

@CaelmBleidd

Problem

The TypeScript frontend records a superclass only by its class signature. It drops type arguments from an extends clause. A field inherited from a generic base therefore keeps an unresolved T even when the subclass fixes T to a specific runtime constructor type.

Minimal TypeScript example

class A {}
class Base<T> { ctor!: T; }
class Child extends Base<typeof A> {}

export function check(value: Child): boolean {
  return typeof value.ctor === "function";
}

For const child = new Child(); child.ctor = A, check(child) is true in Node.js. The current EtsIR contains Child.superClassName = Base and Base.ctor: GenericType(T) but no typeof A substitution from Child extends Base<typeof A>.

Expected support

Preserve superclass type arguments in the EtsIR class model and JSON/Kotlin round trip. Substitute them when resolving inherited field and method types; do not infer the runtime field value solely from the substituted type. Until a consumer models a constructor-valued field input, it should report that input as explicitly unsupported rather than a completed false typeof result.

Acceptance criteria

  • A native frontend regression checks the Child extends Base<typeof A> relation and inherited ctor type after substitution, including JSON round trip.
  • A second regression covers a multi-level generic inheritance chain and an unrelated class with the same name in another file, so substitution follows class identity rather than name alone.
  • Existing nongeneric extends and inherited member resolution remain correct.

Found while reviewing UnitTestBot/usvm#464. That PR guards the unmodeled input conservatively; this issue tracks the missing frontend type relation separately.

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