From c1efd3c9e41f2f2176388bbb0bb375d74afbc38a Mon Sep 17 00:00:00 2001 From: Sami Jaber Date: Mon, 22 Apr 2024 14:14:02 -0300 Subject: [PATCH 01/10] add test --- .../data/blocks/getter-state.raw.lite.tsx | 24 +++++++++++++++++++ packages/core/src/__tests__/test-generator.ts | 2 ++ 2 files changed, 26 insertions(+) create mode 100644 packages/core/src/__tests__/data/blocks/getter-state.raw.lite.tsx diff --git a/packages/core/src/__tests__/data/blocks/getter-state.raw.lite.tsx b/packages/core/src/__tests__/data/blocks/getter-state.raw.lite.tsx new file mode 100644 index 0000000000..a1bd3a907e --- /dev/null +++ b/packages/core/src/__tests__/data/blocks/getter-state.raw.lite.tsx @@ -0,0 +1,24 @@ +import { useStore } from '@builder.io/mitosis'; + +export default function Button(props: { foo: string }) { + const state = useStore({ + get foo() { + return props.foo + 'foo'; + }, + + get bar() { + return 'bar'; + }, + + baz(i: number) { + return i + state.foo.length; + }, + }); + return ( +
+

{state.foo}

+

{state.bar}

+

{state.baz(1)}

+
+ ); +} diff --git a/packages/core/src/__tests__/test-generator.ts b/packages/core/src/__tests__/test-generator.ts index c4a6bdfc14..dd4f53e877 100644 --- a/packages/core/src/__tests__/test-generator.ts +++ b/packages/core/src/__tests__/test-generator.ts @@ -10,6 +10,7 @@ const getRawFile = async (filePath: string) => { type RawFile = ReturnType; +const getterState = getRawFile('./data/blocks/getter-state.raw.lite.tsx'); const basicForShow = getRawFile('./data/basic-for-show.raw.tsx'); const basicBooleanAttribute = getRawFile('./data/basic-boolean-attribute.raw.tsx'); const basicOnMountUpdate = getRawFile('./data/basic-onMount-update.raw.tsx'); @@ -221,6 +222,7 @@ const BASIC_TESTS: Tests = { renderBlock, useTarget, signalsOnUpdate, + getterState, }; const SLOTS_TESTS: Tests = { From e8b7f6eab6e4dd7a7a5cd005fa5bd95486c363d3 Mon Sep 17 00:00:00 2001 From: Sami Jaber Date: Mon, 22 Apr 2024 16:25:26 -0300 Subject: [PATCH 02/10] add test --- .../__snapshots__/alpine.test.ts.snap | 26 ++ .../__snapshots__/angular.import.test.ts.snap | 39 +++ .../__snapshots__/angular.mapper.test.ts.snap | 40 +++ .../__snapshots__/angular.test.ts.snap | 71 +++++ .../__tests__/__snapshots__/html.test.ts.snap | 82 ++++++ .../__snapshots__/liquid.test.ts.snap | 9 + .../__tests__/__snapshots__/lit.test.ts.snap | 37 +++ .../__snapshots__/marko.test.ts.snap | 20 ++ .../__snapshots__/parse-jsx.test.ts.snap | 256 ++++++++++++++++++ .../__snapshots__/preact.test.ts.snap | 30 ++ .../__tests__/__snapshots__/qwik.test.ts.snap | 28 ++ .../__snapshots__/react-native.test.ts.snap | 44 +++ .../__snapshots__/react.test.ts.snap | 29 ++ .../__tests__/__snapshots__/rsc.test.ts.snap | 27 ++ .../__snapshots__/solid.test.ts.snap | 60 ++++ .../__snapshots__/stencil.test.ts.snap | 32 +++ .../__snapshots__/svelte.test.ts.snap | 23 ++ .../__tests__/__snapshots__/taro.test.ts.snap | 30 ++ .../vue-composition.test.ts.snap | 27 ++ .../__tests__/__snapshots__/vue.test.ts.snap | 35 +++ .../__snapshots__/webcomponent.test.ts.snap | 135 +++++++++ 21 files changed, 1080 insertions(+) diff --git a/packages/core/src/__tests__/__snapshots__/alpine.test.ts.snap b/packages/core/src/__tests__/__snapshots__/alpine.test.ts.snap index 1724a20c51..bed53287c3 100644 --- a/packages/core/src/__tests__/__snapshots__/alpine.test.ts.snap +++ b/packages/core/src/__tests__/__snapshots__/alpine.test.ts.snap @@ -1697,6 +1697,32 @@ exports[`Alpine.js > jsx > Javascript Test > expressionState 1`] = ` " `; +exports[`Alpine.js > jsx > Javascript Test > getterState 1`] = ` +"
+

+

+

+
+ +" +`; + exports[`Alpine.js > jsx > Javascript Test > import types 1`] = ` " jsx > Javascript Test > getterState 1`] = ` +"import { NgModule } from \\"@angular/core\\"; +import { CommonModule } from \\"@angular/common\\"; + +import { Component, Input } from \\"@angular/core\\"; + +@Component({ + selector: \\"button, Button\\", + template: \` +
+

{{foo}}

+

{{bar}}

+

{{baz(1)}}

+
+ \`, +}) +export default class Button { + @Input() foo!: any; + + get foo() { + return this.foo + \\"foo\\"; + } + get bar() { + return \\"bar\\"; + } + baz(i) { + return i + this.foo.length; + } +} + +@NgModule({ + declarations: [Button], + imports: [CommonModule], + exports: [Button], +}) +export class ButtonModule {} +" +`; + exports[`Angular with Preserve Imports and File Extensions > jsx > Javascript Test > import types 1`] = ` "import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; diff --git a/packages/core/src/__tests__/__snapshots__/angular.mapper.test.ts.snap b/packages/core/src/__tests__/__snapshots__/angular.mapper.test.ts.snap index f8b3cb42de..e94b71d788 100644 --- a/packages/core/src/__tests__/__snapshots__/angular.mapper.test.ts.snap +++ b/packages/core/src/__tests__/__snapshots__/angular.mapper.test.ts.snap @@ -2729,6 +2729,46 @@ export class MyComponentModule {} " `; +exports[`Angular with Import Mapper Tests > jsx > Javascript Test > getterState 1`] = ` +"import { NgModule } from \\"@angular/core\\"; +import { CommonModule } from \\"@angular/common\\"; + +import { Component, Input } from \\"@angular/core\\"; + +@Component({ + selector: \\"button, Button\\", + template: \` +
+

{{foo}}

+

{{bar}}

+

{{baz(1)}}

+
+ \`, +}) +export default class Button { + @Input() foo!: any; + + get foo() { + return this.foo + \\"foo\\"; + } + get bar() { + return \\"bar\\"; + } + baz(i) { + return i + this.foo.length; + } +} + +@NgModule({ + declarations: [Button], + imports: [CommonModule], + exports: [Button], + bootstrap: [SomeOtherComponent], +}) +export class ButtonModule {} +" +`; + exports[`Angular with Import Mapper Tests > jsx > Javascript Test > import types 1`] = ` "import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; diff --git a/packages/core/src/__tests__/__snapshots__/angular.test.ts.snap b/packages/core/src/__tests__/__snapshots__/angular.test.ts.snap index 32d173daf9..229bb61173 100644 --- a/packages/core/src/__tests__/__snapshots__/angular.test.ts.snap +++ b/packages/core/src/__tests__/__snapshots__/angular.test.ts.snap @@ -4948,6 +4948,77 @@ export default class MyComponent { " `; +exports[`Angular > jsx > Javascript Test > getterState 1`] = ` +"import { NgModule } from \\"@angular/core\\"; +import { CommonModule } from \\"@angular/common\\"; + +import { Component, Input } from \\"@angular/core\\"; + +@Component({ + selector: \\"button, Button\\", + template: \` +
+

{{foo}}

+

{{bar}}

+

{{baz(1)}}

+
+ \`, +}) +export default class Button { + @Input() foo!: any; + + get foo() { + return this.foo + \\"foo\\"; + } + get bar() { + return \\"bar\\"; + } + baz(i) { + return i + this.foo.length; + } +} + +@NgModule({ + declarations: [Button], + imports: [CommonModule], + exports: [Button], +}) +export class ButtonModule {} +" +`; + +exports[`Angular > jsx > Javascript Test > getterState 2`] = ` +"import { Component, Input } from \\"@angular/core\\"; +import { CommonModule } from \\"@angular/common\\"; + +@Component({ + selector: \\"button, Button\\", + template: \` +
+

{{foo}}

+

{{bar}}

+

{{baz(1)}}

+
+ \`, + standalone: true, + imports: [CommonModule], +}) +export default class Button { + @Input() foo!: any; + + get foo() { + return this.foo + \\"foo\\"; + } + get bar() { + return \\"bar\\"; + } + baz(i) { + return i + this.foo.length; + } +} +" +`; + exports[`Angular > jsx > Javascript Test > import types 1`] = ` "import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; diff --git a/packages/core/src/__tests__/__snapshots__/html.test.ts.snap b/packages/core/src/__tests__/__snapshots__/html.test.ts.snap index b30d369cfa..f7e941d11e 100644 --- a/packages/core/src/__tests__/__snapshots__/html.test.ts.snap +++ b/packages/core/src/__tests__/__snapshots__/html.test.ts.snap @@ -4214,6 +4214,88 @@ exports[`Html > jsx > Javascript Test > expressionState 1`] = ` " `; +exports[`Html > jsx > Javascript Test > getterState 1`] = ` +"
+

+ +

+

+ +

+

+ +

+
+ +" +`; + exports[`Html > jsx > Javascript Test > import types 1`] = ` " " diff --git a/packages/core/src/__tests__/__snapshots__/liquid.test.ts.snap b/packages/core/src/__tests__/__snapshots__/liquid.test.ts.snap index 2c83073851..ae1a458f69 100644 --- a/packages/core/src/__tests__/__snapshots__/liquid.test.ts.snap +++ b/packages/core/src/__tests__/__snapshots__/liquid.test.ts.snap @@ -541,6 +541,15 @@ exports[`Liquid > jsx > Javascript Test > expressionState 1`] = ` " `; +exports[`Liquid > jsx > Javascript Test > getterState 1`] = ` +"
+

{{foo}}

+

{{bar}}

+

+
+" +`; + exports[`Liquid > jsx > Javascript Test > import types 1`] = ` " " diff --git a/packages/core/src/__tests__/__snapshots__/lit.test.ts.snap b/packages/core/src/__tests__/__snapshots__/lit.test.ts.snap index fc6cac0ba0..be62f9ff3e 100644 --- a/packages/core/src/__tests__/__snapshots__/lit.test.ts.snap +++ b/packages/core/src/__tests__/__snapshots__/lit.test.ts.snap @@ -2490,6 +2490,43 @@ export default class MyComponent extends LitElement { " `; +exports[`Lit > jsx > Javascript Test > getterState 1`] = ` +"import { LitElement, html, css } from \\"lit\\"; +import { customElement, property, state, query } from \\"lit/decorators.js\\"; + +@customElement(\\"my-button\\") +export default class Button extends LitElement { + createRenderRoot() { + return this; + } + + @property() foo: any; + + get foo() { + return this.foo + \\"foo\\"; + } + get bar() { + return \\"bar\\"; + } + baz(i) { + return i + this.foo.length; + } + + render() { + return html\` + +
+

\${this.foo}

+

\${this.bar}

+

\${this.baz(1)}

+
+ + \`; + } +} +" +`; + exports[`Lit > jsx > Javascript Test > import types 1`] = ` "import RenderBlock from \\"./builder-render-block.raw\\"; diff --git a/packages/core/src/__tests__/__snapshots__/marko.test.ts.snap b/packages/core/src/__tests__/__snapshots__/marko.test.ts.snap index 39f7e5dd4e..66200786f8 100644 --- a/packages/core/src/__tests__/__snapshots__/marko.test.ts.snap +++ b/packages/core/src/__tests__/__snapshots__/marko.test.ts.snap @@ -1597,6 +1597,26 @@ exports[`Marko > jsx > Javascript Test > expressionState 1`] = `
\${state.refToUse}
" `; +exports[`Marko > jsx > Javascript Test > getterState 1`] = ` +"class { + get foo() { + return this.input.foo + \\"foo\\"; + } + get bar() { + return \\"bar\\"; + } + baz(i) { + return i + this.foo.length; + } +} + +
+

\${component.foo}

+

\${component.bar}

+

\${component.baz(1)}

+
" +`; + exports[`Marko > jsx > Javascript Test > import types 1`] = ` "import RenderBlock from \\"./builder-render-block.raw\\"; 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 40c01bbae7..f9cc85e2bd 100644 --- a/packages/core/src/__tests__/__snapshots__/parse-jsx.test.ts.snap +++ b/packages/core/src/__tests__/__snapshots__/parse-jsx.test.ts.snap @@ -6239,6 +6239,131 @@ exports[`Parse JSX > Javascript > expressionState 1`] = ` } `; +exports[`Parse JSX > Javascript > getterState 1`] = ` +{ + "@type": "@builder.io/mitosis/component", + "children": [ + { + "@type": "@builder.io/mitosis/node", + "bindings": {}, + "children": [ + { + "@type": "@builder.io/mitosis/node", + "bindings": {}, + "children": [ + { + "@type": "@builder.io/mitosis/node", + "bindings": { + "_text": { + "code": "state.foo", + "type": "single", + }, + }, + "children": [], + "meta": {}, + "name": "div", + "properties": {}, + "scope": {}, + }, + ], + "meta": {}, + "name": "p", + "properties": {}, + "scope": {}, + }, + { + "@type": "@builder.io/mitosis/node", + "bindings": {}, + "children": [ + { + "@type": "@builder.io/mitosis/node", + "bindings": { + "_text": { + "code": "state.bar", + "type": "single", + }, + }, + "children": [], + "meta": {}, + "name": "div", + "properties": {}, + "scope": {}, + }, + ], + "meta": {}, + "name": "p", + "properties": {}, + "scope": {}, + }, + { + "@type": "@builder.io/mitosis/node", + "bindings": {}, + "children": [ + { + "@type": "@builder.io/mitosis/node", + "bindings": { + "_text": { + "code": "state.baz(1)", + "type": "single", + }, + }, + "children": [], + "meta": {}, + "name": "div", + "properties": {}, + "scope": {}, + }, + ], + "meta": {}, + "name": "p", + "properties": {}, + "scope": {}, + }, + ], + "meta": {}, + "name": "div", + "properties": {}, + "scope": {}, + }, + ], + "context": { + "get": {}, + "set": {}, + }, + "exports": {}, + "hooks": { + "onEvent": [], + "onMount": [], + }, + "imports": [], + "inputs": [], + "meta": {}, + "name": "Button", + "refs": {}, + "state": { + "bar": { + "code": "get bar() { + return 'bar'; +}", + "type": "getter", + }, + "baz": { + "code": "baz(i) { + return i + state.foo.length; +}", + "type": "method", + }, + "foo": { + "code": "get foo() { + return props.foo + 'foo'; +}", + "type": "getter", + }, + }, + "subComponents": [], +} +`; + exports[`Parse JSX > Javascript > import types 1`] = ` { "@type": "@builder.io/mitosis/component", @@ -16335,6 +16460,137 @@ exports[`Parse JSX > Typescript > expressionState 1`] = ` } `; +exports[`Parse JSX > Typescript > getterState 1`] = ` +{ + "@type": "@builder.io/mitosis/component", + "children": [ + { + "@type": "@builder.io/mitosis/node", + "bindings": {}, + "children": [ + { + "@type": "@builder.io/mitosis/node", + "bindings": {}, + "children": [ + { + "@type": "@builder.io/mitosis/node", + "bindings": { + "_text": { + "code": "state.foo", + "type": "single", + }, + }, + "children": [], + "meta": {}, + "name": "div", + "properties": {}, + "scope": {}, + }, + ], + "meta": {}, + "name": "p", + "properties": {}, + "scope": {}, + }, + { + "@type": "@builder.io/mitosis/node", + "bindings": {}, + "children": [ + { + "@type": "@builder.io/mitosis/node", + "bindings": { + "_text": { + "code": "state.bar", + "type": "single", + }, + }, + "children": [], + "meta": {}, + "name": "div", + "properties": {}, + "scope": {}, + }, + ], + "meta": {}, + "name": "p", + "properties": {}, + "scope": {}, + }, + { + "@type": "@builder.io/mitosis/node", + "bindings": {}, + "children": [ + { + "@type": "@builder.io/mitosis/node", + "bindings": { + "_text": { + "code": "state.baz(1)", + "type": "single", + }, + }, + "children": [], + "meta": {}, + "name": "div", + "properties": {}, + "scope": {}, + }, + ], + "meta": {}, + "name": "p", + "properties": {}, + "scope": {}, + }, + ], + "meta": {}, + "name": "div", + "properties": {}, + "scope": {}, + }, + ], + "context": { + "get": {}, + "set": {}, + }, + "exports": {}, + "hooks": { + "onEvent": [], + "onMount": [], + }, + "imports": [], + "inputs": [], + "meta": {}, + "name": "Button", + "propsTypeRef": "ButtonProps", + "refs": {}, + "state": { + "bar": { + "code": "get bar() { + return 'bar'; +}", + "type": "getter", + }, + "baz": { + "code": "baz(i: number) { + return i + state.foo.length; +}", + "type": "method", + }, + "foo": { + "code": "get foo() { + return props.foo + 'foo'; +}", + "type": "getter", + }, + }, + "subComponents": [], + "types": [ + "export interface ButtonProps { + foo: string; +}", + ], +} +`; + exports[`Parse JSX > Typescript > import types 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 3f7d1706a9..20917caf7a 100644 --- a/packages/core/src/__tests__/__snapshots__/preact.test.ts.snap +++ b/packages/core/src/__tests__/__snapshots__/preact.test.ts.snap @@ -2033,6 +2033,36 @@ export default MyComponent; " `; +exports[`Preact > jsx > Javascript Test > getterState 1`] = ` +"/** @jsx h */ +import { h, Fragment } from \\"preact\\"; + +function Button(props) { + function foo() { + return props.foo + \\"foo\\"; + } + + function bar() { + return \\"bar\\"; + } + + function baz(i) { + return i + foo().length; + } + + return ( +
+

{foo()}

+

{bar()}

+

{baz(1)}

+
+ ); +} + +export default Button; +" +`; + exports[`Preact > jsx > Javascript Test > import types 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 4692897e8f..f4de140767 100644 --- a/packages/core/src/__tests__/__snapshots__/qwik.test.ts.snap +++ b/packages/core/src/__tests__/__snapshots__/qwik.test.ts.snap @@ -3814,6 +3814,34 @@ export default MyComponent; " `; +exports[`qwik > jsx > Javascript Test > getterState 1`] = ` +"import { Fragment, component$, h, useComputed$ } from \\"@builder.io/qwik\\"; + +export const baz = function baz(props, state, i) { + return i + foo.value.length; +}; +export const Button = component$((props) => { + const foo = useComputed$(() => { + return props.foo + \\"foo\\"; + }); + const bar = useComputed$(() => { + return \\"bar\\"; + }); + const state = {}; + + return ( +
+

