microsoft / microsoft/TypeScript

Incorrect errors reported if typeckecking only single file

Open
#55,069 0 comments 1 reaction 1 assignee View on GitHub

@sheetalkamat is already working on this.

Since Jul 20, 2023.

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

Description

Bug Report

🔎 Search Terms
🕗 Version & Regression Information
  • This is a crash
  • This changed between versions ______ and _______
  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about _________
  • I was unable to test this on prior versions because _______
⏯ Playground Link

Playground link with relevant code

💻 Code

Dont have reduced repro but here is how to repro:

In Typescript Repo checkout commit at 4879087
Run tsc -b -v src\server
Edit src\server\project.ts to add some comment somewhere (Error is reported only when doing typechecking on this file without typechecking all files in the project)
Run tsc -b -v src\server

// We can quickly address your report if:
//  - The code sample is short. Nearly all TypeScript bugs can be demonstrated in 20-30 lines of code!
//  - It doesn't use external libraries. These are often issues with the type definitions rather than TypeScript bugs.
//  - The incorrectness of the behavior is readily apparent from reading the sample.
// Reports are slower to investigate if:
//  - We have to pare too much extraneous code.
//  - We have to clone a large repo and validate that the problem isn't elsewhere.
//  - The sample is confusing or doesn't clearly demonstrate what's wrong.
🙁 Actual behavior
src/server/project.ts:1668:13 - error TS7023: 'addMissingFileWatcher' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.

1668     private addMissingFileWatcher(missingFilePath: Path) {
                 ~~~~~~~~~~~~~~~~~~~~~

src/server/project.ts:1674:15 - error TS7022: 'fileWatcher' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.

1674         const fileWatcher = this.projectService.watchFactory.watchFile(
                   ~~~~~~~~~~~

🙂 Expected behavior

No Errors

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.