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 · 4 comments

Comments

Projects
None yet
2 participants
@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

This comment has been minimized.

Copy link
Member

kamilmysliwiec commented Jan 16, 2019

Fixed in 5.6.0

@vlapo

This comment has been minimized.

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

This comment has been minimized.

Copy link
Member

kamilmysliwiec commented Jan 16, 2019

Wow, thanks! Fixed and published as 5.6.2 :)

@vlapo

This comment has been minimized.

Copy link
Author

vlapo commented Jan 16, 2019

No. I thank you :) 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.