Skip to content

tsconfig files + include: listed files don't suppress .d.ts siblings or duplicate matches #1010

Open

Description

@kjmin-dev

When tsconfig.json uses both files and include, tsrs builds a different root file list than tsgo at the pinned commit. A .d.ts (or .js with allowJs) next to a file listed in files gets included when include matches it instead of being skipped in favor of the higher-priority source extension, and a file in files that also matches include is added a second time.

Versions

  • tsrs: 7.1.0-beta.tsrs2 from npm (Version 7.1.0-beta (tsrs 7.1.0-beta.tsrs2, microsoft/TypeScript@3e9236361fa9)), 0.25.0-ts7.1.0-beta from npm, and a source build of main at b12862d0
  • Reference: typescript@7.1.0-beta from npm (Version 7.1.0-beta), and tsgo built from ts-ref at the pinned commit 3e9236361fa97a9e6c685f4833ac457ae2d8c50a (HEAD verified, git diff --exit-code HEAD -- tsc packages/typescript clean)
  • Platform: macOS 26.6.2, arm64, APFS (case-insensitive)

Reproduction

tsconfig.json

{
  "compilerOptions": { "strict": true, "noEmit": true },
  "files": ["a.ts"],
  "include": ["*.d.ts"]
}

a.ts

export const v: number = fromDeclaration;

a.d.ts

declare const fromDeclaration: number;

Command run in that directory:

tsrs -p . --pretty false --singleThreaded

Expected (tsgo), exit status 2:

a.ts(1,26): error TS2304: Cannot find name 'fromDeclaration'.

Actual (tsrs), exit status 0:

(No output. --fast gives the same result.)

tsgo skips a.d.ts because a.ts is already in the program via files with a higher-priority extension. tsrs includes a.d.ts as a root file, so fromDeclaration resolves and the error is missed.

The same underlying issue also causes:

  • TS5055 on a second in-place declaration build: with "declaration": true, "files": ["index.ts"], and "include": ["*.d.ts"], the first -p . --pretty false run emits index.d.ts and exits 0, but a second run picks up index.d.ts as an input and fails (exit status 1) with error TS5055: Cannot write file '<dir>/index.d.ts' because it would overwrite input file. (tsgo exits 0 with no output).
  • Duplicate --explainFiles reason: with "files": ["a.ts"], "include": ["*.ts"] (or "files": ["./a.ts", "a.ts"]), Part of 'files' list in tsconfig.json is printed twice for a.ts.
  • False TS1149 on case-insensitive volumes: with a.ts on disk and "files": ["A.ts"], "include": ["*.ts"], tsgo exits 0 with no output while tsrs exits 2 with error TS1149: File name '<dir>/a.ts' differs from already included file name '<dir>/A.ts' only in casing.
  • allowJs sibling inclusion: with a.ts and a.js on disk and "files": ["a.ts"], "include": ["*.js"], --listFilesOnly lists a.js in tsrs but not in tsgo.

Cause

In get_file_names_from_config_specs, literal_file_map is keyed by the raw spec string from files instead of the normalized absolute path.

Go at the pin (tsoptions/tsconfigparsing.go lines 1883 to 1885):

for i := range validatedFilesSpec {
	literalFileMap.Set(keyMapper(validatedFileNames[i]), validatedFileNames[i])
}

Rust on main (tsrs_tsoptions/src/tsconfigparsing.rs lines 3080 to 3083):

literal_file_map.extend(validated_files_spec.iter().map(|file_name| {
    let file = tspath::get_normalized_absolute_path(file_name, &base_path);
    (key_mappper(file_name), file)
}));

Because the map key is e.g. a.ts or ./a.ts while every subsequent lookup in the function (lines 3135, 3154, 3162, and 3180) passes key_mappper on a normalized absolute path, literal_file_map.contains_key never matches.

Go used keyMappper(fileName) until ed4807212c28 (microsoft/TypeScript#64159, "Strongly type file paths"), which changed it to keyMapper(validatedFileNames[i]). That commit is an ancestor of the pin, and this change was missed in notes/typescript-623-ports.md (section 31).

Suggested fix

     literal_file_map.extend(validated_files_spec.iter().map(|file_name| {
         let file = tspath::get_normalized_absolute_path(file_name, &base_path);
-        (key_mappper(file_name), file)
+        (key_mappper(&file), file)
     }));

I tested this one-line change locally on b12862d0:

  • All the reproduction cases above match the pinned tsgo output and exit status.
  • tools/regressions.sh passes 54 of 54 cases.
  • tsrs-test run --suite all has the same pass set before and after: 13,695 passing, and the same five non-passing cases on both sides.

I didn't run the determinism gate, the Fourslash gate, cargo test or Clippy.

Activity

  1. oxc-captain commented on Nov 17, 2026

    @oxc-captain
    Contributor

    Triage failed unexpectedly (attempt 1 of 3).

    Run: https://github.com/oxc-project/tsrs/actions/runs/44052824412

    I can retry if a new comment provides more information or asks me to try again.

    Error:

    [flue] skill("triage") failed: 429 status code (no body)
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    triage: failedAutomated investigation failed unexpectedly

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions