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

Accept abstract class as argument in INestApplicationContext.get() #1452

Closed
vlapo opened this issue Jan 16, 2019 · 5 comments
Closed

Accept abstract class as argument in INestApplicationContext.get() #1452

vlapo opened this issue Jan 16, 2019 · 5 comments

Comments

@vlapo
Copy link

vlapo commented Jan 16, 2019

I'm submitting a...


[ ] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

We are using custom provider defined like

{
    provide: AbstractStorageService,
    useClass: GCloudStorageService
},

where AbstractStorageService is obviously abstract class. During tests we need to call method from storage service. We are using INestApplicationContext.get() method to retrieve instance of current used storage service.

this.storageService = this.app.get<AbstractStorageService>(AbstractStorageService);

We are experiencing Argument of type 'typeof AbstractStorageService' is not assignable to parameter of type 'string | symbol | Type<AbstractStorageService>'. typing error.

Expected behavior

Accept abstract class as argument in INestApplicationContext.get().

Environment


Nest version: 5.5.0
 
For Tooling issues:
- Node version: 10  
- Platform:  Mac
@kamilmysliwiec
Copy link
Member

Fixed in 5.6.0

@vlapo
Copy link
Author

vlapo commented Jan 16, 2019

get<TInput = any, TResult = TInput>(
typeOrToken: Type<TInput> | string | symbol,
options?: { strict: boolean },
): TResult;

Interface still not support Abstract<TInput>

@kamilmysliwiec
Copy link
Member

Wow, thanks! Fixed and published as 5.6.2 :)

@vlapo
Copy link
Author

vlapo commented Jan 16, 2019

No. I thank you :) 👍

@lock
Copy link

lock bot commented Sep 24, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Sep 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants