microsoft / microsoft/TypeScript

TypeError: Cannot read properties of undefined (reading 'length') at elaborateDidYouMeanToCallOrConstruct

Open
#60,278 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Needs More Info
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
1d 19h
Merged PRs (30d)
117

Description

🔎 Search Terms

undefined length elaborateDidYouMeanToCallOrConstruct

🕗 Version & Regression Information
  • This changed between versions 5.5.4 and 5.6.2
  • I was unable to test this on the latest version because npm i typescript@next never completed, spamming the terminal with the following error for about 20 minutes before I killed it:
npm warn ERESOLVE overriding peer dependency
npm warn While resolving: coracle@0.4.14
npm warn Found: typescript@5.7.0-dev.20241018
npm warn node_modules/typescript
npm warn   typescript@"5.7.0-dev.20241018" from the root project
npm warn
npm warn Could not resolve dependency:
npm warn peerOptional typescript@">=5.0.0" from nostr-tools@2.8.1
npm warn node_modules/nostr-tools
npm warn   nostr-tools@"^2.8.1" from the root project
npm warn   4 more (@welshman/content, @welshman/dvm, @welshman/signer, @welshman/util)
⏯ Playground Link

No response

💻 Code

I'm not able to isolate the problem because the compiler is crashing without any information about my source files. You can clone the project from https://github.com/coracle-social/coracle and reproduce simply by running git checkout 5e70d4ed499b6721f41318644b6250713085c923; npm i; npx tsc.

🙁 Actual behavior

Running npx tsc in my project gives me:


/Users/me/nostr/coracle/node_modules/typescript/lib/tsc.js:120987
      throw e;
      ^

TypeError: Cannot read properties of undefined (reading 'length')
    at elaborateDidYouMeanToCallOrConstruct (/Users/me/nostr/coracle/node_modules/typescript/lib/tsc.js:62406:62)
    at elaborateError (/Users/me/nostr/coracle/node_modules/typescript/lib/tsc.js:62360:10)
    at checkTypeRelatedToAndOptionallyElaborate (/Users/me/nostr/coracle/node_modules/typescript/lib/tsc.js:62344:24)
    at getSignatureApplicabilityError (/Users/me/nostr/coracle/node_modules/typescript/lib/tsc.js:74383:14)
    at resolveCall (/Users/me/nostr/coracle/node_modules/typescript/lib/tsc.js:74779:25)
    at resolveCallExpression (/Users/me/nostr/coracle/node_modules/typescript/lib/tsc.js:75194:12)
    at resolveSignature (/Users/me/nostr/coracle/node_modules/typescript/lib/tsc.js:75587:16)
    at getResolvedSignature (/Users/me/nostr/coracle/node_modules/typescript/lib/tsc.js:75613:18)
    at checkCallExpression (/Users/me/nostr/coracle/node_modules/typescript/lib/tsc.js:75724:23)
    at checkExpressionWorker (/Users/me/nostr/coracle/node_modules/typescript/lib/tsc.js:79133:16)

Node.js v20.18.0

On my Debian 11 VPS, I get a similar error:


/home/me/node_modules/typescript/lib/tsc.js:120986
      throw e;
      ^

TypeError: Cannot read properties of undefined (reading 'length')
    at elaborateDidYouMeanToCallOrConstruct (/home/me/node_modules/typescript/lib/tsc.js:62405:62)
    at elaborateError (/home/me/node_modules/typescript/lib/tsc.js:62360:10)
    at checkTypeRelatedToAndOptionallyElaborate (/home/me/node_modules/typescript/lib/tsc.js:62344:24)
    at getSignatureApplicabilityError (/home/me/node_modules/typescript/lib/tsc.js:74382:14)
    at resolveCall (/home/me/node_modules/typescript/lib/tsc.js:74778:25)
    at resolveCallExpression (/home/me/node_modules/typescript/lib/tsc.js:75193:12)
    at resolveSignature (/home/me/node_modules/typescript/lib/tsc.js:75586:16)
    at getResolvedSignature (/home/me/node_modules/typescript/lib/tsc.js:75612:18)
    at checkCallExpression (/home/me/node_modules/typescript/lib/tsc.js:75723:23)
    at checkExpressionWorker (/home/me/node_modules/typescript/lib/tsc.js:79132:16)

Node.js v18.20.4
🙂 Expected behavior

I expect typescript to not crash.

Additional information about the issue

I completely re-installed nvm/npm/node, removed all node_modules folders on my system, removed the project director and re-cloned, just to make sure my environment wasn't dirty somehow.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the crash from the coracle commit with npm i and npx tsc, then compare TypeScript 5.5.4 and 5.6.2 as described. Start at elaborateDidYouMeanToCallOrConstruct in the compiler stack trace. Done means the compiler reports a diagnostic or completes without throwing this TypeError, with regression coverage for the reproducer.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.