From 0da40a4cfefcc79c602c044ec3a338572ae58733 Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Tue, 29 Aug 2023 13:45:51 -0400 Subject: [PATCH 1/5] Fix triple-slash reference in complied output, breaking TS consumers --- ember-async-data/src/helpers/load.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/ember-async-data/src/helpers/load.ts b/ember-async-data/src/helpers/load.ts index db85dfdf..7b890f1b 100644 --- a/ember-async-data/src/helpers/load.ts +++ b/ember-async-data/src/helpers/load.ts @@ -1,4 +1,3 @@ -import { helper } from '@ember/component/helper'; import TrackedAsyncData from '../tracked-async-data'; /** @@ -69,10 +68,8 @@ export function load(data: T | Promise): TrackedAsyncData { // TODO: in v2.0.0, switch this to simply using the function above. (It needs to // be in a breaking change because of the change in the call signature.) -const loadHelper = helper(function loadHelper([data]: [ - T | Promise -]): TrackedAsyncData { +function loadHelper(data: T | Promise): TrackedAsyncData { return new TrackedAsyncData(data); -}); +} export default loadHelper; From b592d4e62748f399f6a49ff30a376c0f1a07d13a Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Tue, 29 Aug 2023 14:08:46 -0400 Subject: [PATCH 2/5] Add function polyfill to support pre ember 4.5 --- ember-async-data/package.json | 3 ++- yarn.lock | 11 ++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ember-async-data/package.json b/ember-async-data/package.json index 3e84dc70..c728e0cf 100644 --- a/ember-async-data/package.json +++ b/ember-async-data/package.json @@ -36,7 +36,8 @@ }, "dependencies": { "@ember/test-waiters": "^3.0.0", - "@embroider/addon-shim": "^1.8.6" + "@embroider/addon-shim": "^1.8.6", + "ember-functions-as-helper-polyfill": "^2.1.2" }, "devDependencies": { "@babel/core": "^7.22.10", diff --git a/yarn.lock b/yarn.lock index 25900892..a9c8a1de 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5053,7 +5053,7 @@ ember-cli-typescript@^2.0.2: stagehand "^1.0.0" walk-sync "^1.0.0" -ember-cli-typescript@^5.1.0: +ember-cli-typescript@^5.0.0, ember-cli-typescript@^5.1.0: version "5.2.1" resolved "https://registry.yarnpkg.com/ember-cli-typescript/-/ember-cli-typescript-5.2.1.tgz#553030f1ce3e8958b8e4fc34909acd1218cb35f2" integrity sha512-qqp5TAIuPHxHiGXJKL+78Euyhy0zSKQMovPh8sJpN/ZBYx0H90pONufHR3anaMcp1snVfx4B+mb9+7ijOik8ZA== @@ -5205,6 +5205,15 @@ ember-compatibility-helpers@^1.1.2: fs-extra "^9.1.0" semver "^5.4.1" +ember-functions-as-helper-polyfill@^2.1.2: + version "2.1.2" + resolved "https://registry.yarnpkg.com/ember-functions-as-helper-polyfill/-/ember-functions-as-helper-polyfill-2.1.2.tgz#5f7a7c7f87b87d4df785c53d1ee0810693c89b6b" + integrity sha512-yvW6xykvZEIYzzwlrC/g9yu6LtLkkj5F+ho6U+BDxN1uREMgoMOZnji7sSILn5ITVpaJ055DPcO+utEFD7IZOA== + dependencies: + ember-cli-babel "^7.26.11" + ember-cli-typescript "^5.0.0" + ember-cli-version-checker "^5.1.2" + ember-load-initializers@^2.1.2: version "2.1.2" resolved "https://registry.yarnpkg.com/ember-load-initializers/-/ember-load-initializers-2.1.2.tgz#8a47a656c1f64f9b10cecdb4e22a9d52ad9c7efa" From ac05237f4835862cce47b1061a2c238d71bae97d Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Tue, 29 Aug 2023 14:13:27 -0400 Subject: [PATCH 3/5] Update type tests --- ember-async-data/type-tests/load-test.ts | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/ember-async-data/type-tests/load-test.ts b/ember-async-data/type-tests/load-test.ts index 88237f50..b4639c0b 100644 --- a/ember-async-data/type-tests/load-test.ts +++ b/ember-async-data/type-tests/load-test.ts @@ -1,10 +1,6 @@ import TrackedAsyncData from '../src/tracked-async-data'; import loadHelper, { load } from '../src/helpers/load'; import { expectTypeOf } from 'expect-type'; -import { - EmptyObject, - FunctionBasedHelperInstance, -} from '@ember/component/helper'; expectTypeOf(load).toEqualTypeOf< (data: T | Promise) => TrackedAsyncData @@ -12,12 +8,10 @@ expectTypeOf(load).toEqualTypeOf< expectTypeOf(load(true)).toEqualTypeOf(new TrackedAsyncData(true)); -type LoadHelper = abstract new () => FunctionBasedHelperInstance<{ - Args: { - Positional: [T | Promise]; - Named: EmptyObject; - }; - Return: TrackedAsyncData; -}>; +expectTypeOf>>().toEqualTypeOf< + TrackedAsyncData +>(); -expectTypeOf(loadHelper).toEqualTypeOf(); +expectTypeOf>>().toEqualTypeOf< + TrackedAsyncData +>(); From e105b0b6842cd62ce942ac104472a7c89d6e4c1f Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Tue, 29 Aug 2023 20:56:15 -0400 Subject: [PATCH 4/5] Update ember-async-data/type-tests/load-test.ts Co-authored-by: Chris Krycho --- ember-async-data/type-tests/load-test.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ember-async-data/type-tests/load-test.ts b/ember-async-data/type-tests/load-test.ts index b4639c0b..8f516787 100644 --- a/ember-async-data/type-tests/load-test.ts +++ b/ember-async-data/type-tests/load-test.ts @@ -12,6 +12,4 @@ expectTypeOf>>().toEqualTypeOf< TrackedAsyncData >(); -expectTypeOf>>().toEqualTypeOf< - TrackedAsyncData ->(); +expectTypeOf(load("hello")).returns.toEqualTypeOf>(); From 2c11570a609c5fa714df9057d94322c379c589a9 Mon Sep 17 00:00:00 2001 From: Sergey Astapov Date: Fri, 1 Sep 2023 23:28:36 -0400 Subject: [PATCH 5/5] remove ember-functions-as-helper-polyfill --- ember-async-data/package.json | 3 +-- ember-async-data/src/helpers/load.ts | 16 +--------------- ember-async-data/src/index.ts | 2 +- yarn.lock | 11 +---------- 4 files changed, 4 insertions(+), 28 deletions(-) diff --git a/ember-async-data/package.json b/ember-async-data/package.json index c728e0cf..3e84dc70 100644 --- a/ember-async-data/package.json +++ b/ember-async-data/package.json @@ -36,8 +36,7 @@ }, "dependencies": { "@ember/test-waiters": "^3.0.0", - "@embroider/addon-shim": "^1.8.6", - "ember-functions-as-helper-polyfill": "^2.1.2" + "@embroider/addon-shim": "^1.8.6" }, "devDependencies": { "@babel/core": "^7.22.10", diff --git a/ember-async-data/src/helpers/load.ts b/ember-async-data/src/helpers/load.ts index 7b890f1b..a31beb15 100644 --- a/ember-async-data/src/helpers/load.ts +++ b/ember-async-data/src/helpers/load.ts @@ -52,24 +52,10 @@ import TrackedAsyncData from '../tracked-async-data'; @param data The (async) data we want to operate on: a value or a `Promise` of a value. - @param context An optional, but highly recommended, context object to use for - managing the destruction of the resulting `TrackedAsyncData`, which can be - any object which participates in Ember's normal destruction lifecycle - (components, helpers, modifiers, etc.). If you do not supply this parameter, - and you have a test failure which causes async code to not get cleaned up - you may see all following tests fail. @returns An object containing the state(, value, and error). @note Prefer to use `TrackedAsyncData` directly! This function is provided simply for symmetry with the helper and backwards compatibility. */ -export function load(data: T | Promise): TrackedAsyncData { +export default function load(data: T | Promise): TrackedAsyncData { return new TrackedAsyncData(data); } - -// TODO: in v2.0.0, switch this to simply using the function above. (It needs to -// be in a breaking change because of the change in the call signature.) -function loadHelper(data: T | Promise): TrackedAsyncData { - return new TrackedAsyncData(data); -} - -export default loadHelper; diff --git a/ember-async-data/src/index.ts b/ember-async-data/src/index.ts index 4d16a81a..9336d3da 100644 --- a/ember-async-data/src/index.ts +++ b/ember-async-data/src/index.ts @@ -1,2 +1,2 @@ export { default as TrackedAsyncData } from './tracked-async-data'; -export { load } from './helpers/load'; +export { default as load } from './helpers/load'; diff --git a/yarn.lock b/yarn.lock index a9c8a1de..25900892 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5053,7 +5053,7 @@ ember-cli-typescript@^2.0.2: stagehand "^1.0.0" walk-sync "^1.0.0" -ember-cli-typescript@^5.0.0, ember-cli-typescript@^5.1.0: +ember-cli-typescript@^5.1.0: version "5.2.1" resolved "https://registry.yarnpkg.com/ember-cli-typescript/-/ember-cli-typescript-5.2.1.tgz#553030f1ce3e8958b8e4fc34909acd1218cb35f2" integrity sha512-qqp5TAIuPHxHiGXJKL+78Euyhy0zSKQMovPh8sJpN/ZBYx0H90pONufHR3anaMcp1snVfx4B+mb9+7ijOik8ZA== @@ -5205,15 +5205,6 @@ ember-compatibility-helpers@^1.1.2: fs-extra "^9.1.0" semver "^5.4.1" -ember-functions-as-helper-polyfill@^2.1.2: - version "2.1.2" - resolved "https://registry.yarnpkg.com/ember-functions-as-helper-polyfill/-/ember-functions-as-helper-polyfill-2.1.2.tgz#5f7a7c7f87b87d4df785c53d1ee0810693c89b6b" - integrity sha512-yvW6xykvZEIYzzwlrC/g9yu6LtLkkj5F+ho6U+BDxN1uREMgoMOZnji7sSILn5ITVpaJ055DPcO+utEFD7IZOA== - dependencies: - ember-cli-babel "^7.26.11" - ember-cli-typescript "^5.0.0" - ember-cli-version-checker "^5.1.2" - ember-load-initializers@^2.1.2: version "2.1.2" resolved "https://registry.yarnpkg.com/ember-load-initializers/-/ember-load-initializers-2.1.2.tgz#8a47a656c1f64f9b10cecdb4e22a9d52ad9c7efa"