microsoft / microsoft/TypeScript

JS typedef merged with default export class behaves strangely

Open
#32,367 4 comments 0 reactions 1 assignee View on GitHub

@sandersn is already working on this.

Since Aug 28, 2026.

Bug Domain: JavaScript
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.