Skip to content

Commit 8d3e596

Browse files
authored
Merge pull request #563 from typed-ember/always-allow-plain-functions
2 parents 54fe967 + 3908403 commit 8d3e596

File tree

8 files changed

+14
-60
lines changed

8 files changed

+14
-60
lines changed

docs/ember/installation.md

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -65,29 +65,6 @@ Because Glint uses your project-local copy of TypeScript and the packages whose
6565

6666
It's possible to use the 4.x versions of the `@types/ember*` packages even if your project is still using an Ember 3.x LTS. Just note that any deprecated APIs you're using that were removed in 4.0 won't be available in the types, and APIs added later _will_ be present in them.
6767

68-
## Functions as Helpers
69-
70-
By default, `@glint/environment-ember-loose` includes support for the [default helper manager RFC](https://github.com/emberjs/rfcs/pull/756).
71-
72-
If your project uses an older version of Ember, you can have Glint treat attempted use of functions as helpers as a type error by setting `allowPlainFunctionInvocation: false` in your environment configuration.
73-
74-
{% code title="tsconfig.json" %}
75-
76-
```javascript
77-
{
78-
"compilerOptions": { /* ... */ },
79-
"glint": {
80-
"environment": {
81-
"ember-loose": {
82-
"allowPlainFunctionInvocation": false
83-
}
84-
}
85-
}
86-
}
87-
```
88-
89-
{% endcode %}
90-
9168
## Ember CLI TypeScript
9269

9370
If you are using Glint with TypeScript and Ember, visit the [Ember CLI TypeScript documentation](https://docs.ember-cli-typescript.com/) for more information.

docs/migrating.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,14 @@ which is a meaningful advantage over templates that were ignored via `include`/`
109109
[nocheck]: ../docs/directives.md#glint-nocheck
110110
[`glint-auto-nocheck`]: https://github.com/typed-ember/glint/tree/main/packages/scripts#auto-glint-nocheck
111111

112+
### `allowPlainFunctionInvocation`
113+
114+
The `allowPlainFunctionInvocation` flag has been dropped from `@glint/environment-ember-loose`'s
115+
configuration. If you are not using Ember 4.5+ with native support for functions as helpers,
116+
consider adopting [the functions-as-helpers polyfill][functions-as-helpers].
117+
118+
[functions-as-helpers]: https://github.com/ember-polyfills/ember-functions-as-helper-polyfill
119+
112120
### Tagged Strings in `ember-template-imports`
113121

114122
Since `<template>` [has been been selected][fccts] as the path forward for template imports (a.k.a

packages/environment-ember-loose/-private/dsl/index.d.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export * from './without-function-resolution';
1+
import './integration-declarations';
22

33
import { ResolveOrReturn } from '@glint/template/-private/dsl';
44
import {
@@ -10,6 +10,9 @@ import {
1010
} from '@glint/template/-private/integration';
1111
import { Globals } from './globals';
1212

13+
export * from '@glint/template/-private/dsl';
14+
export { Globals };
15+
1316
// Items that can be directly invoked by value
1417
export declare function resolve<T extends DirectInvokable>(item: T): T[typeof InvokeDirect];
1518
// Items whose instance type can be invoked

packages/environment-ember-loose/-private/dsl/without-function-resolution.d.ts

Lines changed: 0 additions & 4 deletions
This file was deleted.

packages/environment-ember-loose/-private/environment/index.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@ export default function emberLooseEnvironment(
2020
options: Record<string, unknown>
2121
): GlintEnvironmentConfig {
2222
let typesModule = '@glint/environment-ember-loose/-private/dsl';
23-
if (options['allowPlainFunctionInvocation'] === false) {
24-
typesModule += '/without-function-resolution';
25-
}
26-
2723
let additionalSpecialForms =
2824
typeof options['additionalSpecialForms'] === 'object'
2925
? (options['additionalSpecialForms'] as GlintSpecialFormConfig)

packages/environment-ember-loose/__tests__/environment.test.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -87,22 +87,4 @@ describe('Environments: Ember Loose', () => {
8787
'/routes/hello.js',
8888
]);
8989
});
90-
91-
test('honors `allowPlainFunctionInvocation` configuration', () => {
92-
let envWithNoConfig = envDefinition({});
93-
let envWithPlainFunctions = envDefinition({ allowPlainFunctionInvocation: true });
94-
let envWithoutPlainFunctions = envDefinition({ allowPlainFunctionInvocation: false });
95-
96-
expect(envWithNoConfig.tags?.['ember-cli-htmlbars']['hbs'].typesModule).toEqual(
97-
'@glint/environment-ember-loose/-private/dsl'
98-
);
99-
100-
expect(envWithPlainFunctions.tags?.['ember-cli-htmlbars']['hbs'].typesModule).toEqual(
101-
'@glint/environment-ember-loose/-private/dsl'
102-
);
103-
104-
expect(envWithoutPlainFunctions.tags?.['ember-cli-htmlbars']['hbs'].typesModule).toEqual(
105-
'@glint/environment-ember-loose/-private/dsl/without-function-resolution'
106-
);
107-
});
10890
});

packages/environment-ember-loose/__tests__/type-tests/helper.test.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
import Helper, { helper } from '@ember/component/helper';
2-
import { resolve } from '@glint/environment-ember-loose/-private/dsl';
3-
import {
4-
NamedArgsMarker,
5-
resolve as resolveWithoutFunctionResolution,
6-
} from '@glint/environment-ember-loose/-private/dsl/without-function-resolution';
2+
import { resolve, NamedArgsMarker } from '@glint/environment-ember-loose/-private/dsl';
73
import { expectTypeOf } from 'expect-type';
84
import { HelperLike } from '@glint/template';
95
import { NamedArgs } from '@glint/template/-private/integration';
@@ -214,9 +210,6 @@ import { NamedArgs } from '@glint/template/-private/integration';
214210

215211
// Bare-function helpers
216212
{
217-
// @ts-expect-error: the env with no support for function resolution should reject this
218-
resolveWithoutFunctionResolution(() => 'hi');
219-
220213
let positionalOnlyConcrete = resolve((a: number, b: number) => a + b);
221214
expectTypeOf(positionalOnlyConcrete).toEqualTypeOf<(a: number, b: number) => number>();
222215
expectTypeOf(positionalOnlyConcrete(1, 2)).toBeNumber();

packages/environment-ember-loose/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
".": "./-private/index.js",
1111
"./registry": "./registry/index.js",
1212
"./glint-environment-definition": "./-private/environment/index.js",
13-
"./-private/dsl": "./-private/dsl/index.js",
14-
"./-private/dsl/without-function-resolution": "./-private/dsl/without-function-resolution.js"
13+
"./-private/dsl": "./-private/dsl/index.js"
1514
},
1615
"keywords": [
1716
"glint-environment"

0 commit comments

Comments
 (0)