Skip to content

Don't use exceptions to handle optimistic file opens in the compiler. #39740

@MicahZoltu

Description

@MicahZoltu

Search Terms

compiler exception fileExists

Suggestion

Re-implement the fileSystemEntryExists function in the compiler such that it doesn't use exception handling to determine folder presence.

Use Cases

When using ts-node, if you turn on "break on all exceptions" when trying to track down a bug in some TypeScript code, hundreds of exceptions will be thrown from the TypeScript compiler as it tries to find files on disk by probing a number of locations for each file. At the moment, this makes the "break on all exceptions" feature of my debugger essentially useless unless I can get a breakpoint set before the error in question occurs but after TS has loaded everything which isn't always possible (especially when using dynamic imports).

Examples

N/A I think, let me know what I should put here if something is desired.

Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ExternalRelates to another program, environment, or user action which we cannot control.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions