Skip to content

Coffee-style comments for flotate return type annotation #1826

@Kristinita

Description

@Kristinita

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:

  1. Source:

    "civet coffeeCompat"
    # @flow
    whoIsAGoddess = (goddessName ###: string ###) ###: string ### ->
    	return "#{goddessName} is a Goddess!"
    
    console.log(whoIsAGoddess("Kira"))
  2. 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"))
  3. Current behavior:

    "civet coffeeCompat"
    # @flow
    whoIsAGoddess = (goddessName ###: string ###) ###: string ### ->
                                                                  ^ Failed to parse

3. The reason for the need for the feature

Civet design philosophy:

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.

  1. 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.
  2. 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.
  3. 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.
  4. Preserving Flow comments will ease migration of existing CoffeeScript codebases with Flow type annotations to Civet.

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcoffeescriptCoffeeScript compatibility related

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions