Skip to content

Commit

Permalink
break another cycle
Browse files Browse the repository at this point in the history
  • Loading branch information
ef4 committed Aug 26, 2024
1 parent 02c93d4 commit 49c0436
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 18 deletions.
2 changes: 1 addition & 1 deletion packages/@ember/-internals/glimmer/lib/templates/input.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { precompileTemplate } from '@ember/template-compilation';
import { on } from '@ember/modifier';
import { on } from '@ember/modifier/on';
export default precompileTemplate(
`<input
{{!-- for compatibility --}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { precompileTemplate } from '@ember/template-compilation';
import { on } from '@ember/modifier';
import { on } from '@ember/modifier/on';

export default precompileTemplate(
`<a
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { precompileTemplate } from '@ember/template-compilation';
import { on } from '@ember/modifier';
import { on } from '@ember/modifier/on';

export default precompileTemplate(
`<textarea
Expand Down
15 changes: 1 addition & 14 deletions packages/@ember/modifier/index.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,9 @@
import { on as glimmerOn } from '@glimmer/runtime';
import { setModifierManager as glimmerSetModifierManager } from '@glimmer/manager';

import type { Opaque } from '@ember/-internals/utility-types';
import type Owner from '@ember/owner';
import type { ModifierManager } from '@glimmer/interfaces';

// 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;
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.
Expand Down
16 changes: 16 additions & 0 deletions packages/@ember/modifier/on.ts
Original file line number Diff line number Diff line change
@@ -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;
3 changes: 2 additions & 1 deletion packages/@ember/modifier/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"private": true,
"type": "module",
"exports": {
".": "./index.ts"
".": "./index.ts",
"./on": "./on.ts"
},
"dependencies": {
"@ember/-internals": "workspace:*",
Expand Down

0 comments on commit 49c0436

Please sign in to comment.