microsoft / microsoft/TypeScript

JS typedef merged with default export class behaves strangely

Aperta
#32,367 4 commenti 0 reazioni 1 assegnatario Vedi su GitHub

@sandersn ci sta già lavorando.

Dal 28/8/2026.

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

Descrizione

TypeScript Version: 3.4.0-dev.201xxxxx

Search Terms:

Code

class Cls {
    x = 12;
    static y = "ok"
}
export default Cls;
/**
 * @typedef {string | number} default
 */

with checkJs and allowJs on reports no errors, however on usage:

import Def from "./file.js"

type Q = Def;

console.log(Def);

the quick info is pretty comprehensive:
image
however the type usage is equal to string | number (okay, maybe that's reasonable, how are a typedef and a class even merging anyway), however there's an error on the value usage:

'Def' only refers to a type, but is being used as a value here

Expected behavior:
An error on the attempted merge (a class and a type alias should be overlapping in symbol flags domains) and for the value usage to resolve to the class, probably.

Actual behavior:
The incongruent behavior described above.

cc @sandersn

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.