-
Notifications
You must be signed in to change notification settings - Fork 47
Description
1. Summary
It would be helpful if Civet would support Flow comment-based syntax (flotate syntax) like CoffeeScript.
2. Behavior
Live demonstration on Civet online REPL:
-
Source:
"civet coffeeCompat" # @flow whoIsAGoddess = (goddessName ###: string ###) ###: string ### -> return "#{goddessName} is a Goddess!" console.log(whoIsAGoddess("Kira"))
-
Desired behavior — just convert comments like CoffeeScript does it:
// @flow var whoIsAGoddess; whoIsAGoddess = function(goddessName /*: string */) /*: string */ { return `${goddessName} is a Goddess!` } console.log(whoIsAGoddess("Kira"))
-
Current behavior:
"civet coffeeCompat" # @flow whoIsAGoddess = (goddessName ###: string ###) ###: string ### -> ^ Failed to parse
3. The reason for the need for the feature
Civet is configurable. There is no single "right way" for everyone at all times. Some of us have older CoffeeScript codebases that would benefit from added types. Others have massive TypeScript applications that could benefit from new language features and shorthand syntax. Civet provides a way to get the benefits bit by bit without a complete rewrite. This same configurability lets us experiment with language features to gain experience and improve them before locking them in. It also allows us to adapt to a changing future.
- Users may consciously prefer Flow to TypeScript. For example, users may prefer comment-based syntax, because it doesn’t require an extra compilation step and is supported by all JavaScript parsers. At the moment of writing this issue TypeScript doesn’t support comment-based syntax.
- Flow users may not have problems forcing them to migrate to TypeScript. Flow also has a lot of features and is still actively maintained at the moment of writing this issue.
- Users may know a lot of subtleties and nuances of Flow, but not of TypeScript. Deep learning of the new language TypeScript may require a lot of time and effort.
- Preserving Flow comments will ease migration of existing CoffeeScript codebases with Flow type annotations to Civet.
Thanks.