Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
},
"dependencies": {
"@babel/core": "^7.23.6",
"content-tag": "^3.1.1",
"content-tag": "^3.1.2",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This patch fixes a different bug in the handling of implied export default.

"prettier": "^3.1.1"
},
"devDependencies": {
Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/parse/preprocess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export function preprocessTemplateRange(
suffix = '*/}';

const nextToken = code.slice(template.range.end).toString().match(/\S+/);
if (nextToken && nextToken[0] === 'as') {
if (nextToken && (nextToken[0] === 'as' || nextToken[0] === 'satisfies')) {
// Replace with parenthesized ObjectExpression
prefix = '(' + prefix;
suffix = suffix + ')';
Expand Down
5 changes: 5 additions & 0 deletions tests/cases/gts/implied-export-default-satisfies.gts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import type { TemplateOnlyComponent } from '@ember/component/template-only';

<template>
Implied Export Default with Satisfies
</template> satisfies TemplateOnlyComponent;
9 changes: 9 additions & 0 deletions tests/unit-tests/__snapshots__/format.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,15 @@ export const Exported = <template>
"
`;

exports[`format > config > default > it formats ../cases/gts/implied-export-default-satisfies.gts 1`] = `
"import type { TemplateOnlyComponent } from "@ember/component/template-only";

<template>
Implied Export Default with Satisfies
</template> satisfies TemplateOnlyComponent;
"
`;

exports[`format > config > default > it formats ../cases/gts/issue-191.gts 1`] = `
"import Component from "@glimmer/component";

Expand Down
9 changes: 9 additions & 0 deletions tests/unit-tests/config/__snapshots__/semi-false.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,15 @@ export const Exported = <template>
"
`;

exports[`config > semi: false > it formats ../cases/gts/implied-export-default-satisfies.gts 1`] = `
"import type { TemplateOnlyComponent } from "@ember/component/template-only"

;<template>
Implied Export Default with Satisfies
</template> satisfies TemplateOnlyComponent
"
`;

exports[`config > semi: false > it formats ../cases/gts/issue-191.gts 1`] = `
"import Component from "@glimmer/component"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,15 @@ export const Exported = <template>
"
`;

exports[`config > templateExportDefault: true > it formats ../cases/gts/implied-export-default-satisfies.gts 1`] = `
"import type { TemplateOnlyComponent } from "@ember/component/template-only";

<template>
Implied Export Default with Satisfies
</template> satisfies TemplateOnlyComponent;
"
`;

exports[`config > templateExportDefault: true > it formats ../cases/gts/issue-191.gts 1`] = `
"import Component from "@glimmer/component";

Expand Down