Skip to content

TypeScript ignores triple-slash directives when inserting imports #52263

Closed
@MariaSolOs

Description

@MariaSolOs

Adapted from this issue filed in the developer community.

Bug Report

🔎 Search Terms

  • auto-imports
  • import quick fix

🕗 Version & Regression Information

Not sure if this ever worked TBH.

💻 Code

  1. Create a TypeScript file (let's call it file1.ts) with the following content:
export const x = 0;
  1. Create a second file file2.ts with the following:
// A header

/// <reference lib="es2017.string" />

const y = x + 1;
  1. Request quick fixes for the "Cannot find name 'x'" error in file2.ts and select "Add import from './file1.ts'".

🙁 Actual behavior

The auto-import will modify file2.ts to, which makes the triple-slash directive lose its meaning:

// A header

import { x } from "./file1";

/// <reference lib="es2017.string" />

const y = x + 1;

🙂 Expected behavior

The server adds the import under triple-slash directives.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions