Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] MappingGenericProperty should have optional fields #703

Open
alex-at-cascade opened this issue Jan 24, 2024 · 2 comments
Open

[BUG] MappingGenericProperty should have optional fields #703

alex-at-cascade opened this issue Jan 24, 2024 · 2 comments

Comments

@alex-at-cascade
Copy link
Contributor

alex-at-cascade commented Jan 24, 2024

What is the bug?

The type definition for MappingGenericProperty has mandatory fields

How can one reproduce the bug?

Try to compile this code:

import { MappingTypeMapping } from "@opensearch-project/opensearch/api/types";
const x = { foo: { type: "date" } };
const f = (p: MappingTypeMapping["properties"]) => p;
f(x);

An error is reported:

TSError: ⨯ Unable to compile TypeScript:
bug.ts:4:3 - error TS2345: Argument of type '{ foo: { type: string; }; }' is not assignable to parameter of type 'Record<string, MappingProperty>'.
  Property 'foo' is incompatible with index signature.
    Type '{ type: string; }' is not assignable to type 'MappingProperty'.
      Type '{ type: string; }' is missing the following properties from type 'MappingGenericProperty': analyzer, boost, fielddata, ignore_malformed, and 7 more.

4 f(x);

What is the expected behavior?

It should compile ok.

What is your host/environment?

node 18, typescript 5.2.2

Do you have any screenshots?

N/A

Do you have any additional context?

It appears that the other similar types do have optional fields, but the "generic" version is the odd one out.

@nhtruong
Copy link
Collaborator

@alex-at-cascade would you like to take a crack at fixing this? :)

@alex-at-cascade
Copy link
Contributor Author

Sure thing! I'll ramp up on the contribution guidelines.

alex-at-cascade added a commit to alex-at-cascade/opensearch-js that referenced this issue Jan 30, 2024
alex-at-cascade added a commit to alex-at-cascade/opensearch-js that referenced this issue Jan 30, 2024
alex-at-cascade added a commit to alex-at-cascade/opensearch-js that referenced this issue Jan 30, 2024
alex-at-cascade added a commit to alex-at-cascade/opensearch-js that referenced this issue Feb 5, 2024
dblock pushed a commit that referenced this issue Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants