8000 Function declaration with aliased `this` not treated as a constructor · Issue #39842 · microsoft/TypeScript · GitHub
[go: up one dir, main page]

Skip to content
Function declaration with aliased this not treated as a constructor #39842
Closed
@uniqueiniquity

Description

@uniqueiniquity

TypeScript Version: 3.9.7

Search Terms:
this, alias

Code

// @filename: a.js
var libObjects = {}

libObjects.dataService = function (url) {
	var scope = this;

	/**
	 * updates some data
	 */
	scope.updateData = function () {
		//...
	}

	/**
	 * stop all processing
	 */
	scope.disable = function () {
		//...
	}
}

// @filename: b.js
var service = new libObjects.dataService("");
service
//   ^?

Expected behavior:
service: dataService and should offer updateData and disable in completion.

Actual behavior:
service: any

Playground Link: Workbench Repro

Related Issues:
#36618

Metadata

Metadata

Assignees

No one assigned

    Labels

    Domain: JavaScriptThe issue relates to JavaScript specificallyHas ReproThis issue has compiler-backed repros: https://aka.ms/ts-reprosIn DiscussionNot yet reached consensusSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0