Closed adroitwhiz closed 11 months ago
my typescript-fu is too silly :pensive:
Thanks! This is something to investigate, for sure — sb-edit is my main exposure to TypeScript, honestly, so I'm not versed in any recent additions. 😅
I'll mark here the existing (block.inputs.VARIABLE.value as { id: string }).id
pattern mentioned here. There are plenty of other examples of casting "assumptions" about block inputs which TypeScript isn't picking up on (or, you know, is correctly warning us about in the case of arbitrarily shaped inputs from unknown blocks!).
TypeScript's undergone a lot of improvement since this project started. We could probably make use of a lot of new TS features in order to better infer and narrow types, especially for block inputs.
The way that people write TypeScript has also changed--for instance, TypeScript gained the
unknown
type, which represents a type that is a supertype of every other type. This replaces the unsafeany
type, which can be used to violate type safety. Unfortunately, this codebase makes extensive use ofany
.It's probably worth upgrading this project to use modern TypeScript. Since eliminating
any
could change the public API, it may be worth releasing a new major version?