wrap-cli
wrap-cli copied to clipboard
TypeScript App/Plugin Codegen Types Aren't Very Type-Safe
Currently, most-all interface types for TypeScript applications are like so:
interface ModuleMethodInput extends Record<string, unknown> {
argument?: Types.String | null;
}
export const Module = {
method: async (
input: ModuleMethodInput,
client: Client
): Promise<InvokeApiResult<...>> => {
...
}
}
The problem is that our input types extend from Record<string, unknown>, which is a generic property-map. This means that code like this will still compile, when it shouldn't:
Module.method({ foo: "value" });
// ^ "foo" should be "argument"