nfroidure / nfroidure/knifecycle
Consider using an overridable `Services` interface
@nfroidure is already working on this.
Since Aug 13, 2023.
- Dominant language
- TypeScript
- Stars
- 34
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
In order to allow users to override it and get auto-completion for services injections, a global Services interface mapping to all services types could be useful.
It would give something like services.d.ts in the root of projects sources:
import type { BaseServices } from 'knifecycle'; // For injector/instance etc...
declare module 'knifecycle' {
// Eventually override the process env type here
export interface Services
extends Services {
pg: PGService;
log: LogService;
// ...
}
Maybe that using this could help: https://www.typescriptlang.org/docs/handbook/declaration-merging.html
The $autoload service type could be changed to :
{
get: (serviceName) => Initializer
list: () => Initializer[]
}
That way the whook-repl / whook create command could suggest new services to use.
Also, would be nice to add a special property to set the import.meta.url value of modules so that the build can refer to it (will avoid the need to use the INITIALIZER_PATH_MAP in the whook autoload service).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.