You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 9, 2018. It is now read-only.
Statement currently just adds a semicolon. However, there are more types of statements that don't do this (e.g. if statements.) They all do not have a return value. What's the best way to encode this as a TypeScript type?
Typescript doesn't really do nominal types, only structural types, so if we make a Statement interface that is the exact same as the SyntaxNode interface, then we could pass in an arbitrary SyntaxNode anywhere we want a Statement, which isn't what we want.
If there are a fixed number of statement types, we could maybe do something like:
Statementcurrently just adds a semicolon. However, there are more types of statements that don't do this (e.g. if statements.) They all do not have a return value. What's the best way to encode this as a TypeScript type?Typescript doesn't really do nominal types, only structural types, so if we make a
Statementinterface that is the exact same as theSyntaxNodeinterface, then we could pass in an arbitrarySyntaxNodeanywhere we want aStatement, which isn't what we want.If there are a fixed number of statement types, we could maybe do something like:
(also is there a better name for
Line?)Thoughts?