镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Implementation of inheritance not compatible with Object.getOwnPropertyNames() #13163

Description

TypeScript Version: 2.12.0

Code

class A{
private n :number= 1;
public x :number =2;
protected y: number =3;
}
class B extends A{
private m :number = 2;
}

var obj = new B();
console.log(Object.getOwnPropertyNames(obj)); 

Expected behavior:
this should only give ['m']

Actual behavior:
this when running with nodejs compiled with commonjs module gives [ 'n', 'x', 'y', 'm' ]

Activity

  1. aluanhaddad commented on Dec 25, 2016

    @aluanhaddad
    Contributor

    See this comment #10425 (comment) and the question above it.

  2. mhegazy commented on Dec 26, 2016

    @mhegazy
    Contributor

    should be addressed by #12488

  3. added
    Working as IntendedThe behavior described is the intended behavior; this is not a bug
    and removed
    SuggestionAn idea for TypeScript
    on Aug 13, 2018
  4. RyanCavanaugh commented on Aug 13, 2018

    @RyanCavanaugh
    Member

    This is the expected behavior

  5. locked as resolved and limited conversation to collaborators on Oct 21, 2025
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

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions