Skip to content

Commit

Permalink
Merge pull request #90 from NullVoxPopuli/fix-types-ish-sorta
Browse files Browse the repository at this point in the history
Fix type violations due to missing glint configuration
  • Loading branch information
simonihmig authored Mar 27, 2023
2 parents b1df703 + 8bf8253 commit fdaa81e
Show file tree
Hide file tree
Showing 7 changed files with 2,005 additions and 345 deletions.
6 changes: 4 additions & 2 deletions packages/ember-headless-form/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
"@embroider/util": "^1.10.0",
"ember-async-data": "^0.7.0",
"ember-modifier": "^4.1.0",
"rollup-plugin-glimmer-template-tag": "^0.1.0",
"tracked-built-ins": "^3.1.0"
},
"peerDependencies": {
Expand All @@ -42,7 +41,7 @@
"ember-source": ">=4.4.0"
},
"devDependencies": {
"@babel/core": "^7.17.0",
"@babel/core": "^7.21.3",
"@babel/plugin-proposal-class-properties": "^7.16.7",
"@babel/plugin-proposal-decorators": "^7.17.0",
"@babel/plugin-syntax-decorators": "^7.17.0",
Expand All @@ -52,6 +51,7 @@
"@glimmer/tracking": "^1.1.2",
"@glint/core": "^1.0.0-beta.3",
"@glint/environment-ember-loose": "^1.0.0-beta.3",
"@glint/environment-ember-template-imports": "^1.0.0-beta.3",
"@glint/template": "^1.0.0-beta.3",
"@nullvoxpopuli/eslint-configs": "^3.0.2",
"@tsconfig/ember": "^1.0.0",
Expand All @@ -77,6 +77,7 @@
"@typescript-eslint/parser": "^5.30.5",
"concurrently": "^7.2.1",
"ember-source": "^4.4.0",
"ember-template-imports": "^3.4.1",
"ember-template-lint": "^4.0.0",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0",
Expand All @@ -86,6 +87,7 @@
"prettier": "^2.8.3",
"rollup": "^2.67.0",
"rollup-plugin-copy": "^3.4.0",
"rollup-plugin-glimmer-template-tag": "^0.3.0",
"rollup-plugin-ts": "^3.2.0",
"typescript": "^4.7.4",
"webpack": "^5.75.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/ember-headless-form/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default {
addon.dependencies(),

// compile <template> tag into plain JS
glimmerTemplateTag(),
glimmerTemplateTag({ preprocessOnly: true }),

// compile TypeScript to latest JavaScript, including Babel transpilation
typescript({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{{#let
(unique-id)
(unique-id)
(fn @set @name)
(fn @triggerValidationFor @name)
(unique-id) (unique-id) (fn @set @name) (fn @triggerValidationFor @name)
as |fieldId errorId setValue triggerValidation|
}}
{{yield
Expand Down
11 changes: 8 additions & 3 deletions packages/ember-headless-form/src/components/headless-form.gts
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { assert, warn } from '@ember/debug';
import { hash } from '@ember/helper';
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore hash is missing from ember types
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import { hash, modifier } from '@ember/helper';
import { on } from '@ember/modifier';
import { action, set } from '@ember/object';

import { TrackedAsyncData } from 'ember-async-data';
import { modifier } from 'ember-modifier';
import { modifier as elementModifier } from 'ember-modifier';
import { TrackedObject } from 'tracked-built-ins';

import HeadlessFormFieldComponent from '../-private/components/field';
Expand Down Expand Up @@ -187,9 +190,11 @@ export default class HeadlessFormComponent<
DATA extends UserData,
SUBMISSION_VALUE
> extends Component<HeadlessFormComponentSignature<DATA, SUBMISSION_VALUE>> {
// we cannot use (modifier "on") directly in the template due to https://github.com/emberjs/ember.js/issues/19869
on = on;
formElement?: HTMLFormElement;

registerForm = modifier((el: HTMLFormElement, _p: []) => {
registerForm = elementModifier((el: HTMLFormElement, _p: []) => {
this.formElement = el;
}) as unknown as ModifierLike<unknown>; // @todo getting Glint errors without this. Try again with Glint 1.0 (beta)!

Expand Down
2 changes: 1 addition & 1 deletion packages/ember-headless-form/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"extends": "@tsconfig/ember/tsconfig.json",
"include": ["src/**/*", "unpublished-development-types/**/*"],
"glint": {
"environment": "ember-loose"
"environment": ["ember-loose", "ember-template-imports"]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,14 @@ declare module '@glint/environment-ember-loose/registry' {
modifier: any;
}
}

import '@ember/helper';

declare module '@ember/helper' {
import type { HelperLike, ModifierLike } from '@glint/template';

export const modifier: HelperLike<{
Args: { Positional: unknown[] };
Return: ModifierLike;
}>;
}
Loading

0 comments on commit fdaa81e

Please sign in to comment.