Skip to content

Commit

Permalink
fix: do not crash with comment before method in store (#1629)
Browse files Browse the repository at this point in the history
* test configuration

* fix path

* fix: do not crash with comment before method in store

* changeset

* clean up

* chore: update snapshots
  • Loading branch information
liamdebeasi authored Nov 6, 2024
1 parent 1fd0206 commit 697c307
Show file tree
Hide file tree
Showing 33 changed files with 1,588 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/clean-shrimps-help.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@builder.io/mitosis': patch
---

do not crash with comment before method in store
28 changes: 28 additions & 0 deletions packages/core/src/__tests__/__snapshots__/alpine.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1381,6 +1381,20 @@ showReviewPrompt = false\\"
"
`;
exports[`Alpine.js > jsx > Javascript Test > StoreComment 1`] = `
"<div x-data=\\"stringLiteralStore()\\"><span x-html=\\"foo\\"></span></div>
<script>
document.addEventListener(\\"alpine:init\\", () => {
Alpine.data(\\"stringLiteralStore\\", () => ({
foo: true,
bar() {},
}));
});
</script>
"
`;
exports[`Alpine.js > jsx > Javascript Test > Submit 1`] = `
"<button type=\\"submit\\" x-data=\\"submitButton()\\" x-bind=\\"attributes\\">
<span x-html=\\"text\\"></span>
Expand Down Expand Up @@ -4372,6 +4386,20 @@ showReviewPrompt = false\\"
"
`;
exports[`Alpine.js > jsx > Typescript Test > StoreComment 1`] = `
"<div x-data=\\"stringLiteralStore()\\"><span x-html=\\"foo\\"></span></div>
<script>
document.addEventListener(\\"alpine:init\\", () => {
Alpine.data(\\"stringLiteralStore\\", () => ({
foo: true,
bar() {},
}));
});
</script>
"
`;
exports[`Alpine.js > jsx > Typescript Test > Submit 1`] = `
"<button type=\\"submit\\" x-data=\\"submitButton()\\" x-bind=\\"attributes\\">
<span x-html=\\"text\\"></span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2717,6 +2717,39 @@ export class SmileReviewsModule {}
"
`;

exports[`Angular with Preserve Imports and File Extensions > jsx > Javascript Test > StoreComment 1`] = `
"import { NgModule } from \\"@angular/core\\";
import { CommonModule } from \\"@angular/common\\";

import { Component } from \\"@angular/core\\";

@Component({
selector: \\"string-literal-store\\",
template: \`
<ng-container>{{foo}}</ng-container>
\`,
styles: [
\`
:host {
display: contents;
}
\`,
],
})
export default class StringLiteralStore {
foo = true;
bar() {}
}

@NgModule({
declarations: [StringLiteralStore],
imports: [CommonModule],
exports: [StringLiteralStore],
})
export class StringLiteralStoreModule {}
"
`;

exports[`Angular with Preserve Imports and File Extensions > jsx > Javascript Test > Submit 1`] = `
"import { NgModule } from \\"@angular/core\\";
import { CommonModule } from \\"@angular/common\\";
Expand Down Expand Up @@ -10184,6 +10217,39 @@ export class SmileReviewsModule {}
"
`;

exports[`Angular with Preserve Imports and File Extensions > jsx > Typescript Test > StoreComment 1`] = `
"import { NgModule } from \\"@angular/core\\";
import { CommonModule } from \\"@angular/common\\";

import { Component } from \\"@angular/core\\";

@Component({
selector: \\"string-literal-store\\",
template: \`
<ng-container>{{foo}}</ng-container>
\`,
styles: [
\`
:host {
display: contents;
}
\`,
],
})
export default class StringLiteralStore {
foo = true;
bar() {}
}

@NgModule({
declarations: [StringLiteralStore],
imports: [CommonModule],
exports: [StringLiteralStore],
})
export class StringLiteralStoreModule {}
"
`;

exports[`Angular with Preserve Imports and File Extensions > jsx > Typescript Test > Submit 1`] = `
"import { NgModule } from \\"@angular/core\\";
import { CommonModule } from \\"@angular/common\\";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2754,6 +2754,40 @@ export class SmileReviewsModule {}
"
`;

exports[`Angular with Import Mapper Tests > jsx > Javascript Test > StoreComment 1`] = `
"import { NgModule } from \\"@angular/core\\";
import { CommonModule } from \\"@angular/common\\";

import { Component } from \\"@angular/core\\";

@Component({
selector: \\"string-literal-store\\",
template: \`
<ng-container>{{foo}}</ng-container>
\`,
styles: [
\`
:host {
display: contents;
}
\`,
],
})
export default class StringLiteralStore {
foo = true;
bar() {}
}

@NgModule({
declarations: [StringLiteralStore],
imports: [CommonModule],
exports: [StringLiteralStore],
bootstrap: [SomeOtherComponent],
})
export class StringLiteralStoreModule {}
"
`;

exports[`Angular with Import Mapper Tests > jsx > Javascript Test > Submit 1`] = `
"import { NgModule } from \\"@angular/core\\";
import { CommonModule } from \\"@angular/common\\";
Expand Down Expand Up @@ -10343,6 +10377,40 @@ export class SmileReviewsModule {}
"
`;

exports[`Angular with Import Mapper Tests > jsx > Typescript Test > StoreComment 1`] = `
"import { NgModule } from \\"@angular/core\\";
import { CommonModule } from \\"@angular/common\\";

import { Component } from \\"@angular/core\\";

@Component({
selector: \\"string-literal-store\\",
template: \`
<ng-container>{{foo}}</ng-container>
\`,
styles: [
\`
:host {
display: contents;
}
\`,
],
})
export default class StringLiteralStore {
foo = true;
bar() {}
}

@NgModule({
declarations: [StringLiteralStore],
imports: [CommonModule],
exports: [StringLiteralStore],
bootstrap: [SomeOtherComponent],
})
export class StringLiteralStoreModule {}
"
`;

exports[`Angular with Import Mapper Tests > jsx > Typescript Test > Submit 1`] = `
"import { NgModule } from \\"@angular/core\\";
import { CommonModule } from \\"@angular/common\\";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2797,6 +2797,39 @@ export class SmileReviewsModule {}
"
`;

exports[`Angular with manually creating and handling class properties as bindings (more stable) > jsx > Javascript Test > StoreComment 1`] = `
"import { NgModule } from \\"@angular/core\\";
import { CommonModule } from \\"@angular/common\\";

import { Component } from \\"@angular/core\\";

@Component({
selector: \\"string-literal-store\\",
template: \`
<ng-container>{{foo}}</ng-container>
\`,
styles: [
\`
:host {
display: contents;
}
\`,
],
})
export default class StringLiteralStore {
foo = true;
bar() {}
}

@NgModule({
declarations: [StringLiteralStore],
imports: [CommonModule],
exports: [StringLiteralStore],
})
export class StringLiteralStoreModule {}
"
`;

exports[`Angular with manually creating and handling class properties as bindings (more stable) > jsx > Javascript Test > Submit 1`] = `
"import { NgModule } from \\"@angular/core\\";
import { CommonModule } from \\"@angular/common\\";
Expand Down Expand Up @@ -10517,6 +10550,39 @@ export class SmileReviewsModule {}
"
`;

exports[`Angular with manually creating and handling class properties as bindings (more stable) > jsx > Typescript Test > StoreComment 1`] = `
"import { NgModule } from \\"@angular/core\\";
import { CommonModule } from \\"@angular/common\\";

import { Component } from \\"@angular/core\\";

@Component({
selector: \\"string-literal-store\\",
template: \`
<ng-container>{{foo}}</ng-container>
\`,
styles: [
\`
:host {
display: contents;
}
\`,
],
})
export default class StringLiteralStore {
foo = true;
bar() {}
}

@NgModule({
declarations: [StringLiteralStore],
imports: [CommonModule],
exports: [StringLiteralStore],
})
export class StringLiteralStoreModule {}
"
`;

exports[`Angular with manually creating and handling class properties as bindings (more stable) > jsx > Typescript Test > Submit 1`] = `
"import { NgModule } from \\"@angular/core\\";
import { CommonModule } from \\"@angular/common\\";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2486,6 +2486,32 @@ export class SmileReviewsModule {}
"
`;

exports[`Angular with visuallyIgnoreHostElement = false > jsx > Javascript Test > StoreComment 1`] = `
"import { NgModule } from \\"@angular/core\\";
import { CommonModule } from \\"@angular/common\\";

import { Component } from \\"@angular/core\\";

@Component({
selector: \\"string-literal-store\\",
template: \`
<ng-container>{{foo}}</ng-container>
\`,
})
export default class StringLiteralStore {
foo = true;
bar() {}
}

@NgModule({
declarations: [StringLiteralStore],
imports: [CommonModule],
exports: [StringLiteralStore],
})
export class StringLiteralStoreModule {}
"
`;

exports[`Angular with visuallyIgnoreHostElement = false > jsx > Javascript Test > Submit 1`] = `
"import { NgModule } from \\"@angular/core\\";
import { CommonModule } from \\"@angular/common\\";
Expand Down Expand Up @@ -9175,6 +9201,32 @@ export class SmileReviewsModule {}
"
`;

exports[`Angular with visuallyIgnoreHostElement = false > jsx > Typescript Test > StoreComment 1`] = `
"import { NgModule } from \\"@angular/core\\";
import { CommonModule } from \\"@angular/common\\";

import { Component } from \\"@angular/core\\";

@Component({
selector: \\"string-literal-store\\",
template: \`
<ng-container>{{foo}}</ng-container>
\`,
})
export default class StringLiteralStore {
foo = true;
bar() {}
}

@NgModule({
declarations: [StringLiteralStore],
imports: [CommonModule],
exports: [StringLiteralStore],
})
export class StringLiteralStoreModule {}
"
`;

exports[`Angular with visuallyIgnoreHostElement = false > jsx > Typescript Test > Submit 1`] = `
"import { NgModule } from \\"@angular/core\\";
import { CommonModule } from \\"@angular/common\\";
Expand Down
Loading

0 comments on commit 697c307

Please sign in to comment.