microsoft / microsoft/TypeScript

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

Aperta
#56,789 6 commenti 0 reazioni 1 assegnatario Vedi su GitHub

@sandersn ci sta già lavorando.

Dal 22/12/2023.

Bug Domain: JSDoc Rescheduled
Lingua principale
Go
Stelle
111k
Fork
14.4k
Merge medio
1g 19h
PR unite (30g)
117

Descrizione

🔎 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

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.