Skip to content

'extends null' doesn't error on using methods from Object.prototype #4454

Closed
@sophiajt

Description

@sophiajt

We currently support extends null using #3516 and #3524, but I was wondering if we might also want to error on incorrectly using 'extends null'

class C extends null{
    x: number;
}

var c: C;
c.toString()

From the Mozilla docs "Extending from null works like with a normal class, except that the prototype object does not inherit from Object.prototype."

I may be missing something in the above example (apologies if so), but it looks like we might want to warn on the use of toString since, assuming I'm reading it correctly, this method does not exist on an instance of C.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptWon't FixThe severity and priority of this issue do not warrant the time or complexity needed to fix it

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions