Skip to content

crash in new addImplementationSuccessElaboration #41015

Closed

Description

Crashes 44 packages in DT.

✔ ~/DefinitelyTyped/types/agent-base [master|✔] 
09:28 $ tsc
/home/nathansa/ts/built/local/tsc.js:105472
                throw e;
                ^

TypeError: Cannot read property 'length' of undefined
    at getSignatureFromDeclaration (/home/nathansa/ts/built/local/tsc.js:53357:89)
    at addImplementationSuccessElaboration (/home/nathansa/ts/built/local/tsc.js:67988:37)
    at resolveCall (/home/nathansa/ts/built/local/tsc.js:67955:25)
    at resolveCallExpression (/home/nathansa/ts/built/local/tsc.js:68284:20)
    at resolveSignature (/home/nathansa/ts/built/local/tsc.js:68657:28)
    at getResolvedSignature (/home/nathansa/ts/built/local/tsc.js:68688:26)
    at checkCallExpression (/home/nathansa/ts/built/local/tsc.js:68814:29)
    at checkExpressionWorker (/home/nathansa/ts/built/local/tsc.js:71378:28)
    at checkExpression (/home/nathansa/ts/built/local/tsc.js:71287:38)
    at checkExpressionStatement (/home/nathansa/ts/built/local/tsc.js:73819:13)

Added in #41001

Activity

  1. added
    BugA bug in TypeScript
    CrashFor flagging bugs which are compiler or service crashes or unclean exits, rather than bad output
    on Oct 9, 2020
  2. sandersn commented on Oct 9, 2020

    @sandersn
    MemberAuthor

    calling getSignatureFromDeclaration on a ModuleDeclaration, which has no parameters, so declaration.parameters.length crashes.

  3. sandersn commented on Oct 9, 2020

    @sandersn
    MemberAuthor

    Overloaded ambient function merged with namespace, such that the function implementation is not the last declaration. An easy fix is to skip such merges, although it's probably possible to use a different method to find the implementation declaration.

    This crash might only apply in d.ts files, where there IS no implementation.

    declare namespace Agent {
      interface Agent { ... }
    }
    declare function Agent(opts?): Agent.Agent;
    declare function Agent(callback, opts?): Agent.Agent;
    export = Agent;
  4. weswigham commented on Oct 9, 2020

    @weswigham
    Member

    The crash is just because of an unchecked cast - turns out having a .body member isn't enough to guarantee the declaration is function-like, since namespaces also have a .body 😛 - PR is up: #41017

  5. 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 TypeScriptCrashFor flagging bugs which are compiler or service crashes or unclean exits, rather than bad outputFix 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