Skip to content

Commit

Permalink
feat(test-app): add Typescript. Migrate some files
Browse files Browse the repository at this point in the history
  • Loading branch information
BobrImperator committed Dec 29, 2024
1 parent 4d925a9 commit c587784
Show file tree
Hide file tree
Showing 11 changed files with 295 additions and 104 deletions.
3 changes: 2 additions & 1 deletion packages/classic-test-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"ember-engines": "0.11.0",
"ember-engines-router-service": "0.6.0",
"ember-fetch": "8.1.2",
"ember-inflector": "^5.0.2",
"ember-load-initializers": "2.1.2",
"ember-maybe-import-regenerator": "1.0.0",
"ember-qunit": "7.0.0",
Expand All @@ -54,7 +55,7 @@
"globals": "15.12.0",
"handlebars": "4.7.8",
"loader.js": "4.7.0",
"my-engine": "workspace:../classic-test-app/lib/my-engine",
"my-engine": "workspace:./lib/my-engine",
"npm-run-all2": "7.0.2",
"pretender": "3.4.7",
"qunit": "2.23.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Controller from '@ember/controller';
import { inject as service } from '@ember/service';
import type SessionService from 'test-app/services/session';

export default class ApplicationIndexController extends Controller {
@service session;
@service declare session: SessionService;
}
13 changes: 0 additions & 13 deletions packages/test-app/app/services/session.js

This file was deleted.

18 changes: 18 additions & 0 deletions packages/test-app/app/services/session.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { inject as service } from '@ember/service';
import Session from 'ember-simple-auth/services/session';

export default class SessionService extends Session {
@service sessionAccount: any;

handleAuthentication(routeAfterInvalidation: string) {
super.handleAuthentication(routeAfterInvalidation);

this.sessionAccount.loadCurrentUser().catch(() => (this as any).invalidate());
}
}

declare module '@ember/service' {
interface Registry {
session: SessionService;
}
}
4 changes: 2 additions & 2 deletions packages/test-app/app/session-stores/application.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import Cookie from 'ember-simple-auth/session-stores/cookie';
import CookieStore from 'ember-simple-auth/session-stores/cookie';

export default Cookie.extend();
export default class ApplicationStore extends CookieStore {}
3 changes: 2 additions & 1 deletion packages/test-app/babel.config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"plugins": [
"@embroider/addon-dev/template-colocation-plugin",
["@babel/plugin-transform-typescript", { "allowDeclareFields": true }],
["@babel/plugin-proposal-decorators", { "legacy": true }],
"@babel/plugin-proposal-class-properties"
"@babel/plugin-proposal-class-properties",
]
}
2 changes: 1 addition & 1 deletion packages/test-app/ember-cli-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const EmberApp = require('ember-cli/lib/broccoli/ember-app');

module.exports = function (defaults) {
let app = new EmberApp(defaults, {});
let app = new EmberApp(defaults, { 'ember-cli-babel': { enableTypeScriptTransform: true } });

// Use `app.import` to add additional libraries to the generated
// output files.
Expand Down
15 changes: 12 additions & 3 deletions packages/test-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"lint:fix": "npm-run-all --aggregate-output --continue-on-error --parallel \"lint:*:fix\"",
"lint:js": "eslint . --cache",
"lint:js:fix": "eslint . --fix",
"lint:types": "tsc --noEmit",
"start": "ember serve",
"start:fastboot": "NODE_ENV=production node fastboot-server.js",
"start:demo-api": "node server/demo-api.js",
Expand All @@ -17,13 +18,22 @@
"test:fastboot": "ember fastboot:test"
},
"devDependencies": {
"@babel/eslint-parser": "7.25.9",
"@babel/plugin-transform-typescript": "7.26.3",
"@ember/legacy-built-in-components": "0.5.0",
"@ember/optional-features": "2.2.0",
"@ember/string": "3.1.1",
"@ember/test-helpers": "3.3.1",
"@embroider/test-setup": "4.0.0",
"@glimmer/component": "1.1.2",
"@glimmer/tracking": "1.1.2",
"@glint/core": "1.5.0",
"@glint/environment-ember-loose": "1.5.0",
"@glint/environment-ember-template-imports": "1.5.0",
"@tsconfig/ember": "3.0.8",
"@types/ember__service": "4.0.9",
"@typescript-eslint/eslint-plugin": "8.18.1",
"@typescript-eslint/parser": "8.18.1",
"body-parser": "1.20.3",
"bootstrap": "5.3.3",
"broccoli-asset-rev": "3.0.0",
Expand All @@ -44,6 +54,7 @@
"ember-engines": "0.11.0",
"ember-engines-router-service": "0.6.0",
"ember-fetch": "8.1.2",
"ember-inflector": "^5.0.2",
"ember-load-initializers": "2.1.2",
"ember-maybe-import-regenerator": "1.0.0",
"ember-qunit": "7.0.0",
Expand All @@ -65,6 +76,7 @@
"qunit": "2.23.1",
"qunit-dom": "2.0.0",
"torii": "1.0.0-beta.2",
"typescript": "5.7.2",
"webpack": "5.96.1"
},
"fastbootDependencies": [
Expand All @@ -73,8 +85,5 @@
],
"ember": {
"edition": "octane"
},
"dependencies": {
"@babel/eslint-parser": "^7.24.7"
}
}
23 changes: 23 additions & 0 deletions packages/test-app/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"extends": "@tsconfig/ember/tsconfig.json",
"compilerOptions": {
"target": "es2020",
"module": "esnext",
// The combination of `baseUrl` with `paths` allows Ember's classic package
// layout, which is not resolvable with the Node resolution algorithm, to
// work with TypeScript.
"baseUrl": ".",
"experimentalDecorators": true,

"paths": {
"test-app/tests/*": ["tests/*"],
"test-app/*": ["app/*"],
"*": ["types/*"]
},
"types": ["ember-source/types"]
},
"glint": {
"environment": "ember-loose"
},
"include": ["app", "tests"]
}
1 change: 1 addition & 0 deletions packages/test-app/types/global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import '@glint/environment-ember-loose';
Loading

0 comments on commit c587784

Please sign in to comment.