Skip to content

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

Closed

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"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions