API: `tsc.exe` opens a visible console window on Windows when the parent process has no console

Aberta Para iniciantes
#65,083 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
2/5
Tempo estimado
1-3 horas
Facilidade para iniciantes
75/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
node.js, typescript
Domínio
api, devtools

Direção de pesquisa

Comece pelas chamadas que iniciam processos em dist/api/syncChannel.js e dist/api/async/client.js e, em seguida, verifique os arquivos-fonte e os testes correspondentes. Reproduza o relato no Windows usando o launcher fornecido e verifique os dois caminhos da API. O objetivo é que tsc.exe seja iniciado sem uma janela de console visível quando o processo pai não tiver um console.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

🔎 Search Terms

windowsHide, tsc.exe console window, API console window Windows spawn, SyncRpcChannel, ELECTRON_RUN_AS_NODE, cmd window opens, console window flash Windows, conhost tsc

🕗 Version & Regression Information
  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about Windows console windows and the API

I reproduced this on 7.0.2, 7.1.0-beta, and 7.1.0-dev.20261031.1. TypeScript 6.0.3 does not export this API.

⏯ Playground Link

No response

💻 Code

Install typescript@next in an empty directory on Windows and add these two files.

api-console.mjs (on 7.0.2, import from typescript/unstable/sync):

import { API } from "typescript/sync";

const api = new API({ cwd: process.cwd() });
setTimeout(() => api.close(), 8_000);

launch.mjs (replace the path with your VS Code installation):

import { spawn } from "node:child_process";

const env = { ...process.env, ELECTRON_RUN_AS_NODE: "1" };
spawn("C:/path/to/Microsoft VS Code/Code.exe", ["api-console.mjs"], {
  detached: true,
  stdio: "ignore",
  env,
}).unref();

Run node launch.mjs.

detached: true starts Code.exe without a console. Running api-console.mjs directly with Node from a terminal does not show the problem.

🙁 Actual behavior

A console window opens and stays open until the API closes. Its title is the path of tsc.exe. In my environment, Windows Terminal is the default terminal application, so the window opens in Windows Terminal.

This is wrong because the API communicates through pipes, so users have no reason to see this window. Tools that start one API for each project or restart the API open several windows. I found this in a VS Code extension.

🙂 Expected behavior

tsc.exe runs without a visible window, regardless of whether the parent process has a console.

Additional information about the issue

Code.exe is a GUI subsystem program, so it has no console even when it runs with ELECTRON_RUN_AS_NODE=1. Windows therefore creates a new console for tsc.exe. Other Electron-based hosts should behave the same way, but I tested only Code.exe.

These calls do not pass windowsHide in the published 7.1.0-dev.20261031.1 package:

  • dist/api/syncChannel.js: the call that starts tsc.exe with --pipe
  • dist/api/async/client.js: the call that starts tsc.exe with stdio pipes

Passing windowsHide: true in these calls should fix the problem. I confirmed this on 7.0.2 with the sync API: the unchanged script opened one window, and a run with windowsHide: true added to spawn opened none. tsc.exe started in both runs. I did not run the async API.

As a workaround, we temporarily replace child_process.spawn, call syncBuiltinESMExports(), and construct API. This works only because the sync API spawns in its constructor, and it depends on internal behavior.


AI Disclosure: Used Claude Opus 5.5 for investigation and writing.

Linguagem predominante
Go
Estrelas
112k
Forks
16k
Merge médio
3d 6h
PRs com merge (30d)
136

Preparar o ambiente

Abrir no Codespaces

Inicia o contêiner de desenvolvimento do projeto no navegador, com a sua própria conta do GitHub.

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de microsoft/TypeScript

Todas as issues de microsoft/TypeScript

Issues semelhantes

Mais issues de Go

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.