`typescript/sync`: tuples and type literals from `checker.typeToTypeNode` print multi-line (SingleLine flag lost)
Mantenedores costumam responder em até 1 dia
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 53/100
- Tipo de issue
- Bug
- Clareza
- Claramente especificada
- Status de atividade
- Ativa
- Stack de tecnologia
- node.js, typescript
- Domínio
- developer-experience, tooling
Direção de pesquisa
Start with the typescript/sync API's checker.typeToTypeNode and api.printer.printNode path, then inspect dist/api/node/encoder.generated.js and how getNodeCommonData encodes multiLine. Compare the emitted node flags with the classic API behavior for tuple and inline object types. Done means the provided reproduction prints [Date, number] and { a: string; } on one line through typescript/sync.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
🔎 Search Terms
typeToTypeNode multiline, printNode single line, EmitFlags SingleLine api, typescript/sync printer, typeToTypeNode tuple printed on several lines
🕗 Version & Regression Information
- This changed between versions 6.0.2 (classic API) and 7.1.0-dev.20261027.1 (
typescript/sync, gitHead 49e69830) - not the same as #64429 - that one asks for
setEmitFlagson nodes the caller builds. here the checker builds the nodes, and the 6.0 node builder marks them single-line itself
⏯ Playground Link
n/a - needs the typescript/sync API
💻 Code
// input.ts
export type Shape = { tuple: [Date, number]; obj: { a: string } };
// repro.mjs - node 24.18, [email protected]
import path from 'node:path';
import { API } from 'typescript/sync';
const entry = path.resolve('input.ts');
const api = new API({ cwd: process.cwd() });
const program = api.createProgram([entry], { strict: true });
const checker = program.getProject().checker;
const sourceFile = program.getSourceFile(entry);
const alias = sourceFile.statements.find(s => s.name?.text === 'Shape');
const shape = checker.getDeclaredTypeOfSymbol(checker.getSymbolAtLocation(alias.name));
for (const prop of checker.getPropertiesOfType(shape)) {
const type = checker.getTypeOfSymbol(prop);
const node = checker.typeToTypeNode(type, sourceFile, 0);
console.log(`--- ${prop.name}`);
console.log('printNode:');
console.log(api.printer.printNode(node));
console.log(`typeToString: ${checker.typeToString(type)}`);
}
api.close();
🙁 Actual behavior
--- tuple
printNode:
[
Date,
number
]
typeToString: [Date, number]
--- obj
printNode:
{
a: string;
}
typeToString: { a: string; }
the same script on 6.0.2 (ts.createProgram, ts.createPrinter().printNode(ts.EmitHint.Unspecified, node, sourceFile)) prints [Date, number] and { a: string; }
🙂 Expected behavior
printNode gives [Date, number] and { a: string; } on one line, like 6.0 and like typeToString
Additional information about the issue
we generate a big .ts file of request/response types from typeToTypeNode output and are moving the generator from the 6.0 API to typescript/sync. this is the one difference we can't work around - every tuple and inline object type from the checker now takes several lines, and on one of our services ~14.5k of the 16k lines of the generated file change
as far as we can see the node encoder only sends multiLine for blocks and object/array literals (getNodeCommonData in dist/api/node/encoder.generated.js), and PrintNodeOptions only has preserveSourceNewlines, neverAsciiEscape and terminateUnterminatedLiterals, so the client can't ask for single-line. keeping the node builder's single-line flag on these nodes, or a printer option, would both do it for us
- Linguagem predominante
- Go
- Estrelas
- 112k
- Forks
- 16k
- Merge médio
- 3d 6h
- PRs com merge (30d)
- 136
Preparar o ambiente
Inicia o contêiner de desenvolvimento do projeto no navegador, com a sua própria conta do GitHub.
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de microsoft/TypeScript
-
API: `tsc.exe` opens a visible console window on Windows when the parent process has no consoleAberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
microsoft/TypeScript#65083 ·
Mantenedores costumam responder em até 1 dia
-
TS7 LSP: documentHighlight returns nothing when the file path contains '@'Talvez livre de novo Um pull request para esta issue foi fechado sem ser mesclado. AbertaBug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
microsoft/TypeScript#64758 ·
Mantenedores costumam responder em até 1 dia
-
Language server (tsc --lsp) exits with code 1 after `shutdown` and `exit`Talvez já em andamento @rajnish-verma-22172 assumiu há 11 dias. AbertaBug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
microsoft/TypeScript#64742 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
Class names `eval` and `arguments` are not reported as invalid strict mode bindingsTalvez já em andamento @dmety assumiu há 24 dias. AbertaBug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
microsoft/TypeScript#64661 ·
Mantenedores costumam responder em até 1 dia
-
Non-enum CLI options with multiple values separated by comma and space aren't whitespace trimmedTalvez já em andamento @RyanCavanaugh assumiu há 25 dias. AbertaBug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
microsoft/TypeScript#64618 · 1 responsável ·
Mantenedores costumam responder em até 1 dia
Todas as issues de microsoft/TypeScript
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 66/100
Mantenedores costumam responder em até 1 dia
-
[Request]: pigAbertapackage-request
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
ScoopInstaller/Extras#19203 ·
Mantenedores costumam responder em até 1 dia
-
terminal: with OptionAsAlt, ⌥E types ´ after ESC e on macOSTalvez já em andamento @egoist assumiu hoje. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 70/100
Mantenedores costumam responder em até 1 dia
-
security
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
Waschndolos/open-clubmanager#185 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
router-for-me/CLIProxyAPI#7161 ·
Mantenedores costumam responder em até 1 dia