Skip to content

[JS/TS] an explicit class that inherits another explicit class loses the base #5168

Closed

Description

@shayanhabibi
type Base =
    val Name: string
    new(name) = { Name = name }
type Derived =
    inherit Base
    val Extra: int
    new() = { inherit Base("derived"); Extra = 5 }

Derived().Name is undefined (.NET derived). The emitted class Derived does not extend Base, and the constructor calls Base's constructor function and discards the result. Members of Base called on a Derived then see none of its fields.

Fickl related

Activity

  1. MangelMaxime commented on Nov 2, 2026

    @MangelMaxime
    Member

    Fixed by #5226: Derived now extends Base and calls super(...), so Derived().Name is "derived" as on .NET. #5226 also added tests for this pattern in tests/Js/Main/TypeTests.fs.

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