Skip to content

Commit 23de516

Browse files
authored
Merge pull request #341 from ef4/satisfies-example
Fix implied export default with satisfies
2 parents b3a0f2b + 2c7fba8 commit 23de516

File tree

7 files changed

+38
-6
lines changed

7 files changed

+38
-6
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
},
4646
"dependencies": {
4747
"@babel/core": "^7.23.6",
48-
"content-tag": "^3.1.1",
48+
"content-tag": "^3.1.2",
4949
"prettier": "^3.1.1"
5050
},
5151
"devDependencies": {

pnpm-lock.yaml

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/parse/preprocess.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export function preprocessTemplateRange(
7171
suffix = '*/}';
7272

7373
const nextToken = code.slice(template.range.end).toString().match(/\S+/);
74-
if (nextToken && nextToken[0] === 'as') {
74+
if (nextToken && (nextToken[0] === 'as' || nextToken[0] === 'satisfies')) {
7575
// Replace with parenthesized ObjectExpression
7676
prefix = '(' + prefix;
7777
suffix = suffix + ')';
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import type { TemplateOnlyComponent } from '@ember/component/template-only';
2+
3+
<template>
4+
Implied Export Default with Satisfies
5+
</template> satisfies TemplateOnlyComponent;

tests/unit-tests/__snapshots__/format.test.ts.snap

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,15 @@ export const Exported = <template>
453453
"
454454
`;
455455
456+
exports[`format > config > default > it formats ../cases/gts/implied-export-default-satisfies.gts 1`] = `
457+
"import type { TemplateOnlyComponent } from "@ember/component/template-only";
458+
459+
<template>
460+
Implied Export Default with Satisfies
461+
</template> satisfies TemplateOnlyComponent;
462+
"
463+
`;
464+
456465
exports[`format > config > default > it formats ../cases/gts/issue-191.gts 1`] = `
457466
"import Component from "@glimmer/component";
458467

tests/unit-tests/config/__snapshots__/semi-false.test.ts.snap

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,15 @@ export const Exported = <template>
453453
"
454454
`;
455455
456+
exports[`config > semi: false > it formats ../cases/gts/implied-export-default-satisfies.gts 1`] = `
457+
"import type { TemplateOnlyComponent } from "@ember/component/template-only"
458+
459+
;<template>
460+
Implied Export Default with Satisfies
461+
</template> satisfies TemplateOnlyComponent
462+
"
463+
`;
464+
456465
exports[`config > semi: false > it formats ../cases/gts/issue-191.gts 1`] = `
457466
"import Component from "@glimmer/component"
458467

tests/unit-tests/config/__snapshots__/template-export-default.test.ts.snap

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,15 @@ export const Exported = <template>
453453
"
454454
`;
455455
456+
exports[`config > templateExportDefault: true > it formats ../cases/gts/implied-export-default-satisfies.gts 1`] = `
457+
"import type { TemplateOnlyComponent } from "@ember/component/template-only";
458+
459+
<template>
460+
Implied Export Default with Satisfies
461+
</template> satisfies TemplateOnlyComponent;
462+
"
463+
`;
464+
456465
exports[`config > templateExportDefault: true > it formats ../cases/gts/issue-191.gts 1`] = `
457466
"import Component from "@glimmer/component";
458467

0 commit comments

Comments
 (0)