Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/dts_resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,10 @@ impl<Fs: FileSystem> ResolverGeneric<Fs> {
{
return Some(p);
}
// TS: `extensions & Extensions.Json && tryExtension(Extension.Json)`
if let Some(p) = self.dts_try_file(base, ".json", ctx) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Guard .json fallback by active extension set

This unconditional .json probe runs even when the caller intentionally excludes runtime files (for example the first node_modules pass uses priority_exts = TYPESCRIPT|DECLARATION in dts_resolve_node_modules). In that path, a package whose main points to index.json now resolves to the JSON implementation before the resolver gets to the @types lookup, which regresses declaration-priority behavior and can return runtime JSON where typings are available.

Useful? React with 馃憤聽/ 馃憥.

return Some(p);
Comment thread
Boshen marked this conversation as resolved.
}
}
".tsx" | ".jsx" => {
if extensions.contains(Extensions::TYPESCRIPT) {
Expand Down Expand Up @@ -404,9 +408,7 @@ impl<Fs: FileSystem> ResolverGeneric<Fs> {

// TS uses getRelativePathFromDirectory to compute the specifier,
// which strips the "./" prefix from package.json entry values.
let vp_specifier = entry
.map(|e| e.strip_prefix("./").unwrap_or(e))
.unwrap_or("index");
let vp_specifier = entry.map_or("index", |e| e.strip_prefix("./").unwrap_or(e));
if let Some(path) = self.dts_resolve_via_version_paths(
extensions,
vp_specifier,
Expand Down
Loading