Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default import syntax doesn't work, but { default as } does. #24847

Closed
rdsedmundo opened this issue Jun 10, 2018 · 3 comments
Closed

Default import syntax doesn't work, but { default as } does. #24847

rdsedmundo opened this issue Jun 10, 2018 · 3 comments
Labels
Duplicate An existing issue was already created

Comments

@rdsedmundo
Copy link

Hello, look at the following please:

This results in a compile error:

import API from 'apifn';

// TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
export default new API('https://google.com', []);

This works:

import { default as API } from 'apifn';

export default new API('https://google.com', []);

Both allowSyntheticDefaultImports and esModuleInterop are set to true here.

I can't understand how those syntaxes are different, as I believe the default import syntax is part of the TC39 standard already or isn't it? Asking because this works perfectly with Babel. Only when I'm with projects with TypeScript that this confusion with default starts to happen.

The apifn package is a small package developed by myself. It uses TypeScript for generating ES5+Common JS.

Related Issues: #21621 (I originally posted there, but it was informed that they aren't related)

@Jessidhia
Copy link

Jessidhia commented Jun 11, 2018

This sounds like the problem and workaround I identified in #24528 (comment). Maybe it's fixed in @next.

@rdsedmundo
Copy link
Author

Indeed they look related. I'll try with the @next version and let you know the results.

@rdsedmundo
Copy link
Author

Yes, it's fixed by typescript@next.

Thank you.

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Jun 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

3 participants