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

Typescript error for dropdown field #7715

Closed
1 task done
pachtymi opened this issue Dec 13, 2023 · 6 comments · Fixed by #7939
Closed
1 task done

Typescript error for dropdown field #7715

pachtymi opened this issue Dec 13, 2023 · 6 comments · Fixed by #7939
Assignees
Labels
component: TypeScript issue: bug Describes why the code or behaviour is wrong

Comments

@pachtymi
Copy link

pachtymi commented Dec 13, 2023

Check for duplicates

  • I have searched for similar issues before opening a new one.

Description

When appending a dropdown field I get:

Argument of type 'FieldDropdown' is not assignable to parameter of type 'string | Field<string | undefined>'.
  Type 'FieldDropdown' is not assignable to type 'Field<string | undefined>'.
    Types of property 'validator_' are incompatible.
      Type 'FieldValidator<string> | null' is not assignable to type 'FieldValidator<string | undefined> | null'.
        Type 'FieldValidator<string>' is not assignable to type 'FieldValidator<string | undefined>'.
          Types of parameters 'newValue' and 'newValue' are incompatible.
            Type 'string | undefined' is not assignable to type 'string'.
              Type 'undefined' is not assignable to type 'string'.

The code, which is straight from the docs:

this.appendDummyInput()
                .appendField('drop down:')
                .appendField(new Blockly.FieldDropdown([
                    ['first item', 'ITEM1'],
                    ['second item', 'ITEM2']
                ]), 'FIELDNAME');

Reproduction steps

  1. Attempt to put a new FieldDropdown into an appendField

Stack trace

No response

Screenshots

No response

Browsers

No response

@pachtymi pachtymi added issue: bug Describes why the code or behaviour is wrong issue: triage Issues awaiting triage by a Blockly team member labels Dec 13, 2023
@pachtymi
Copy link
Author

A workaround I can do is

this.appendDummyInput()
                .appendField('drop down:')
                .appendField(new Blockly.FieldDropdown([
                    ['first item', 'ITEM1'],
                    ['second item', 'ITEM2']
                ]) as Blockly.Field, 'FIELDNAME');

But this is less than ideal.

@BeksOmega
Copy link
Collaborator

Looks like this might be a change with typescript 5.3 #7713

@maribethb maribethb added component: TypeScript and removed issue: triage Issues awaiting triage by a Blockly team member labels Jan 3, 2024
@BeksOmega
Copy link
Collaborator

Christopher added notes

@maribethb
Copy link
Contributor

@btw17 would you be interested in looking at this one next? it's something we wanted to fix this quarter but haven't been able to prioritize. there's some more details in the PR comments beka linked above

@btw17
Copy link
Member

btw17 commented Feb 23, 2024

@btw17 would you be interested in looking at this one next? it's something we wanted to fix this quarter but haven't been able to prioritize. there's some more details in the PR comments beka linked above

Looks interesting - I'll take a look @maribethb!

@btw17
Copy link
Member

btw17 commented Mar 15, 2024

Found the issue! Thank you for your patience with this - wasn't able to work on this the last few weeks.

The fix was actually rather simple - just needed to update doClassValidation_ in FieldDropdown.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: TypeScript issue: bug Describes why the code or behaviour is wrong
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants