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

Q: What is the type of a dynamic loaded es module? #22044

Closed
bobaaaaa opened this issue Feb 20, 2018 · 2 comments
Closed

Q: What is the type of a dynamic loaded es module? #22044

bobaaaaa opened this issue Feb 20, 2018 · 2 comments

Comments

@bobaaaaa
Copy link

I haven't find any resources for this question.

Example

// Foo.ts
export class Foo {}
export class Unused {}
// Bar.ts
export async function getFoo(): Promise<Foo> {
    // tslint:disable:no-any
    // What is the return type of a dynamic loaded es-module?
    return import('./Foo').then(({ Foo }: any): Foo => new Foo());
    // tslint:enable:no-any
}
@yortus
Copy link
Contributor

yortus commented Feb 20, 2018

@bobaaaaa this works:

// Bar.ts
export async function getFoo() {
    // return type is Promise<Foo>
    return import('./foo').then(({Foo}) => new Foo());
}

As for resources, did you come across #14495?

@bobaaaaa
Copy link
Author

I see. At the moment it's Promise<any> but there is a open issue #14844

Thanks for the fast answer 👍

@microsoft microsoft locked and limited conversation to collaborators Jul 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants