Help

Upcoming database upgrades. Airtable functionality will be reduced for ~15 minutes at 06:00 UTC on Feb. 4 / 10:00 pm PT on Feb. 3. Learn more here

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

Topic Labels: Scripting extentions
2678 0
cancel
Showing results for 
Search instead for 
Did you mean: 

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