Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
sophiajt opened this issue Aug 25, 2015 · 3 comments
Closed

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

sophiajt opened this issue Aug 25, 2015 · 3 comments
Labels
Bug A bug in TypeScript Won't Fix The severity and priority of this issue do not warrant the time or complexity needed to fix it

Comments

@sophiajt
Copy link
Contributor

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.

@sophiajt sophiajt changed the title 'extends null' doesn't seem to error on using methods from Object.prototype 'extends null' doesn't error on using methods from Object.prototype Aug 25, 2015
@danquirk
Copy link
Member

Probably some relevant discussion in #3696 and the linked issues therein

@sophiajt
Copy link
Contributor Author

Good catch. Missed that one when I searched

@mhegazy
Copy link
Contributor

mhegazy commented Aug 26, 2015

This is by design so far. We assume that Object is the super type of everything. if we want this to work, we need to change this assumption. the complexity of the change does not map to the value added to the user by enabling this feature.

@mhegazy mhegazy added By Design Deprecated - use "Working as Intended" or "Design Limitation" instead Won't Fix The severity and priority of this issue do not warrant the time or complexity needed to fix it Bug A bug in TypeScript and removed By Design Deprecated - use "Working as Intended" or "Design Limitation" instead labels Aug 26, 2015
@mhegazy mhegazy closed this as completed Aug 26, 2015
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Won't Fix The severity and priority of this issue do not warrant the time or complexity needed to fix it
Projects
None yet
Development

No branches or pull requests

3 participants