diff --git a/packages/util/index.d.ts b/packages/util/index.d.ts index 3e64df453..0faf7116f 100644 --- a/packages/util/index.d.ts +++ b/packages/util/index.d.ts @@ -1,4 +1,17 @@ -export function ensureSafeComponent( - component: unknown, +import { ComponentLike } from '@glint/template'; +import Helper from '@ember/component/helper'; + +export function ensureSafeComponent, S>( + component: C, thingWithOwner: unknown -): unknown; +): C extends string ? ComponentLike : C; + +export class EnsureSafeComponentHelper< + C extends string | ComponentLike, + S +> extends Helper<{ + Args: { + Positional: [component: C]; + }; + Return: C extends string ? ComponentLike : C; +}> {} diff --git a/packages/util/package.json b/packages/util/package.json index 464857b2a..5165d1713 100644 --- a/packages/util/package.json +++ b/packages/util/package.json @@ -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", @@ -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", diff --git a/yarn.lock b/yarn.lock index 5fe846f57..aae0996c7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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"