Skip to content

Commit

Permalink
Merge pull request #1301 from chriskrycho/ensureSafeComponent-types
Browse files Browse the repository at this point in the history
Make `ensureSafeComponent` usable with Glint
  • Loading branch information
ef4 committed Dec 2, 2022
2 parents 3c6c7bd + bafee9c commit 3d6fb98
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
19 changes: 16 additions & 3 deletions packages/util/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
export function ensureSafeComponent(
component: unknown,
import { ComponentLike } from '@glint/template';
import Helper from '@ember/component/helper';

export function ensureSafeComponent<C extends string | ComponentLike<S>, S>(
component: C,
thingWithOwner: unknown
): unknown;
): C extends string ? ComponentLike<unknown> : C;

export class EnsureSafeComponentHelper<
C extends string | ComponentLike<S>,
S
> extends Helper<{
Args: {
Positional: [component: C];
};
Return: C extends string ? ComponentLike<unknown> : C;
}> {}
9 changes: 8 additions & 1 deletion packages/util/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,13 @@
"ember-cli-babel": "^7.26.11"
},
"peerDependencies": {
"ember-source": "*"
"ember-source": "*",
"@glint/template": "^1.0.0-beta.1"
},
"peerDependenciesMeta": {
"@glint/template": {
"optional": true
}
},
"devDependencies": {
"@babel/core": "^7.19.6",
Expand All @@ -46,6 +52,7 @@
"@embroider/webpack": "2.0.2",
"@glimmer/component": "^1.1.2",
"@glimmer/tracking": "^1.1.2",
"@glint/template": "^1.0.0-beta.1",
"@typescript-eslint/eslint-plugin": "^4.1.1",
"@typescript-eslint/parser": "^4.1.1",
"babel-eslint": "^10.1.0",
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1975,6 +1975,11 @@
dependencies:
babel-plugin-debug-macros "^0.3.4"

"@glint/template@^1.0.0-beta.1":
version "1.0.0-beta.1"
resolved "https://registry.yarnpkg.com/@glint/template/-/template-1.0.0-beta.1.tgz#2474d5cde637c8742f3da39c53ccffae03bcb997"
integrity sha512-JQboeRc9BCuYu2Avle592L+gWxKvJggwxkNKxpHlOeg9Xng5f/sMvG6yWssC8J4fURJmH5tvF7e/BgdUAMegeg==

"@handlebars/parser@^1.1.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@handlebars/parser/-/parser-1.1.0.tgz#d6dbc7574774b238114582410e8fee0dc3532bdf"
Expand Down

0 comments on commit 3d6fb98

Please sign in to comment.