Skip to content
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

expanding comments proposal #717

Closed
gertcuykens opened this issue Oct 20, 2016 · 3 comments
Closed

expanding comments proposal #717

gertcuykens opened this issue Oct 20, 2016 · 3 comments
Labels
feature suggestion Please see https://github.com/tc39/ecma262/blob/HEAD/CONTRIBUTING.md#creating-a-new-proposal

Comments

@gertcuykens
Copy link

gertcuykens commented Oct 20, 2016

Currently there are two ways to make comments // and /**/ I think if ecma262 has a broader way of implementing comments it can open up the door for third party type checkers and leave the burden onto others without the need for transpiling.

I am looking into how close ES20XX syntax for example compares to typescript syntax. A js compiler doesn't need to look at the typings at all, just be smart enough to ignore typings. Is the ECMA262 community willing to look at a few syntax notations that a js parser should ignore?

If there is no objection at first look I am going to put in the effort to try to cover a complete syntax that extends // and /**/ so others can use that to implement for example a type checker? Notice that I am not asking for type checking itself, just expanding // and /**/ that makes it possible for others to do for example type checking and maintain a clean syntax look of their code.

EDIT: We can "use strict comments"; to prevent web breakage

Example ES2015 code

<!DOCTYPE html>
<html > 

<head>
  <title>Test</title>
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0" />
</head>

<body>
  <template>
    <style>
      :host {
          display: block;                                                                                                      
          box-sizing: border-box;                                                                                              
          border: 1px solid red;
          margin: 13px 0;
          padding: 0 17px;
      }
    </style>
    <p>Test <slot></slot></p>
  </template>
  <script>
    class HelloWorld extends HTMLElement {
      constructor() {
        super()
        const t = document.querySelector('template')
        const instance = t.content.cloneNode(true)
        const shadowRoot = this.attachShadow({ mode: 'open' })
        shadowRoot.appendChild(instance)
      }
    }
    customElements.define('hello-world', HelloWorld)
  </script>
  <hello-world>Hello World</hello-world>
</body>
</html>

Example typescript code

<!DOCTYPE html>
<html > 

<head>
  <title>Test</title>
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0" />
</head>

<body>
  <template>
    <style>
      :host {
          display: block;                                                                                                      
          box-sizing: border-box;                                                                                              
          border: 1px solid red;
          margin: 13px 0;
          padding: 0 17px;
      }
    </style>
    <p>Test <slot></slot></p>
  </template>
  <script type="ts/module">
    class HelloWorld extends HTMLElement {
      constructor() {
        super()
        const t:type1 = document.querySelector('template')
        const instance:type2 = t.content.cloneNode(true)
        const shadowRoot:type3 = this.attachShadow({ mode: 'open' })
        shadowRoot.appendChild(instance)
      }
    }
    customElements.define('hello-world', HelloWorld)
  </script>
  <hello-world>Hello World</hello-world>
</body>
</html>
@ljharb
Copy link
Member

ljharb commented Oct 20, 2016

You're forgetting the third, HTML comments:

<!-- this is a comment
--> so is this

Also, please note that this repo is not the place for proposals - see https://github.com/tc39/ecma262/blob/master/CONTRIBUTING.md

@gertcuykens
Copy link
Author

Ok thanks, you are right forgot about <!-- --> going to try to make a proposal.

@domenic
Copy link
Member

domenic commented Oct 20, 2016

Closing per CONTRIBUTING.md.

@domenic domenic closed this as completed Oct 20, 2016
@ljharb ljharb added the feature suggestion Please see https://github.com/tc39/ecma262/blob/HEAD/CONTRIBUTING.md#creating-a-new-proposal label Jan 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature suggestion Please see https://github.com/tc39/ecma262/blob/HEAD/CONTRIBUTING.md#creating-a-new-proposal
Projects
None yet
Development

No branches or pull requests

3 participants