From 697c3079c77cefb2fa82357b444c6fc5d7a61210 Mon Sep 17 00:00:00 2001 From: Liam DeBeasi Date: Wed, 6 Nov 2024 12:36:38 -0500 Subject: [PATCH] fix: do not crash with comment before method in store (#1629) * test configuration * fix path * fix: do not crash with comment before method in store * changeset * clean up * chore: update snapshots --- .changeset/clean-shrimps-help.md | 5 + .../__snapshots__/alpine.test.ts.snap | 28 +++ .../__snapshots__/angular.import.test.ts.snap | 66 ++++++ .../__snapshots__/angular.mapper.test.ts.snap | 68 +++++++ .../__snapshots__/angular.state.test.ts.snap | 66 ++++++ .../__snapshots__/angular.styles.test.ts.snap | 52 +++++ .../__snapshots__/angular.test.ts.snap | 118 +++++++++++ .../__tests__/__snapshots__/html.test.ts.snap | 108 ++++++++++ .../__snapshots__/liquid.test.ts.snap | 10 + .../__tests__/__snapshots__/lit.test.ts.snap | 50 +++++ .../__snapshots__/marko.test.ts.snap | 24 +++ .../__snapshots__/mitosis.test.ts.snap | 82 ++++++++ .../__snapshots__/parse-jsx.test.ts.snap | 118 +++++++++++ .../__snapshots__/preact.test.ts.snap | 34 ++++ .../__tests__/__snapshots__/qwik.test.ts.snap | 28 +++ .../__snapshots__/react-native.test.ts.snap | 66 ++++++ .../react-state-builder.test.ts.snap | 28 +++ .../react-state-mobx.test.ts.snap | 32 +++ .../react-state-solid.test.ts.snap | 30 +++ .../react-state-valtio.test.ts.snap | 30 +++ .../react-state-variables.test.ts.snap | 30 +++ .../__snapshots__/react.test.ts.snap | 34 ++++ .../__tests__/__snapshots__/rsc.test.ts.snap | 34 ++++ .../__snapshots__/solid.test.ts.snap | 76 +++++++ .../__snapshots__/stencil.test.ts.snap | 36 ++++ .../__snapshots__/svelte.test.ts.snap | 20 ++ .../__tests__/__snapshots__/taro.test.ts.snap | 36 ++++ .../vue-composition.test.ts.snap | 28 +++ .../__tests__/__snapshots__/vue.test.ts.snap | 40 ++++ .../__snapshots__/webcomponent.test.ts.snap | 188 ++++++++++++++++++ .../data/store/store-comment.raw.tsx | 10 + packages/core/src/__tests__/test-generator.ts | 2 + packages/core/src/parsers/jsx/state.ts | 12 +- 33 files changed, 1588 insertions(+), 1 deletion(-) create mode 100644 .changeset/clean-shrimps-help.md create mode 100644 packages/core/src/__tests__/data/store/store-comment.raw.tsx diff --git a/.changeset/clean-shrimps-help.md b/.changeset/clean-shrimps-help.md new file mode 100644 index 0000000000..3e5c37c3fa --- /dev/null +++ b/.changeset/clean-shrimps-help.md @@ -0,0 +1,5 @@ +--- +'@builder.io/mitosis': patch +--- + +do not crash with comment before method in store diff --git a/packages/core/src/__tests__/__snapshots__/alpine.test.ts.snap b/packages/core/src/__tests__/__snapshots__/alpine.test.ts.snap index 1a8c2cc408..7dca832e43 100644 --- a/packages/core/src/__tests__/__snapshots__/alpine.test.ts.snap +++ b/packages/core/src/__tests__/__snapshots__/alpine.test.ts.snap @@ -1381,6 +1381,20 @@ showReviewPrompt = false\\" " `; +exports[`Alpine.js > jsx > Javascript Test > StoreComment 1`] = ` +"
+ +" +`; + exports[`Alpine.js > jsx > Javascript Test > Submit 1`] = ` " " @@ -1330,6 +1335,11 @@ exports[`Liquid > jsx > Typescript Test > Stamped.io 1`] = ` " `; +exports[`Liquid > jsx > Typescript Test > StoreComment 1`] = ` +"
{{foo}}
+" +`; + exports[`Liquid > jsx > Typescript Test > Submit 1`] = ` " " diff --git a/packages/core/src/__tests__/__snapshots__/lit.test.ts.snap b/packages/core/src/__tests__/__snapshots__/lit.test.ts.snap index 19d318a016..6127f10d55 100644 --- a/packages/core/src/__tests__/__snapshots__/lit.test.ts.snap +++ b/packages/core/src/__tests__/__snapshots__/lit.test.ts.snap @@ -1874,6 +1874,31 @@ export default class SmileReviews extends LitElement { " `; +exports[`Lit > jsx > Javascript Test > StoreComment 1`] = ` +"import { LitElement, html, css } from \\"lit\\"; +import { customElement, property, state, query } from \\"lit/decorators.js\\"; + +@customElement(\\"string-literal-store\\") +export default class StringLiteralStore extends LitElement { + createRenderRoot() { + return this; + } + + @state() foo = true; + + bar() {} + + render() { + return html\` + + \${this.foo} + + \`; + } +} +" +`; + exports[`Lit > jsx > Javascript Test > Submit 1`] = ` "import { LitElement, html, css } from \\"lit\\"; import { customElement, property, state, query } from \\"lit/decorators.js\\"; @@ -6559,6 +6584,31 @@ export default class SmileReviews extends LitElement { " `; +exports[`Lit > jsx > Typescript Test > StoreComment 1`] = ` +"import { LitElement, html, css } from \\"lit\\"; +import { customElement, property, state, query } from \\"lit/decorators.js\\"; + +@customElement(\\"string-literal-store\\") +export default class StringLiteralStore extends LitElement { + createRenderRoot() { + return this; + } + + @state() foo = true; + + bar() {} + + render() { + return html\` + + \${this.foo} + + \`; + } +} +" +`; + exports[`Lit > jsx > Typescript Test > Submit 1`] = ` "import { LitElement, html, css } from \\"lit\\"; import { customElement, property, state, query } from \\"lit/decorators.js\\"; diff --git a/packages/core/src/__tests__/__snapshots__/marko.test.ts.snap b/packages/core/src/__tests__/__snapshots__/marko.test.ts.snap index 4386722c0a..44d8914368 100644 --- a/packages/core/src/__tests__/__snapshots__/marko.test.ts.snap +++ b/packages/core/src/__tests__/__snapshots__/marko.test.ts.snap @@ -1309,6 +1309,18 @@ style { " `; +exports[`Marko > jsx > Javascript Test > StoreComment 1`] = ` +"class { + bar() {} + + onCreate() { + this.state = { foo: true }; + } +} + +\${state.foo}" +`; + exports[`Marko > jsx > Javascript Test > Submit 1`] = ` "class {} @@ -3953,6 +3965,18 @@ style { " `; +exports[`Marko > jsx > Typescript Test > StoreComment 1`] = ` +"class { + bar() {} + + onCreate() { + this.state = { foo: true }; + } +} + +\${state.foo}" +`; + exports[`Marko > jsx > Typescript Test > Submit 1`] = ` "class {} diff --git a/packages/core/src/__tests__/__snapshots__/mitosis.test.ts.snap b/packages/core/src/__tests__/__snapshots__/mitosis.test.ts.snap index d3d340ddf2..9d7f880e8b 100644 --- a/packages/core/src/__tests__/__snapshots__/mitosis.test.ts.snap +++ b/packages/core/src/__tests__/__snapshots__/mitosis.test.ts.snap @@ -1423,6 +1423,18 @@ export default function SmileReviews(props) { " `; +exports[`Mitosis, format: legacy (native loops and conditionals) > jsx > Javascript Test > StoreComment 1`] = ` +"import { useStore } from \\"@builder.io/mitosis\\"; +import { Fragment } from \\"@components\\"; + +export default function StringLiteralStore(props) { + const state = useStore({ foo: true, bar() {} }); + + return [{state.foo}]; +} +" +`; + exports[`Mitosis, format: legacy (native loops and conditionals) > jsx > Javascript Test > Submit 1`] = ` "export default function SubmitButton(props) { return [ @@ -4575,6 +4587,18 @@ export default function SmileReviews(props) { " `; +exports[`Mitosis, format: legacy (native loops and conditionals) > jsx > Typescript Test > StoreComment 1`] = ` +"import { useStore } from \\"@builder.io/mitosis\\"; +import { Fragment } from \\"@components\\"; + +export default function StringLiteralStore(props) { + const state = useStore({ foo: true, bar() {} }); + + return [{state.foo}]; +} +" +`; + exports[`Mitosis, format: legacy (native loops and conditionals) > jsx > Typescript Test > Submit 1`] = ` "export interface ButtonProps { attributes?: any; @@ -8443,6 +8467,18 @@ export default function SmileReviews(props) { " `; +exports[`Mitosis, format: legacy > jsx > Javascript Test > StoreComment 1`] = ` +"import { useStore } from \\"@builder.io/mitosis\\"; +import { Fragment } from \\"@components\\"; + +export default function StringLiteralStore(props) { + const state = useStore({ foo: true, bar() {} }); + + return {state.foo}; +} +" +`; + exports[`Mitosis, format: legacy > jsx > Javascript Test > Submit 1`] = ` "export default function SubmitButton(props) { return ( @@ -11650,6 +11686,18 @@ export default function SmileReviews(props) { " `; +exports[`Mitosis, format: legacy > jsx > Typescript Test > StoreComment 1`] = ` +"import { useStore } from \\"@builder.io/mitosis\\"; +import { Fragment } from \\"@components\\"; + +export default function StringLiteralStore(props) { + const state = useStore({ foo: true, bar() {} }); + + return {state.foo}; +} +" +`; + exports[`Mitosis, format: legacy > jsx > Typescript Test > Submit 1`] = ` "export interface ButtonProps { attributes?: any; @@ -15676,6 +15724,23 @@ export default SmileReviews; " `; +exports[`Mitosis, format: react > jsx > Javascript Test > StoreComment 1`] = ` +"\\"use client\\"; +import * as React from \\"react\\"; +import { useState } from \\"react\\"; + +function StringLiteralStore(props) { + const [foo, setFoo] = useState(() => true); + + function bar() {} + + return <>{foo}; +} + +export default StringLiteralStore; +" +`; + exports[`Mitosis, format: react > jsx > Javascript Test > Submit 1`] = ` "import * as React from \\"react\\"; @@ -19270,6 +19335,23 @@ export default SmileReviews; " `; +exports[`Mitosis, format: react > jsx > Typescript Test > StoreComment 1`] = ` +"\\"use client\\"; +import * as React from \\"react\\"; +import { useState } from \\"react\\"; + +function StringLiteralStore(props) { + const [foo, setFoo] = useState(() => true); + + function bar() {} + + return <>{foo}; +} + +export default StringLiteralStore; +" +`; + exports[`Mitosis, format: react > jsx > Typescript Test > Submit 1`] = ` "import * as React from \\"react\\"; diff --git a/packages/core/src/__tests__/__snapshots__/parse-jsx.test.ts.snap b/packages/core/src/__tests__/__snapshots__/parse-jsx.test.ts.snap index 424d58cd78..b1fc764325 100644 --- a/packages/core/src/__tests__/__snapshots__/parse-jsx.test.ts.snap +++ b/packages/core/src/__tests__/__snapshots__/parse-jsx.test.ts.snap @@ -5270,6 +5270,65 @@ exports[`Parse JSX > Javascript > Stamped.io 1`] = ` } `; +exports[`Parse JSX > Javascript > StoreComment 1`] = ` +{ + "@type": "@builder.io/mitosis/component", + "children": [ + { + "@type": "@builder.io/mitosis/node", + "bindings": {}, + "children": [ + { + "@type": "@builder.io/mitosis/node", + "bindings": { + "_text": { + "bindingType": "expression", + "code": "state.foo", + "type": "single", + }, + }, + "children": [], + "meta": {}, + "name": "div", + "properties": {}, + "scope": {}, + }, + ], + "meta": {}, + "name": "Fragment", + "properties": {}, + "scope": {}, + }, + ], + "context": { + "get": {}, + "set": {}, + }, + "exports": {}, + "hooks": { + "onEvent": [], + "onMount": [], + }, + "imports": [], + "inputs": [], + "meta": {}, + "name": "StringLiteralStore", + "refs": {}, + "state": { + "bar": { + "code": "bar() {}", + "type": "method", + }, + "foo": { + "code": "true", + "propertyType": "normal", + "type": "property", + }, + }, + "subComponents": [], +} +`; + exports[`Parse JSX > Javascript > Submit 1`] = ` { "@type": "@builder.io/mitosis/component", @@ -17955,6 +18014,65 @@ exports[`Parse JSX > Typescript > Stamped.io 1`] = ` } `; +exports[`Parse JSX > Typescript > StoreComment 1`] = ` +{ + "@type": "@builder.io/mitosis/component", + "children": [ + { + "@type": "@builder.io/mitosis/node", + "bindings": {}, + "children": [ + { + "@type": "@builder.io/mitosis/node", + "bindings": { + "_text": { + "bindingType": "expression", + "code": "state.foo", + "type": "single", + }, + }, + "children": [], + "meta": {}, + "name": "div", + "properties": {}, + "scope": {}, + }, + ], + "meta": {}, + "name": "Fragment", + "properties": {}, + "scope": {}, + }, + ], + "context": { + "get": {}, + "set": {}, + }, + "exports": {}, + "hooks": { + "onEvent": [], + "onMount": [], + }, + "imports": [], + "inputs": [], + "meta": {}, + "name": "StringLiteralStore", + "refs": {}, + "state": { + "bar": { + "code": "bar() {}", + "type": "method", + }, + "foo": { + "code": "true", + "propertyType": "normal", + "type": "property", + }, + }, + "subComponents": [], +} +`; + exports[`Parse JSX > Typescript > Submit 1`] = ` { "@type": "@builder.io/mitosis/component", diff --git a/packages/core/src/__tests__/__snapshots__/preact.test.ts.snap b/packages/core/src/__tests__/__snapshots__/preact.test.ts.snap index 914d385e35..abe69e64a6 100644 --- a/packages/core/src/__tests__/__snapshots__/preact.test.ts.snap +++ b/packages/core/src/__tests__/__snapshots__/preact.test.ts.snap @@ -1479,6 +1479,23 @@ export default SmileReviews; " `; +exports[`Preact > jsx > Javascript Test > StoreComment 1`] = ` +"/** @jsx h */ +import { h, Fragment } from \\"preact\\"; +import { useState } from \\"preact/hooks\\"; + +function StringLiteralStore(props) { + const [foo, setFoo] = useState(() => true); + + function bar() {} + + return {foo}; +} + +export default StringLiteralStore; +" +`; + exports[`Preact > jsx > Javascript Test > Submit 1`] = ` "/** @jsx h */ import { h, Fragment } from \\"preact\\"; @@ -5301,6 +5318,23 @@ export default SmileReviews; " `; +exports[`Preact > jsx > Typescript Test > StoreComment 1`] = ` +"/** @jsx h */ +import { h, Fragment } from \\"preact\\"; +import { useState } from \\"preact/hooks\\"; + +function StringLiteralStore(props: any) { + const [foo, setFoo] = useState(() => true); + + function bar() {} + + return {foo}; +} + +export default StringLiteralStore; +" +`; + exports[`Preact > jsx > Typescript Test > Submit 1`] = ` "/** @jsx h */ import { h, Fragment } from \\"preact\\"; diff --git a/packages/core/src/__tests__/__snapshots__/qwik.test.ts.snap b/packages/core/src/__tests__/__snapshots__/qwik.test.ts.snap index e5072a17f2..00710ef64d 100644 --- a/packages/core/src/__tests__/__snapshots__/qwik.test.ts.snap +++ b/packages/core/src/__tests__/__snapshots__/qwik.test.ts.snap @@ -3401,6 +3401,20 @@ export const STYLES = \` " `; +exports[`qwik > jsx > Javascript Test > StoreComment 1`] = ` +"import { Fragment, component$, h, useStore } from \\"@builder.io/qwik\\"; + +export const bar = function bar(props, state) {}; +export const StringLiteralStore = component$((props) => { + const state = useStore({ foo: true }); + + return {state.foo}; +}); + +export default StringLiteralStore; +" +`; + exports[`qwik > jsx > Javascript Test > Submit 1`] = ` "import { Fragment, component$, h } from \\"@builder.io/qwik\\"; @@ -7170,6 +7184,20 @@ export const STYLES = \` " `; +exports[`qwik > jsx > Typescript Test > StoreComment 1`] = ` +"import { Fragment, component$, h, useStore } from \\"@builder.io/qwik\\"; + +export const bar = function bar(props, state) {}; +export const StringLiteralStore = component$((props: any) => { + const state = useStore({ foo: true }); + + return {state.foo}; +}); + +export default StringLiteralStore; +" +`; + exports[`qwik > jsx > Typescript Test > Submit 1`] = ` "import { Fragment, component$, h } from \\"@builder.io/qwik\\"; diff --git a/packages/core/src/__tests__/__snapshots__/react-native.test.ts.snap b/packages/core/src/__tests__/__snapshots__/react-native.test.ts.snap index a0004ba2dc..4436d5cce8 100644 --- a/packages/core/src/__tests__/__snapshots__/react-native.test.ts.snap +++ b/packages/core/src/__tests__/__snapshots__/react-native.test.ts.snap @@ -1909,6 +1909,39 @@ export default SmileReviews; " `; +exports[`React Native > jsx > Javascript Test > StoreComment 1`] = ` +"import * as React from \\"react\\"; +import { + FlatList, + ScrollView, + View, + StyleSheet, + Image, + Text, + Pressable, + TextInput, + TouchableOpacity, + Button, + Linking, +} from \\"react-native\\"; +import { useState } from \\"react\\"; + +function StringLiteralStore(props) { + const [foo, setFoo] = useState(() => true); + + function bar() {} + + return ( + <> + {foo} + + ); +} + +export default StringLiteralStore; +" +`; + exports[`React Native > jsx > Javascript Test > Submit 1`] = ` "import * as React from \\"react\\"; import { @@ -7176,6 +7209,39 @@ export default SmileReviews; " `; +exports[`React Native > jsx > Typescript Test > StoreComment 1`] = ` +"import * as React from \\"react\\"; +import { + FlatList, + ScrollView, + View, + StyleSheet, + Image, + Text, + Pressable, + TextInput, + TouchableOpacity, + Button, + Linking, +} from \\"react-native\\"; +import { useState } from \\"react\\"; + +function StringLiteralStore(props: any) { + const [foo, setFoo] = useState(() => true); + + function bar() {} + + return ( + <> + {foo} + + ); +} + +export default StringLiteralStore; +" +`; + exports[`React Native > jsx > Typescript Test > Submit 1`] = ` "import * as React from \\"react\\"; import { diff --git a/packages/core/src/__tests__/__snapshots__/react-state-builder.test.ts.snap b/packages/core/src/__tests__/__snapshots__/react-state-builder.test.ts.snap index b7172bba6c..e086e5473c 100644 --- a/packages/core/src/__tests__/__snapshots__/react-state-builder.test.ts.snap +++ b/packages/core/src/__tests__/__snapshots__/react-state-builder.test.ts.snap @@ -1492,6 +1492,20 @@ export default SmileReviews; " `; +exports[`React - stateType: builder > jsx > Javascript Test > StoreComment 1`] = ` +"\\"use client\\"; +import * as React from \\"react\\"; + +function StringLiteralStore(props) { + const state = useBuilderState({ foo: true, bar() {} }); + + return <>{state.foo}; +} + +export default StringLiteralStore; +" +`; + exports[`React - stateType: builder > jsx > Javascript Test > Submit 1`] = ` "import * as React from \\"react\\"; @@ -5299,6 +5313,20 @@ export default SmileReviews; " `; +exports[`React - stateType: builder > jsx > Typescript Test > StoreComment 1`] = ` +"\\"use client\\"; +import * as React from \\"react\\"; + +function StringLiteralStore(props: any) { + const state = useBuilderState({ foo: true, bar() {} }); + + return <>{state.foo}; +} + +export default StringLiteralStore; +" +`; + exports[`React - stateType: builder > jsx > Typescript Test > Submit 1`] = ` "import * as React from \\"react\\"; diff --git a/packages/core/src/__tests__/__snapshots__/react-state-mobx.test.ts.snap b/packages/core/src/__tests__/__snapshots__/react-state-mobx.test.ts.snap index 2c8cff924d..4215739286 100644 --- a/packages/core/src/__tests__/__snapshots__/react-state-mobx.test.ts.snap +++ b/packages/core/src/__tests__/__snapshots__/react-state-mobx.test.ts.snap @@ -1525,6 +1525,22 @@ export default observedSmileReviews; " `; +exports[`React - stateType: mobx > jsx > Javascript Test > StoreComment 1`] = ` +"\\"use client\\"; +import * as React from \\"react\\"; +import { useLocalObservable, observer } from \\"mobx-react-lite\\"; + +function StringLiteralStore(props) { + const state = useLocalObservable(() => ({ foo: true, bar() {} })); + + return <>{state.foo}; +} + +const observedStringLiteralStore = observer(StringLiteralStore); +export default observedStringLiteralStore; +" +`; + exports[`React - stateType: mobx > jsx > Javascript Test > Submit 1`] = ` "import * as React from \\"react\\"; @@ -5365,6 +5381,22 @@ export default observedSmileReviews; " `; +exports[`React - stateType: mobx > jsx > Typescript Test > StoreComment 1`] = ` +"\\"use client\\"; +import * as React from \\"react\\"; +import { useLocalObservable, observer } from \\"mobx-react-lite\\"; + +function StringLiteralStore(props: any) { + const state = useLocalObservable(() => ({ foo: true, bar() {} })); + + return <>{state.foo}; +} + +const observedStringLiteralStore = observer(StringLiteralStore); +export default observedStringLiteralStore; +" +`; + exports[`React - stateType: mobx > jsx > Typescript Test > Submit 1`] = ` "import * as React from \\"react\\"; diff --git a/packages/core/src/__tests__/__snapshots__/react-state-solid.test.ts.snap b/packages/core/src/__tests__/__snapshots__/react-state-solid.test.ts.snap index 4f991e00a1..257df7099e 100644 --- a/packages/core/src/__tests__/__snapshots__/react-state-solid.test.ts.snap +++ b/packages/core/src/__tests__/__snapshots__/react-state-solid.test.ts.snap @@ -1484,6 +1484,21 @@ export default SmileReviews; " `; +exports[`React - stateType: solid > jsx > Javascript Test > StoreComment 1`] = ` +"\\"use client\\"; +import * as React from \\"react\\"; +import { useMutable } from \\"react-solid-state\\"; + +function StringLiteralStore(props) { + const state = useMutable({ foo: true, bar() {} }); + + return <>{state.foo}; +} + +export default StringLiteralStore; +" +`; + exports[`React - stateType: solid > jsx > Javascript Test > Submit 1`] = ` "import * as React from \\"react\\"; @@ -5205,6 +5220,21 @@ export default SmileReviews; " `; +exports[`React - stateType: solid > jsx > Typescript Test > StoreComment 1`] = ` +"\\"use client\\"; +import * as React from \\"react\\"; +import { useMutable } from \\"react-solid-state\\"; + +function StringLiteralStore(props: any) { + const state = useMutable({ foo: true, bar() {} }); + + return <>{state.foo}; +} + +export default StringLiteralStore; +" +`; + exports[`React - stateType: solid > jsx > Typescript Test > Submit 1`] = ` "import * as React from \\"react\\"; diff --git a/packages/core/src/__tests__/__snapshots__/react-state-valtio.test.ts.snap b/packages/core/src/__tests__/__snapshots__/react-state-valtio.test.ts.snap index fcb771543c..3f475646d1 100644 --- a/packages/core/src/__tests__/__snapshots__/react-state-valtio.test.ts.snap +++ b/packages/core/src/__tests__/__snapshots__/react-state-valtio.test.ts.snap @@ -1487,6 +1487,21 @@ export default SmileReviews; " `; +exports[`React - stateType: valtio > jsx > Javascript Test > StoreComment 1`] = ` +"\\"use client\\"; +import * as React from \\"react\\"; +import { useLocalProxy } from \\"valtio/utils\\"; + +function StringLiteralStore(props) { + const state = useLocalProxy({ foo: true, bar() {} }); + + return <>{state.foo}; +} + +export default StringLiteralStore; +" +`; + exports[`React - stateType: valtio > jsx > Javascript Test > Submit 1`] = ` "import * as React from \\"react\\"; @@ -5211,6 +5226,21 @@ export default SmileReviews; " `; +exports[`React - stateType: valtio > jsx > Typescript Test > StoreComment 1`] = ` +"\\"use client\\"; +import * as React from \\"react\\"; +import { useLocalProxy } from \\"valtio/utils\\"; + +function StringLiteralStore(props: any) { + const state = useLocalProxy({ foo: true, bar() {} }); + + return <>{state.foo}; +} + +export default StringLiteralStore; +" +`; + exports[`React - stateType: valtio > jsx > Typescript Test > Submit 1`] = ` "import * as React from \\"react\\"; diff --git a/packages/core/src/__tests__/__snapshots__/react-state-variables.test.ts.snap b/packages/core/src/__tests__/__snapshots__/react-state-variables.test.ts.snap index f44535b561..d79d7da075 100644 --- a/packages/core/src/__tests__/__snapshots__/react-state-variables.test.ts.snap +++ b/packages/core/src/__tests__/__snapshots__/react-state-variables.test.ts.snap @@ -954,6 +954,21 @@ export default SmileReviews; " `; +exports[`React - stateType: variables > jsx > Javascript Test > StoreComment 1`] = ` +"\\"use client\\"; +import * as React from \\"react\\"; + +function StringLiteralStore(props) { + const foo = true; + const bar = function bar() {}; + + return <>{foo}; +} + +export default StringLiteralStore; +" +`; + exports[`React - stateType: variables > jsx > Javascript Test > Submit 1`] = ` "import * as React from \\"react\\"; @@ -3774,6 +3789,21 @@ export default SmileReviews; " `; +exports[`React - stateType: variables > jsx > Typescript Test > StoreComment 1`] = ` +"\\"use client\\"; +import * as React from \\"react\\"; + +function StringLiteralStore(props: any) { + const foo = true; + const bar = function bar() {}; + + return <>{foo}; +} + +export default StringLiteralStore; +" +`; + exports[`React - stateType: variables > jsx > Typescript Test > Submit 1`] = ` "import * as React from \\"react\\"; diff --git a/packages/core/src/__tests__/__snapshots__/react.test.ts.snap b/packages/core/src/__tests__/__snapshots__/react.test.ts.snap index 12e4a119d6..647806ce83 100644 --- a/packages/core/src/__tests__/__snapshots__/react.test.ts.snap +++ b/packages/core/src/__tests__/__snapshots__/react.test.ts.snap @@ -1465,6 +1465,23 @@ export default SmileReviews; " `; +exports[`React - stateType: useState > jsx > Javascript Test > StoreComment 1`] = ` +"\\"use client\\"; +import * as React from \\"react\\"; +import { useState } from \\"react\\"; + +function StringLiteralStore(props) { + const [foo, setFoo] = useState(() => true); + + function bar() {} + + return <>{foo}; +} + +export default StringLiteralStore; +" +`; + exports[`React - stateType: useState > jsx > Javascript Test > Submit 1`] = ` "import * as React from \\"react\\"; @@ -5184,6 +5201,23 @@ export default SmileReviews; " `; +exports[`React - stateType: useState > jsx > Typescript Test > StoreComment 1`] = ` +"\\"use client\\"; +import * as React from \\"react\\"; +import { useState } from \\"react\\"; + +function StringLiteralStore(props: any) { + const [foo, setFoo] = useState(() => true); + + function bar() {} + + return <>{foo}; +} + +export default StringLiteralStore; +" +`; + exports[`React - stateType: useState > jsx > Typescript Test > Submit 1`] = ` "import * as React from \\"react\\"; diff --git a/packages/core/src/__tests__/__snapshots__/rsc.test.ts.snap b/packages/core/src/__tests__/__snapshots__/rsc.test.ts.snap index 30048b6bfa..616f33435e 100644 --- a/packages/core/src/__tests__/__snapshots__/rsc.test.ts.snap +++ b/packages/core/src/__tests__/__snapshots__/rsc.test.ts.snap @@ -1462,6 +1462,23 @@ export default SmileReviews; " `; +exports[`RSC > jsx > Javascript Test > StoreComment 1`] = ` +"\\"use client\\"; +import * as React from \\"react\\"; +import { useState } from \\"react\\"; + +function StringLiteralStore(props) { + const [foo, setFoo] = useState(() => true); + + function bar() {} + + return <>{foo}; +} + +export default StringLiteralStore; +" +`; + exports[`RSC > jsx > Javascript Test > Submit 1`] = ` "import * as React from \\"react\\"; @@ -4910,6 +4927,23 @@ export default SmileReviews; " `; +exports[`RSC > jsx > Typescript Test > StoreComment 1`] = ` +"\\"use client\\"; +import * as React from \\"react\\"; +import { useState } from \\"react\\"; + +function StringLiteralStore(props: any) { + const [foo, setFoo] = useState(() => true); + + function bar() {} + + return <>{foo}; +} + +export default StringLiteralStore; +" +`; + exports[`RSC > jsx > Typescript Test > Submit 1`] = ` "import * as React from \\"react\\"; diff --git a/packages/core/src/__tests__/__snapshots__/solid.test.ts.snap b/packages/core/src/__tests__/__snapshots__/solid.test.ts.snap index 9f64f8eaf9..89669adfd6 100644 --- a/packages/core/src/__tests__/__snapshots__/solid.test.ts.snap +++ b/packages/core/src/__tests__/__snapshots__/solid.test.ts.snap @@ -3402,6 +3402,44 @@ export default SmileReviews; " `; +exports[`Solid > jsx > Javascript Test > StoreComment 1`] = ` +"import { createSignal, createMemo } from \\"solid-js\\"; + +function StringLiteralStore(props) { + const [foo, setFoo] = createSignal(true); + + function bar() {} + + return ( + <> + <>{foo()} + + ); +} + +export default StringLiteralStore; +" +`; + +exports[`Solid > jsx > Javascript Test > StoreComment 2`] = ` +"import { createSignal, createMemo } from \\"solid-js\\"; + +function StringLiteralStore(props) { + const [foo, setFoo] = createSignal(true); + + function bar() {} + + return ( + <> + <>{foo()} + + ); +} + +export default StringLiteralStore; +" +`; + exports[`Solid > jsx > Javascript Test > Submit 1`] = ` "function SubmitButton(props) { return ( @@ -11444,6 +11482,44 @@ export default SmileReviews; " `; +exports[`Solid > jsx > Typescript Test > StoreComment 1`] = ` +"import { createSignal, createMemo } from \\"solid-js\\"; + +function StringLiteralStore(props: any) { + const [foo, setFoo] = createSignal(true); + + function bar() {} + + return ( + <> + <>{foo()} + + ); +} + +export default StringLiteralStore; +" +`; + +exports[`Solid > jsx > Typescript Test > StoreComment 2`] = ` +"import { createSignal, createMemo } from \\"solid-js\\"; + +function StringLiteralStore(props: any) { + const [foo, setFoo] = createSignal(true); + + function bar() {} + + return ( + <> + <>{foo()} + + ); +} + +export default StringLiteralStore; +" +`; + exports[`Solid > jsx > Typescript Test > Submit 1`] = ` "export interface ButtonProps { attributes?: any; diff --git a/packages/core/src/__tests__/__snapshots__/stencil.test.ts.snap b/packages/core/src/__tests__/__snapshots__/stencil.test.ts.snap index ff6e7522fd..cb94a646ae 100644 --- a/packages/core/src/__tests__/__snapshots__/stencil.test.ts.snap +++ b/packages/core/src/__tests__/__snapshots__/stencil.test.ts.snap @@ -1763,6 +1763,24 @@ export class SmileReviews { " `; +exports[`Stencil > jsx > Javascript Test > StoreComment 1`] = ` +"import { Component, h, Fragment, State } from \\"@stencil/core\\"; + +@Component({ + tag: \\"string-literal-store\\", +}) +export class StringLiteralStore { + @State() foo = true; + + bar() {} + + render() { + return {this.foo}; + } +} +" +`; + exports[`Stencil > jsx > Javascript Test > Submit 1`] = ` "import { Component, h, Fragment, Prop } from \\"@stencil/core\\"; @@ -5742,6 +5760,24 @@ export class SmileReviews { " `; +exports[`Stencil > jsx > Typescript Test > StoreComment 1`] = ` +"import { Component, h, Fragment, State } from \\"@stencil/core\\"; + +@Component({ + tag: \\"string-literal-store\\", +}) +export class StringLiteralStore { + @State() foo = true; + + bar() {} + + render() { + return {this.foo}; + } +} +" +`; + exports[`Stencil > jsx > Typescript Test > Submit 1`] = ` "import { Component, h, Fragment, Prop } from \\"@stencil/core\\"; diff --git a/packages/core/src/__tests__/__snapshots__/svelte.test.ts.snap b/packages/core/src/__tests__/__snapshots__/svelte.test.ts.snap index ce33212532..231137a1b5 100644 --- a/packages/core/src/__tests__/__snapshots__/svelte.test.ts.snap +++ b/packages/core/src/__tests__/__snapshots__/svelte.test.ts.snap @@ -1404,6 +1404,16 @@ exports[`Svelte > jsx > Javascript Test > Stamped.io 1`] = ` " `; +exports[`Svelte > jsx > Javascript Test > StoreComment 1`] = ` +" + +{foo}" +`; + exports[`Svelte > jsx > Javascript Test > Submit 1`] = ` " + +{foo}" +`; + exports[`Svelte > jsx > Typescript Test > Submit 1`] = ` "" +`; + exports[`Vue > jsx > Javascript Test > Submit 1`] = ` "