3 ms·
An off-topic question: In the declaration let door = "open"; the intended type of door is DoorState, but it could also be a string type. How does the com
by chmaynard 6y ago
An off-topic question:
In the declaration
let door = "open";
the intended type of door is DoorState, but it could also be a string type. How does the compiler decide which is the best choice? By looking ahead?
- kevmo314 6y agoAh good catch, the TS compiler can't as it types it as string that fails. let door: DoorState = "open"; works though. :) I've updated the post and a link to the TS playground.