Skip to content

"Unexpected PrivateIdentifier in name expression with literal-like access" being hit #48487

Closed

Description

Bug Report

🔎 Search Terms

"Unexpected PrivateIdentifier in name expression with literal-like access."
"Private Identifier"
"isSameEntityName"
"isPrivateIdentifier"

🕗 Version & Regression Information

I noticed this bug today (3/30/2022), but we believe that this bug goes back to Typescript 3.8

  • This changed between versions 3.7.5 and 3.8.3

⏯ Playground Link

Playground link with relevant code

💻 Code

type SomeObj = {foo?: string};

class PrivateMemberBug {
    #privateMember?: SomeObj;

    someFunc() {
        const someObj = this.#privateMember || {};
    }
}

This is a workaround I found:

type SomeObj = {foo?: string};

class PrivateMemberBug {
    #privateMember?: SomeObj;

    someFunc() {
        const someObj: SomeObj = this.#privateMember || {};
    }
}

🙁 Actual behavior

Received cryptic error in console and no errors in vscode UI.

🙂 Expected behavior

No errors expected.

Activity

  1. MartinJohns commented on Mar 30, 2022

    @MartinJohns
    Contributor

    This changed between versions 3.7.5 and 3.8.3

    Private fields were only added with version 3.8, so how could it change between these two versions?

    I'm also not sure what the issue is. This works fine, no errors. The error appears in the console of the playground.

  2. yipstanley commented on Mar 30, 2022

    @yipstanley
    Author

    This changed between versions 3.7.5 and 3.8.3

    Private fields were only added with version 3.8, so how could it change between these two versions?

    My bad, I mean that 3.8 introduced this bug. I was following the format that fit the best in the issue template.

  3. DanielRosenwasser commented on Apr 4, 2022

    @DanielRosenwasser
    Member

    Specific stack trace for searchers

    Response received: encodedSemanticClassifications-full (608). Request took 950 ms. Success: false . Message: Error processing request. Debug Failure. Unexpected PrivateIdentifier in name expression with literal-like access.
    Error: Debug Failure. Unexpected PrivateIdentifier in name expression with literal-like access.
        at isSameEntityName (node_modules/typescript/lib/tsserver.js:16334:26)
        at Object.isDefaultedExpandoInitializer (node_modules/typescript/lib/tsserver.js:16297:118)
        at getContextualTypeForBinaryOperand (node_modules/typescript/lib/tsserver.js:71833:84)
        at getContextualType (node_modules/typescript/lib/tsserver.js:72220:28)
        at getApparentTypeOfContextualType (node_modules/typescript/lib/tsserver.js:72122:17)
        at checkObjectLiteral (node_modules/typescript/lib/tsserver.js:72726:34)
        at checkExpressionWorker (node_modules/typescript/lib/tsserver.js:79103:28)
        at checkExpression (node_modules/typescript/lib/tsserver.js:79020:38)
        at maybeCheckExpression (node_modules/typescript/lib/tsserver.js:78138:38)
        at BinaryExpressionStateMachine.onRight (node_modules/typescript/lib/tsserver.js:78109:28)
        at Array.right (node_modules/typescript/lib/tsserver.js:30036:36)
        at trampoline (node_modules/typescript/lib/tsserver.js:30137:52)
        at node_modules/typescript/lib/tsserver.js:78053:30
        at checkExpressionWorker (node_modules/typescript/lib/tsserver.js:79148:28)
        at checkExpression (node_modules/typescript/lib/tsserver.js:79020:38)
        at checkExpressionCached (node_modules/typescript/lib/tsserver.js:78684:38)
        at checkDeclarationInitializer (node_modules/typescript/lib/tsserver.js:78701:23)
        at getTypeForVariableLikeDeclaration (node_modules/typescript/lib/tsserver.js:55293:74)
        at getWidenedTypeForVariableLikeDeclaration (node_modules/typescript/lib/tsserver.js:55757:56)
        at getTypeOfVariableOrParameterOrPropertyWorker (node_modules/typescript/lib/tsserver.js:55915:24)
        at getTypeOfVariableOrParameterOrProperty (node_modules/typescript/lib/tsserver.js:55803:28)
        at getTypeOfSymbol (node_modules/typescript/lib/tsserver.js:56175:24)
        at getTypeOfNode (node_modules/typescript/lib/tsserver.js:85717:28)
        at Object.getTypeAtLocation (node_modules/typescript/lib/tsserver.js:47728:31)
        at reclassifyByType (node_modules/typescript/lib/tsserver.js:129658:46)
        at visit (node_modules/typescript/lib/tsserver.js:129595:43)
        at visitNode (node_modules/typescript/lib/tsserver.js:30188:24)
        at Object.forEachChild (node_modules/typescript/lib/tsserver.js:30310:21)
        at visit (node_modules/typescript/lib/tsserver.js:129625:24)
        at visitNodes (node_modules/typescript/lib/tsserver.js:30197:30)
        at Object.forEachChild (node_modules/typescript/lib/tsserver.js:30483:24)
        at visit (node_modules/typescript/lib/tsserver.js:129625:24)
        at visitNode (node_modules/typescript/lib/tsserver.js:30188:24)
        at Object.forEachChild (node_modules/typescript/lib/tsserver.js:30481:21)
        at visit (node_modules/typescript/lib/tsserver.js:129625:24)
        at visitNodes (node_modules/typescript/lib/tsserver.js:30197:30)
        at Object.forEachChild (node_modules/typescript/lib/tsserver.js:30474:24)
        at visit (node_modules/typescript/lib/tsserver.js:129625:24)
        at visitNode (node_modules/typescript/lib/tsserver.js:30188:24)
        at Object.forEachChild (node_modules/typescript/lib/tsserver.js:30349:21)
        at visit (node_modules/typescript/lib/tsserver.js:129625:24)
        at visitNodes (node_modules/typescript/lib/tsserver.js:30197:30)
        at Object.forEachChild (node_modules/typescript/lib/tsserver.js:30549:21)
        at visit (node_modules/typescript/lib/tsserver.js:129625:24)
        at visitNodes (node_modules/typescript/lib/tsserver.js:30197:30)
        at Object.forEachChild (node_modules/typescript/lib/tsserver.js:30476:24)
        at visit (node_modules/typescript/lib/tsserver.js:129625:24)
        at collectTokens (node_modules/typescript/lib/tsserver.js:129628:17)
        at getSemanticTokens (node_modules/typescript/lib/tsserver.js:129548:21)
        at Object.getEncodedSemanticClassifications (node_modules/typescript/lib/tsserver.js:129537:28)
        at Object.getEncodedSemanticClassifications (node_modules/typescript/lib/tsserver.js:163781:44)
        at IpcIOSession.Session.getEncodedSemanticClassifications (node_modules/typescript/lib/tsserver.js:174498:53)
        at Session.handlers.ts.Map.ts.getEntries._a.<computed> (node_modules/typescript/lib/tsserver.js:173958:61)
        at node_modules/typescript/lib/tsserver.js:175836:88
        at IpcIOSession.Session.executeWithRequestId (node_modules/typescript/lib/tsserver.js:175827:28)
        at IpcIOSession.Session.executeCommand (node_modules/typescript/lib/tsserver.js:175836:33)
        at IpcIOSession.Session.onMessage (node_modules/typescript/lib/tsserver.js:175862:35)
        at process.<anonymous> (node_modules/typescript/lib/tsserver.js:178497:31)
        at process.emit (node:events:390:28)
        at emit (node:internal/child_process:917:12)
        at processTicksAndRejections (node:internal/process/task_queues:84:21)
    
  4. locked as resolved and limited conversation to collaborators on Oct 22, 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