Skip to content

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

Closed

Description

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.

Activity

  1. sandersn commented on Aug 21, 2019

    @sandersn
    MemberAuthor

    I reverted the strict-jsdoc-type-references and no change, so it's just constructor-functions-as-classes at fault.

  2. sandersn commented on Aug 22, 2019

    @sandersn
    MemberAuthor

    In constructor-functions-as-classes, I forgot to update getTypeReferenceType. It should be a lot simpler now.

  3. locked as resolved and limited conversation to collaborators on Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

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