{foo.value}

+

{bar.value}

+

{baz(props, state, 1)}

+
+ ); +}); + +export default Button; +" +`; + exports[`qwik > jsx > Javascript Test > import types 1`] = ` "import RenderBlock from \\"./builder-render-block.raw\\"; 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 fad1ff2074..64291f4d68 100644 --- a/packages/core/src/__tests__/__snapshots__/react-native.test.ts.snap +++ b/packages/core/src/__tests__/__snapshots__/react-native.test.ts.snap @@ -2419,6 +2419,50 @@ export default MyComponent; " `; +exports[`React Native > jsx > Javascript Test > getterState 1`] = ` +"import * as React from \\"react\\"; +import { + FlatList, + ScrollView, + View, + StyleSheet, + Image, + Text, + Pressable, +} from \\"react-native\\"; + +function Button(props) { + function foo() { + return props.foo + \\"foo\\"; + } + + function bar() { + return \\"bar\\"; + } + + function baz(i) { + return i + foo().length; + } + + return ( + + + {foo()} + + + {bar()} + + + {baz(1)} + + + ); +} + +export default Button; +" +`; + exports[`React Native > jsx > Javascript Test > import types 1`] = ` "import * as React from \\"react\\"; import { diff --git a/packages/core/src/__tests__/__snapshots__/react.test.ts.snap b/packages/core/src/__tests__/__snapshots__/react.test.ts.snap index e20212e0f5..4e35dc0396 100644 --- a/packages/core/src/__tests__/__snapshots__/react.test.ts.snap +++ b/packages/core/src/__tests__/__snapshots__/react.test.ts.snap @@ -2016,6 +2016,35 @@ export default MyComponent; " `; +exports[`React > jsx > Javascript Test > getterState 1`] = ` +"import * as React from \\"react\\"; + +function Button(props) { + function foo() { + return props.foo + \\"foo\\"; + } + + function bar() { + return \\"bar\\"; + } + + function baz(i) { + return i + foo().length; + } + + return ( +
+

{foo()}

+

{bar()}

+

{baz(1)}

+
+ ); +} + +export default Button; +" +`; + exports[`React > jsx > Javascript Test > import types 1`] = ` "import * as React from \\"react\\"; import RenderBlock from \\"./builder-render-block.raw\\"; diff --git a/packages/core/src/__tests__/__snapshots__/rsc.test.ts.snap b/packages/core/src/__tests__/__snapshots__/rsc.test.ts.snap index 9aa63ebf03..397416c06e 100644 --- a/packages/core/src/__tests__/__snapshots__/rsc.test.ts.snap +++ b/packages/core/src/__tests__/__snapshots__/rsc.test.ts.snap @@ -2013,6 +2013,33 @@ export default MyComponent; " `; +exports[`RSC > jsx > Javascript Test > getterState 1`] = ` +"import * as React from \\"react\\"; + +function Button(props) { + const foo = function foo() { + return props.foo + \\"foo\\"; + }; + const bar = function bar() { + return \\"bar\\"; + }; + const baz = function baz(i) { + return i + foo().length; + }; + + return ( +
+

{foo()}

+

{bar()}

+

{baz(1)}

+
+ ); +} + +export default Button; +" +`; + exports[`RSC > jsx > Javascript Test > import types 1`] = ` "import * as React from \\"react\\"; import RenderBlock from \\"./builder-render-block.raw\\"; diff --git a/packages/core/src/__tests__/__snapshots__/solid.test.ts.snap b/packages/core/src/__tests__/__snapshots__/solid.test.ts.snap index f0bc53359e..96a7b291b3 100644 --- a/packages/core/src/__tests__/__snapshots__/solid.test.ts.snap +++ b/packages/core/src/__tests__/__snapshots__/solid.test.ts.snap @@ -4122,6 +4122,66 @@ export default MyComponent; " `; +exports[`Solid > jsx > Javascript Test > getterState 1`] = ` +"import { createSignal, createMemo } from \\"solid-js\\"; + +function Button(props) { + const foo = createMemo(() => { + return props.foo + \\"foo\\"; + }); + + const bar = createMemo(() => { + return \\"bar\\"; + }); + + function baz(i) { + return i + foo().length; + } + + return ( +
+

{foo()}

+

{bar()}

+

{baz(1)}

+
+ ); +} + +export default Button; +" +`; + +exports[`Solid > jsx > Javascript Test > getterState 2`] = ` +"import { createSignal, createMemo } from \\"solid-js\\"; + +function Button(props) { + const foo = createMemo(() => { + return props.foo + \\"foo\\"; + }); + + const bar = createMemo(() => { + return \\"bar\\"; + }); + + function baz(i) { + return i + foo().length; + } + + return ( + <> +
+

{foo()}

+

{bar()}

+

{baz(1)}

+
+ + ); +} + +export default Button; +" +`; + exports[`Solid > jsx > Javascript Test > import types 1`] = ` "import { createSignal, createMemo } from \\"solid-js\\"; diff --git a/packages/core/src/__tests__/__snapshots__/stencil.test.ts.snap b/packages/core/src/__tests__/__snapshots__/stencil.test.ts.snap index f390c4642d..883ea17514 100644 --- a/packages/core/src/__tests__/__snapshots__/stencil.test.ts.snap +++ b/packages/core/src/__tests__/__snapshots__/stencil.test.ts.snap @@ -1854,6 +1854,38 @@ export default class MyComponent { " `; +exports[`Stencil > jsx > Javascript Test > getterState 1`] = ` +"import { Component, Prop, h, State, Fragment } from \\"@stencil/core\\"; + +@Component({ + tag: \\"button\\", +}) +export default class Button { + @Prop() foo: any; + + get foo() { + return this.foo + \\"foo\\"; + } + get bar() { + return \\"bar\\"; + } + baz(i) { + return i + this.foo.length; + } + + render() { + return ( +
+

{this.foo}

+

{this.bar}

+

{this.baz(1)}

+
+ ); + } +} +" +`; + exports[`Stencil > jsx > Javascript Test > import types 1`] = ` "import RenderBlock from \\"./builder-render-block.raw\\"; diff --git a/packages/core/src/__tests__/__snapshots__/svelte.test.ts.snap b/packages/core/src/__tests__/__snapshots__/svelte.test.ts.snap index 2f32c73de5..f62590ae2c 100644 --- a/packages/core/src/__tests__/__snapshots__/svelte.test.ts.snap +++ b/packages/core/src/__tests__/__snapshots__/svelte.test.ts.snap @@ -1758,6 +1758,29 @@ exports[`Svelte > jsx > Javascript Test > expressionState 1`] = `
{refToUse}
" `; +exports[`Svelte > jsx > Javascript Test > getterState 1`] = ` +" + +
+

{foo()}

+

{bar()}

+

{baz(1)}

+
" +`; + exports[`Svelte > jsx > Javascript Test > import types 1`] = ` "" `; +exports[`Vue > jsx > Javascript Test > getterState 1`] = ` +" + +" +`; + exports[`Vue > jsx > Javascript Test > import types 1`] = ` "