Skip to content

Commit e757dc6

Browse files
authored
Merge pull request embroider-build#2112 from patricklx/test-ts-syntax
fix build with gts
2 parents 89d7d7f + 68df644 commit e757dc6

File tree

5 files changed

+75
-11
lines changed

5 files changed

+75
-11
lines changed

pnpm-lock.yaml

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/scenarios/typescript-app-test.ts

+48
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,31 @@ let typescriptApp = tsAppScenarios.map('typescript-app', project => {
88
merge(project.files, {
99
app: {
1010
components: {
11+
'test-gts.gts': `
12+
import Component from '@glimmer/component';
13+
import { tracked } from '@glimmer/tracking';
14+
import { action } from '@ember/object';
15+
import { on } from '@ember/modifier';
16+
17+
interface Signature {
18+
Element: HTMLDivElement;
19+
Blocks: {
20+
default: [number]
21+
}
22+
}
23+
24+
export default class Incrementer extends Component<Signature> {
25+
@tracked count = 0;
26+
27+
@action increment() { this.count++ }
28+
<template>
29+
<div ...attributes>
30+
<button {{on 'click' this.increment}}>increment</button>
31+
{{yield this.count}}
32+
</div>
33+
</template>
34+
}
35+
`,
1136
'incrementer.ts': `
1237
import Component from '@glimmer/component';
1338
import { tracked } from '@glimmer/tracking';
@@ -36,6 +61,29 @@ let typescriptApp = tsAppScenarios.map('typescript-app', project => {
3661
},
3762
tests: {
3863
rendering: {
64+
'gts-test.gts': `
65+
import { module, test } from 'qunit';
66+
import { setupRenderingTest } from 'ember-qunit';
67+
import { render, click } from '@ember/test-helpers';
68+
import TestGts from '/app/components/test-gts';
69+
70+
module('Rendering', function (hooks) {
71+
setupRenderingTest(hooks);
72+
73+
test('increments', async function (assert) {
74+
await render(<template>
75+
<TestGts as |count|>
76+
<out>{{count}}</out>
77+
</TestGts>
78+
</template>);
79+
80+
assert.dom('out').hasText('0');
81+
82+
await click('button');
83+
assert.dom('out').hasText('1');
84+
});
85+
});
86+
`,
3987
'incrementer-test.ts': `
4088
import { module, test } from 'qunit';
4189
import { setupRenderingTest } from 'ember-qunit';

tests/scenarios/vite-internals-test.ts

+22-11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { appScenarios, baseAddon } from './scenarios';
1+
import { baseAddon, tsAppScenarios } from './scenarios';
22
import type { PreparedApp } from 'scenario-tester';
33
import QUnit from 'qunit';
44
import fetch from 'node-fetch';
@@ -7,7 +7,7 @@ import { setupAuditTest } from '@embroider/test-support/audit-assertions';
77

88
const { module: Qmodule, test } = QUnit;
99

10-
appScenarios
10+
tsAppScenarios
1111
.only('release')
1212
.map('vite-internals', app => {
1313
// These are for a custom testem setup that will let us do runtime tests
@@ -54,10 +54,19 @@ appScenarios
5454

5555
app: {
5656
components: {
57-
'alpha.js': `
57+
'fancy-gts.gts': `
5858
import Component from '@glimmer/component';
5959
export default class extends Component {
60-
message = "alpha";
60+
message: string = "fancy gts";
61+
<template>
62+
<div class="fancy-gts">{{this.message}}</div>
63+
</template>
64+
}
65+
`,
66+
'alpha.ts': `
67+
import Component from '@glimmer/component';
68+
export default class extends Component {
69+
message: string = "alpha";
6170
}
6271
`,
6372
'alpha.hbs': `
@@ -80,7 +89,7 @@ appScenarios
8089
import Component from '@glimmer/component';
8190
export default class extends Component {
8291
message = "delta";
83-
}
92+
}
8493
`,
8594
},
8695
templates: {
@@ -90,6 +99,7 @@ appScenarios
9099
`,
91100
'index.hbs': `
92101
<FancyButton />
102+
<FancyGts />
93103
<WelcomePage />
94104
`,
95105
},
@@ -109,12 +119,13 @@ appScenarios
109119
components: {
110120
'example-test.js': `
111121
import { module, test } from 'qunit';
112-
import { setupRenderingTest } from 'app-template/tests/helpers';
122+
import { setupRenderingTest } from 'ts-app-template/tests/helpers';
113123
import { render } from '@ember/test-helpers';
114124
import { hbs } from 'ember-cli-htmlbars';
115-
import { appLibOne as libOneViaAddon, appLibTwo as libTwoViaAddon } from 'app-template/v1-example-addon';
116-
import appLibOne from 'app-template/lib/app-lib-one';
117-
import appLibTwo from 'app-template/lib/app-lib-two';
125+
import { appLibOne as libOneViaAddon, appLibTwo as libTwoViaAddon } from 'ts-app-template/v1-example-addon';
126+
import appLibOne from 'ts-app-template/lib/app-lib-one';
127+
import appLibTwo from 'ts-app-template/lib/app-lib-two';
128+
118129
119130
module('Integration | Component | example', function (hooks) {
120131
setupRenderingTest(hooks);
@@ -187,7 +198,7 @@ appScenarios
187198
app: {
188199
'v1-example-addon.js': `
189200
import appLibOne from './lib/app-lib-one';
190-
import appLibTwo from 'app-template/lib/app-lib-two';
201+
import appLibTwo from 'ts-app-template/lib/app-lib-two';
191202
export { appLibOne, appLibTwo };
192203
`,
193204
templates: {
@@ -240,7 +251,7 @@ appScenarios
240251
.module('./index.html')
241252
.resolves(/\/index.html.*/) // in-html app-boot script
242253
.toModule()
243-
.resolves(/\/app\.js.*/)
254+
.resolves(/\/app\.ts.*/)
244255
.toModule()
245256
.resolves(/.*\/-embroider-entrypoint.js/)
246257
.toModule()

tests/ts-app-template/babel.config.cjs

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const { babelCompatSupport, templateCompatSupport } = require('@embroider/compat
22

33
module.exports = {
44
plugins: [
5+
['@babel/plugin-transform-typescript'],
56
[
67
'babel-plugin-ember-template-compilation',
78
{

tests/ts-app-template/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
},
3131
"devDependencies": {
3232
"@babel/core": "^7.22.20",
33+
"@babel/plugin-transform-typescript": "^7.21.3",
3334
"@babel/eslint-parser": "^7.21.3",
3435
"@babel/plugin-proposal-decorators": "^7.21.0",
3536
"@ember/optional-features": "^2.0.0",

0 commit comments

Comments
 (0)