Skip to content

Commit 096aa79

Browse files
committed
We don't want to add export default when we encounter satisfies
1 parent e678c1b commit 096aa79

File tree

2 files changed

+29
-25
lines changed
  • packages/environment-ember-template-imports/-private/environment
  • test-packages/package-test-core/__tests__/transform

2 files changed

+29
-25
lines changed

packages/environment-ember-template-imports/-private/environment/transform.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ type ETIDefaultTemplate =
121121

122122
function isETIDefaultTemplate(ts: TSLib, node: ts.Node): node is ETIDefaultTemplate {
123123
return (
124-
(ts.isExpressionStatement(node) || ts.isSatisfiesExpression(node)) &&
124+
(ts.isExpressionStatement(node)) &&
125125
isETITemplateLiteral(ts, node.expression)
126126
);
127127
}

test-packages/package-test-core/__tests__/transform/rewrite.test.ts

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -32,30 +32,6 @@ describe('Transform: rewriteModule', () => {
3232
`);
3333
});
3434

35-
test('handles satisfies', () => {
36-
let script = {
37-
filename: 'test.gts',
38-
contents: [
39-
`import type { TOC } from '@ember/component/template-only';`,
40-
``,
41-
`const SmolComp = `,
42-
` <template>`,
43-
` Hello there, {{@name}}`,
44-
` <template> satisfies TOC<{ Args: { name: string }}>;`,
45-
``,
46-
`<template>`,
47-
` <SmolComp @name="Ember" />`,
48-
`</template>`,
49-
``,
50-
].join('\n'),
51-
};
52-
53-
let transformedModule = rewriteModule(ts, { script }, emberTemplateImportsEnvironment);
54-
55-
expect(transformedModule?.errors).toEqual([]);
56-
expect(transformedModule?.transformedContents).toMatchInlineSnapshot();
57-
});
58-
5935
test('handles the $ character', () => {
6036
let script = {
6137
filename: 'test.gts',
@@ -490,6 +466,34 @@ describe('Transform: rewriteModule', () => {
490466
}"
491467
`);
492468
});
469+
470+
471+
test('handles satisfies', () => {
472+
const emberTemplateImportsEnvironment = GlintEnvironment.load('ember-template-imports');
473+
474+
let script = {
475+
filename: 'test.gts',
476+
contents: [
477+
`import type { TOC } from '@ember/component/template-only';`,
478+
``,
479+
`const SmolComp = `,
480+
` <template>`,
481+
` Hello there, {{@name}}`,
482+
` <template> satisfies TOC<{ Args: { name: string }}>;`,
483+
``,
484+
`<template>`,
485+
` <SmolComp @name="Ember" />`,
486+
`</template> satisfies TOC<{ Args: {}, Blocks: {}, Element: null }>`,
487+
``,
488+
].join('\n'),
489+
};
490+
491+
let transformedModule = rewriteModule(ts, { script }, emberTemplateImportsEnvironment);
492+
493+
expect(transformedModule?.transformedContents).toMatchInlineSnapshot('two components');
494+
expect(transformedModule?.errors).toEqual([]);
495+
});
496+
493497
test('embedded gts templates', () => {
494498
let customEnv = GlintEnvironment.load(['ember-loose', 'ember-template-imports']);
495499
let script = {

0 commit comments

Comments
 (0)