Skip to content

Commit 56c2d8b

Browse files
authored
Move to glint v2 & improve typescript story (#1030)
* Move to glint v2 * Fix lint * Add triggerHtmlTag to resolve glint issue, fix triggerElement type in calculate Position * Fix lint * Fix lint * Fix lint / ember-cli-update in docs
1 parent 8d1b4c1 commit 56c2d8b

24 files changed

Lines changed: 353 additions & 358 deletions

File tree

docs/app/components/code-block.gts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,3 @@ export default class CodeBlock extends Component<CodeBlockSignature> {
2626
</div>
2727
</template>
2828
}
29-
30-
declare module '@glint/environment-ember-loose/registry' {
31-
export default interface Registry {
32-
CodeBlock: typeof CodeBlock;
33-
}
34-
}

docs/app/components/code-inline.gts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,3 @@ export default class CodeInline extends Component<CodeInlineSignature> {
5555
</div>
5656
</template>
5757
}
58-
59-
declare module '@glint/environment-ember-loose/registry' {
60-
export default interface Registry {
61-
CodeInline: typeof CodeInline;
62-
}
63-
}

docs/app/components/snippets/custom-position-1.gts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import type {
77

88
export default class extends Component {
99
calculatePosition(
10-
trigger: Element,
10+
trigger: HTMLElement,
1111
content: HTMLElement,
1212
_destination: HTMLElement,
1313
{ horizontalPosition, verticalPosition }: CalculatePositionOptions,

docs/app/templates/public-pages.gts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ export default class extends Component {
3232
}
3333
}
3434

35-
setBrandColor(color: string, dropdown: BasicDropdownDefaultBlock) {
35+
setBrandColor(color: string, dropdown: BasicDropdownDefaultBlock<'span'>) {
3636
brands.forEach((klass) => document.body.classList.remove(klass));
3737
document.body.classList.add(`${color}-brand`);
3838
dropdown.actions.close();
3939
}
4040

4141
// Methods
4242
calculatePosition(
43-
trigger: Element,
43+
trigger: HTMLElement,
4444
content: HTMLElement,
4545
destination: HTMLElement,
4646
options: CalculatePositionOptions,

docs/config/ember-cli-update.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"isBaseBlueprint": true,
1313
"options": [
1414
"--no-welcome",
15+
"--pnpm",
1516
"--typescript"
1617
]
1718
}

docs/package.json

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@
1313
"scripts": {
1414
"build": "vite build",
1515
"format": "prettier . --cache --write",
16-
"lint": "concurrently \"npm:lint:*(!fix)\" --names \"lint:\" --prefixColors auto",
16+
"lint": "concurrently \"pnpm:lint:*(!fix)\" --names \"lint:\" --prefixColors auto",
1717
"lint:css": "stylelint \"**/*.css\" --allow-empty-input",
1818
"lint:css:fix": "concurrently \"pnpm:lint:css -- --fix\"",
19-
"lint:fix": "concurrently \"npm:lint:*:fix\" --names \"fix:\" --prefixColors auto && npm run format",
19+
"lint:fix": "concurrently \"pnpm:lint:*:fix\" --names \"fix:\" --prefixColors auto && npm run format",
2020
"lint:format": "prettier . --cache --check",
2121
"lint:hbs": "ember-template-lint .",
2222
"lint:hbs:fix": "ember-template-lint . --fix",
2323
"lint:js": "eslint . --cache",
2424
"lint:js:fix": "eslint . --fix",
25-
"lint:types": "glint",
25+
"lint:types": "ember-tsc --noEmit",
2626
"start": "vite",
27-
"test": "concurrently \"npm:lint\" \"npm:test:*\" --names \"lint,test:\" --prefixColors auto",
27+
"test": "concurrently \"pnpm:lint\" \"pnpm:test:*\" --names \"lint,test:\" --prefixColors auto",
2828
"test:ember": "vite build --mode development && ember test --path dist"
2929
},
3030
"dependenciesMeta": {
@@ -49,10 +49,8 @@
4949
"@eslint/js": "^9.39.1",
5050
"@glimmer/component": "^2.0.0",
5151
"@glimmer/tracking": "^1.1.2",
52-
"@glint/core": "^1.5.2",
53-
"@glint/environment-ember-loose": "^1.5.2",
54-
"@glint/environment-ember-template-imports": "^1.5.2",
55-
"@glint/template": "1.5.2",
52+
"@glint/ember-tsc": "^1.0.8",
53+
"@glint/template": "^1.7.3",
5654
"@rollup/plugin-babel": "^6.1.0",
5755
"@tsconfig/ember": "^3.0.12",
5856
"@types/qunit": "^2.19.13",

docs/tsconfig.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
{
22
"extends": "@tsconfig/ember",
3-
"glint": {
4-
"environment": ["ember-loose", "ember-template-imports"]
5-
},
63
"compilerOptions": {
74
// The combination of `baseUrl` with `paths` allows Ember's classic package
85
// layout, which is not resolvable with the Node resolution algorithm, to

docs/types/global.d.ts

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1 @@
1-
import '@glint/environment-ember-loose';
2-
import type EmberBasicDropdownRegistry from 'ember-basic-dropdown/template-registry';
3-
4-
export interface GetCodeSnippetHelperRegistry {
5-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
6-
[key: string]: any;
7-
}
8-
9-
export interface CodeBlockRegistry {
10-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
11-
[key: string]: any;
12-
}
13-
14-
declare module '@glint/environment-ember-loose/registry' {
15-
export default interface Registry
16-
extends
17-
EmberBasicDropdownRegistry,
18-
GetCodeSnippetHelperRegistry,
19-
CodeBlockRegistry {}
20-
}
1+
import '@glint/ember-tsc/types';

ember-basic-dropdown/package.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"lint:hbs:fix": "ember-template-lint . --fix --no-error-on-unmatched-pattern",
5555
"lint:js": "eslint . --cache",
5656
"lint:js:fix": "eslint . --fix",
57-
"lint:types": "glint",
57+
"lint:types": "ember-tsc --noEmit",
5858
"prepack": "rollup --config",
5959
"start": "rollup --config --watch",
6060
"test": "echo 'A v2 addon does not have tests, run tests in test-app'"
@@ -78,10 +78,8 @@
7878
"@ember/test-helpers": "^5.4.1",
7979
"@embroider/addon-dev": "^8.1.2",
8080
"@eslint/js": "^9.39.1",
81-
"@glint/core": "^1.5.2",
82-
"@glint/environment-ember-loose": "^1.5.2",
83-
"@glint/environment-ember-template-imports": "^1.5.2",
84-
"@glint/template": "1.5.2",
81+
"@glint/ember-tsc": "^1.0.8",
82+
"@glint/template": "^1.7.3",
8583
"@glimmer/component": "^2.0.0",
8684
"@glimmer/tracking": "^1.1.2",
8785
"@rollup/plugin-babel": "^6.1.0",

ember-basic-dropdown/rollup.config.mjs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ import { babel } from '@rollup/plugin-babel';
22
import { Addon } from '@embroider/addon-dev/rollup';
33
import sass from 'rollup-plugin-sass';
44
import postcss from 'postcss';
5+
import { fileURLToPath } from 'node:url';
6+
import { resolve, dirname } from 'node:path';
7+
8+
const rootDirectory = dirname(fileURLToPath(import.meta.url));
9+
const tsConfig = resolve(rootDirectory, './tsconfig.json');
510

611
const addon = new Addon({
712
srcDir: 'src',
@@ -91,7 +96,10 @@ export default [
9196
addon.gjs(),
9297

9398
// Emit .d.ts declaration files
94-
addon.declarations('declarations'),
99+
addon.declarations(
100+
'declarations',
101+
`pnpm ember-tsc --declaration --project ${tsConfig}`,
102+
),
95103

96104
// addons are allowed to contain imports of .css files, which we want rollup
97105
// to leave alone and keep in the published output.

0 commit comments

Comments
 (0)