Skip to content

Transpilation-Free Syntax Proposal for JavaScript Developers #60699

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
6 tasks done
DevScholar opened this issue Dec 6, 2024 · 1 comment
Closed
6 tasks done

Transpilation-Free Syntax Proposal for JavaScript Developers #60699

DevScholar opened this issue Dec 6, 2024 · 1 comment

Comments

@DevScholar
Copy link

πŸ” Search Terms

transpilation-free, /*:

βœ… Viability Checklist

⭐ Suggestion

This proposal aims to introduce a transpilation-free syntax that allows developers to add certain TypeScript features without transpiling TypeScript to JavaScript. This syntax will be implemented through special comment markers, enabling TypeScript's type safety while reducing transpilation steps. This proposal is not intended to eliminate the transpilation step of TypeScript, but rather to provide an alternative option for JSDoc users.

Transpilation-Free Syntax:

  • Introduce a new comment marker /*:
  • For example:
    /*:
    type Point = {
        x: number;
        y: number;
    };
    */
    
    let point/*: Point*/ = {
        x: 10,
        y: 20
    };
  • In this syntax, content between /*: and */ is considered TypeScript features.

The syntax is primarily designed for type annotations, so certain specific TypeScript syntax (such as enum, interface) may not be available. If developers want to use these potentially unavailable syntaxes, JavaScript developers may need to write code twice in one file, once for TypeScript and once for JavaScript.

πŸ“ƒ Motivating Example

By introducing transpilation-free syntax, JavaScript developers can use TypeScript's powerful type system and development tool support without transpilation.

πŸ’» Use Cases

  1. What do you want to use this for?
    Use TypeScript's powerful type system and development tool support without transpilation.
  2. What shortcomings exist with current approaches?
    TypeScript needed to be transpiled before running.
  3. What workarounds are you using in the meantime?
    Use JSDoc. JSDoc is more verbose than TypeScript.
@MartinJohns
Copy link
Contributor

Duplicate of #48650. Used search terms: comments in:title label:Suggestion

@DevScholar DevScholar closed this as not planned Won't fix, can't repro, duplicate, stale Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants