question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Type annotations for default export

See original GitHub issue

TypeScript Version: 2.1.1

Code

import * as webpack from 'webpack';
export default: webpack.Configuration {
};

Expected behavior: No error

Actual behavior:

[ts] Expression expected. error at default:

I couldn’t find an issue for this but it’s very likely it’s a duplicate


Please 👍 on this issue if you want to see this feature in TypeScript and avoid adding "me too" comments. Thank you!

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:348
  • Comments:36 (7 by maintainers)

github_iconTop GitHub Comments

172reactions
pelotomcommented, Apr 1, 2019

The problem with

export default ... as X

is that it’s a cast, so it purposely loses type safety.

164reactions
mohsen1commented, Dec 12, 2018

Yes, that’s what I do know but I wish I didn’t have to.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Avoid Export Default - TypeScript Deep Dive - Gitbook
Discoverability is very poor for default exports. You cannot explore a module with intellisense to see if it has a default export or...
Read more >
How to flow type annotate a default object export?
The shortest way to add a type definition to your problem is a cast in flow like the following: export default ({ test:...
Read more >
Documentation - Modules - TypeScript
Each module can optionally export a default export. Default exports are marked with the keyword default ; and there can only be one...
Read more >
Flow Annotate-Exports
Flow Annotate-Exports · It won't be able to fill in every required type annotation. Some cases will require manual effort. · Inserted annotations...
Read more >
PEP 484 – Type Hints - Python Enhancement Proposals
For a checked function, the default annotation for arguments and for the return ... classes exported from typing (e.g. Sequence and Dict ),...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found