microsoft / microsoft/TypeScript

Investigate altering extension priorities for wildcard loading

Open
#33,623 0 comments 0 reactions 1 assignee View on GitHub

@weswigham is already working on this.

Since Sep 26, 2019.

Bug Domain: Module Resolution
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

Our rules for loading files from wildcard matches prioritize .d.ts files over .json files (and at the same priority as .js files). Now that we support declaration files for .json and .js files, this is undesirable, as when declarations are emitted in-place (ie, with emitDeclarationsOnly), subsequent compilations using wildcard lookups will load the generated declaration files over the original source .js (maybe) and .json (definitely) files. Fixing this would require rejiggering the extension priority machinery in src\compiler\utilities.ts, so that declaration files are truly the lowest priority extension to load. This comment thread has a bit more discussion on the topic. A cursory glance also leads me to believe that extension priorities for extraFileExtensions as passed into getSupportedExtensions are largely unhandled, so there's probably a fair chunk of work here to revisit this system.

In the meantime, if you encounter an issue likely caused by this discrepancy, the workaround is pretty simple: Use the outDir compiler option.

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.