Skip to content

In JS, constructor functions without property assignments aren't recognised as classes #18171

Description

@mjbvz

TypeScript Version: 2.5.1

Code

For the JS:

function Foo() {
	this.init();
}

Foo.prototype.init = function () {
	// code
}

const a = new Foo();
a.init()

Expected behavior:
In the function Foo, this is the type of Foo and you can run go to definition on this.init

Actual behavior:
this is any. go to definition does not work on this.init but does on a.init

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugA bug in TypeScriptDomain: JavaScriptThe issue relates to JavaScript specificallyDomain: LS: Symbol NavigationRelates to go-to-definition, find-all-references, highlighting/occurrences.Effort: ModerateRequires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Fix AvailableA PR has been opened for this issueVS Code TrackedThere is a VS Code equivalent to this issue

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions