microsoft / microsoft/TypeScript
JS Typedef merged with default export alias behaves strangely
Nobody has claimed this yet.
- 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
in a TS file:
import Def from "./file.js"
type Q = Def;
console.log(Def);
with file.js:
const x = 12;
export {x as default};
/**
* @typedef {string | number} default
*/
with checkJs and allowJs both on, the hover text for Def is surprisingly correct:

however the console.log is marked as an error, stating:
'Def' only refers to a type, but is being used as a value here.
Expected behavior:
Since the quickinfo shows it's clearly a value (and a value is, in fact, exported), the default import should be usable as a value.
Actual behavior:
The default import is not usable as a value without error.
cc @sandersn
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with the TypeScript 3.4.0-dev setup using the provided .ts and .js snippets, with checkJs and allowJs enabled. Trace how the default export alias and JSDoc typedef named default are merged, then verify that the imported Def is accepted in console.log while retaining the shown type information.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 52/100