Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes TypeScript errors in
setSpace()
.The main issue is this:
setSpace
accepts a three-letter string, where every three-letter combination of be statically checked by TypeScript. However, when running asubstring()
, the return type is astring
, rather than one of the known letters, and keeping the return value a string literal is better for type safety.After extensive research(!!!) it seems like the solution is just to say
.substring() as MyType
, because inputs are already typechecked and we just need to tell TypeScript that after this point the only valid values forsubstring()
are values we know about, don't worry about it.Also removes a code path for a position value of
k
which is never used and does the same thing ash
.