From 49c0436ba7bee3bc1f1bc0a4ce55c9a1ba27f31c Mon Sep 17 00:00:00 2001 From: Edward Faulkner Date: Mon, 26 Aug 2024 17:48:12 -0400 Subject: [PATCH] break another cycle --- .../-internals/glimmer/lib/templates/input.ts | 2 +- .../-internals/glimmer/lib/templates/link-to.ts | 2 +- .../-internals/glimmer/lib/templates/textarea.ts | 2 +- packages/@ember/modifier/index.ts | 15 +-------------- packages/@ember/modifier/on.ts | 16 ++++++++++++++++ packages/@ember/modifier/package.json | 3 ++- 6 files changed, 22 insertions(+), 18 deletions(-) create mode 100644 packages/@ember/modifier/on.ts diff --git a/packages/@ember/-internals/glimmer/lib/templates/input.ts b/packages/@ember/-internals/glimmer/lib/templates/input.ts index 295bb8d2a69..1d15a85275c 100644 --- a/packages/@ember/-internals/glimmer/lib/templates/input.ts +++ b/packages/@ember/-internals/glimmer/lib/templates/input.ts @@ -1,5 +1,5 @@ import { precompileTemplate } from '@ember/template-compilation'; -import { on } from '@ember/modifier'; +import { on } from '@ember/modifier/on'; export default precompileTemplate( ` {} - -// SAFETY: at the time of writing, the cast here is from `{}` to `OnModifier`, -// which makes it strictly safer to use outside this module because it is not -// usable as "any non-null item", which is what `{}` means, without loss of any -// information from the type itself. -export const on = glimmerOn as OnModifier; +export { on, type OnModifier } from './on'; // NOTE: this uses assignment to *require* that the `glimmerSetModifierManager` // is legally assignable to this type, i.e. that variance is properly upheld. diff --git a/packages/@ember/modifier/on.ts b/packages/@ember/modifier/on.ts new file mode 100644 index 00000000000..a90b73eb78e --- /dev/null +++ b/packages/@ember/modifier/on.ts @@ -0,0 +1,16 @@ +import { on as glimmerOn } from '@glimmer/runtime'; + +import type { Opaque } from '@ember/-internals/utility-types'; + +// In normal TypeScript, this modifier is essentially an opaque token that just +// needs to be importable. Declaring it with a unique interface like this, +// however, gives tools like Glint (that *do* have a richer notion of what it +// is) a place to install more detailed type information. +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface OnModifier extends Opaque<'modifier:on'> {} + +// SAFETY: at the time of writing, the cast here is from `{}` to `OnModifier`, +// which makes it strictly safer to use outside this module because it is not +// usable as "any non-null item", which is what `{}` means, without loss of any +// information from the type itself. +export const on = glimmerOn as OnModifier; diff --git a/packages/@ember/modifier/package.json b/packages/@ember/modifier/package.json index 8207dcfbd39..292afe5c459 100644 --- a/packages/@ember/modifier/package.json +++ b/packages/@ember/modifier/package.json @@ -3,7 +3,8 @@ "private": true, "type": "module", "exports": { - ".": "./index.ts" + ".": "./index.ts", + "./on": "./on.ts" }, "dependencies": { "@ember/-internals": "workspace:*",