Skip to content

Compiler throws with "Declaration to checkResolvedBlockScopedVariable is undefined" #27061

@athasach

Description

@athasach

TypeScript Version: 3.1.0-dev.20180912

Search Terms:

  • checkResolvedBlockScopedVariable

Code

/**
 * @enum {string} <-- Commenting this out sucessfully compiles
 */
var DICTIONARY: { [key: string]: string } = {
    '&': '&amp;'
};

// Or commenting out this function causes the compilation to succeed.
function lookup(s: string): string {
    return DICTIONARY[s] || "";
}

Expected behavior:

  • Should compile without error.

Actual behavior:

If the @enum {string} comment is removed or if the function is commented out, the compiler will be successful. Otherwise, if the function is present and the @enum {string} is present it will not.

/Users/athasach/dev/research/ts3.1_bug/node_modules/typescript/lib/tsc.js:69144
                throw e;
                ^

Error: Debug Failure. Declaration to checkResolvedBlockScopedVariable is undefined
    at checkResolvedBlockScopedVariable (/Users/athasach/dev/research/ts3.1_bug/node_modules/typescript/lib/tsc.js:25869:33)
    at resolveNameHelper (/Users/athasach/dev/research/ts3.1_bug/node_modules/typescript/lib/tsc.js:25720:25)
    at resolveName (/Users/athasach/dev/research/ts3.1_bug/node_modules/typescript/lib/tsc.js:25487:20)
    at getResolvedSymbol (/Users/athasach/dev/research/ts3.1_bug/node_modules/typescript/lib/tsc.js:35871:21)
    at checkIdentifier (/Users/athasach/dev/research/ts3.1_bug/node_modules/typescript/lib/tsc.js:37132:26)
    at checkExpressionWorker (/Users/athasach/dev/research/ts3.1_bug/node_modules/typescript/lib/tsc.js:42140:28)
    at checkExpression (/Users/athasach/dev/research/ts3.1_bug/node_modules/typescript/lib/tsc.js:42116:42)
    at checkNonNullExpression (/Users/athasach/dev/research/ts3.1_bug/node_modules/typescript/lib/tsc.js:39149:37)
    at checkIndexedAccess (/Users/athasach/dev/research/ts3.1_bug/node_modules/typescript/lib/tsc.js:39465:30)
    at checkExpressionWorker (/Users/athasach/dev/research/ts3.1_bug/node_modules/typescript/lib/tsc.js:42168:28)

Playground Link:

https://www.typescriptlang.org/play/index.html#src=%2F**%0D%0A%20*%20%40enum%20%7Bstring%7D%20%3C--%20Commenting%20this%20out%20sucessfully%20compiles%0D%0A%20*%2F%0D%0Avar%20DICTIONARY%3A%20%7B%20%5Bkey%3A%20string%5D%3A%20string%20%7D%20%3D%20%7B%0D%0A%20%20%20%20'%26'%3A%20'%26amp%3B'%0D%0A%7D%3B%0D%0A%0D%0A%2F%2F%20Or%20commenting%20out%20this%20function%20causes%20the%20compilation%20to%20succeed.%0D%0Afunction%20lookup(s%3A%20string)%3A%20string%20%7B%0D%0A%20%20%20%20return%20DICTIONARY%5Bs%5D%20%7C%7C%20%22%22%3B%0D%0A%7D

Related Issues:

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptFixedA PR has been merged for this issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions