spectator
spectator copied to clipboard
change the type of the `properties` argument in mockProvider
[ ] Regression (a behavior that used to work and stopped working in a new release) [ ] Bug report [ ] Performance issue [ ] Feature request [ ] Documentation issue or request [x] Support request [ ] Other... Please describe: Types
Current behavior
//..\node_modules\@ngneat\spectator\jest\lib\mock.d.ts
export declare function mockProvider<T>(type: Type<T> | AbstractType<T>, properties?: Partial<Record<keyof T, any>>): FactoryProvider;
Expected behavior
//..\node_modules\@ngneat\spectator\jest\lib\mock.d.ts
export declare function mockProvider<T>(type: Type<T> | AbstractType<T>, properties?: Partial<T>>): FactoryProvider;
or
type RecursivePartial<T> = {
[P in keyof T]?: RecursivePartial<T[P]>;
};
mockProvider<T>(type: Type<T> | AbstractType<T>, properties?: RecursivePartial<T>>): FactoryProvider;
Minimal reproduction of the problem with instructions
interface PostData {
description: string;
title: string;
image: string;
}
interface Post {
post: PostData;
}
@Injectable()
export class ExampleService {
store: Post;
}
const StoreServiceMock = mockProvider(ExampleService, {store}); // store => any
store is now any type and not Post type
with the suggestion would not change its type, something like MockedProvider from ng-mocks.
angular: 9.1.11, @ngneat/spectator: 6.1.1 typescript: 3.8.3
For Tooling issues:
- Node version: v12.16.0
- Platform: Window