grantila / grantila/typeconv

OpenAPI -> TypeScript adds wildcard prop to each type

Open
#24 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
447
Forks
10
PR merge metrics
No merged PRs in 30d

Description

I'm using typeconv to convert some OpenAPI schemas into TypeScript interfaces. Generally working great, but I noticed one thing.

When I start with the below OpenAPI spec:

```js
{
components: {
schemas: {
Person: {
type: "object",
properties: {
first_name: {
type: "string",
example: "Pam",
},
last_name: {
type: "string",
example: "Halpert",
},
},
required: [],
title: "Person",
},
},
},
};
```

It produces the following type:

```ts
export interface Person {
first_name?: string;
last_name?: string;
[key: string]: any;
}
```

Almost perfect, except for that last line:

```ts
[key: string]: any;
```

It's appending a wildcard accessor to my type, for some reason, essentially asserting that on `Person`, any string can access any value, which makes the type not particularly helpful.

Any ideas what this is happening? I could get rid of this line through string manipulation, but I wonder why it's happening, and if there's some option I'm missing.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.