Skip to content

Triple-slash references to marker-free TypeScript files depend on import order #3593

Closed

Description

@nickna

A triple-slash path reference to a marker-free .ts file fails if a side-effect import loads the same file first.

shared.ts

const marker = 1;

referrer.ts

/// <reference path="./shared.ts" />
export {};

main.ts

import './shared';
import './referrer';
console.log('main');

SharpTS reports that the path reference cannot refer to a module file and claims shared.ts contains import/export statements. Swapping the two import lines prints main in interpretation and in saved IL with verification passing. TypeScript 6.0.3 with --module NodeNext accepts both orders, and both emitted programs print main in Node v22.23.2.

Reproduce with --no-tsconfig --noLib main.ts or --no-tsconfig --noLib --compile main.ts --verify -o main.dll. Both orders behave the same on the compiler before the #3552 follow-up changes and on PR #3577. The resolver mutates the cached IsScript after an import, then uses that value to validate a later path reference. This differs from #3547, which classifies sources with explicit ESM extensions.

Activity

  1. added a commit that references this issue on Nov 9, 2026
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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions