Help

The Community will be temporarily unavailable starting on Friday February 28. We’ll be back as soon as we can! To learn more, check out our Announcements blog post.

Typescript Error: "Type 'number' is not assignable to type '0 | 4 | 3 | 2 | 1'."

Topic Labels: Scripting extentions
7340 0
cancel
Showing results for 
Search instead for 
Did you mean: 
David_Brownman
5 - Automation Enthusiast
5 - Automation Enthusiast

Hi there! I found a minor DX issue in the generated Typescript definitions (which are incredibly cool, by the way).

I’ve got a rating field in my base:

54496ef71664e904faca92b4c771608354093615.png

When writing scripting to update it, I’ve got an await input.buttonsAsync where each item is has a value and label: { label: "", value: 4 }, etc.

The selected button goes into a payload object that’s eventually passed to table.updateRecordAsync. The actual script works flawlessly, but there’s a TS error:

Type "number" is not assignable to type '0 | 1 | 2 | 3 | 4'

3102799ce95fd1de68f1e44e5836867751cc134d.png

I tried to add a type assertion, but apparently the script input isn’t a TS file. I think the fix is as simple as demoting the Rating type to accept numbers instead of a specific set of numbers.

Not a big deal, since the error doesn’t affect execution, but I figured I’d flag. Thanks!

0 Replies 0