Skip to content

TypeScript App/Plugin Codegen Types Aren't Very Type-Safe #897

@dOrgJelli

Description

@dOrgJelli

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"

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions