Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix triple-slash reference in complied output, breaking TS consumers #704

Merged
merged 6 commits into from
Oct 1, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion ember-async-data/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
7 changes: 2 additions & 5 deletions ember-async-data/src/helpers/load.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { helper } from '@ember/component/helper';
import TrackedAsyncData from '../tracked-async-data';

/**
Expand Down Expand Up @@ -69,10 +68,8 @@ export function load<T>(data: T | Promise<T>): TrackedAsyncData<T> {

// 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<T>([data]: [
T | Promise<T>
]): TrackedAsyncData<T> {
function loadHelper<T>(data: T | Promise<T>): TrackedAsyncData<T> {
return new TrackedAsyncData(data);
});
}
SergeAstapov marked this conversation as resolved.
Show resolved Hide resolved

export default loadHelper;
18 changes: 6 additions & 12 deletions ember-async-data/type-tests/load-test.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
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<
<T>(data: T | Promise<T>) => TrackedAsyncData<T>
>();

expectTypeOf(load(true)).toEqualTypeOf(new TrackedAsyncData(true));

type LoadHelper = abstract new <T>() => FunctionBasedHelperInstance<{
Args: {
Positional: [T | Promise<T>];
Named: EmptyObject;
};
Return: TrackedAsyncData<T>;
}>;
expectTypeOf<ReturnType<typeof loadHelper<number>>>().toEqualTypeOf<
TrackedAsyncData<number>
>();

expectTypeOf(loadHelper).toEqualTypeOf<LoadHelper>();
expectTypeOf<ReturnType<typeof loadHelper<string>>>().toEqualTypeOf<
TrackedAsyncData<string>
>();
NullVoxPopuli marked this conversation as resolved.
Show resolved Hide resolved
11 changes: 10 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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==
Expand Down Expand Up @@ -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"
Expand Down