microsoft / microsoft/TypeScript

`@type {const}` produces namespace in .d.ts instead of normal object type

Offen
#56,789 6 Kommentare 0 Reaktionen 1 zugewiesene Person Auf GitHub ansehen

@sandersn arbeitet bereits daran.

Seit 22.12.2023.

Bug Domain: JSDoc Rescheduled
Vorherrschende Sprache
Go
Sterne
111k
Forks
14.4k
Ø Merge
1 T. 19 Std.
Gemergte PRs (30 T.)
117

Beschreibung

🔎 Search Terms

@type {const}
const
definition types

🕗 Version & Regression Information
  • This is a crash in all versions
⏯ Playground Link

https://www.typescriptlang.org/play?target=99&jsx=0&ts=5.3.2&filetype=ts#code/KYDwDg9gTgLgBAYwgOwM7wLYE8DCL1wC8cA9AFRlwACMWYwcA3kmjAL5xklMCwAUAEgAZhAgAuOAHIARgEMokgDT9hAV1UTGK4aIkz5klW35sA3PyA

💻 Code
// Typescript file
export const myConst = /** @type {const} */ {
	foo: 'bar',
	fuu: {
		foo: 'bar'
	}
};
// Javascript file
export const myConst = /** @type {const} */ {
	foo: 'bar',
	fuu: {
		foo: 'bar'
	}
};
🙁 Actual behavior
// .D.TS from Typescript file
export declare const myConst: {
    foo: string;
    fuu: {
        foo: string;
    };
};
// .D.TS from Javascript file
export namespace myConst {
    let foo: string;
    namespace fuu {
        let foo_1: string;
        export { foo_1 as foo };
    }
}
🙂 Expected behavior

Same output in both cases. Typescript file output is the correct one.

Additional information about the issue

No response

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.