mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-04 21:53:42 -06:00
Fixed JSDoc get-only accessors to be serialized as const (#55444)
This commit is contained in:
parent
f996bab056
commit
647c41d26e
@ -9697,11 +9697,12 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
serializeAsFunctionNamespaceMerge(typeToSerialize, symbol, varName, isExportAssignmentCompatibleSymbolName ? ModifierFlags.None : ModifierFlags.Export);
|
||||
}
|
||||
else {
|
||||
const flags = context.enclosingDeclaration?.kind === SyntaxKind.ModuleDeclaration && (!(symbol.flags & SymbolFlags.Accessor) || symbol.flags & SymbolFlags.SetAccessor) ? NodeFlags.Let : NodeFlags.Const;
|
||||
const statement = factory.createVariableStatement(
|
||||
/*modifiers*/ undefined,
|
||||
factory.createVariableDeclarationList([
|
||||
factory.createVariableDeclaration(varName, /*exclamationToken*/ undefined, serializeTypeForDeclaration(context, typeToSerialize, symbol, enclosingDeclaration, includePrivateSymbol, bundled)),
|
||||
], context.enclosingDeclaration?.kind === SyntaxKind.ModuleDeclaration ? NodeFlags.Let : NodeFlags.Const),
|
||||
], flags),
|
||||
);
|
||||
// Inlined JSON types exported with [module.]exports= will already emit an export=, so should use `declare`.
|
||||
// Otherwise, the type itself should be exported.
|
||||
|
||||
@ -27,7 +27,7 @@ export const t3 = {
|
||||
//// [a.d.ts]
|
||||
export namespace t1 {
|
||||
let p: string;
|
||||
let getter: string;
|
||||
const getter: string;
|
||||
}
|
||||
export namespace t2 {
|
||||
let v: string;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user