embroider-build / content-tag

A rust program that uses a fork of SWC to parse and transform Javascript containing the content-tag proposal
MIT License
8 stars 7 forks source link

fails to process when missing semi #37

Open patricklx opened 11 months ago

patricklx commented 11 months ago

https://github.com/gitKrystan/prettier-plugin-ember-template-tag/pull/162

const num:   number = 1
(oops) => {}
import Component from '@glimmer/component'

/** It's a component */
class MyComponent
  extends Component {
    get whatever() {}

        <template>

    <h1>   Class top level template. Class top level template. Class top level template. Class top level template. Class top level template. </h1>
  </template>
  (oops) => {}
}
import type { TemplateOnlyComponent } from '@ember/component/template-only'

export interface Signature {
  Element: HTMLElement,
  Args: {

  }
  Yields: []
}

export const Exported:    TemplateOnlyComponent<Signature> = <template>       Exported variable template. Exported variable template.  Exported variable template.  Exported variable template.  Exported variable template. Exported variable template. Exported variable template. </template>
(oops) => {}
patricklx commented 11 months ago

mmm, just was testing this on astexplorer and its also not working... typescript can parse it, but joins in into the initializer

patricklx commented 11 months ago

I think content tag should be able to parse at least the ones with the template+ missing semi

patricklx commented 10 months ago

@ef4

NullVoxPopuli commented 10 months ago

that second case isn't valid even without <template> like, you can't have

let a = 1
() => {}

You get:

Uncaught SyntaxError: invalid arrow-function arguments (parentheses around the arrow-function may help)

And following FireFox's advice:

let a = 1
(() => {})

Uncaught TypeError: 1 is not a function

(this is also more evidence that ASI is a bad idea (or at least one that didn't work out))

NullVoxPopuli commented 10 months ago

Made a failing test PR from the first example, tho: https://github.com/embroider-build/content-tag/pull/38 (which, I think makes sense, because you can't have <template></template>() )