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
@@ -67,12 +67,15 @@ describe('HEAD and OPTIONS decorators', () => {
|
||||
});
|
||||
|
||||
describe('mesh export flags', () => {
|
||||
it('providers/steps carry export (default false)', () => {
|
||||
@Provider({ provides: 'config', export: true }) class C { provide() { return {}; } }
|
||||
it('steps carry export, and a provider defaults to not exported', () => {
|
||||
@Step({ provides: 'auth', export: true }) class A { run() { return {}; } }
|
||||
@Provider({ provides: 'priv' }) class P { provide() { return {}; } }
|
||||
expect(getProviderMeta(C)!.export).toBe(true);
|
||||
expect(getStepMeta(A)!.export).toBe(true);
|
||||
// No `export: true` case for a provider: the option is gone from `@Provider`'s type, and its
|
||||
// only behaviour is the boot throw that `test/mesh/failure.test.ts` covers end to end —
|
||||
// asserting it is *stored* here would assert the option works. The default is a different
|
||||
// claim and still load-bearing: `collectProviders` throws on anything truthy, so every plain
|
||||
// provider recording `false` is what keeps ordinary apps booting.
|
||||
expect(getProviderMeta(P)!.export).toBe(false);
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user