refactor(mesh): @Provider's options no longer advertise export
The framework's public type offered an option whose only behaviour is to throw at boot. Removing the field from the options type means a TypeScript caller gets a compile error at the decorator, where the mistake is, instead of a boot error a deploy away. The runtime throw in collectProviders stays as the JavaScript backstop, so ProviderMeta keeps the field and the decorator still records it through a cast — a JS caller reaches the error naming the provider and its replacement rather than having the option silently ignored. The `as any` in the boot-throw test is now genuinely load-bearing, since no TypeScript caller can write that decorator at all, and says so. test/metadata.test.ts asserted the flag was stored for a provider. That half described the option working, which is the message being removed, and the boot throw it fed is already covered end to end in test/mesh/failure.test.ts. The default is a different claim and stays: collectProviders throws on anything truthy, so every plain provider recording `false` is what keeps ordinary apps booting. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
This commit is contained in:
3 files changed
+20
-10
No files matched your search
@@ -124,6 +124,9 @@ describe('mesh link failure', () => {
|
||||
|
||||
describe('provider export', () => {
|
||||
it('refuses to boot when a provider is exported over the mesh', async () => {
|
||||
// `as any` is load-bearing, not laziness: `export` is not in `@Provider`'s options type, so a
|
||||
// TypeScript caller cannot write this at all. The cast is how the test reaches the runtime
|
||||
// backstop that a JavaScript caller would hit.
|
||||
@Provider({ provides: 'db', needs: [], export: true } as any)
|
||||
class Db {
|
||||
provide() {
|
||||
|
||||
Reference in new issue
Block a user