Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Approach Resource typing differently in the UI (#58)
Previously the Resource typing was awkward at best - asserting Resources to concrete types seamed like needles work that defied the point of having them defined as interfaces One potential solution was asserting string literal to string literal, but that felt backwards, example: "literal" as "literal" Someone in the Github thread[0] suggested asserting them in the following manner: "literal" as const - which is a bit better, but still misses the point Due to technical reasons the literal inferred type was string, rather than the literal itself. What seams to solve the problem is asserting the whole object to be a Resource. That also solves the problem with creeping import scope while at the same time setting up correct guards at compile time Last, but not least I think that the documentation on type assertion is misleading at best (couldn't find an example describing the mechanism and didn't feel like going through the source) - the mechanism is much more safe than described in the official docs, which cover the case of any -> T. Whereas in the more general case of T -> U assertion the overlap is checked (so that if I make a typo in the object an error is raised) [0] microsoft/TypeScript#25889
- Loading branch information