chore: do not allow redefing types from blueprint in make config schema

Signed-off-by: blam <ben@blam.sh>
This commit is contained in:
blam
2024-07-24 11:51:52 +02:00
parent cac9c3f851
commit 97157c5470
2 changed files with 38 additions and 0 deletions
@@ -189,4 +189,40 @@ describe('createExtensionBlueprint', () => {
},
}).render();
});
it('should not allow overlapping config keys', () => {
const TestExtensionBlueprint = createExtensionBlueprint({
kind: 'test-extension',
attachTo: { id: 'test', input: 'default' },
output: {
element: coreExtensionData.reactElement,
},
config: {
schema: {
text: z => z.string(),
},
},
factory(params: { text: string }) {
return {
element: <div>{params.text}</div>,
};
},
});
TestExtensionBlueprint.make({
name: 'my-extension',
params: {
text: 'Hello, world!',
},
config: {
schema: {
// @ts-expect-error
text: z => z.number(),
something: z => z.string(),
},
},
});
expect('test').toBe('test');
});
});
@@ -92,6 +92,8 @@ export interface ExtensionBlueprint<
[key in keyof TExtensionConfigSchema]: (
zImpl: typeof z,
) => TExtensionConfigSchema[key];
} & {
[key in keyof TConfig]?: never;
};
};
} & (