Skip to content

JS: Prototype property assignment prevents property lookup from type reference #33013

Closed
@sandersn

Description

@sandersn
var Validator = function Validator(parser) {
    this.flags = "gim"
};

Validator.prototype.num = 12
/**
 * @param {Validator} state
 */
var validateRegExpFlags = function(state) {
    return state.flags
};

Expected behavior:
state.flags: string

Actual behavior:
Property 'flags' does not exist on type 'Validator'

Note that if you use a value like new Validator().flags, the property is resolved just fine. If you remove the prototype property assignment, the property also resolves.

Seems like an interaction of the contructor-functions-as-classes + stricter-jsdoc-type-references PR.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFix AvailableA PR has been opened for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions