Skip to content

TypeScript ignores triple-slash directives when inserting imports #52263

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
MariaSolOs opened this issue Jan 16, 2023 · 0 comments · Fixed by #52484
Closed

TypeScript ignores triple-slash directives when inserting imports #52263

MariaSolOs opened this issue Jan 16, 2023 · 0 comments · Fixed by #52484
Labels
Bug A bug in TypeScript Domain: Auto-import Help Wanted You can do this
Milestone

Comments

@MariaSolOs
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: Auto-import Help Wanted You can do this
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants