language
stringclasses 1
value | owner
stringlengths 2
15
| repo
stringlengths 2
21
| sha
stringlengths 45
45
| message
stringlengths 7
36.3k
| path
stringlengths 1
199
| patch
stringlengths 15
102k
| is_multipart
bool 2
classes |
---|---|---|---|---|---|---|---|
Other | emberjs | ember.js | 78b3590bf074cc1f7e3cb4422aeed9b2bfe57e5d.json | Add v4.10.0-beta.5 to CHANGELOG
(cherry picked from commit b3f9de3c9b2d3ee98724bc39f672bdfee56cb62b) | CHANGELOG.md | @@ -1,8 +1,20 @@
# Ember Changelog
+## v4.10.0-beta.5 (December 28, 2022)
+
+- [#20327](https://github.com/emberjs/ember.js/pull/20327) [BUGFIX] Fix the types for the mutation-methods of `NativeArray`
+
## v4.10.0-beta.4 (December 13, 2022)
-- [#20321](https://github.com/emberjs/ember.js/pull/20321) [BUGFIX LTS] types: `ContainerDebugAdapter` extends `EmberObject`, not `Object`
+- [#20321](https://github.com/emberjs/ember.js/pull/20321) [BUGFIX] types: `ContainerDebugAdapter` extends `EmberObject`, not `Object`
+
+## v4.9.3 (December 13, 2022)
+
+- [#20321](https://github.com/emberjs/ember.js/pull/20321) [BUGFIX] ContainerDebugAdapter extends EmberObject
+
+## v4.8.4 (December 13, 2022)
+
+- [#20321](https://github.com/emberjs/ember.js/pull/20321) [BUGFIX] ContainerDebugAdapter extends EmberObject
## v4.9.2 (December 12, 2022)
@@ -30,7 +42,7 @@
## v3.28.11 (November 30, 2022)
-- [#20286](https://github.com/emberjs/ember.js/pull/20286) [BUGFIX LTS] Allow class-based helpers in strict-mode
+- [#20286](https://github.com/emberjs/ember.js/pull/20286) [BUGFIX] Allow class-based helpers in strict-mode
## v4.10.0-beta.1 (November 28, 2022)
| false |
Other | emberjs | ember.js | 5ee2c9b95a3c4b96fa66d811cb24d63fdcba4ada.json | Add 4.10.0-beta.4 to CHANGELOG
(cherry picked from commit 220650a333cb8c8aa345a061a492d66869ea950b) | CHANGELOG.md | @@ -1,5 +1,9 @@
# Ember Changelog
+## v4.10.0-beta.4 (December 13, 2022)
+
+- [#20321](https://github.com/emberjs/ember.js/pull/20321) [BUGFIX LTS] types: `ContainerDebugAdapter` extends `EmberObject`, not `Object`
+
## v4.9.2 (December 12, 2022)
- [#20296](https://github.com/emberjs/ember.js/pull/20296) Controller `queryParams` should support `readonly` arrays | false |
Other | emberjs | ember.js | 285a7195a351ecb9d90b2d573a2be5b6a77db190.json | Fix more bugs in type publishing infra
- Properly handle `import SomeItem, { anotherItem } from '.'` relative
declarations, i.e. imports from the root/`index` of a directory.
- Handle `const item: import('<some path>').Type` declarations TS emits
for cases like `export default opaquify(InternalClass)`.
One particularly degenerate case is `import()` type annotations which
TS generates as relative paths, e.g. `'../../@ember/object'`, since
we cannot yet use project references and therefore also cannot use
dependencies properly and therefore also cannot get TS to understand
that it should be writing that as an absolute specifier.
- Remove `declare enum` as with as all other `declare <item>` cases.
- Noticing that we actually *cannot* handle `declare global { ... }`
declarations, update the handful of places we do that internally.
This has an added benefit of not adding those to the actual global
type scope for the whole rest of the program! | packages/@ember/debug/lib/deprecate.ts | @@ -5,11 +5,13 @@ import { assert } from '../index';
import type { HandlerCallback } from './handlers';
import { invoke, registerHandler as genericRegisterHandler } from './handlers';
-declare global {
- const __fail__: {
- fail(): void;
- };
-}
+// This is a "global", but instead of declaring it as `declare global`, which
+// will expose it to all other modules, declare it *locally* (and don't export
+// it) so that it has the desired "private global" semantics -- however odd that
+// particular notion is.
+declare const __fail__: {
+ fail(): void;
+};
interface Available {
available: string; | true |
Other | emberjs | ember.js | 285a7195a351ecb9d90b2d573a2be5b6a77db190.json | Fix more bugs in type publishing infra
- Properly handle `import SomeItem, { anotherItem } from '.'` relative
declarations, i.e. imports from the root/`index` of a directory.
- Handle `const item: import('<some path>').Type` declarations TS emits
for cases like `export default opaquify(InternalClass)`.
One particularly degenerate case is `import()` type annotations which
TS generates as relative paths, e.g. `'../../@ember/object'`, since
we cannot yet use project references and therefore also cannot use
dependencies properly and therefore also cannot get TS to understand
that it should be writing that as an absolute specifier.
- Remove `declare enum` as with as all other `declare <item>` cases.
- Noticing that we actually *cannot* handle `declare global { ... }`
declarations, update the handful of places we do that internally.
This has an added benefit of not adding those to the actual global
type scope for the whole rest of the program! | packages/internal-test-helpers/lib/ember-dev/assertion.ts | @@ -5,12 +5,11 @@ import { callWithStub, checkTest } from './utils';
type ExpectAssertionFunc = (func: () => void, expectedMessage: Message) => void;
type IgnoreAssertionFunc = (func: () => void) => void;
-declare global {
- interface Window {
+type ExtendedWindow = Window &
+ typeof globalThis & {
expectAssertion: ExpectAssertionFunc | null;
ignoreAssertion: IgnoreAssertionFunc | null;
- }
-}
+ };
const BREAK = {};
@@ -68,17 +67,19 @@ export function setupAssertionHelpers(hooks: NestedHooks, env: DebugEnv): void {
callWithStub(env, 'assert', func);
};
- window.expectAssertion = expectAssertion;
- window.ignoreAssertion = ignoreAssertion;
+ let w = window as ExtendedWindow;
+ w.expectAssertion = expectAssertion;
+ w.ignoreAssertion = ignoreAssertion;
});
hooks.afterEach(function () {
// Edge will occasionally not run finally blocks, so we have to be extra
// sure we restore the original assert function
env.setDebugFunction('assert', originalAssertFunc);
- window.expectAssertion = null;
- window.ignoreAssertion = null;
+ let w = window as ExtendedWindow;
+ w.expectAssertion = null;
+ w.ignoreAssertion = null;
});
}
| true |
Other | emberjs | ember.js | 285a7195a351ecb9d90b2d573a2be5b6a77db190.json | Fix more bugs in type publishing infra
- Properly handle `import SomeItem, { anotherItem } from '.'` relative
declarations, i.e. imports from the root/`index` of a directory.
- Handle `const item: import('<some path>').Type` declarations TS emits
for cases like `export default opaquify(InternalClass)`.
One particularly degenerate case is `import()` type annotations which
TS generates as relative paths, e.g. `'../../@ember/object'`, since
we cannot yet use project references and therefore also cannot use
dependencies properly and therefore also cannot get TS to understand
that it should be writing that as an absolute specifier.
- Remove `declare enum` as with as all other `declare <item>` cases.
- Noticing that we actually *cannot* handle `declare global { ... }`
declarations, update the handful of places we do that internally.
This has an added benefit of not adding those to the actual global
type scope for the whole rest of the program! | packages/internal-test-helpers/lib/ember-dev/deprecation.ts | @@ -2,15 +2,15 @@ import { assert } from '@ember/debug';
import DebugAssert from './debug';
import type { DebugEnv, Message } from './utils';
import { callWithStub } from './utils';
-declare global {
- interface Window {
+
+type ExtendedWindow = Window &
+ typeof globalThis & {
expectNoDeprecation: DeprecationAssert['expectNoDeprecation'] | undefined;
expectNoDeprecationAsync: DeprecationAssert['expectNoDeprecationAsync'] | undefined;
expectDeprecation: DeprecationAssert['expectDeprecation'] | undefined;
expectDeprecationAsync: DeprecationAssert['expectDeprecationAsync'] | undefined;
ignoreDeprecation: DeprecationAssert['ignoreDeprecation'] | undefined;
- }
-}
+ };
export function setupDeprecationHelpers(hooks: NestedHooks, env: DebugEnv): void {
let assertion = new DeprecationAssert(env);
@@ -62,22 +62,24 @@ class DeprecationAssert extends DebugAssert {
}
inject(): void {
- window.expectNoDeprecation = expectNoDeprecation = this.expectNoDeprecation.bind(this);
- window.expectNoDeprecationAsync = expectNoDeprecationAsync =
+ let w = window as ExtendedWindow;
+ w.expectNoDeprecation = expectNoDeprecation = this.expectNoDeprecation.bind(this);
+ w.expectNoDeprecationAsync = expectNoDeprecationAsync =
this.expectNoDeprecationAsync.bind(this);
- window.expectDeprecation = expectDeprecation = this.expectDeprecation.bind(this);
- window.expectDeprecationAsync = expectDeprecationAsync = this.expectDeprecationAsync.bind(this);
- window.ignoreDeprecation = ignoreDeprecation = this.ignoreDeprecation.bind(this);
+ w.expectDeprecation = expectDeprecation = this.expectDeprecation.bind(this);
+ w.expectDeprecationAsync = expectDeprecationAsync = this.expectDeprecationAsync.bind(this);
+ w.ignoreDeprecation = ignoreDeprecation = this.ignoreDeprecation.bind(this);
super.inject();
}
restore(): void {
super.restore();
- window.expectNoDeprecation = undefined;
- window.expectNoDeprecationAsync = undefined;
- window.expectDeprecation = undefined;
- window.expectDeprecationAsync = undefined;
- window.ignoreDeprecation = undefined;
+ let w = window as ExtendedWindow;
+ w.expectNoDeprecation = undefined;
+ w.expectNoDeprecationAsync = undefined;
+ w.expectDeprecation = undefined;
+ w.expectDeprecationAsync = undefined;
+ w.ignoreDeprecation = undefined;
}
// Expects no deprecation to happen within a function, or if no function is | true |
Other | emberjs | ember.js | 285a7195a351ecb9d90b2d573a2be5b6a77db190.json | Fix more bugs in type publishing infra
- Properly handle `import SomeItem, { anotherItem } from '.'` relative
declarations, i.e. imports from the root/`index` of a directory.
- Handle `const item: import('<some path>').Type` declarations TS emits
for cases like `export default opaquify(InternalClass)`.
One particularly degenerate case is `import()` type annotations which
TS generates as relative paths, e.g. `'../../@ember/object'`, since
we cannot yet use project references and therefore also cannot use
dependencies properly and therefore also cannot get TS to understand
that it should be writing that as an absolute specifier.
- Remove `declare enum` as with as all other `declare <item>` cases.
- Noticing that we actually *cannot* handle `declare global { ... }`
declarations, update the handful of places we do that internally.
This has an added benefit of not adding those to the actual global
type scope for the whole rest of the program! | packages/internal-test-helpers/lib/ember-dev/warning.ts | @@ -9,13 +9,12 @@ type ExpectWarningFunc = (
) => void;
type IgnoreWarningFunc = (func: () => void) => void;
-declare global {
- interface Window {
+type ExtendedWindow = Window &
+ typeof globalThis & {
expectNoWarning: ExpectNoWarningFunc | null;
expectWarning: ExpectWarningFunc | null;
ignoreWarning: IgnoreWarningFunc | null;
- }
-}
+ };
export function setupWarningHelpers(hooks: NestedHooks, env: DebugEnv) {
let assertion = new WarningAssert(env);
@@ -95,16 +94,19 @@ class WarningAssert extends DebugAssert {
callWithStub(this.env, 'warn', func);
};
- window.expectNoWarning = expectNoWarning;
- window.expectWarning = expectWarning;
- window.ignoreWarning = ignoreWarning;
+ let w = window as ExtendedWindow;
+
+ w.expectNoWarning = expectNoWarning;
+ w.expectWarning = expectWarning;
+ w.ignoreWarning = ignoreWarning;
}
restore() {
super.restore();
- window.expectWarning = null;
- window.expectNoWarning = null;
- window.ignoreWarning = null;
+ let w = window as ExtendedWindow;
+ w.expectWarning = null;
+ w.expectNoWarning = null;
+ w.ignoreWarning = null;
}
}
| true |
Other | emberjs | ember.js | 285a7195a351ecb9d90b2d573a2be5b6a77db190.json | Fix more bugs in type publishing infra
- Properly handle `import SomeItem, { anotherItem } from '.'` relative
declarations, i.e. imports from the root/`index` of a directory.
- Handle `const item: import('<some path>').Type` declarations TS emits
for cases like `export default opaquify(InternalClass)`.
One particularly degenerate case is `import()` type annotations which
TS generates as relative paths, e.g. `'../../@ember/object'`, since
we cannot yet use project references and therefore also cannot use
dependencies properly and therefore also cannot get TS to understand
that it should be writing that as an absolute specifier.
- Remove `declare enum` as with as all other `declare <item>` cases.
- Noticing that we actually *cannot* handle `declare global { ... }`
declarations, update the handful of places we do that internally.
This has an added benefit of not adding those to the actual global
type scope for the whole rest of the program! | types/publish.mjs | @@ -40,6 +40,7 @@ import {
isStringLiteral,
isVariableDeclaration,
isTSDeclareFunction,
+ isTSEnumDeclaration,
} from '@babel/types';
import { builders as b, visit } from 'ast-types';
import { parse, print } from 'recast';
@@ -548,6 +549,14 @@ export function rewriteModule(code, moduleName) {
this.traverse(path);
},
+ // Remove `declare` from `declare enum` in the top-level module.
+ visitTSEnumDeclaration(path) {
+ if (isTSEnumDeclaration(path.node) && !hasParentModuleDeclarationBlock(path)) {
+ path.node.declare = false;
+ }
+ this.traverse(path);
+ },
+
// For any relative imports like `import { something } from './somewhere';`,
// rewrite as `import { something } from '@ember/some-package/somewhere';`
// since relative imports are not allowed in `declare module { }` blocks.
@@ -561,14 +570,20 @@ export function rewriteModule(code, moduleName) {
// Do the same for `export ... from './relative-path'`.
visitExportNamedDeclaration(path) {
- let source = path.node.source;
- if (isStringLiteral(source)) {
- if (source.value.startsWith('./') || source.value.startsWith('../')) {
- source.value = normalizeSpecifier(moduleName, source.value);
- }
+ let specifier = path.node.source;
+ if (isStringLiteral(specifier)) {
+ specifier.value = normalizeSpecifier(moduleName, specifier.value);
}
this.traverse(path);
},
+
+ // We need to rewrite annotations like `export const: import('./foo').foo`
+ // to use relative paths, as well.
+ visitTSImportType(path) {
+ let specifier = path.node.argument.value;
+ path.node.argument.value = normalizeSpecifier(moduleName, specifier);
+ this.traverse(path);
+ },
});
let newAST = b.file(
@@ -604,16 +619,32 @@ function hasParentModuleDeclarationBlock(path) {
const TERMINAL_MODULE_RE = /\/[\w-_]+\.d\.ts$/;
const NEIGHBOR_PATH_RE = /^(\.)\//;
+const SHOULD_BE_ABSOLUTE = /(\.\.\/)+(@.*)/;
/**
- Given a relative path, `./` or `(../)+`, rewrite it as an absolute path.
+ Given a relative path, `'.'`, `./`, or `(../)+`, rewrite it as an absolute path.
@param {string} moduleName The name of the host module we are declaring.
@param {string} specifier The name of the module it is importing.
@return {string}
*/
function normalizeSpecifier(moduleName, specifier) {
- if (specifier.startsWith('./')) {
+ // One particularly degenerate case is `import()` type annotations which TS
+ // generates as relative paths, e.g. `'../../@ember/object'`, since we cannot
+ // yet use project references and therefore also cannot use dependencies
+ // properly and therefore also cannot get TS to understand that it should be
+ // writing that as an absolute specifier.
+ let nonsensicalRelativePath = specifier.match(SHOULD_BE_ABSOLUTE);
+ // First match is the whole string, second match is the (last) leading `../`,
+ // third match is the package we care about.
+ if (nonsensicalRelativePath && nonsensicalRelativePath[2]) {
+ return nonsensicalRelativePath[2];
+ }
+
+ // The other cases are more normal: we replace
+ if (specifier === '.') {
+ return moduleName.replace(TERMINAL_MODULE_RE, '');
+ } else if (specifier.startsWith('./')) {
let parentModuleName = moduleName.replace(TERMINAL_MODULE_RE, '');
let sansLeadingDot = specifier.replace(NEIGHBOR_PATH_RE, '');
let newImportName = `${parentModuleName}/${sansLeadingDot}`; | true |
Other | emberjs | ember.js | eeaca69dcacc7ade0e1fe40d216a2f86d35ff8bb.json | Add v4.9.2 to CHANGELOG
(cherry picked from commit 6cd5147c96f926129777a6c1c876d629e2da0d00) | CHANGELOG.md | @@ -1,5 +1,10 @@
# Ember Changelog
+## v4.9.2 (December 12, 2022)
+
+- [#20296](https://github.com/emberjs/ember.js/pull/20296) Controller `queryParams` should support `readonly` arrays
+- [#20318](https://github.com/emberjs/ember.js/pull/20318) Backport `Resolver` to preview types
+
## v4.10.0-beta.3 (December 12, 2022)
- [#20296](https://github.com/emberjs/ember.js/pull/20296) Controller `queryParams` should support `readonly` arrays | false |
Other | emberjs | ember.js | 6635c775c945597993b6c8a118caffec72201ac4.json | Add v4.10.0-beta.3 to CHANGELOG
(cherry picked from commit d2cd073751e829404b0d63969a27c871399605fc) | CHANGELOG.md | @@ -1,5 +1,10 @@
# Ember Changelog
+## v4.10.0-beta.3 (December 12, 2022)
+
+- [#20296](https://github.com/emberjs/ember.js/pull/20296) Controller `queryParams` should support `readonly` arrays
+- [#20319](https://github.com/emberjs/ember.js/pull/20319) Types: resolve services with `Owner.lookup`
+
## v4.8.3 (December 12, 2022)
- [#20296](https://github.com/emberjs/ember.js/pull/20296) Controller `queryParams` should support `readonly` arrays | false |
Other | emberjs | ember.js | 1748d37781b40ee562f35e9b6a059810f9b759bc.json | Add v4.8.3 to CHANGELOG
(cherry picked from commit d817c0084e26ef8a6d7b5f9188fd93596b032617) | CHANGELOG.md | @@ -1,5 +1,10 @@
# Ember Changelog
+## v4.8.3 (December 12, 2022)
+
+- [#20296](https://github.com/emberjs/ember.js/pull/20296) Controller `queryParams` should support `readonly` arrays
+- [#20318](https://github.com/emberjs/ember.js/pull/20318) Backport `Resolver` to preview types
+
## v4.9.1 (November 30, 2022)
- [#20284](https://github.com/emberjs/ember.js/pull/20284) [BUGFIX] remove incorrect types for deprecation functions | false |
Other | emberjs | ember.js | 50705087e9def750879b05187ac992bf3eb5d235.json | Types: resolve services with `Owner.lookup`
Integrate the service registry into the `DIRegistry` introduced as part
of rationalizing the `Owner` types in PR #20271 (94276b5). This allows
`Owner.lookup('service:foo')` to resolve a `FooService` if one is set
up in the `@ember/service` module's `Registry` interface. The preview
types already used this mechanic (as of 5658b13), so this just means
that when we ship the stable (i.e. built from source) version of
`@ember/service`, it will *continue* working.
Meta: Shipping this implementation for the lookup was blocked on being
able to publish type modules with `declare module`, which was
implemented in PR #20316 (9adcd15). We will likely need to rework other
parts of the type hierarchy to support publishing from source. | packages/@ember/service/index.ts | @@ -93,3 +93,16 @@ export function service(
export default class Service extends FrameworkObject {
static isServiceFactory = true;
}
+
+/**
+ A type registry for Ember `Service`s. Meant to be declaration-merged so string
+ lookups resolve to the correct type.
+ */
+// eslint-disable-next-line @typescript-eslint/no-empty-interface
+export interface Registry extends Record<string, Service> {}
+
+declare module '@ember/owner' {
+ export interface DIRegistry {
+ service: Registry;
+ }
+} | false |
Other | emberjs | ember.js | aa030fc94f54eb6e035da7103a881a7a66047a84.json | Fix typo in doc comment in types/publish.mjs | types/publish.mjs | @@ -500,7 +500,7 @@ function processModule(moduleName) {
statement.
- Remove all `declare` modifiers from items in the module itself.
- Update all `import` specifiers to be absolute in terms of the package
- name (which means )
+ name, which means handling both `./` and `../` correctly.
- Preserve existing `declare module` statements, so that anything using e.g.
declaration merging continues to work correctly.
| false |
Other | emberjs | ember.js | d324fc9be0823613795f81bb703190204ef3fda2.json | Fix Prettier 2.8 issues | tests/node/app-boot-test.js | @@ -26,9 +26,12 @@ QUnit.module('App Boot', function (hooks) {
hasExistence: true,
});
- this.template('components/foo-bar', '\
+ this.template(
+ 'components/foo-bar',
+ '\
<p>The files are *inside* the computer?!</p>\
- ');
+ '
+ );
return this.renderToHTML('/').then(function (html) {
assert.htmlMatches( | false |
Other | emberjs | ember.js | 5a299d471512804d3f14c36fbc8b54894f1d274f.json | Use `Engine` API in `verifyRegistration`
This is a dumb set of tests, which are verifying internal mechanics of
*how* we make this work, rather than verify *that* it works for each of
these issues. However, for the moment the key is to unblock decoupling
work, so I'm creating [a separate issue][1] to make sure we cover this
in other ways and then delete the tests which cause this coupling.
[1]: https://github.com/emberjs/ember.js/issues/20315 | packages/internal-test-helpers/lib/registry-check.ts | @@ -1,5 +1,6 @@
-import type { FullName, default as Owner } from '@ember/-internals/owner';
+import type { FullName } from '@ember/-internals/owner';
+import type Engine from '@ember/engine';
-export function verifyRegistration(assert: QUnit['assert'], owner: Owner, fullName: FullName) {
- assert.ok(owner.factoryFor(fullName), `has registration: ${fullName}`);
+export function verifyRegistration(assert: QUnit['assert'], owner: Engine, fullName: FullName) {
+ assert.ok(owner.resolveRegistration(fullName), `has registration: ${fullName}`);
} | false |
Other | emberjs | ember.js | 8a30266b02bf66a5635fc5ea97a7d2589f07c486.json | Remove runtime dependence on `InternalOwner`
As a follow-on to #20310, this removes all remaining direct uses of the
`InternalOwner` type; the only place we use it now is in the defintion
of `EngineInstance`. This frees us to start chipping away further at
this type: we can deprecate *nearly all of it*, and we know that our
internal code does not depend on any of it except where it explicitly
uses `EngineInstance`.
Part of #20303. | packages/@ember/routing/router.ts | @@ -6,7 +6,7 @@ import type {
} from '@ember/-internals/glimmer';
import { computed, get, set } from '@ember/object';
import type { default as Owner, FactoryManager } from '@ember/owner';
-import { getOwner, type InternalOwner } from '@ember/-internals/owner';
+import { getOwner } from '@ember/owner';
import { BucketCache, DSL, RouterState } from '@ember/routing/-internals';
import type { DSLCallback, EngineRouteInfo } from '@ember/routing/-internals';
import {
@@ -1717,27 +1717,21 @@ function findRouteStateName(route: Route, state: string) {
return routeHasBeenDefined(owner, router, stateName, stateNameFull) ? stateNameFull : '';
}
-// TODO: rewrite `InternalOwner` to `Owner` by switching to `factoryFor`.
/**
Determines whether or not a route has been defined by checking that the route
is in the Router's map and the owner has a registration for that route.
@private
- @param {InternalOwner} owner
+ @param {Owner} owner
@param {Router} router
@param {String} localName
@param {String} fullName
@return {Boolean}
*/
-function routeHasBeenDefined(
- owner: InternalOwner,
- router: any,
- localName: string,
- fullName: string
-) {
+function routeHasBeenDefined(owner: Owner, router: any, localName: string, fullName: string) {
let routerHasRoute = router.hasRoute(fullName);
let ownerHasRoute =
- owner.hasRegistration(`template:${localName}`) || owner.hasRegistration(`route:${localName}`);
+ owner.factoryFor(`template:${localName}`) || owner.factoryFor(`route:${localName}`);
return routerHasRoute && ownerHasRoute;
}
| true |
Other | emberjs | ember.js | 8a30266b02bf66a5635fc5ea97a7d2589f07c486.json | Remove runtime dependence on `InternalOwner`
As a follow-on to #20310, this removes all remaining direct uses of the
`InternalOwner` type; the only place we use it now is in the defintion
of `EngineInstance`. This frees us to start chipping away further at
this type: we can deprecate *nearly all of it*, and we know that our
internal code does not depend on any of it except where it explicitly
uses `EngineInstance`.
Part of #20303. | packages/internal-test-helpers/lib/registry-check.ts | @@ -1,9 +1,5 @@
-import type { FullName, InternalOwner } from '@ember/-internals/owner';
+import type { FullName, default as Owner } from '@ember/-internals/owner';
-export function verifyRegistration(
- assert: QUnit['assert'],
- owner: InternalOwner,
- fullName: FullName
-) {
- assert.ok(owner.resolveRegistration(fullName), `has registration: ${fullName}`);
+export function verifyRegistration(assert: QUnit['assert'], owner: Owner, fullName: FullName) {
+ assert.ok(owner.factoryFor(fullName), `has registration: ${fullName}`);
} | true |
Other | emberjs | ember.js | 8c008fdb98f9c89b4d34d756c6dbefe0e7987101.json | Fix debug imports | packages/@ember/-internals/glimmer/lib/environment.ts | @@ -5,7 +5,7 @@ import { getDebugName } from '@ember/-internals/utils';
import { constructStyleDeprecationMessage } from '@ember/-internals/views';
import { EMBER_DEFAULT_HELPER_MANAGER } from '@ember/canary-features';
import { assert, deprecate, warn } from '@ember/debug';
-import type { DeprecationOptions } from '@ember/debug/lib/deprecate';
+import type { DeprecationOptions } from '@ember/debug';
import { schedule, _backburner } from '@ember/runloop';
import { DEBUG } from '@glimmer/env';
import setGlobalContext from '@glimmer/global-context'; | true |
Other | emberjs | ember.js | 8c008fdb98f9c89b4d34d756c6dbefe0e7987101.json | Fix debug imports | packages/@ember/-internals/metal/lib/deprecate_property.ts | @@ -3,7 +3,7 @@
*/
import { deprecate } from '@ember/debug';
-import type { DeprecationOptions } from '@ember/debug/lib/deprecate';
+import type { DeprecationOptions } from '@ember/debug';
import { get } from './property_get';
import { set } from './property_set';
| true |
Other | emberjs | ember.js | e5a35b653655026489491530c38ebe6d19a5a3b3.json | Remove test polyfills | .github/dependabot.yml | @@ -13,10 +13,6 @@ updates:
- dependency-name: ember-cli
versions:
- 3.25.0
- - dependency-name: core-js
- versions:
- - 3.8.1
- - 3.8.3
- dependency-name: broccoli-rollup
versions:
- 4.1.1 | true |
Other | emberjs | ember.js | e5a35b653655026489491530c38ebe6d19a5a3b3.json | Remove test polyfills | bin/build-for-publishing.js | @@ -1,5 +1,5 @@
'use strict';
-/* eslint-env node, es6 */
+/* eslint-env node */
const fs = require('fs');
const path = require('path'); | true |
Other | emberjs | ember.js | e5a35b653655026489491530c38ebe6d19a5a3b3.json | Remove test polyfills | broccoli/test-polyfills.js | @@ -1,27 +0,0 @@
-const Rollup = require('broccoli-rollup');
-const writeFile = require('broccoli-file-creator');
-const resolve = require('rollup-plugin-node-resolve');
-const commonjs = require('rollup-plugin-commonjs');
-
-module.exports = function polyfills() {
- let polyfillEntry = writeFile(
- 'polyfill-entry.js',
- `
- require('core-js/modules/es6.promise');
- require('core-js/modules/es6.symbol');
- require('regenerator-runtime/runtime');
- `
- );
-
- return new Rollup(polyfillEntry, {
- rollup: {
- input: 'polyfill-entry.js',
- output: {
- file: 'polyfill.js',
- name: 'polyfill',
- format: 'iife',
- },
- plugins: [resolve(), commonjs()],
- },
- });
-}; | true |
Other | emberjs | ember.js | e5a35b653655026489491530c38ebe6d19a5a3b3.json | Remove test polyfills | ember-cli-build.js | @@ -5,7 +5,6 @@ const Funnel = require('broccoli-funnel');
const babelHelpers = require('./broccoli/babel-helpers');
const concatBundle = require('./lib/concat-bundle');
const testIndexHTML = require('./broccoli/test-index-html');
-const testPolyfills = require('./broccoli/test-polyfills');
const rollupPackage = require('./broccoli/rollup-package');
const minify = require('./broccoli/minify');
const debugTree = require('broccoli-debug').buildDebugCallback('ember-source:ember-cli-build');
@@ -250,7 +249,7 @@ function templateCompilerBundle(emberPackages, transpileTree) {
}
function testHarness() {
- return new MergeTrees([emptyTestem(), testPolyfills(), testIndexHTML(), loader(), qunit()]);
+ return new MergeTrees([emptyTestem(), testIndexHTML(), loader(), qunit()]);
}
function emptyTestem() { | true |
Other | emberjs | ember.js | e5a35b653655026489491530c38ebe6d19a5a3b3.json | Remove test polyfills | package.json | @@ -118,7 +118,6 @@
"broccoli-typescript-compiler": "^8.0.0",
"broccoli-uglify-sourcemap": "^4.0.0",
"common-tags": "^1.8.2",
- "core-js": "^3.26.0",
"dag-map": "^2.0.2",
"ember-cli": "^4.8.0",
"ember-cli-blueprint-test-helpers": "^0.19.2", | true |
Other | emberjs | ember.js | e5a35b653655026489491530c38ebe6d19a5a3b3.json | Remove test polyfills | smoke-tests/ember-test-app/package.json | @@ -42,7 +42,6 @@
"ember-export-application-global": "^2.0.1",
"ember-fetch": "^8.1.1",
"ember-load-initializers": "^2.1.2",
- "ember-maybe-import-regenerator": "^0.1.6",
"ember-page-title": "^6.2.2",
"ember-qunit": "^5.1.4",
"ember-resolver": "^8.0.2", | true |
Other | emberjs | ember.js | e5a35b653655026489491530c38ebe6d19a5a3b3.json | Remove test polyfills | tests/index.html | @@ -9,7 +9,6 @@
display: none;
}
</style>
- <script src="./polyfill.js"></script>
<script src="./loader.js"></script>
<script src="./qunit/qunit.js"></script>
<script src="/testem.js"></script> | true |
Other | emberjs | ember.js | e5a35b653655026489491530c38ebe6d19a5a3b3.json | Remove test polyfills | yarn.lock | @@ -3872,11 +3872,6 @@ core-js@^2.4.0, core-js@^2.6.5:
resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.6.5.tgz#44bc8d249e7fb2ff5d00e0341a7ffb94fbf67895"
integrity sha512-klh/kDpwX8hryYL14M9w/xei6vrv6sE8gTHDG7/T/+SEovB/G4ejwcfE/CBzO6Edsu+OETZMZ3wcX/EjUkrl5A==
-core-js@^3.26.0:
- version "3.26.0"
- resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.26.0.tgz#a516db0ed0811be10eac5d94f3b8463d03faccfe"
- integrity sha512-+DkDrhoR4Y0PxDz6rurahuB+I45OsEUv8E1maPTB6OuHRohMMcznBq9TMpdpDMm/hUPob/mJJS3PqgbHpMTQgw==
-
core-object@^3.1.5:
version "3.1.5"
resolved "https://registry.yarnpkg.com/core-object/-/core-object-3.1.5.tgz#fa627b87502adc98045e44678e9a8ec3b9c0d2a9" | true |
Other | emberjs | ember.js | 7073f8ca47ad7690a835d4ca3602c46726601a54.json | Remove unnecessary step from CI | .github/workflows/ci.yml | @@ -43,8 +43,6 @@ jobs:
cache: yarn
- name: install dependencies
run: yarn install --frozen-lockfile --non-interactive
- - name: build stable type definitions
- run: yarn build:types
- name: Check published types
run: yarn type-check:types
| false |
Other | emberjs | ember.js | c6edaa3982510527b6f435641b3c9ef8d50ece1a.json | Build types when checking | package.json | @@ -51,7 +51,7 @@
"test:node": "qunit tests/node/**/*-test.js",
"test:browserstack": "node bin/run-browserstack-tests.js",
"type-check:internals": "tsc --noEmit",
- "type-check:types": "tsc --noEmit --project type-tests",
+ "type-check:types": "yarn build:types && tsc --noEmit --project type-tests",
"type-check": "npm-run-all type-check:*"
},
"dependencies": { | false |
Other | emberjs | ember.js | c5d614ad7c1a7b62b797d55b8e5ea2d089dae9e7.json | Add missing date to 4.10.0-beta.2 in CHANGELOG | CHANGELOG.md | @@ -4,7 +4,7 @@
- [#20284](https://github.com/emberjs/ember.js/pull/20284) [BUGFIX] remove incorrect types for deprecation functions
-## v4.10.0-beta.2
+## v4.10.0-beta.2 (November 30, 2022)
- [#20283](https://github.com/emberjs/ember.js/pull/20283) [BUGFIX] revert TS `compilerOptions.target` to ES2017
- [#20284](https://github.com/emberjs/ember.js/pull/20284) [BUGFIX] remove incorrect types for deprecation functions | false |
Other | emberjs | ember.js | 8dd9622e7f70c4e70096987389908f44661edba5.json | Add v4.9.1 to CHANGELOG
(cherry picked from commit cf8671d626e177ae70fabd594ff51895405443db) | CHANGELOG.md | @@ -1,5 +1,9 @@
# Ember Changelog
+## v4.9.1 (November 30, 2022)
+
+- [#20284](https://github.com/emberjs/ember.js/pull/20284) [BUGFIX] remove incorrect types for deprecation functions
+
## v4.10.0-beta.2
- [#20283](https://github.com/emberjs/ember.js/pull/20283) [BUGFIX] revert TS `compilerOptions.target` to ES2017 | false |
Other | emberjs | ember.js | 9747f080fea1e4c2c0cc02d73453dbf85f1c3948.json | Add v4.10.0-beta.2 to CHANGELOG
(cherry picked from commit 326b6b83f66e743bea6298a2a1334f3432d30888) | CHANGELOG.md | @@ -1,5 +1,10 @@
# Ember Changelog
+## v4.10.0-beta.2
+
+- [#20283](https://github.com/emberjs/ember.js/pull/20283) [BUGFIX] revert TS `compilerOptions.target` to ES2017
+- [#20284](https://github.com/emberjs/ember.js/pull/20284) [BUGFIX] remove incorrect types for deprecation functions
+
## v3.28.11 (November 30, 2022)
- [#20286](https://github.com/emberjs/ember.js/pull/20286) [BUGFIX LTS] Allow class-based helpers in strict-mode | false |
Other | emberjs | ember.js | 38363419e2e673afa1ebec3e541fb9d8f399239f.json | Add v3.28.11 to CHANGELOG
(cherry picked from commit fd694aab7fb87bf281b5b601a80fdd69ae4de9a7) | CHANGELOG.md | @@ -1,5 +1,9 @@
# Ember Changelog
+## v3.28.11 (November 30, 2022)
+
+- [#20286](https://github.com/emberjs/ember.js/pull/20286) [BUGFIX LTS] Allow class-based helpers in strict-mode
+
### v4.10.0-beta.1 (November 28, 2022)
- [#20253](https://github.com/emberjs/ember.js/pull/20253) [FEATURE] Add the `Resolver` type to preview types | false |
Other | emberjs | ember.js | ed4a6e97d853df921c01f96d6b5a2e57641f7e02.json | Move type tests for deprecated `(get|set)Owner`
These really belong in the `@ember/application` re-export, not in the
tests for `@ember/owner` itself, which should have no knowledge of the
existence of `@ember/application` (but vice versa is fine). | type-tests/preview/@ember/application-test/index.ts | @@ -4,6 +4,10 @@ import Owner from '@ember/owner';
import ApplicationInstance from '@ember/application/instance';
import Service from '@ember/service';
import { expectTypeOf } from 'expect-type';
+import { getOwner as getOwnerProper, setOwner as setOwnerProper } from '@ember/owner';
+
+expectTypeOf(getOwner).toEqualTypeOf(getOwnerProper);
+expectTypeOf(setOwner).toEqualTypeOf(setOwnerProper);
expectTypeOf(getOwner({})).toEqualTypeOf<Owner | undefined>();
| true |
Other | emberjs | ember.js | ed4a6e97d853df921c01f96d6b5a2e57641f7e02.json | Move type tests for deprecated `(get|set)Owner`
These really belong in the `@ember/application` re-export, not in the
tests for `@ember/owner` itself, which should have no knowledge of the
existence of `@ember/application` (but vice versa is fine). | type-tests/preview/@ember/owner-tests.ts | @@ -10,13 +10,6 @@ import Owner, {
} from '@ember/owner';
import Component from '@glimmer/component';
import { expectTypeOf } from 'expect-type';
-import {
- getOwner as getOwnerApplication,
- setOwner as setOwnerApplication,
-} from '@ember/application';
-
-expectTypeOf(getOwnerApplication).toEqualTypeOf(getOwner);
-expectTypeOf(setOwnerApplication).toEqualTypeOf(setOwner);
// Just a class we can construct in the Factory and FactoryManager tests
declare class ConstructThis { | true |
Other | emberjs | ember.js | ed4a6e97d853df921c01f96d6b5a2e57641f7e02.json | Move type tests for deprecated `(get|set)Owner`
These really belong in the `@ember/application` re-export, not in the
tests for `@ember/owner` itself, which should have no knowledge of the
existence of `@ember/application` (but vice versa is fine). | type-tests/stable/@ember/owner-tests.ts | @@ -10,13 +10,6 @@ import Owner, {
} from '@ember/owner';
import Component from '@glimmer/component';
import { expectTypeOf } from 'expect-type';
-import {
- getOwner as getOwnerApplication,
- setOwner as setOwnerApplication,
-} from '@ember/application';
-
-expectTypeOf(getOwnerApplication).toEqualTypeOf(getOwner);
-expectTypeOf(setOwnerApplication).toEqualTypeOf(setOwner);
// Just a class we can construct in the Factory and FactoryManager tests
declare class ConstructThis { | true |
Other | emberjs | ember.js | 3ca98347b0a6e6ff154144106c4b47f232ec2366.json | Introduce stable types for `@ember/owner`
- Remove `@ember/-internals/owner` and `@ember/owner` from the list of
excluded preview types in the types publishing script, so they now
get emitted correctly into `types/stable`.
- Remove `@ember/owner` from the preview types and put it in the stable
types instead, so users don't get conflicting type dependencies.
- Internally in `@ember/owner`, use absolute package paths, not
relative. For referencing other (even internal) packages, it's
important that we *not* use relative paths, so that (a) the published
types work when wrapped in `declare module` statements but also (b)
we have clearer boundaries for them, which will unlock further
improvements to this infrastructure in the future. | packages/@ember/owner/index.ts | @@ -33,7 +33,7 @@
// We need to provide a narrower public interface to `getOwner` so that we only
// expose the `Owner` type, *not* our richer `InternalOwner` type and its
// various bits of private API.
-import Owner, { getOwner as internalGetOwner } from '../-internals/owner';
+import Owner, { getOwner as internalGetOwner } from '@ember/-internals/owner';
// NOTE: this documentation appears here instead of at the definition site so
// it can appear correctly in both API docs and for TS, while providing a richer
@@ -99,4 +99,4 @@ export {
KnownForTypeResult,
Resolver,
DIRegistry,
-} from '../-internals/owner';
+} from '@ember/-internals/owner'; | true |
Other | emberjs | ember.js | 3ca98347b0a6e6ff154144106c4b47f232ec2366.json | Introduce stable types for `@ember/owner`
- Remove `@ember/-internals/owner` and `@ember/owner` from the list of
excluded preview types in the types publishing script, so they now
get emitted correctly into `types/stable`.
- Remove `@ember/owner` from the preview types and put it in the stable
types instead, so users don't get conflicting type dependencies.
- Internally in `@ember/owner`, use absolute package paths, not
relative. For referencing other (even internal) packages, it's
important that we *not* use relative paths, so that (a) the published
types work when wrapped in `declare module` statements but also (b)
we have clearer boundaries for them, which will unlock further
improvements to this infrastructure in the future. | type-tests/stable/@ember/owner-tests.ts | @@ -0,0 +1,223 @@
+import Owner, {
+ Factory,
+ FactoryManager,
+ FullName,
+ RegisterOptions,
+ Resolver,
+ KnownForTypeResult,
+ getOwner,
+ setOwner,
+} from '@ember/owner';
+import Component from '@glimmer/component';
+import { expectTypeOf } from 'expect-type';
+import {
+ getOwner as getOwnerApplication,
+ setOwner as setOwnerApplication,
+} from '@ember/application';
+
+expectTypeOf(getOwnerApplication).toEqualTypeOf(getOwner);
+expectTypeOf(setOwnerApplication).toEqualTypeOf(setOwner);
+
+// Just a class we can construct in the Factory and FactoryManager tests
+declare class ConstructThis {
+ hasProps: boolean;
+}
+
+// ----- RegisterOptions ----- //
+declare let regOptionsA: RegisterOptions;
+expectTypeOf(regOptionsA.instantiate).toEqualTypeOf<boolean | undefined>();
+expectTypeOf(regOptionsA.singleton).toEqualTypeOf<boolean | undefined>();
+
+// ----- Factory ----- //
+// This gives us coverage for the cases where you are *casting*.
+declare let aFactory: Factory<ConstructThis>;
+
+aFactory.create();
+aFactory.create({});
+aFactory.create({
+ hasProps: true,
+});
+aFactory.create({
+ hasProps: false,
+});
+
+// NOTE: it would be nice if these could be rejected by way of EPC, but alas: it
+// cannot, because the public contract for `create` allows implementors to
+// define their `create` config object basically however they like. :-/
+aFactory.create({ unrelatedNonsense: 'yep yep yep' });
+aFactory.create({ hasProps: true, unrelatedNonsense: 'yep yep yep' });
+
+// But this should be legal.
+const goodPojo = { hasProps: true, unrelatedNonsense: 'also true' };
+aFactory.create(goodPojo);
+
+// This should also be rejected, though for *type error* reasons, not EPC; alas,
+// it cannot, for the same reason.
+const badPojo = { hasProps: 'huzzah', unrelatedNonsense: 'also true' };
+aFactory.create(badPojo);
+
+// ----- FactoryManager ----- //
+declare let aFactoryManager: FactoryManager<ConstructThis>;
+expectTypeOf(aFactoryManager.class).toEqualTypeOf<Factory<ConstructThis>>();
+expectTypeOf(aFactoryManager.create({})).toEqualTypeOf<ConstructThis>();
+expectTypeOf(aFactoryManager.create({ hasProps: true })).toEqualTypeOf<ConstructThis>();
+expectTypeOf(aFactoryManager.create({ hasProps: false })).toEqualTypeOf<ConstructThis>();
+
+// Likewise with these.
+aFactoryManager.create({ otherStuff: 'nope' });
+aFactoryManager.create({ hasProps: true, otherStuff: 'nope' });
+expectTypeOf(aFactoryManager.create(goodPojo)).toEqualTypeOf<ConstructThis>();
+aFactoryManager.create(badPojo);
+
+// ----- Resolver ----- //
+declare let resolver: Resolver;
+expectTypeOf<Resolver['normalize']>().toEqualTypeOf<
+ ((fullName: FullName) => FullName) | undefined
+>();
+expectTypeOf<Resolver['lookupDescription']>().toEqualTypeOf<
+ ((fullName: FullName) => string) | undefined
+>();
+expectTypeOf(resolver.resolve('random:some-name')).toEqualTypeOf<
+ object | Factory<object> | undefined
+>();
+const knownForFoo = resolver.knownForType?.('foo');
+expectTypeOf(knownForFoo).toEqualTypeOf<KnownForTypeResult<'foo'> | undefined>();
+expectTypeOf(knownForFoo?.['foo:bar']).toEqualTypeOf<boolean | undefined>();
+// @ts-expect-error -- there is no `blah` on `knownForFoo`, *only* `foo`.
+knownForFoo?.blah;
+
+// This one is last so it can reuse the bits from above!
+// ----- Owner ----- //
+declare let owner: Owner;
+
+// @ts-expect-error
+owner.lookup();
+expectTypeOf(owner.lookup('type:name')).toEqualTypeOf<unknown>();
+// @ts-expect-error
+owner.lookup('non-namespace-string');
+expectTypeOf(owner.lookup('namespace@type:name')).toEqualTypeOf<unknown>();
+
+// Arbitrary registration patterns work, as here.
+declare module '@ember/owner' {
+ export interface DIRegistry {
+ etc: {
+ 'my-type-test': ConstructThis;
+ };
+ }
+}
+
+expectTypeOf(owner.lookup('etc:my-type-test')).toEqualTypeOf<ConstructThis>();
+
+expectTypeOf(owner.register('type:name', aFactory)).toEqualTypeOf<void>();
+expectTypeOf(owner.register('type:name', aFactory, {})).toEqualTypeOf<void>();
+expectTypeOf(owner.register('type:name', aFactory, { instantiate: true })).toEqualTypeOf<void>();
+expectTypeOf(owner.register('type:name', aFactory, { instantiate: false })).toEqualTypeOf<void>();
+expectTypeOf(owner.register('type:name', aFactory, { singleton: true })).toEqualTypeOf<void>();
+expectTypeOf(owner.register('type:name', aFactory, { singleton: false })).toEqualTypeOf<void>();
+expectTypeOf(
+ owner.register('type:name', aFactory, { instantiate: true, singleton: true })
+).toEqualTypeOf<void>();
+expectTypeOf(
+ owner.register('type:name', aFactory, { instantiate: true, singleton: false })
+).toEqualTypeOf<void>();
+expectTypeOf(
+ owner.register('type:name', aFactory, { instantiate: false, singleton: true })
+).toEqualTypeOf<void>();
+expectTypeOf(
+ owner.register('type:name', aFactory, { instantiate: false, singleton: false })
+).toEqualTypeOf<void>();
+// @ts-expect-error
+owner.register('non-namespace-string', aFactory);
+expectTypeOf(owner.register('namespace@type:name', aFactory)).toEqualTypeOf<void>();
+
+expectTypeOf(owner.factoryFor('type:name')).toEqualTypeOf<FactoryManager<object> | undefined>();
+expectTypeOf(owner.factoryFor('type:name')?.class).toEqualTypeOf<Factory<object> | undefined>();
+expectTypeOf(owner.factoryFor('type:name')?.create()).toEqualTypeOf<object | undefined>();
+expectTypeOf(owner.factoryFor('type:name')?.create({})).toEqualTypeOf<object | undefined>();
+expectTypeOf(owner.factoryFor('type:name')?.create({ anythingGoes: true })).toEqualTypeOf<
+ object | undefined
+>();
+// @ts-expect-error
+owner.factoryFor('non-namespace-string');
+expectTypeOf(owner.factoryFor('namespace@type:name')).toEqualTypeOf<
+ FactoryManager<object> | undefined
+>();
+
+// Tests deal with the fact that string literals are a special case! `let`
+// bindings will accordingly not "just work" as a result. The separate
+// assignments both satisfy the linter and show why it matters.
+let aName;
+aName = 'type:name';
+// @ts-expect-error
+owner.lookup(aName);
+
+let aTypedName: FullName;
+aTypedName = 'type:name';
+expectTypeOf(owner.lookup(aTypedName)).toBeUnknown();
+
+// Nor will callbacks work "out of the box". But they can work if they have the
+// correct type.
+declare const justStrings: string[];
+// @ts-expect-error
+justStrings.map((aString) => owner.lookup(aString));
+declare let typedStrings: FullName[];
+typedStrings.map((aString) => owner.lookup(aString));
+
+// Also make sure it keeps working with const bindings
+const aConstName = 'type:name';
+expectTypeOf(owner.lookup(aConstName)).toBeUnknown();
+
+// Check handling with Glimmer components carrying a Signature: they should
+// properly resolve to `Owner`, *not* `Owner | undefined`.
+interface Sig<T> {
+ Args: {
+ name: string;
+ age: number;
+ extra: T;
+ };
+ Element: HTMLParagraphElement;
+ Blocks: {
+ default: [greeting: string];
+ extra: [T];
+ };
+}
+
+class ExampleComponent<T> extends Component<Sig<T>> {
+ checkThis() {
+ expectTypeOf(getOwner(this)).toEqualTypeOf<Owner | undefined>();
+ }
+}
+
+declare let example: ExampleComponent<string>;
+expectTypeOf(getOwner(example)).toEqualTypeOf<Owner | undefined>();
+
+// ----- Minimal further coverage for POJOs ----- //
+// `Factory` and `FactoryManager` don't have to deal in actual classes. :sigh:
+const Creatable = {
+ hasProps: true,
+};
+
+const pojoFactory: Factory<typeof Creatable> = {
+ // If you want *real* safety here, alas: you cannot have it. The public
+ // contract for `create` allows implementors to define their `create` config
+ // object basically however they like. As a result, this is the safest version
+ // possible: Making it be `Partial<Thing>` is *compatible* with `object`, and
+ // requires full checking *inside* the function body. It does not, alas, give
+ // any safety *outside* the class. A future rationalization of this would be
+ // very welcome.
+ create(initialValues?: Partial<typeof Creatable>) {
+ const instance = Creatable;
+ if (initialValues) {
+ if (initialValues.hasProps) {
+ Object.defineProperty(instance, 'hasProps', {
+ value: initialValues.hasProps,
+ enumerable: true,
+ writable: true,
+ });
+ }
+ }
+ return instance;
+ },
+};
+
+expectTypeOf(pojoFactory.create()).toEqualTypeOf<{ hasProps: boolean }>(); | true |
Other | emberjs | ember.js | 3ca98347b0a6e6ff154144106c4b47f232ec2366.json | Introduce stable types for `@ember/owner`
- Remove `@ember/-internals/owner` and `@ember/owner` from the list of
excluded preview types in the types publishing script, so they now
get emitted correctly into `types/stable`.
- Remove `@ember/owner` from the preview types and put it in the stable
types instead, so users don't get conflicting type dependencies.
- Internally in `@ember/owner`, use absolute package paths, not
relative. For referencing other (even internal) packages, it's
important that we *not* use relative paths, so that (a) the published
types work when wrapped in `declare module` statements but also (b)
we have clearer boundaries for them, which will unlock further
improvements to this infrastructure in the future. | type-tests/stable/index.d.ts | @@ -0,0 +1,2 @@
+// This is equivalent to do `import 'ember-source/types';`.
+import '../../types/stable'; | true |
Other | emberjs | ember.js | 3ca98347b0a6e6ff154144106c4b47f232ec2366.json | Introduce stable types for `@ember/owner`
- Remove `@ember/-internals/owner` and `@ember/owner` from the list of
excluded preview types in the types publishing script, so they now
get emitted correctly into `types/stable`.
- Remove `@ember/owner` from the preview types and put it in the stable
types instead, so users don't get conflicting type dependencies.
- Internally in `@ember/owner`, use absolute package paths, not
relative. For referencing other (even internal) packages, it's
important that we *not* use relative paths, so that (a) the published
types work when wrapped in `declare module` statements but also (b)
we have clearer boundaries for them, which will unlock further
improvements to this infrastructure in the future. | type-tests/stable/tsconfig.json | @@ -0,0 +1,3 @@
+{
+ "extends": "@tsconfig/ember/tsconfig.json",
+} | true |
Other | emberjs | ember.js | 3ca98347b0a6e6ff154144106c4b47f232ec2366.json | Introduce stable types for `@ember/owner`
- Remove `@ember/-internals/owner` and `@ember/owner` from the list of
excluded preview types in the types publishing script, so they now
get emitted correctly into `types/stable`.
- Remove `@ember/owner` from the preview types and put it in the stable
types instead, so users don't get conflicting type dependencies.
- Internally in `@ember/owner`, use absolute package paths, not
relative. For referencing other (even internal) packages, it's
important that we *not* use relative paths, so that (a) the published
types work when wrapped in `declare module` statements but also (b)
we have clearer boundaries for them, which will unlock further
improvements to this infrastructure in the future. | types/preview/@ember/owner/index.d.ts | @@ -1,423 +0,0 @@
-declare module '@ember/owner' {
- /**
- * The name for a factory consists of a namespace and the name of a specific
- * type within that namespace, like `'service:session'`.
- */
- export type FullName<
- Type extends string = string,
- Name extends string = string
- > = `${Type}:${Name}`;
-
- /**
- * A type registry for the DI system, which other participants in the DI system
- * can register themselves into with declaration merging. The contract for this
- * type is that its keys are the `Type` from a `FullName`, and each value for a
- * `Type` is another registry whose keys are the `Name` from a `FullName`. The
- * mechanic for providing a registry is [declaration merging][handbook].
- *
- * [handbook]: https://www.typescriptlang.org/docs/handbook/declaration-merging.html
- *
- * For example, Ember's `Service` class uses this :
- *
- * ```ts
- * export default class Service extends EmberObject {}
- *
- * // For concrete singleton classes to be merged into.
- * interface Registry extends Record<string, Service> {}
- *
- * declare module '@ember/owner' {
- * service: Registry;
- * }
- * ```
- *
- * Declarations of services can then include the registry:
- *
- * ```ts
- * import Service from '@ember/service';
- *
- * export default class Session extends Service {
- * login(username: string, password: string) {
- * // ...
- * }
- * }
- *
- * declare module '@ember/service' {
- * interface Registry {
- * session: Session;
- * }
- * }
- * ```
- *
- * Then users of the `Owner` API will be able to reliably do things like this:
- *
- * ```ts
- * getOwner(this)?.lookup('service:session').login("hello", "1234abcd");
- * ```
- */
- export interface DIRegistry extends Record<string, Record<string, unknown>> {}
-
- // Convenience utilities for pulling a specific factory manager off `DIRegistry`
- // if one exists, or falling back to the default definition otherwise.
- type ResolveFactoryManager<
- Type extends ValidType,
- Name extends ValidName<Type>
- > = DIRegistry[Type][Name] extends object
- ? FactoryManager<DIRegistry[Type][Name]>
- : FactoryManager<object> | undefined;
-
- type ResolveFactory<
- Type extends ValidType,
- Name extends ValidName<Type>
- > = DIRegistry[Type][Name] extends object
- ? Factory<DIRegistry[Type][Name]>
- : Factory<object> | object | undefined;
-
- // This type is shared between `Owner` and `RegistryProxy
- interface BasicRegistry {
- /**
- Registers a factory that can be used for dependency injection (with
- `inject`) or for service lookup. Each factory is registered with
- a full name including two parts: `type:name`.
-
- A simple example:
-
- ```javascript
- import Application from '@ember/application';
- import EmberObject from '@ember/object';
-
- let App = Application.create();
-
- App.Orange = EmberObject.extend();
- App.register('fruit:favorite', App.Orange);
- ```
-
- Ember will resolve factories from the `App` namespace automatically.
- For example `App.CarsController` will be discovered and returned if
- an application requests `controller:cars`.
-
- An example of registering a controller with a non-standard name:
-
- ```javascript
- import Application from '@ember/application';
- import Controller from '@ember/controller';
-
- let App = Application.create();
- let Session = Controller.extend();
-
- App.register('controller:session', Session);
-
- // The Session controller can now be treated like a normal controller,
- // despite its non-standard name.
- App.ApplicationController = Controller.extend({
- needs: ['session']
- });
- ```
-
- Registered factories are **instantiated** by having `create`
- called on them. Additionally they are **singletons**, each time
- they are looked up they return the same instance.
-
- Some examples modifying that default behavior:
-
- ```javascript
- import Application from '@ember/application';
- import EmberObject from '@ember/object';
-
- let App = Application.create();
-
- App.Person = EmberObject.extend();
- App.Orange = EmberObject.extend();
- App.Email = EmberObject.extend();
- App.session = EmberObject.create();
-
- App.register('model:user', App.Person, { singleton: false });
- App.register('fruit:favorite', App.Orange);
- App.register('communication:main', App.Email, { singleton: false });
- App.register('session', App.session, { instantiate: false });
- ```
-
- @method register
- @param fullName {String} type:name (e.g., 'model:user')
- @param factory {any} (e.g., App.Person)
- @param options {Object} (optional) disable instantiation or singleton usage
- @public
- */
- // Dear future maintainer: yes, `Factory<object> | object` is an exceedingly
- // weird type here. We actually allow more or less *anything* to be passed
- // here. In the future, we may possibly be able to update this to actually
- // take advantage of the `FullName` here to require that the registered
- // factory and corresponding options do the right thing (passing an *actual*
- // factory, not needing `create` if `options.instantiate` is `false`, etc.)
- // but doing so will require rationalizing Ember's own internals and may need
- // a full Ember RFC.
- register(
- fullName: FullName,
- factory: Factory<object> | object,
- options?: RegisterOptions
- ): void;
- }
-
- type ValidType = keyof DIRegistry & string;
- type ValidName<Type extends ValidType> = keyof DIRegistry[Type] & string;
-
- interface BasicContainer {
- /**
- * Given a {@linkcode FullName} return a corresponding instance.
- */
- lookup<Type extends ValidType, Name extends ValidName<Type>>(
- fullName: FullName<Type, Name>,
- options?: RegisterOptions
- ): DIRegistry[Type][Name];
-
- /**
- * Given a fullName of the form `'type:name'`, like `'route:application'`,
- * return a corresponding factory manager.
- *
- * Any instances created via the factory's `.create()` method must be
- * destroyed manually by the caller of `.create()`. Typically, this is done
- * during the creating objects own `destroy` or `willDestroy` methods.
- */
- factoryFor<Type extends ValidType, Name extends ValidName<Type>>(
- fullName: FullName<Type, Name>
- ): ResolveFactoryManager<Type, Name>;
- }
-
- /**
- * Framework objects in an Ember application (components, services, routes,
- * etc.) are created via a factory and dependency injection system. Each of
- * these objects is the responsibility of an "owner", which handles its
- * instantiation and manages its lifetime.
- */
- export default interface Owner extends BasicRegistry, BasicContainer {}
-
- export interface RegisterOptions {
- instantiate?: boolean | undefined;
- singleton?: boolean | undefined;
- }
-
- /**
- * Registered factories are instantiated by having create called on them.
- * Additionally they are singletons by default, so each time they are looked up
- * they return the same instance.
- *
- * However, that behavior can be modified with the `instantiate` and `singleton`
- * options to the {@linkcode Owner.register} method.
- */
- export interface Factory<T> {
- // NOTE: this does not check against the types of the target object in any
- // way, unfortunately. However, we actually *cannot* constrain it further than
- // this without going down a *very* deep rabbit hole (see the historic types
- // for `.create()` on DefinitelyTyped if you're curious), because we need (for
- // historical reasons) to support classes which implement this contract to be
- // able to provide a *narrower* interface than "exactly the public fields on
- // the class" while still falling back to the "exactly the public fields on
- // the class" for the general case. :sigh:
- /**
- * A function that will create an instance of the class with any
- * dependencies injected.
- *
- * @param initialValues Any values to set on an instance of the class
- */
- create(initialValues?: object): T;
- }
-
- /**
- * A manager which can be used for introspection of the factory's class or for
- * the creation of factory instances with initial properties. The manager is an
- * object with the following properties:
- *
- * - `class` - The registered or resolved class.
- * - `create` - A function that will create an instance of the class with any
- * dependencies injected.
- *
- * @note `FactoryManager` is *not* user-constructible; the only legal way to get
- * a `FactoryManager` is via {@linkcode Owner.factoryFor}.
- */
- export interface FactoryManager<T> extends Factory<T> {
- /** The registered or resolved class. */
- readonly class: Factory<T>;
- }
-
- /**
- * A record mapping all known items of a given type: if the item is known it
- * will be `true`; otherwise it will be `false` or `undefined`.
- */
- export type KnownForTypeResult<Type extends string> = {
- [FullName in `${Type}:${string}`]: boolean | undefined;
- };
-
- /**
- * A `Resolver` is the mechanism responsible for looking up code in your
- * application and converting its naming conventions into the actual classes,
- * functions, and templates that Ember needs to resolve its dependencies, for
- * example, what template to render for a given route. It is a system that helps
- * the app resolve the lookup of JavaScript modules agnostic of what kind of
- * module system is used, which can be AMD, CommonJS or just plain globals. It
- * is used to lookup routes, models, components, templates, or anything that is
- * used in your Ember app.
- *
- * This interface represents the contract a custom resolver must implement. Most
- * apps never need to think about this: the application's resolver is supplied by
- * `ember-resolver` in the default blueprint.
- */
- export interface Resolver {
- resolve: <Type extends ValidType, Name extends ValidName<Type>>(
- name: FullName<Type, Name>
- ) => ResolveFactory<Type, Name>;
- knownForType?: <Type extends string>(type: Type) => KnownForTypeResult<Type>;
- lookupDescription?: (fullName: FullName) => string;
- makeToString?: (factory: Factory<object>, fullName: FullName) => string;
- normalize?: (fullName: FullName) => FullName;
- }
-
- /**
- * Framework objects in an Ember application (components, services, routes, etc.)
- * are created via a factory and dependency injection system. Each of these
- * objects is the responsibility of an "owner", which handled its
- * instantiation and manages its lifetime.
- *
- * `getOwner` fetches the owner object responsible for an instance. This can
- * be used to lookup or resolve other class instances, or register new factories
- * into the owner.
- *
- * For example, this component dynamically looks up a service based on the
- * `audioType` passed as an argument:
- *
- * ```app/components/play-audio.js
- * import Component from '@glimmer/component';
- * import { action } from '@ember/object';
- * import { getOwner } from '@ember/application';
- *
- * // Usage:
- * //
- * // <PlayAudio @audioType={{@model.audioType}} @audioFile={{@model.file}}/>
- * //
- * export default class PlayAudio extends Component {
- * get audioService() {
- * return getOwner(this)?.lookup(`service:${this.args.audioType}`);
- * }
- *
- * @action
- * onPlay() {
- * this.audioService?.play(this.args.audioFile);
- * }
- * }
- * ```
- */
- export function getOwner(object: object): Owner | undefined;
-
- /**
- * `setOwner` forces a new owner on a given object instance. This is primarily
- * useful in some testing cases.
- *
- * @param object An object instance.
- * @param owner The new owner object of the object instance.
- */
- export function setOwner(object: object, owner: Owner): void;
-
- export interface ContainerProxy extends BasicContainer {
- /**
- * Returns an object that can be used to provide an owner to a
- * manually created instance.
- *
- * Example:
- *
- * ```
- * import { getOwner } from '@ember/application';
- *
- * let owner = getOwner(this);
- *
- * User.create(
- * owner.ownerInjection(),
- * { username: 'rwjblue' }
- * )
- * ```
- */
- ownerInjection(): object;
- }
-
- export interface RegistryProxy extends BasicRegistry {
- /**
- * Given a fullName return the corresponding factory.
- */
- resolveRegistration(fullName: FullName): Factory<object> | object | undefined;
-
- /**
- * Unregister a factory.
- *
- *
- * ```javascript
- * import Application from '@ember/application';
- * import EmberObject from '@ember/object';
- * let App = Application.create();
- * let User = EmberObject.extend();
- * App.register('model:user', User);
- *
- * App.resolveRegistration('model:user').create() instanceof User //=> true
- *
- * App.unregister('model:user')
- * App.resolveRegistration('model:user') === undefined //=> true
- * ```
- */
- unregister(fullName: FullName): void;
-
- /**
- * Check if a factory is registered.
- */
- hasRegistration(fullName: FullName): boolean;
-
- /**
- * Return a specific registered option for a particular factory.
- */
- registeredOption<K extends keyof RegisterOptions>(
- fullName: FullName,
- optionName: K
- ): RegisterOptions[K] | undefined;
-
- /**
- * Register options for a particular factory.
- */
- registerOptions(fullName: FullName, options: RegisterOptions): void;
-
- /**
- * Return registered options for a particular factory.
- */
- registeredOptions(fullName: FullName): RegisterOptions | undefined;
-
- /**
- * Allow registering options for all factories of a type.
- *
- * ```javascript
- * import Application from '@ember/application';
- *
- * let App = Application.create();
- * let appInstance = App.buildInstance();
- *
- * // if all of type `connection` must not be singletons
- * appInstance.registerOptionsForType('connection', { singleton: false });
- *
- * appInstance.register('connection:twitter', TwitterConnection);
- * appInstance.register('connection:facebook', FacebookConnection);
- *
- * let twitter = appInstance.lookup('connection:twitter');
- * let twitter2 = appInstance.lookup('connection:twitter');
- *
- * twitter === twitter2; // => false
- *
- * let facebook = appInstance.lookup('connection:facebook');
- * let facebook2 = appInstance.lookup('connection:facebook');
- *
- * facebook === facebook2; // => false
- * ```
- */
- registerOptionsForType(type: string, options: RegisterOptions): void;
-
- /**
- * Return the registered options for all factories of a type.
- */
- registeredOptionsForType(type: string): RegisterOptions | undefined;
- }
-
- // Don't export things unless we *intend* to.
- export {};
-} | true |
Other | emberjs | ember.js | 3ca98347b0a6e6ff154144106c4b47f232ec2366.json | Introduce stable types for `@ember/owner`
- Remove `@ember/-internals/owner` and `@ember/owner` from the list of
excluded preview types in the types publishing script, so they now
get emitted correctly into `types/stable`.
- Remove `@ember/owner` from the preview types and put it in the stable
types instead, so users don't get conflicting type dependencies.
- Internally in `@ember/owner`, use absolute package paths, not
relative. For referencing other (even internal) packages, it's
important that we *not* use relative paths, so that (a) the published
types work when wrapped in `declare module` statements but also (b)
we have clearer boundaries for them, which will unlock further
improvements to this infrastructure in the future. | types/preview/@ember/owner/tsconfig.json | @@ -1,3 +0,0 @@
-{
- "extends": "../../tsconfig.json"
-} | true |
Other | emberjs | ember.js | 3ca98347b0a6e6ff154144106c4b47f232ec2366.json | Introduce stable types for `@ember/owner`
- Remove `@ember/-internals/owner` and `@ember/owner` from the list of
excluded preview types in the types publishing script, so they now
get emitted correctly into `types/stable`.
- Remove `@ember/owner` from the preview types and put it in the stable
types instead, so users don't get conflicting type dependencies.
- Internally in `@ember/owner`, use absolute package paths, not
relative. For referencing other (even internal) packages, it's
important that we *not* use relative paths, so that (a) the published
types work when wrapped in `declare module` statements but also (b)
we have clearer boundaries for them, which will unlock further
improvements to this infrastructure in the future. | types/preview/index.d.ts | @@ -91,8 +91,6 @@ import './@ember/object/observers';
import './@ember/object/promise-proxy-mixin';
import './@ember/object/proxy';
-import './@ember/owner';
-
import './@ember/polyfills';
import './@ember/polyfills/types';
| true |
Other | emberjs | ember.js | 3ca98347b0a6e6ff154144106c4b47f232ec2366.json | Introduce stable types for `@ember/owner`
- Remove `@ember/-internals/owner` and `@ember/owner` from the list of
excluded preview types in the types publishing script, so they now
get emitted correctly into `types/stable`.
- Remove `@ember/owner` from the preview types and put it in the stable
types instead, so users don't get conflicting type dependencies.
- Internally in `@ember/owner`, use absolute package paths, not
relative. For referencing other (even internal) packages, it's
important that we *not* use relative paths, so that (a) the published
types work when wrapped in `declare module` statements but also (b)
we have clearer boundaries for them, which will unlock further
improvements to this infrastructure in the future. | types/publish.mjs | @@ -149,7 +149,6 @@ const PREVIEW_MODULES = [
'@ember/-internals/metal/lib/tags.d.ts',
'@ember/-internals/metal/lib/tracked.d.ts',
'@ember/-internals/overrides/index.d.ts',
- '@ember/-internals/owner/index.d.ts',
'@ember/-internals/routing/index.d.ts',
'@ember/-internals/runtime/index.d.ts',
'@ember/-internals/runtime/lib/ext/rsvp.d.ts',
@@ -243,7 +242,6 @@ const PREVIEW_MODULES = [
'@ember/object/observers.d.ts',
'@ember/object/promise-proxy-mixin.d.ts',
'@ember/object/proxy.d.ts',
- '@ember/owner/index.d.ts',
'@ember/polyfills/index.d.ts',
'@ember/polyfills/lib/assign.d.ts',
'@ember/renderer/index.d.ts',
@@ -457,8 +455,8 @@ function wrapInDeclareModule(moduleName) {
// that will be, it will be *way* more reliable.
let string = new MagicString(contents);
string
- .replaceAll(/^export declare /gm, 'export ') // g for global, m for multiline
- .replaceAll(/^declare /gm, '') // g for global, m for multiline
+ .replace(/^export declare /gm, 'export ') // g for global, m for multiline
+ .replace(/^declare /gm, '') // g for global, m for multiline
.indent(' ')
.prepend(`declare module '${moduleNameForDeclaration}' {\n`)
.append('}\n'); | true |
Other | emberjs | ember.js | 86f6e52889ed5fb10070e5925c977095a1c7d837.json | Fix some bugs in `types/publish` script
- The modules needed to be "absolute" not "relative" for the filtering
to work correctly.
- That in turn meant we needed to *insert* a relative lookup.
- But we also needed to make sure we treat top-level packages *as such*
rather than linking to their `index`, else TS does not resolve them
correctly with these side effect modules. | types/publish.mjs | @@ -43,297 +43,300 @@ import MagicString from 'magic-string';
modules.
*/
const PREVIEW_MODULES = [
- './@ember/-internals/bootstrap/index.d.ts',
- './@ember/-internals/browser-environment/index.d.ts',
- './@ember/-internals/browser-environment/lib/has-dom.d.ts',
- './@ember/-internals/container/index.d.ts',
- './@ember/-internals/container/lib/container.d.ts',
- './@ember/-internals/container/lib/registry.d.ts',
- './@ember/-internals/environment/index.d.ts',
- './@ember/-internals/environment/lib/context.d.ts',
- './@ember/-internals/environment/lib/env.d.ts',
- './@ember/-internals/environment/lib/global.d.ts',
- './@ember/-internals/error-handling/index.d.ts',
- './@ember/-internals/glimmer/index.d.ts',
- './@ember/-internals/glimmer/lib/component-managers/curly.d.ts',
- './@ember/-internals/glimmer/lib/component-managers/mount.d.ts',
- './@ember/-internals/glimmer/lib/component-managers/outlet.d.ts',
- './@ember/-internals/glimmer/lib/component-managers/root.d.ts',
- './@ember/-internals/glimmer/lib/component.d.ts',
- './@ember/-internals/glimmer/lib/components/abstract-input.d.ts',
- './@ember/-internals/glimmer/lib/components/input.d.ts',
- './@ember/-internals/glimmer/lib/components/internal.d.ts',
- './@ember/-internals/glimmer/lib/components/link-to.d.ts',
- './@ember/-internals/glimmer/lib/components/textarea.d.ts',
- './@ember/-internals/glimmer/lib/dom.d.ts',
- './@ember/-internals/glimmer/lib/environment.d.ts',
- './@ember/-internals/glimmer/lib/glimmer-component-docs.d.ts',
- './@ember/-internals/glimmer/lib/glimmer-tracking-docs.d.ts',
- './@ember/-internals/glimmer/lib/helper.d.ts',
- './@ember/-internals/glimmer/lib/helpers/-disallow-dynamic-resolution.d.ts',
- './@ember/-internals/glimmer/lib/helpers/-in-element-null-check.d.ts',
- './@ember/-internals/glimmer/lib/helpers/-normalize-class.d.ts',
- './@ember/-internals/glimmer/lib/helpers/-resolve.d.ts',
- './@ember/-internals/glimmer/lib/helpers/-track-array.d.ts',
- './@ember/-internals/glimmer/lib/helpers/action.d.ts',
- './@ember/-internals/glimmer/lib/helpers/array.d.ts',
- './@ember/-internals/glimmer/lib/helpers/component.d.ts',
- './@ember/-internals/glimmer/lib/helpers/concat.d.ts',
- './@ember/-internals/glimmer/lib/helpers/each-in.d.ts',
- './@ember/-internals/glimmer/lib/helpers/fn.d.ts',
- './@ember/-internals/glimmer/lib/helpers/get.d.ts',
- './@ember/-internals/glimmer/lib/helpers/hash.d.ts',
- './@ember/-internals/glimmer/lib/helpers/helper.d.ts',
- './@ember/-internals/glimmer/lib/helpers/if-unless.d.ts',
- './@ember/-internals/glimmer/lib/helpers/internal-helper.d.ts',
- './@ember/-internals/glimmer/lib/helpers/log.d.ts',
- './@ember/-internals/glimmer/lib/helpers/modifier.d.ts',
- './@ember/-internals/glimmer/lib/helpers/mut.d.ts',
- './@ember/-internals/glimmer/lib/helpers/page-title.d.ts',
- './@ember/-internals/glimmer/lib/helpers/readonly.d.ts',
- './@ember/-internals/glimmer/lib/helpers/unbound.d.ts',
- './@ember/-internals/glimmer/lib/helpers/unique-id.d.ts',
- './@ember/-internals/glimmer/lib/modifiers/action.d.ts',
- './@ember/-internals/glimmer/lib/modifiers/internal.d.ts',
- './@ember/-internals/glimmer/lib/modifiers/on.d.ts',
- './@ember/-internals/glimmer/lib/renderer.d.ts',
- './@ember/-internals/glimmer/lib/resolver.d.ts',
- './@ember/-internals/glimmer/lib/setup-registry.d.ts',
- './@ember/-internals/glimmer/lib/syntax/in-element.d.ts',
- './@ember/-internals/glimmer/lib/syntax/let.d.ts',
- './@ember/-internals/glimmer/lib/syntax/mount.d.ts',
- './@ember/-internals/glimmer/lib/syntax/outlet.d.ts',
- './@ember/-internals/glimmer/lib/syntax/utils.d.ts',
- './@ember/-internals/glimmer/lib/template_registry.d.ts',
- './@ember/-internals/glimmer/lib/template.d.ts',
- './@ember/-internals/glimmer/lib/utils/bindings.d.ts',
- './@ember/-internals/glimmer/lib/utils/curly-component-state-bucket.d.ts',
- './@ember/-internals/glimmer/lib/utils/debug-render-message.d.ts',
- './@ember/-internals/glimmer/lib/utils/iterator.d.ts',
- './@ember/-internals/glimmer/lib/utils/managers.d.ts',
- './@ember/-internals/glimmer/lib/utils/outlet.d.ts',
- './@ember/-internals/glimmer/lib/utils/process-args.d.ts',
- './@ember/-internals/glimmer/lib/utils/serialization-first-node-helpers.d.ts',
- './@ember/-internals/glimmer/lib/utils/string.d.ts',
- './@ember/-internals/glimmer/lib/utils/to-bool.d.ts',
- './@ember/-internals/glimmer/lib/views/outlet.d.ts',
- './@ember/-internals/meta/index.d.ts',
- './@ember/-internals/meta/lib/meta.d.ts',
- './@ember/-internals/metal/index.d.ts',
- './@ember/-internals/metal/lib/alias.d.ts',
- './@ember/-internals/metal/lib/array_events.d.ts',
- './@ember/-internals/metal/lib/array.d.ts',
- './@ember/-internals/metal/lib/cache.d.ts',
- './@ember/-internals/metal/lib/cached.d.ts',
- './@ember/-internals/metal/lib/chain-tags.d.ts',
- './@ember/-internals/metal/lib/change_event.d.ts',
- './@ember/-internals/metal/lib/computed_cache.d.ts',
- './@ember/-internals/metal/lib/computed.d.ts',
- './@ember/-internals/metal/lib/decorator.d.ts',
- './@ember/-internals/metal/lib/dependent_keys.d.ts',
- './@ember/-internals/metal/lib/deprecate_property.d.ts',
- './@ember/-internals/metal/lib/each_proxy_events.d.ts',
- './@ember/-internals/metal/lib/events.d.ts',
- './@ember/-internals/metal/lib/expand_properties.d.ts',
- './@ember/-internals/metal/lib/get_properties.d.ts',
- './@ember/-internals/metal/lib/injected_property.d.ts',
- './@ember/-internals/metal/lib/libraries.d.ts',
- './@ember/-internals/metal/lib/namespace_search.d.ts',
- './@ember/-internals/metal/lib/observer.d.ts',
- './@ember/-internals/metal/lib/path_cache.d.ts',
- './@ember/-internals/metal/lib/properties.d.ts',
- './@ember/-internals/metal/lib/property_events.d.ts',
- './@ember/-internals/metal/lib/property_get.d.ts',
- './@ember/-internals/metal/lib/property_set.d.ts',
- './@ember/-internals/metal/lib/set_properties.d.ts',
- './@ember/-internals/metal/lib/tags.d.ts',
- './@ember/-internals/metal/lib/tracked.d.ts',
- './@ember/-internals/overrides/index.d.ts',
- './@ember/-internals/owner/index.d.ts',
- './@ember/-internals/routing/index.d.ts',
- './@ember/-internals/runtime/index.d.ts',
- './@ember/-internals/runtime/lib/ext/rsvp.d.ts',
- './@ember/-internals/runtime/lib/mixins/-proxy.d.ts',
- './@ember/-internals/runtime/lib/mixins/action_handler.d.ts',
- './@ember/-internals/runtime/lib/mixins/comparable.d.ts',
- './@ember/-internals/runtime/lib/mixins/container_proxy.d.ts',
- './@ember/-internals/runtime/lib/mixins/registry_proxy.d.ts',
- './@ember/-internals/runtime/lib/mixins/target_action_support.d.ts',
- './@ember/-internals/utils/index.d.ts',
- './@ember/-internals/utils/lib/cache.d.ts',
- './@ember/-internals/utils/lib/dictionary.d.ts',
- './@ember/-internals/utils/lib/ember-array.d.ts',
- './@ember/-internals/utils/lib/get-debug-name.d.ts',
- './@ember/-internals/utils/lib/guid.d.ts',
- './@ember/-internals/utils/lib/inspect.d.ts',
- './@ember/-internals/utils/lib/intern.d.ts',
- './@ember/-internals/utils/lib/invoke.d.ts',
- './@ember/-internals/utils/lib/is_proxy.d.ts',
- './@ember/-internals/utils/lib/lookup-descriptor.d.ts',
- './@ember/-internals/utils/lib/make-array.d.ts',
- './@ember/-internals/utils/lib/mandatory-setter.d.ts',
- './@ember/-internals/utils/lib/name.d.ts',
- './@ember/-internals/utils/lib/spec.d.ts',
- './@ember/-internals/utils/lib/super.d.ts',
- './@ember/-internals/utils/lib/symbol.d.ts',
- './@ember/-internals/utils/lib/to-string.d.ts',
- './@ember/-internals/utils/types.d.ts',
- './@ember/-internals/views/index.d.ts',
- './@ember/-internals/views/lib/compat/attrs.d.ts',
- './@ember/-internals/views/lib/compat/fallback-view-registry.d.ts',
- './@ember/-internals/views/lib/component_lookup.d.ts',
- './@ember/-internals/views/lib/mixins/action_support.d.ts',
- './@ember/-internals/views/lib/mixins/child_views_support.d.ts',
- './@ember/-internals/views/lib/mixins/class_names_support.d.ts',
- './@ember/-internals/views/lib/mixins/view_state_support.d.ts',
- './@ember/-internals/views/lib/mixins/view_support.d.ts',
- './@ember/-internals/views/lib/system/action_manager.d.ts',
- './@ember/-internals/views/lib/system/event_dispatcher.d.ts',
- './@ember/-internals/views/lib/system/utils.d.ts',
- './@ember/-internals/views/lib/views/states.d.ts',
- './@ember/-internals/views/lib/views/states/default.d.ts',
- './@ember/-internals/views/lib/views/states/destroying.d.ts',
- './@ember/-internals/views/lib/views/states/has_element.d.ts',
- './@ember/-internals/views/lib/views/states/in_dom.d.ts',
- './@ember/-internals/views/lib/views/states/pre_render.d.ts',
- './@ember/application/index.d.ts',
- './@ember/application/instance.d.ts',
- './@ember/application/lib/lazy_load.d.ts',
- './@ember/application/namespace.d.ts',
- './@ember/array/index.d.ts',
- './@ember/array/mutable.d.ts',
- './@ember/array/proxy.d.ts',
- './@ember/canary-features/index.d.ts',
- './@ember/component/helper.d.ts',
- './@ember/component/index.d.ts',
- './@ember/component/template-only.d.ts',
- './@ember/debug/container-debug-adapter.d.ts',
- './@ember/debug/data-adapter.d.ts',
- './@ember/debug/index.d.ts',
- './@ember/debug/lib/capture-render-tree.d.ts',
- './@ember/debug/lib/deprecate.d.ts',
- './@ember/debug/lib/handlers.d.ts',
- './@ember/debug/lib/testing.d.ts',
- './@ember/debug/lib/warn.d.ts',
- './@ember/deprecated-features/index.d.ts',
- './@ember/destroyable/index.d.ts',
- './@ember/engine/index.d.ts',
- './@ember/engine/instance.d.ts',
- './@ember/engine/lib/engine-parent.d.ts',
- './@ember/enumerable/index.d.ts',
- './@ember/enumerable/mutable.d.ts',
- './@ember/error/index.d.ts',
- './@ember/helper/index.d.ts',
- './@ember/instrumentation/index.d.ts',
- './@ember/modifier/index.d.ts',
- './@ember/object/compat.d.ts',
- './@ember/object/computed.d.ts',
- './@ember/object/core.d.ts',
- './@ember/object/evented.d.ts',
- './@ember/object/events.d.ts',
- './@ember/object/index.d.ts',
- './@ember/object/internals.d.ts',
- './@ember/object/lib/computed/computed_macros.d.ts',
- './@ember/object/lib/computed/reduce_computed_macros.d.ts',
- './@ember/object/mixin.d.ts',
- './@ember/object/observable.d.ts',
- './@ember/object/observers.d.ts',
- './@ember/object/promise-proxy-mixin.d.ts',
- './@ember/object/proxy.d.ts',
- './@ember/owner/index.d.ts',
- './@ember/polyfills/index.d.ts',
- './@ember/polyfills/lib/assign.d.ts',
- './@ember/renderer/index.d.ts',
- './@ember/routing/-internals.d.ts',
- './@ember/routing/auto-location.d.ts',
- './@ember/routing/hash-location.d.ts',
- './@ember/routing/history-location.d.ts',
- './@ember/routing/index.d.ts',
- './@ember/routing/lib/cache.d.ts',
- './@ember/routing/lib/controller_for.d.ts',
- './@ember/routing/lib/dsl.d.ts',
- './@ember/routing/lib/engines.d.ts',
- './@ember/routing/lib/generate_controller.d.ts',
- './@ember/routing/lib/location-utils.d.ts',
- './@ember/routing/lib/query_params.d.ts',
- './@ember/routing/lib/route-info.d.ts',
- './@ember/routing/lib/router_state.d.ts',
- './@ember/routing/lib/routing-service.d.ts',
- './@ember/routing/lib/transition.d.ts',
- './@ember/routing/lib/utils.d.ts',
- './@ember/routing/location.d.ts',
- './@ember/routing/none-location.d.ts',
- './@ember/routing/route-info.d.ts',
- './@ember/routing/route.d.ts',
- './@ember/routing/router-service.d.ts',
- './@ember/routing/router.d.ts',
- './@ember/routing/transition.d.ts',
- './@ember/runloop/index.d.ts',
- './@ember/service/index.d.ts',
- './@ember/string/index.d.ts',
- './@ember/string/lib/string_registry.d.ts',
- './@ember/template-compilation/index.d.ts',
- './@ember/template-factory/index.d.ts',
- './@ember/template/index.d.ts',
- './@ember/test/adapter.d.ts',
- './@ember/test/index.d.ts',
- './@ember/utils/index.d.ts',
- './@ember/utils/lib/compare.d.ts',
- './@ember/utils/lib/is_blank.d.ts',
- './@ember/utils/lib/is_empty.d.ts',
- './@ember/utils/lib/is_none.d.ts',
- './@ember/utils/lib/is_present.d.ts',
- './@ember/utils/lib/is-equal.d.ts',
- './@ember/utils/lib/type-of.d.ts',
- './@ember/version/index.d.ts',
- './@glimmer/tracking/index.d.ts',
- './@glimmer/tracking/primitives/cache.d.ts',
- './ember-template-compiler/index.d.ts',
- './ember-template-compiler/lib/plugins/assert-against-attrs.d.ts',
- './ember-template-compiler/lib/plugins/assert-against-named-outlets.d.ts',
- './ember-template-compiler/lib/plugins/assert-input-helper-without-block.d.ts',
- './ember-template-compiler/lib/plugins/assert-reserved-named-arguments.d.ts',
- './ember-template-compiler/lib/plugins/assert-splattribute-expression.d.ts',
- './ember-template-compiler/lib/plugins/index.d.ts',
- './ember-template-compiler/lib/plugins/transform-action-syntax.d.ts',
- './ember-template-compiler/lib/plugins/transform-each-in-into-each.d.ts',
- './ember-template-compiler/lib/plugins/transform-each-track-array.d.ts',
- './ember-template-compiler/lib/plugins/transform-in-element.d.ts',
- './ember-template-compiler/lib/plugins/transform-quoted-bindings-into-just-bindings.d.ts',
- './ember-template-compiler/lib/plugins/transform-resolutions.d.ts',
- './ember-template-compiler/lib/plugins/transform-wrap-mount-and-outlet.d.ts',
- './ember-template-compiler/lib/plugins/utils.d.ts',
- './ember-template-compiler/lib/system/bootstrap.d.ts',
- './ember-template-compiler/lib/system/calculate-location-display.d.ts',
- './ember-template-compiler/lib/system/compile-options.d.ts',
- './ember-template-compiler/lib/system/compile.d.ts',
- './ember-template-compiler/lib/system/dasherize-component-name.d.ts',
- './ember-template-compiler/lib/system/initializer.d.ts',
- './ember-template-compiler/lib/system/precompile.d.ts',
- './ember-testing/index.d.ts',
- './ember-testing/lib/adapters/adapter.d.ts',
- './ember-testing/lib/adapters/qunit.d.ts',
- './ember-testing/lib/ext/application.d.ts',
- './ember-testing/lib/ext/rsvp.d.ts',
- './ember-testing/lib/helpers.d.ts',
- './ember-testing/lib/helpers/and_then.d.ts',
- './ember-testing/lib/helpers/current_path.d.ts',
- './ember-testing/lib/helpers/current_route_name.d.ts',
- './ember-testing/lib/helpers/current_url.d.ts',
- './ember-testing/lib/helpers/pause_test.d.ts',
- './ember-testing/lib/helpers/visit.d.ts',
- './ember-testing/lib/helpers/wait.d.ts',
- './ember-testing/lib/initializers.d.ts',
- './ember-testing/lib/setup_for_testing.d.ts',
- './ember-testing/lib/test.d.ts',
- './ember-testing/lib/test/adapter.d.ts',
- './ember-testing/lib/test/helpers.d.ts',
- './ember-testing/lib/test/on_inject_helpers.d.ts',
- './ember-testing/lib/test/pending_requests.d.ts',
- './ember-testing/lib/test/promise.d.ts',
- './ember-testing/lib/test/run.d.ts',
- './ember-testing/lib/test/waiters.d.ts',
- './ember/index.d.ts',
+ '@ember/-internals/bootstrap/index.d.ts',
+ '@ember/-internals/browser-environment/index.d.ts',
+ '@ember/-internals/browser-environment/lib/has-dom.d.ts',
+ '@ember/-internals/container/index.d.ts',
+ '@ember/-internals/container/lib/container.d.ts',
+ '@ember/-internals/container/lib/registry.d.ts',
+ '@ember/-internals/environment/index.d.ts',
+ '@ember/-internals/environment/lib/context.d.ts',
+ '@ember/-internals/environment/lib/env.d.ts',
+ '@ember/-internals/environment/lib/global.d.ts',
+ '@ember/-internals/error-handling/index.d.ts',
+ '@ember/-internals/glimmer/index.d.ts',
+ '@ember/-internals/glimmer/lib/component-managers/curly.d.ts',
+ '@ember/-internals/glimmer/lib/component-managers/mount.d.ts',
+ '@ember/-internals/glimmer/lib/component-managers/outlet.d.ts',
+ '@ember/-internals/glimmer/lib/component-managers/root.d.ts',
+ '@ember/-internals/glimmer/lib/component.d.ts',
+ '@ember/-internals/glimmer/lib/components/abstract-input.d.ts',
+ '@ember/-internals/glimmer/lib/components/input.d.ts',
+ '@ember/-internals/glimmer/lib/components/internal.d.ts',
+ '@ember/-internals/glimmer/lib/components/link-to.d.ts',
+ '@ember/-internals/glimmer/lib/components/textarea.d.ts',
+ '@ember/-internals/glimmer/lib/dom.d.ts',
+ '@ember/-internals/glimmer/lib/environment.d.ts',
+ '@ember/-internals/glimmer/lib/glimmer-component-docs.d.ts',
+ '@ember/-internals/glimmer/lib/glimmer-tracking-docs.d.ts',
+ '@ember/-internals/glimmer/lib/helper.d.ts',
+ '@ember/-internals/glimmer/lib/helpers/-disallow-dynamic-resolution.d.ts',
+ '@ember/-internals/glimmer/lib/helpers/-in-element-null-check.d.ts',
+ '@ember/-internals/glimmer/lib/helpers/-normalize-class.d.ts',
+ '@ember/-internals/glimmer/lib/helpers/-resolve.d.ts',
+ '@ember/-internals/glimmer/lib/helpers/-track-array.d.ts',
+ '@ember/-internals/glimmer/lib/helpers/action.d.ts',
+ '@ember/-internals/glimmer/lib/helpers/array.d.ts',
+ '@ember/-internals/glimmer/lib/helpers/component.d.ts',
+ '@ember/-internals/glimmer/lib/helpers/concat.d.ts',
+ '@ember/-internals/glimmer/lib/helpers/each-in.d.ts',
+ '@ember/-internals/glimmer/lib/helpers/fn.d.ts',
+ '@ember/-internals/glimmer/lib/helpers/get.d.ts',
+ '@ember/-internals/glimmer/lib/helpers/hash.d.ts',
+ '@ember/-internals/glimmer/lib/helpers/helper.d.ts',
+ '@ember/-internals/glimmer/lib/helpers/if-unless.d.ts',
+ '@ember/-internals/glimmer/lib/helpers/internal-helper.d.ts',
+ '@ember/-internals/glimmer/lib/helpers/log.d.ts',
+ '@ember/-internals/glimmer/lib/helpers/modifier.d.ts',
+ '@ember/-internals/glimmer/lib/helpers/mut.d.ts',
+ '@ember/-internals/glimmer/lib/helpers/page-title.d.ts',
+ '@ember/-internals/glimmer/lib/helpers/readonly.d.ts',
+ '@ember/-internals/glimmer/lib/helpers/unbound.d.ts',
+ '@ember/-internals/glimmer/lib/helpers/unique-id.d.ts',
+ '@ember/-internals/glimmer/lib/modifiers/action.d.ts',
+ '@ember/-internals/glimmer/lib/modifiers/internal.d.ts',
+ '@ember/-internals/glimmer/lib/modifiers/on.d.ts',
+ '@ember/-internals/glimmer/lib/renderer.d.ts',
+ '@ember/-internals/glimmer/lib/resolver.d.ts',
+ '@ember/-internals/glimmer/lib/setup-registry.d.ts',
+ '@ember/-internals/glimmer/lib/syntax/in-element.d.ts',
+ '@ember/-internals/glimmer/lib/syntax/let.d.ts',
+ '@ember/-internals/glimmer/lib/syntax/mount.d.ts',
+ '@ember/-internals/glimmer/lib/syntax/outlet.d.ts',
+ '@ember/-internals/glimmer/lib/syntax/utils.d.ts',
+ '@ember/-internals/glimmer/lib/template_registry.d.ts',
+ '@ember/-internals/glimmer/lib/template.d.ts',
+ '@ember/-internals/glimmer/lib/utils/bindings.d.ts',
+ '@ember/-internals/glimmer/lib/utils/curly-component-state-bucket.d.ts',
+ '@ember/-internals/glimmer/lib/utils/debug-render-message.d.ts',
+ '@ember/-internals/glimmer/lib/utils/iterator.d.ts',
+ '@ember/-internals/glimmer/lib/utils/managers.d.ts',
+ '@ember/-internals/glimmer/lib/utils/outlet.d.ts',
+ '@ember/-internals/glimmer/lib/utils/process-args.d.ts',
+ '@ember/-internals/glimmer/lib/utils/serialization-first-node-helpers.d.ts',
+ '@ember/-internals/glimmer/lib/utils/string.d.ts',
+ '@ember/-internals/glimmer/lib/utils/to-bool.d.ts',
+ '@ember/-internals/glimmer/lib/views/outlet.d.ts',
+ '@ember/-internals/meta/index.d.ts',
+ '@ember/-internals/meta/lib/meta.d.ts',
+ '@ember/-internals/metal/index.d.ts',
+ '@ember/-internals/metal/lib/alias.d.ts',
+ '@ember/-internals/metal/lib/array_events.d.ts',
+ '@ember/-internals/metal/lib/array.d.ts',
+ '@ember/-internals/metal/lib/cache.d.ts',
+ '@ember/-internals/metal/lib/cached.d.ts',
+ '@ember/-internals/metal/lib/chain-tags.d.ts',
+ '@ember/-internals/metal/lib/change_event.d.ts',
+ '@ember/-internals/metal/lib/computed_cache.d.ts',
+ '@ember/-internals/metal/lib/computed.d.ts',
+ '@ember/-internals/metal/lib/decorator.d.ts',
+ '@ember/-internals/metal/lib/dependent_keys.d.ts',
+ '@ember/-internals/metal/lib/deprecate_property.d.ts',
+ '@ember/-internals/metal/lib/each_proxy_events.d.ts',
+ '@ember/-internals/metal/lib/events.d.ts',
+ '@ember/-internals/metal/lib/expand_properties.d.ts',
+ '@ember/-internals/metal/lib/get_properties.d.ts',
+ '@ember/-internals/metal/lib/injected_property.d.ts',
+ '@ember/-internals/metal/lib/libraries.d.ts',
+ '@ember/-internals/metal/lib/namespace_search.d.ts',
+ '@ember/-internals/metal/lib/observer.d.ts',
+ '@ember/-internals/metal/lib/path_cache.d.ts',
+ '@ember/-internals/metal/lib/properties.d.ts',
+ '@ember/-internals/metal/lib/property_events.d.ts',
+ '@ember/-internals/metal/lib/property_get.d.ts',
+ '@ember/-internals/metal/lib/property_set.d.ts',
+ '@ember/-internals/metal/lib/set_properties.d.ts',
+ '@ember/-internals/metal/lib/tags.d.ts',
+ '@ember/-internals/metal/lib/tracked.d.ts',
+ '@ember/-internals/overrides/index.d.ts',
+ '@ember/-internals/owner/index.d.ts',
+ '@ember/-internals/routing/index.d.ts',
+ '@ember/-internals/runtime/index.d.ts',
+ '@ember/-internals/runtime/lib/ext/rsvp.d.ts',
+ '@ember/-internals/runtime/lib/mixins/-proxy.d.ts',
+ '@ember/-internals/runtime/lib/mixins/action_handler.d.ts',
+ '@ember/-internals/runtime/lib/mixins/comparable.d.ts',
+ '@ember/-internals/runtime/lib/mixins/container_proxy.d.ts',
+ '@ember/-internals/runtime/lib/mixins/registry_proxy.d.ts',
+ '@ember/-internals/runtime/lib/mixins/target_action_support.d.ts',
+ '@ember/-internals/utils/index.d.ts',
+ '@ember/-internals/utils/lib/cache.d.ts',
+ '@ember/-internals/utils/lib/dictionary.d.ts',
+ '@ember/-internals/utils/lib/ember-array.d.ts',
+ '@ember/-internals/utils/lib/get-debug-name.d.ts',
+ '@ember/-internals/utils/lib/guid.d.ts',
+ '@ember/-internals/utils/lib/inspect.d.ts',
+ '@ember/-internals/utils/lib/intern.d.ts',
+ '@ember/-internals/utils/lib/invoke.d.ts',
+ '@ember/-internals/utils/lib/is_proxy.d.ts',
+ '@ember/-internals/utils/lib/lookup-descriptor.d.ts',
+ '@ember/-internals/utils/lib/make-array.d.ts',
+ '@ember/-internals/utils/lib/mandatory-setter.d.ts',
+ '@ember/-internals/utils/lib/name.d.ts',
+ '@ember/-internals/utils/lib/spec.d.ts',
+ '@ember/-internals/utils/lib/super.d.ts',
+ '@ember/-internals/utils/lib/symbol.d.ts',
+ '@ember/-internals/utils/lib/to-string.d.ts',
+ '@ember/-internals/utils/types.d.ts',
+ '@ember/-internals/views/index.d.ts',
+ '@ember/-internals/views/lib/compat/attrs.d.ts',
+ '@ember/-internals/views/lib/compat/fallback-view-registry.d.ts',
+ '@ember/-internals/views/lib/component_lookup.d.ts',
+ '@ember/-internals/views/lib/mixins/action_support.d.ts',
+ '@ember/-internals/views/lib/mixins/child_views_support.d.ts',
+ '@ember/-internals/views/lib/mixins/class_names_support.d.ts',
+ '@ember/-internals/views/lib/mixins/view_state_support.d.ts',
+ '@ember/-internals/views/lib/mixins/view_support.d.ts',
+ '@ember/-internals/views/lib/system/action_manager.d.ts',
+ '@ember/-internals/views/lib/system/event_dispatcher.d.ts',
+ '@ember/-internals/views/lib/system/utils.d.ts',
+ '@ember/-internals/views/lib/views/core_view.d.ts',
+ '@ember/-internals/views/lib/views/states.d.ts',
+ '@ember/-internals/views/lib/views/states/default.d.ts',
+ '@ember/-internals/views/lib/views/states/destroying.d.ts',
+ '@ember/-internals/views/lib/views/states/has_element.d.ts',
+ '@ember/-internals/views/lib/views/states/in_dom.d.ts',
+ '@ember/-internals/views/lib/views/states/pre_render.d.ts',
+ '@ember/application/index.d.ts',
+ '@ember/application/instance.d.ts',
+ '@ember/application/lib/lazy_load.d.ts',
+ '@ember/application/namespace.d.ts',
+ '@ember/array/index.d.ts',
+ '@ember/array/mutable.d.ts',
+ '@ember/array/proxy.d.ts',
+ '@ember/canary-features/index.d.ts',
+ '@ember/component/helper.d.ts',
+ '@ember/component/index.d.ts',
+ '@ember/component/template-only.d.ts',
+ '@ember/controller/index.d.ts',
+ '@ember/debug/container-debug-adapter.d.ts',
+ '@ember/debug/data-adapter.d.ts',
+ '@ember/debug/index.d.ts',
+ '@ember/debug/lib/capture-render-tree.d.ts',
+ '@ember/debug/lib/deprecate.d.ts',
+ '@ember/debug/lib/handlers.d.ts',
+ '@ember/debug/lib/testing.d.ts',
+ '@ember/debug/lib/warn.d.ts',
+ '@ember/deprecated-features/index.d.ts',
+ '@ember/destroyable/index.d.ts',
+ '@ember/engine/index.d.ts',
+ '@ember/engine/instance.d.ts',
+ '@ember/engine/lib/engine-parent.d.ts',
+ '@ember/enumerable/index.d.ts',
+ '@ember/enumerable/mutable.d.ts',
+ '@ember/error/index.d.ts',
+ '@ember/helper/index.d.ts',
+ '@ember/instrumentation/index.d.ts',
+ '@ember/modifier/index.d.ts',
+ '@ember/object/-internals.d.ts',
+ '@ember/object/compat.d.ts',
+ '@ember/object/computed.d.ts',
+ '@ember/object/core.d.ts',
+ '@ember/object/evented.d.ts',
+ '@ember/object/events.d.ts',
+ '@ember/object/index.d.ts',
+ '@ember/object/internals.d.ts',
+ '@ember/object/lib/computed/computed_macros.d.ts',
+ '@ember/object/lib/computed/reduce_computed_macros.d.ts',
+ '@ember/object/mixin.d.ts',
+ '@ember/object/observable.d.ts',
+ '@ember/object/observers.d.ts',
+ '@ember/object/promise-proxy-mixin.d.ts',
+ '@ember/object/proxy.d.ts',
+ '@ember/owner/index.d.ts',
+ '@ember/polyfills/index.d.ts',
+ '@ember/polyfills/lib/assign.d.ts',
+ '@ember/renderer/index.d.ts',
+ '@ember/routing/-internals.d.ts',
+ '@ember/routing/auto-location.d.ts',
+ '@ember/routing/hash-location.d.ts',
+ '@ember/routing/history-location.d.ts',
+ '@ember/routing/index.d.ts',
+ '@ember/routing/lib/cache.d.ts',
+ '@ember/routing/lib/controller_for.d.ts',
+ '@ember/routing/lib/dsl.d.ts',
+ '@ember/routing/lib/engines.d.ts',
+ '@ember/routing/lib/generate_controller.d.ts',
+ '@ember/routing/lib/location-utils.d.ts',
+ '@ember/routing/lib/query_params.d.ts',
+ '@ember/routing/lib/route-info.d.ts',
+ '@ember/routing/lib/router_state.d.ts',
+ '@ember/routing/lib/routing-service.d.ts',
+ '@ember/routing/lib/transition.d.ts',
+ '@ember/routing/lib/utils.d.ts',
+ '@ember/routing/location.d.ts',
+ '@ember/routing/none-location.d.ts',
+ '@ember/routing/route-info.d.ts',
+ '@ember/routing/route.d.ts',
+ '@ember/routing/router-service.d.ts',
+ '@ember/routing/router.d.ts',
+ '@ember/routing/transition.d.ts',
+ '@ember/runloop/index.d.ts',
+ '@ember/service/index.d.ts',
+ '@ember/string/index.d.ts',
+ '@ember/string/lib/string_registry.d.ts',
+ '@ember/template-compilation/index.d.ts',
+ '@ember/template-factory/index.d.ts',
+ '@ember/template/index.d.ts',
+ '@ember/test/adapter.d.ts',
+ '@ember/test/index.d.ts',
+ '@ember/utils/index.d.ts',
+ '@ember/utils/lib/compare.d.ts',
+ '@ember/utils/lib/is_blank.d.ts',
+ '@ember/utils/lib/is_empty.d.ts',
+ '@ember/utils/lib/is_none.d.ts',
+ '@ember/utils/lib/is_present.d.ts',
+ '@ember/utils/lib/is-equal.d.ts',
+ '@ember/utils/lib/type-of.d.ts',
+ '@ember/version/index.d.ts',
+ '@glimmer/tracking/index.d.ts',
+ '@glimmer/tracking/primitives/cache.d.ts',
+ 'ember-template-compiler/index.d.ts',
+ 'ember-template-compiler/lib/plugins/assert-against-attrs.d.ts',
+ 'ember-template-compiler/lib/plugins/assert-against-named-outlets.d.ts',
+ 'ember-template-compiler/lib/plugins/assert-input-helper-without-block.d.ts',
+ 'ember-template-compiler/lib/plugins/assert-reserved-named-arguments.d.ts',
+ 'ember-template-compiler/lib/plugins/assert-splattribute-expression.d.ts',
+ 'ember-template-compiler/lib/plugins/index.d.ts',
+ 'ember-template-compiler/lib/plugins/transform-action-syntax.d.ts',
+ 'ember-template-compiler/lib/plugins/transform-each-in-into-each.d.ts',
+ 'ember-template-compiler/lib/plugins/transform-each-track-array.d.ts',
+ 'ember-template-compiler/lib/plugins/transform-in-element.d.ts',
+ 'ember-template-compiler/lib/plugins/transform-quoted-bindings-into-just-bindings.d.ts',
+ 'ember-template-compiler/lib/plugins/transform-resolutions.d.ts',
+ 'ember-template-compiler/lib/plugins/transform-wrap-mount-and-outlet.d.ts',
+ 'ember-template-compiler/lib/plugins/utils.d.ts',
+ 'ember-template-compiler/lib/system/bootstrap.d.ts',
+ 'ember-template-compiler/lib/system/calculate-location-display.d.ts',
+ 'ember-template-compiler/lib/system/compile-options.d.ts',
+ 'ember-template-compiler/lib/system/compile.d.ts',
+ 'ember-template-compiler/lib/system/dasherize-component-name.d.ts',
+ 'ember-template-compiler/lib/system/initializer.d.ts',
+ 'ember-template-compiler/lib/system/precompile.d.ts',
+ 'ember-testing/index.d.ts',
+ 'ember-testing/lib/adapters/adapter.d.ts',
+ 'ember-testing/lib/adapters/qunit.d.ts',
+ 'ember-testing/lib/ext/application.d.ts',
+ 'ember-testing/lib/ext/rsvp.d.ts',
+ 'ember-testing/lib/helpers.d.ts',
+ 'ember-testing/lib/helpers/and_then.d.ts',
+ 'ember-testing/lib/helpers/current_path.d.ts',
+ 'ember-testing/lib/helpers/current_route_name.d.ts',
+ 'ember-testing/lib/helpers/current_url.d.ts',
+ 'ember-testing/lib/helpers/pause_test.d.ts',
+ 'ember-testing/lib/helpers/visit.d.ts',
+ 'ember-testing/lib/helpers/wait.d.ts',
+ 'ember-testing/lib/initializers.d.ts',
+ 'ember-testing/lib/setup_for_testing.d.ts',
+ 'ember-testing/lib/test.d.ts',
+ 'ember-testing/lib/test/adapter.d.ts',
+ 'ember-testing/lib/test/helpers.d.ts',
+ 'ember-testing/lib/test/on_inject_helpers.d.ts',
+ 'ember-testing/lib/test/pending_requests.d.ts',
+ 'ember-testing/lib/test/promise.d.ts',
+ 'ember-testing/lib/test/run.d.ts',
+ 'ember-testing/lib/test/waiters.d.ts',
+ 'ember/index.d.ts',
];
const MODULES_PLACEHOLDER = '~~~MODULES GO HERE~~~';
@@ -410,8 +413,19 @@ async function main() {
}
let sideEffectModules = moduleNames
- .filter((module) => !PREVIEW_MODULES.includes(module))
- .map((moduleName) => `import './${moduleName}';`)
+ .filter((moduleName) => !PREVIEW_MODULES.includes(moduleName))
+ .map((moduleName) => {
+ // We need to import "package root" types as such, *not* via the actual
+ // module which provides them, or TS does not see them correctly via the
+ // side effect imports, so transform them accordingly:
+ // `@ember/owner/index.d.ts` -> `@ember/owner`
+ let moduleOrPackagePath = moduleName.replace(/\/index.d.ts$/, '');
+
+ // Then create a relative path *to* the path on disk so that the
+ // side-effect import is e.g. `import './@ember/owner';`, which makes it
+ // resolve the actual local file, *not* go looking for some other package.
+ return `import './${moduleOrPackagePath}';`;
+ })
.join('\n');
let stableIndexDTsContents = BASE_INDEX_D_TS.replace(MODULES_PLACEHOLDER, sideEffectModules);
@@ -438,8 +452,16 @@ function wrapInDeclareModule(moduleName) {
let moduleNameForDeclaration = moduleName.replace('/index.d.ts', '');
+ // This is a horrible nightmare of a hack; in a later PR I'm going to just
+ // replace all of this by going ahead and using recast or such. As annoying as
+ // that will be, it will be *way* more reliable.
let string = new MagicString(contents);
- string.indent(' ').prepend(`declare module '${moduleNameForDeclaration}' {\n`).append('}\n');
+ string
+ .replaceAll(/^export declare /gm, 'export ') // g for global, m for multiline
+ .replaceAll(/^declare /gm, '') // g for global, m for multiline
+ .indent(' ')
+ .prepend(`declare module '${moduleNameForDeclaration}' {\n`)
+ .append('}\n');
try {
fs.writeFileSync(modulePath, string.toString()); | false |
Other | emberjs | ember.js | 32003505c1908c68f35e0504a8df297949db62dc.json | Add 4.10.0-beta.1 to CHANGELOG
(cherry picked from commit 107e7e9fe2df133a7918c5198725601c3462e66f) | CHANGELOG.md | @@ -1,5 +1,10 @@
# Ember Changelog
+### v4.10.0-beta.1 (November 28, 2022)
+
+- [#20253](https://github.com/emberjs/ember.js/pull/20253) [FEATURE] Add the `Resolver` type to preview types
+- [#20270](https://github.com/emberjs/ember.js/pull/20270) / [#20271](https://github.com/emberjs/ember.js/pull/20271) [FEATURE] Add new imports for `getOwner` and `setOwner` from `@ember/owner` and introduce new `@ember/routing` sub-modules as part of [RFC #821](https://rfcs.emberjs.com/id/0821-public-types).
+
### v4.9.0 (November 28, 2022)
- [#20274](https://github.com/emberjs/ember.js/pull/20274) [BUGFIX] Add some missing types to preview types | false |
Other | emberjs | ember.js | 70b98dac9e0b54b498c85d68162b560580654bc9.json | Add v4.9.0 to CHANGELOG
(cherry picked from commit 4d4200dfe09d79a5b836123916701daddb7f3dd2) | CHANGELOG.md | @@ -1,22 +1,21 @@
# Ember Changelog
-### v4.9.0-beta.4 (November 15, 2022)
+### v4.9.0 (November 28, 2022)
+- [#20274](https://github.com/emberjs/ember.js/pull/20274) [BUGFIX] Add some missing types to preview types
- [#20256](https://github.com/emberjs/ember.js/pull/20256) [BUGFIX] Correct types for Ember Arrays
- [#20257](https://github.com/emberjs/ember.js/pull/20257) [BUGFIX] Fix types for `getOwner` and GlimmerComponent
+- [#20233](https://github.com/emberjs/ember.js/pull/20233) [BUGFIX] Include package name in deprecation error message
+- [#20235](https://github.com/emberjs/ember.js/pull/20235) [BUGFIX] Update `@types/node` for TS 4.9 issue
+- [#20238](https://github.com/emberjs/ember.js/pull/20238) [BUGFIX] Update Node.js versions to match support policy
+- [#20227](https://github.com/emberjs/ember.js/pull/20227) [BUGFIX] Fix unsafe internal cast for NativeArray
+- [#20228](https://github.com/emberjs/ember.js/pull/20228) [BUGFIX] Remove type export for ControllerMixin
+- [#20203](https://github.com/emberjs/ember.js/pull/20203) / [#20204](https://github.com/emberjs/ember.js/pull/20204) [FEATURE] Preview types: Update to Typescript 4.8
### v4.8.2 (November 3, 2022)
- [#20244](https://github.com/emberjs/ember.js/pull/20244) Add missing type for `getComponentTemplate` to preview types
-### v4.9.0-beta.3 (November 2, 2022)
-
-- [CVE pending](https://emberjs.com/blog/ember-4-8-1-released) Fix a prototype pollution vulnerability in `set` and `setProperties`
-- [#20233](https://github.com/emberjs/ember.js/pull/20233) [BUGFIX] Include package name in deprecation error message
-- [#20235](https://github.com/emberjs/ember.js/pull/20235) [BUGFIX] Update `@types/node` for TS 4.9 issue
-- [#20238](https://github.com/emberjs/ember.js/pull/20238) [BUGFIX] Update Node.js versions to match support policy
-- [#20244](https://github.com/emberjs/ember.js/pull/20244) [BUGFIX] Expose getComponentTemplate type
-
### v4.8.1 (November 2, 2022)
- [CVE pending](https://emberjs.com/blog/ember-4-8-1-released) Fix a prototype pollution vulnerability in `set` and `setProperties`
@@ -33,15 +32,6 @@
- [CVE pending](https://emberjs.com/blog/ember-4-8-1-released) Fix a prototype pollution vulnerability in `set` and `setProperties`
-### v4.9.0-beta.2 (October 25, 2022)
-
-- [#20227](https://github.com/emberjs/ember.js/pull/20227) [BUGFIX] Fix unsafe internal cast for NativeArray
-- [#20228](https://github.com/emberjs/ember.js/pull/20228) [BUGFIX] Remove type export for ControllerMixin
-
-### v4.9.0-beta.1 (October 17, 2022)
-
-- [#20203](https://github.com/emberjs/ember.js/pull/20203) / [#20204](https://github.com/emberjs/ember.js/pull/20204) [FEATURE] Preview types: Update to Typescript 4.8
-
### v4.8.0 (October 17, 2022)
- [#20180](https://github.com/emberjs/ember.js/pull/20180) [FEATURE] Publish an opt-in preview of public types for Ember | false |
Other | emberjs | ember.js | 7bef3141fa8ed1c82f213e5d95a661186b9324cd.json | Fix typo in internal comments for @ember/object
Co-authored-by: Dan Freeman <dfreeman@salsify.com> | packages/@ember/object/-internals.ts | @@ -13,7 +13,7 @@ import EmberObject from '.';
// binding below for `FrameworkObject`, TS gets stuck because this creates
// `FrameworkObject` with a class expression (rather than the usual class
// declaration form). That in turn means TS needs to be able to fully name the
-// type produced by the clsas expression, which includes the `OWNER` symbol from
+// type produced by the class expression, which includes the `OWNER` symbol from
// `@glimmer/owner`.
//
// By explicitly giving the declaration a type when assigning it the class | false |
Other | emberjs | ember.js | f37f561ac5a333d577749cb80c37b17ecdfef5c0.json | Fix incomplete sentence in stable types module doc | types/publish.mjs | @@ -369,7 +369,7 @@ const BASE_INDEX_D_TS = `\
// same work, but automatically.
// STATUS NOTE: this does not yet include Ember's full public API, only the
-// subset of it for which we have determined
+// subset of it for which we have determined the types are ready to stabilize.
//
// Over time, it will come to include *all* of Ember's types, and the matching
// \`preview\` types will become empty. This is means that someone who writes the | false |
Other | emberjs | ember.js | 845b60e84d06ba123064c9b451ee8614060d2c93.json | Introduce a script to publish stable types
Provide a script which runs the compiler against a new tsconfig for
generating types, wraps all the generated modules in `declare module`
statements, and then creates an `index.d.ts` which uses side-effect
style imports to expose them all, just the same as the preview types
but generated from source.
Critically, this infrastructure does not expose *any* stable types in
and of itself. Instead, it introduces a list of all the types still in
preview mode which acts as a filter, and currently *all* modules are in
that filter. Stabilizing the types for a given module will mean
removing modules from that list and removing the corresponding preview
types definitions. | package.json | @@ -35,6 +35,7 @@
"scripts": {
"build": "ember build --environment production",
"docs": "ember ember-cli-yuidoc",
+ "types": "tsc --project tsconfig/publish-types.json && node types/publish.mjs",
"link:glimmer": "node bin/yarn-link-glimmer.js",
"start": "ember serve",
"lint": "npm-run-all --continue-on-error --aggregate-output --parallel \"lint:!(fix)\"",
@@ -143,6 +144,7 @@
"glob": "^8.0.3",
"html-differ": "^1.4.0",
"lodash.uniq": "^4.5.0",
+ "magic-string": "^0.26.7",
"mkdirp": "^1.0.4",
"mocha": "^9.2.2",
"npm-run-all": "^4.1.5", | true |
Other | emberjs | ember.js | 845b60e84d06ba123064c9b451ee8614060d2c93.json | Introduce a script to publish stable types
Provide a script which runs the compiler against a new tsconfig for
generating types, wraps all the generated modules in `declare module`
statements, and then creates an `index.d.ts` which uses side-effect
style imports to expose them all, just the same as the preview types
but generated from source.
Critically, this infrastructure does not expose *any* stable types in
and of itself. Instead, it introduces a list of all the types still in
preview mode which acts as a filter, and currently *all* modules are in
that filter. Stabilizing the types for a given module will mean
removing modules from that list and removing the corresponding preview
types definitions. | tsconfig/publish-types.json | @@ -0,0 +1,31 @@
+{
+ "$schema": "https://json.schemastore.org/tsconfig",
+ "extends": "./compiler-options.json",
+ "compilerOptions": {
+ "noEmit": false,
+ "declaration": true,
+ "emitDeclarationOnly": true,
+ // It'd be really nice to be able to supply sourcemaps, and at some point we
+ // will be able to by using e.g. rollup-plugin-ts once we solve other issues
+ // blocking that in our publishing pipeline by way of circular and repeated
+ // dependencies in the graph, but at the moment we are using `magic-string`
+ // to post-process these to add `declare module` declarations (see the
+ // `types/publish.mjs` script or details), and that doesn't support updating
+ // *existing* source maps, unfortunately.
+ "declarationMap": false,
+ "declarationDir": "../types/stable"
+ },
+ "include": [
+ // Note: these will also pull on all their transitive dependencies, so we
+ // will end up publishing the (private!) types for packages not named here
+ // until we update the actual internals to avoid referencing them!
+ "../packages/@ember/**/*",
+ "../packages/ember/**/*",
+ "../packages/@glimmer/**/*"
+ ],
+ "exclude": [
+ "../**/type-tests",
+ "../**/tests",
+ "../**/internal-test-helpers"
+ ]
+} | true |
Other | emberjs | ember.js | 845b60e84d06ba123064c9b451ee8614060d2c93.json | Introduce a script to publish stable types
Provide a script which runs the compiler against a new tsconfig for
generating types, wraps all the generated modules in `declare module`
statements, and then creates an `index.d.ts` which uses side-effect
style imports to expose them all, just the same as the preview types
but generated from source.
Critically, this infrastructure does not expose *any* stable types in
and of itself. Instead, it introduces a list of all the types still in
preview mode which acts as a filter, and currently *all* modules are in
that filter. Stabilizing the types for a given module will mean
removing modules from that list and removing the corresponding preview
types definitions. | types/publish.mjs | @@ -0,0 +1,443 @@
+#!/usr/bin/env node
+// @ts-check
+
+/**
+ This script is used to publish Ember's type definitions. The basic workflow
+ is:
+
+ 1. Run `tsc` against the Ember packages which make up its public API, with
+ the output being `/types/stable`.
+
+ 2. Wrap each emitted module in a `declare module` statement. While doing so,
+ keep track of the full list of emitted modules.
+
+ 3. Check that each module emitted is included in `types/stable/index.d.ts`,
+ if and only if it also appears in a list of stable types modules defined
+ in this script, so that they all "show up" to end users. That list will
+ eventually be the list of *all* modules, but this allows us to publish
+ iteratively as we gain confidence in the stability of the types.
+
+ This is *not* an optimal long-term publishing strategy. We would prefer to
+ generate per-package roll-ups, using a Rollup plugin or some such, but we are
+ currently blocked on a number of internal circular dependencies as well as
+ the difficulty of avoiding multiple definitions of the same types reused
+ across many rollups.
+
+ @packageDocumentation
+ */
+
+import glob from 'glob';
+import { spawnSync } from 'node:child_process';
+import fs from 'node:fs';
+import path from 'node:path';
+import MagicString from 'magic-string';
+
+/**
+ Modules we know we are not ready to expose yet, mostly because they do not
+ have enough annotations on their internals to make the generated types clear
+ about what is public and what is private.
+
+ Notably, the modules will still be published, but they won't be visible to
+ consumers because the only way they *become* visible is by being included in
+ the set of type-only side effect imports, which excludes exactly these
+ modules.
+ */
+const PREVIEW_MODULES = [
+ './@ember/-internals/bootstrap/index.d.ts',
+ './@ember/-internals/browser-environment/index.d.ts',
+ './@ember/-internals/browser-environment/lib/has-dom.d.ts',
+ './@ember/-internals/container/index.d.ts',
+ './@ember/-internals/container/lib/container.d.ts',
+ './@ember/-internals/container/lib/registry.d.ts',
+ './@ember/-internals/environment/index.d.ts',
+ './@ember/-internals/environment/lib/context.d.ts',
+ './@ember/-internals/environment/lib/env.d.ts',
+ './@ember/-internals/environment/lib/global.d.ts',
+ './@ember/-internals/error-handling/index.d.ts',
+ './@ember/-internals/glimmer/index.d.ts',
+ './@ember/-internals/glimmer/lib/component-managers/curly.d.ts',
+ './@ember/-internals/glimmer/lib/component-managers/mount.d.ts',
+ './@ember/-internals/glimmer/lib/component-managers/outlet.d.ts',
+ './@ember/-internals/glimmer/lib/component-managers/root.d.ts',
+ './@ember/-internals/glimmer/lib/component.d.ts',
+ './@ember/-internals/glimmer/lib/components/abstract-input.d.ts',
+ './@ember/-internals/glimmer/lib/components/input.d.ts',
+ './@ember/-internals/glimmer/lib/components/internal.d.ts',
+ './@ember/-internals/glimmer/lib/components/link-to.d.ts',
+ './@ember/-internals/glimmer/lib/components/textarea.d.ts',
+ './@ember/-internals/glimmer/lib/dom.d.ts',
+ './@ember/-internals/glimmer/lib/environment.d.ts',
+ './@ember/-internals/glimmer/lib/glimmer-component-docs.d.ts',
+ './@ember/-internals/glimmer/lib/glimmer-tracking-docs.d.ts',
+ './@ember/-internals/glimmer/lib/helper.d.ts',
+ './@ember/-internals/glimmer/lib/helpers/-disallow-dynamic-resolution.d.ts',
+ './@ember/-internals/glimmer/lib/helpers/-in-element-null-check.d.ts',
+ './@ember/-internals/glimmer/lib/helpers/-normalize-class.d.ts',
+ './@ember/-internals/glimmer/lib/helpers/-resolve.d.ts',
+ './@ember/-internals/glimmer/lib/helpers/-track-array.d.ts',
+ './@ember/-internals/glimmer/lib/helpers/action.d.ts',
+ './@ember/-internals/glimmer/lib/helpers/array.d.ts',
+ './@ember/-internals/glimmer/lib/helpers/component.d.ts',
+ './@ember/-internals/glimmer/lib/helpers/concat.d.ts',
+ './@ember/-internals/glimmer/lib/helpers/each-in.d.ts',
+ './@ember/-internals/glimmer/lib/helpers/fn.d.ts',
+ './@ember/-internals/glimmer/lib/helpers/get.d.ts',
+ './@ember/-internals/glimmer/lib/helpers/hash.d.ts',
+ './@ember/-internals/glimmer/lib/helpers/helper.d.ts',
+ './@ember/-internals/glimmer/lib/helpers/if-unless.d.ts',
+ './@ember/-internals/glimmer/lib/helpers/internal-helper.d.ts',
+ './@ember/-internals/glimmer/lib/helpers/log.d.ts',
+ './@ember/-internals/glimmer/lib/helpers/modifier.d.ts',
+ './@ember/-internals/glimmer/lib/helpers/mut.d.ts',
+ './@ember/-internals/glimmer/lib/helpers/page-title.d.ts',
+ './@ember/-internals/glimmer/lib/helpers/readonly.d.ts',
+ './@ember/-internals/glimmer/lib/helpers/unbound.d.ts',
+ './@ember/-internals/glimmer/lib/helpers/unique-id.d.ts',
+ './@ember/-internals/glimmer/lib/modifiers/action.d.ts',
+ './@ember/-internals/glimmer/lib/modifiers/internal.d.ts',
+ './@ember/-internals/glimmer/lib/modifiers/on.d.ts',
+ './@ember/-internals/glimmer/lib/renderer.d.ts',
+ './@ember/-internals/glimmer/lib/resolver.d.ts',
+ './@ember/-internals/glimmer/lib/setup-registry.d.ts',
+ './@ember/-internals/glimmer/lib/syntax/in-element.d.ts',
+ './@ember/-internals/glimmer/lib/syntax/let.d.ts',
+ './@ember/-internals/glimmer/lib/syntax/mount.d.ts',
+ './@ember/-internals/glimmer/lib/syntax/outlet.d.ts',
+ './@ember/-internals/glimmer/lib/syntax/utils.d.ts',
+ './@ember/-internals/glimmer/lib/template_registry.d.ts',
+ './@ember/-internals/glimmer/lib/template.d.ts',
+ './@ember/-internals/glimmer/lib/utils/bindings.d.ts',
+ './@ember/-internals/glimmer/lib/utils/curly-component-state-bucket.d.ts',
+ './@ember/-internals/glimmer/lib/utils/debug-render-message.d.ts',
+ './@ember/-internals/glimmer/lib/utils/iterator.d.ts',
+ './@ember/-internals/glimmer/lib/utils/managers.d.ts',
+ './@ember/-internals/glimmer/lib/utils/outlet.d.ts',
+ './@ember/-internals/glimmer/lib/utils/process-args.d.ts',
+ './@ember/-internals/glimmer/lib/utils/serialization-first-node-helpers.d.ts',
+ './@ember/-internals/glimmer/lib/utils/string.d.ts',
+ './@ember/-internals/glimmer/lib/utils/to-bool.d.ts',
+ './@ember/-internals/glimmer/lib/views/outlet.d.ts',
+ './@ember/-internals/meta/index.d.ts',
+ './@ember/-internals/meta/lib/meta.d.ts',
+ './@ember/-internals/metal/index.d.ts',
+ './@ember/-internals/metal/lib/alias.d.ts',
+ './@ember/-internals/metal/lib/array_events.d.ts',
+ './@ember/-internals/metal/lib/array.d.ts',
+ './@ember/-internals/metal/lib/cache.d.ts',
+ './@ember/-internals/metal/lib/cached.d.ts',
+ './@ember/-internals/metal/lib/chain-tags.d.ts',
+ './@ember/-internals/metal/lib/change_event.d.ts',
+ './@ember/-internals/metal/lib/computed_cache.d.ts',
+ './@ember/-internals/metal/lib/computed.d.ts',
+ './@ember/-internals/metal/lib/decorator.d.ts',
+ './@ember/-internals/metal/lib/dependent_keys.d.ts',
+ './@ember/-internals/metal/lib/deprecate_property.d.ts',
+ './@ember/-internals/metal/lib/each_proxy_events.d.ts',
+ './@ember/-internals/metal/lib/events.d.ts',
+ './@ember/-internals/metal/lib/expand_properties.d.ts',
+ './@ember/-internals/metal/lib/get_properties.d.ts',
+ './@ember/-internals/metal/lib/injected_property.d.ts',
+ './@ember/-internals/metal/lib/libraries.d.ts',
+ './@ember/-internals/metal/lib/namespace_search.d.ts',
+ './@ember/-internals/metal/lib/observer.d.ts',
+ './@ember/-internals/metal/lib/path_cache.d.ts',
+ './@ember/-internals/metal/lib/properties.d.ts',
+ './@ember/-internals/metal/lib/property_events.d.ts',
+ './@ember/-internals/metal/lib/property_get.d.ts',
+ './@ember/-internals/metal/lib/property_set.d.ts',
+ './@ember/-internals/metal/lib/set_properties.d.ts',
+ './@ember/-internals/metal/lib/tags.d.ts',
+ './@ember/-internals/metal/lib/tracked.d.ts',
+ './@ember/-internals/overrides/index.d.ts',
+ './@ember/-internals/owner/index.d.ts',
+ './@ember/-internals/routing/index.d.ts',
+ './@ember/-internals/runtime/index.d.ts',
+ './@ember/-internals/runtime/lib/ext/rsvp.d.ts',
+ './@ember/-internals/runtime/lib/mixins/-proxy.d.ts',
+ './@ember/-internals/runtime/lib/mixins/action_handler.d.ts',
+ './@ember/-internals/runtime/lib/mixins/comparable.d.ts',
+ './@ember/-internals/runtime/lib/mixins/container_proxy.d.ts',
+ './@ember/-internals/runtime/lib/mixins/registry_proxy.d.ts',
+ './@ember/-internals/runtime/lib/mixins/target_action_support.d.ts',
+ './@ember/-internals/utils/index.d.ts',
+ './@ember/-internals/utils/lib/cache.d.ts',
+ './@ember/-internals/utils/lib/dictionary.d.ts',
+ './@ember/-internals/utils/lib/ember-array.d.ts',
+ './@ember/-internals/utils/lib/get-debug-name.d.ts',
+ './@ember/-internals/utils/lib/guid.d.ts',
+ './@ember/-internals/utils/lib/inspect.d.ts',
+ './@ember/-internals/utils/lib/intern.d.ts',
+ './@ember/-internals/utils/lib/invoke.d.ts',
+ './@ember/-internals/utils/lib/is_proxy.d.ts',
+ './@ember/-internals/utils/lib/lookup-descriptor.d.ts',
+ './@ember/-internals/utils/lib/make-array.d.ts',
+ './@ember/-internals/utils/lib/mandatory-setter.d.ts',
+ './@ember/-internals/utils/lib/name.d.ts',
+ './@ember/-internals/utils/lib/spec.d.ts',
+ './@ember/-internals/utils/lib/super.d.ts',
+ './@ember/-internals/utils/lib/symbol.d.ts',
+ './@ember/-internals/utils/lib/to-string.d.ts',
+ './@ember/-internals/utils/types.d.ts',
+ './@ember/-internals/views/index.d.ts',
+ './@ember/-internals/views/lib/compat/attrs.d.ts',
+ './@ember/-internals/views/lib/compat/fallback-view-registry.d.ts',
+ './@ember/-internals/views/lib/component_lookup.d.ts',
+ './@ember/-internals/views/lib/mixins/action_support.d.ts',
+ './@ember/-internals/views/lib/mixins/child_views_support.d.ts',
+ './@ember/-internals/views/lib/mixins/class_names_support.d.ts',
+ './@ember/-internals/views/lib/mixins/view_state_support.d.ts',
+ './@ember/-internals/views/lib/mixins/view_support.d.ts',
+ './@ember/-internals/views/lib/system/action_manager.d.ts',
+ './@ember/-internals/views/lib/system/event_dispatcher.d.ts',
+ './@ember/-internals/views/lib/system/utils.d.ts',
+ './@ember/-internals/views/lib/views/states.d.ts',
+ './@ember/-internals/views/lib/views/states/default.d.ts',
+ './@ember/-internals/views/lib/views/states/destroying.d.ts',
+ './@ember/-internals/views/lib/views/states/has_element.d.ts',
+ './@ember/-internals/views/lib/views/states/in_dom.d.ts',
+ './@ember/-internals/views/lib/views/states/pre_render.d.ts',
+ './@ember/application/index.d.ts',
+ './@ember/application/instance.d.ts',
+ './@ember/application/lib/lazy_load.d.ts',
+ './@ember/application/namespace.d.ts',
+ './@ember/array/index.d.ts',
+ './@ember/array/mutable.d.ts',
+ './@ember/array/proxy.d.ts',
+ './@ember/canary-features/index.d.ts',
+ './@ember/component/helper.d.ts',
+ './@ember/component/index.d.ts',
+ './@ember/component/template-only.d.ts',
+ './@ember/debug/container-debug-adapter.d.ts',
+ './@ember/debug/data-adapter.d.ts',
+ './@ember/debug/index.d.ts',
+ './@ember/debug/lib/capture-render-tree.d.ts',
+ './@ember/debug/lib/deprecate.d.ts',
+ './@ember/debug/lib/handlers.d.ts',
+ './@ember/debug/lib/testing.d.ts',
+ './@ember/debug/lib/warn.d.ts',
+ './@ember/deprecated-features/index.d.ts',
+ './@ember/destroyable/index.d.ts',
+ './@ember/engine/index.d.ts',
+ './@ember/engine/instance.d.ts',
+ './@ember/engine/lib/engine-parent.d.ts',
+ './@ember/enumerable/index.d.ts',
+ './@ember/enumerable/mutable.d.ts',
+ './@ember/error/index.d.ts',
+ './@ember/helper/index.d.ts',
+ './@ember/instrumentation/index.d.ts',
+ './@ember/modifier/index.d.ts',
+ './@ember/object/compat.d.ts',
+ './@ember/object/computed.d.ts',
+ './@ember/object/core.d.ts',
+ './@ember/object/evented.d.ts',
+ './@ember/object/events.d.ts',
+ './@ember/object/index.d.ts',
+ './@ember/object/internals.d.ts',
+ './@ember/object/lib/computed/computed_macros.d.ts',
+ './@ember/object/lib/computed/reduce_computed_macros.d.ts',
+ './@ember/object/mixin.d.ts',
+ './@ember/object/observable.d.ts',
+ './@ember/object/observers.d.ts',
+ './@ember/object/promise-proxy-mixin.d.ts',
+ './@ember/object/proxy.d.ts',
+ './@ember/owner/index.d.ts',
+ './@ember/polyfills/index.d.ts',
+ './@ember/polyfills/lib/assign.d.ts',
+ './@ember/renderer/index.d.ts',
+ './@ember/routing/-internals.d.ts',
+ './@ember/routing/auto-location.d.ts',
+ './@ember/routing/hash-location.d.ts',
+ './@ember/routing/history-location.d.ts',
+ './@ember/routing/index.d.ts',
+ './@ember/routing/lib/cache.d.ts',
+ './@ember/routing/lib/controller_for.d.ts',
+ './@ember/routing/lib/dsl.d.ts',
+ './@ember/routing/lib/engines.d.ts',
+ './@ember/routing/lib/generate_controller.d.ts',
+ './@ember/routing/lib/location-utils.d.ts',
+ './@ember/routing/lib/query_params.d.ts',
+ './@ember/routing/lib/route-info.d.ts',
+ './@ember/routing/lib/router_state.d.ts',
+ './@ember/routing/lib/routing-service.d.ts',
+ './@ember/routing/lib/transition.d.ts',
+ './@ember/routing/lib/utils.d.ts',
+ './@ember/routing/location.d.ts',
+ './@ember/routing/none-location.d.ts',
+ './@ember/routing/route-info.d.ts',
+ './@ember/routing/route.d.ts',
+ './@ember/routing/router-service.d.ts',
+ './@ember/routing/router.d.ts',
+ './@ember/routing/transition.d.ts',
+ './@ember/runloop/index.d.ts',
+ './@ember/service/index.d.ts',
+ './@ember/string/index.d.ts',
+ './@ember/string/lib/string_registry.d.ts',
+ './@ember/template-compilation/index.d.ts',
+ './@ember/template-factory/index.d.ts',
+ './@ember/template/index.d.ts',
+ './@ember/test/adapter.d.ts',
+ './@ember/test/index.d.ts',
+ './@ember/utils/index.d.ts',
+ './@ember/utils/lib/compare.d.ts',
+ './@ember/utils/lib/is_blank.d.ts',
+ './@ember/utils/lib/is_empty.d.ts',
+ './@ember/utils/lib/is_none.d.ts',
+ './@ember/utils/lib/is_present.d.ts',
+ './@ember/utils/lib/is-equal.d.ts',
+ './@ember/utils/lib/type-of.d.ts',
+ './@ember/version/index.d.ts',
+ './@glimmer/tracking/index.d.ts',
+ './@glimmer/tracking/primitives/cache.d.ts',
+ './ember-template-compiler/index.d.ts',
+ './ember-template-compiler/lib/plugins/assert-against-attrs.d.ts',
+ './ember-template-compiler/lib/plugins/assert-against-named-outlets.d.ts',
+ './ember-template-compiler/lib/plugins/assert-input-helper-without-block.d.ts',
+ './ember-template-compiler/lib/plugins/assert-reserved-named-arguments.d.ts',
+ './ember-template-compiler/lib/plugins/assert-splattribute-expression.d.ts',
+ './ember-template-compiler/lib/plugins/index.d.ts',
+ './ember-template-compiler/lib/plugins/transform-action-syntax.d.ts',
+ './ember-template-compiler/lib/plugins/transform-each-in-into-each.d.ts',
+ './ember-template-compiler/lib/plugins/transform-each-track-array.d.ts',
+ './ember-template-compiler/lib/plugins/transform-in-element.d.ts',
+ './ember-template-compiler/lib/plugins/transform-quoted-bindings-into-just-bindings.d.ts',
+ './ember-template-compiler/lib/plugins/transform-resolutions.d.ts',
+ './ember-template-compiler/lib/plugins/transform-wrap-mount-and-outlet.d.ts',
+ './ember-template-compiler/lib/plugins/utils.d.ts',
+ './ember-template-compiler/lib/system/bootstrap.d.ts',
+ './ember-template-compiler/lib/system/calculate-location-display.d.ts',
+ './ember-template-compiler/lib/system/compile-options.d.ts',
+ './ember-template-compiler/lib/system/compile.d.ts',
+ './ember-template-compiler/lib/system/dasherize-component-name.d.ts',
+ './ember-template-compiler/lib/system/initializer.d.ts',
+ './ember-template-compiler/lib/system/precompile.d.ts',
+ './ember-testing/index.d.ts',
+ './ember-testing/lib/adapters/adapter.d.ts',
+ './ember-testing/lib/adapters/qunit.d.ts',
+ './ember-testing/lib/ext/application.d.ts',
+ './ember-testing/lib/ext/rsvp.d.ts',
+ './ember-testing/lib/helpers.d.ts',
+ './ember-testing/lib/helpers/and_then.d.ts',
+ './ember-testing/lib/helpers/current_path.d.ts',
+ './ember-testing/lib/helpers/current_route_name.d.ts',
+ './ember-testing/lib/helpers/current_url.d.ts',
+ './ember-testing/lib/helpers/pause_test.d.ts',
+ './ember-testing/lib/helpers/visit.d.ts',
+ './ember-testing/lib/helpers/wait.d.ts',
+ './ember-testing/lib/initializers.d.ts',
+ './ember-testing/lib/setup_for_testing.d.ts',
+ './ember-testing/lib/test.d.ts',
+ './ember-testing/lib/test/adapter.d.ts',
+ './ember-testing/lib/test/helpers.d.ts',
+ './ember-testing/lib/test/on_inject_helpers.d.ts',
+ './ember-testing/lib/test/pending_requests.d.ts',
+ './ember-testing/lib/test/promise.d.ts',
+ './ember-testing/lib/test/run.d.ts',
+ './ember-testing/lib/test/waiters.d.ts',
+ './ember/index.d.ts',
+];
+
+const MODULES_PLACEHOLDER = '~~~MODULES GO HERE~~~';
+
+const BASE_INDEX_D_TS = `\
+/**
+ Provides stable type definitions for Ember.js. It is generated automatically
+ as part of Ember's publishing process and should never be edited manually.
+
+ To use these type definitions, add this import to any TypeScript file in your
+ Ember app or addon:
+
+ \`\`\`ts
+ import 'ember-source/types';
+ import 'ember-source/types/preview';
+ \`\`\`
+
+ @module
+ */
+
+// This works because each of these modules presents \`declare module\` definition
+// of the module and *only* that, so importing this file in turn makes those
+// module declarations "visible" automatically throughout a consuming project.
+// Combined with use of \`typesVersions\` (or, in the future, possibly \`exports\`)
+// in \`package.json\`, this allows users to import the types without knowing the
+// exact layout details.
+//
+// Somewhat annoyingly, every single module in the graph must appear here. For
+// now, while we are publishing ambient types, that means we must maintain this
+// by hand. When we start emitting types from the source, we will need to do the
+// same work, but automatically.
+
+// STATUS NOTE: this does not yet include Ember's full public API, only the
+// subset of it for which we have determined
+//
+// Over time, it will come to include *all* of Ember's types, and the matching
+// \`preview\` types will become empty. This is means that someone who writes the
+// import we recommend--
+//
+// \`\`\`ts
+// import 'ember-source/types';
+// import 'ember-source/types/preview';
+// \`\`\`
+//
+// --will always get the most up-to-date mix of preview and stable types, with
+// no extra effort required.
+
+${MODULES_PLACEHOLDER}
+`;
+
+const TYPES_DIR = path.join('types', 'stable');
+
+async function main() {
+ fs.rmSync(TYPES_DIR, { recursive: true, force: true });
+ fs.mkdirSync(TYPES_DIR, { recursive: true });
+
+ spawnSync('yarn', ['tsc', '--project', 'tsconfig/publish-types.json']);
+
+ // This is rooted in the `TYPES_DIR` so that the result is just the names of
+ // the modules, as generated directly from the tsconfig above.
+ let moduleNames = glob.sync('**/*.d.ts', {
+ ignore: 'index.d.ts', // ignore the root file itself if it somehow exists
+ cwd: TYPES_DIR,
+ });
+
+ for (let moduleName of moduleNames) {
+ wrapInDeclareModule(moduleName);
+ }
+
+ let sideEffectModules = moduleNames
+ .filter((module) => !PREVIEW_MODULES.includes(module))
+ .map((moduleName) => `import './${moduleName}';`)
+ .join('\n');
+
+ let stableIndexDTsContents = BASE_INDEX_D_TS.replace(MODULES_PLACEHOLDER, sideEffectModules);
+ fs.writeFileSync(path.join(TYPES_DIR, 'index.d.ts'), stableIndexDTsContents);
+}
+
+/**
+ * @param {string} moduleName
+ */
+function wrapInDeclareModule(moduleName) {
+ let modulePath = path.join(TYPES_DIR, moduleName);
+
+ /** @type {string} */
+ let contents;
+ try {
+ contents = fs.readFileSync(modulePath, { encoding: 'utf-8' });
+ } catch (e) {
+ console.error(`Error reading ${modulePath}: ${e}`);
+ return;
+ }
+
+ let moduleNameForDeclaration = moduleName.replace('/index.d.ts', '');
+
+ let string = new MagicString(contents);
+ string.indent(' ').prepend(`declare module '${moduleNameForDeclaration}' {\n`).append('}\n');
+
+ try {
+ fs.writeFileSync(modulePath, string.toString());
+ } catch (e) {
+ console.error(`Error writing ${modulePath}: ${e}`);
+ }
+}
+
+// Run it!
+main(); | true |
Other | emberjs | ember.js | 845b60e84d06ba123064c9b451ee8614060d2c93.json | Introduce a script to publish stable types
Provide a script which runs the compiler against a new tsconfig for
generating types, wraps all the generated modules in `declare module`
statements, and then creates an `index.d.ts` which uses side-effect
style imports to expose them all, just the same as the preview types
but generated from source.
Critically, this infrastructure does not expose *any* stable types in
and of itself. Instead, it introduces a list of all the types still in
preview mode which acts as a filter, and currently *all* modules are in
that filter. Stabilizing the types for a given module will mean
removing modules from that list and removing the corresponding preview
types definitions. | types/stable/index.d.ts | @@ -1,12 +0,0 @@
-// Future home of stable Ember types! This file currently does nothing, but in
-// the months ahead will look more and more like the `/types/preview/index.d.ts`
-// while that one empties. This is just here so that someone who writes the
-// import we recommend--
-//
-// ```ts
-// import 'ember-source/types';
-// import 'ember-source/types/preview';
-// ```
-//
-// --will not get warnings from TypeScript while we wait on putting actual
-// things here! | true |
Other | emberjs | ember.js | 845b60e84d06ba123064c9b451ee8614060d2c93.json | Introduce a script to publish stable types
Provide a script which runs the compiler against a new tsconfig for
generating types, wraps all the generated modules in `declare module`
statements, and then creates an `index.d.ts` which uses side-effect
style imports to expose them all, just the same as the preview types
but generated from source.
Critically, this infrastructure does not expose *any* stable types in
and of itself. Instead, it introduces a list of all the types still in
preview mode which acts as a filter, and currently *all* modules are in
that filter. Stabilizing the types for a given module will mean
removing modules from that list and removing the corresponding preview
types definitions. | yarn.lock | @@ -7711,6 +7711,13 @@ magic-string@^0.25.2, magic-string@^0.25.7:
dependencies:
sourcemap-codec "^1.4.4"
+magic-string@^0.26.7:
+ version "0.26.7"
+ resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.26.7.tgz#caf7daf61b34e9982f8228c4527474dac8981d6f"
+ integrity sha512-hX9XH3ziStPoPhJxLq1syWuZMxbDvGNbVchfrdCtanC7D13888bMFow61x8axrx+GfHLtVeAx2kxL7tTGRl+Ow==
+ dependencies:
+ sourcemap-codec "^1.4.8"
+
make-dir@^3.0.0, make-dir@^3.0.2, make-dir@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-3.1.0.tgz#415e967046b3a7f1d185277d84aa58203726a13f"
@@ -9980,6 +9987,11 @@ sourcemap-codec@^1.4.1, sourcemap-codec@^1.4.4:
resolved "https://registry.yarnpkg.com/sourcemap-codec/-/sourcemap-codec-1.4.4.tgz#c63ea927c029dd6bd9a2b7fa03b3fec02ad56e9f"
integrity "sha1-xj6pJ8Ap3WvZorf6A7P+wCrVbp8= sha512-CYAPYdBu34781kLHkaW3m6b/uUSyMOC2R61gcYMWooeuaGtjof86ZA/8T+qVPPt7np1085CR9hmMGrySwEc8Xg=="
+sourcemap-codec@^1.4.8:
+ version "1.4.8"
+ resolved "https://registry.yarnpkg.com/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz#ea804bd94857402e6992d05a38ef1ae35a9ab4c4"
+ integrity sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==
+
sourcemap-validator@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/sourcemap-validator/-/sourcemap-validator-1.1.0.tgz#00454547d1682186e1498a7208e022e8dfa8738f" | true |
Other | emberjs | ember.js | fb8fc0222624491abfcc4da6101e6d5ac14f3d0a.json | Correct some public types | type-tests/preview/@ember/component-test/capabilities.ts | @@ -0,0 +1,16 @@
+import { capabilities } from '@ember/component';
+import { expectTypeOf } from 'expect-type';
+
+expectTypeOf(capabilities('3.13')).toMatchTypeOf<{
+ asyncLifecycleCallbacks?: boolean | undefined;
+ destructor?: boolean | undefined;
+ updateHook?: boolean | undefined;
+}>();
+
+capabilities('3.13', { asyncLifecycleCallbacks: true });
+capabilities('3.4', { asyncLifecycleCallbacks: true });
+
+// @ts-expect-error invalid capabilities
+capabilities('3.13', { asyncLifecycleCallbacks: 1 });
+// @ts-expect-error invalid verison
+capabilities('3.12'); | true |
Other | emberjs | ember.js | fb8fc0222624491abfcc4da6101e6d5ac14f3d0a.json | Correct some public types | type-tests/preview/@ember/component-test/set-component-template.ts | @@ -0,0 +1,8 @@
+import { setComponentTemplate } from '@ember/component';
+import type { TemplateFactory } from 'htmlbars-inline-precompile';
+import { expectTypeOf } from 'expect-type';
+
+// Good enough for testing
+let factory = {} as TemplateFactory;
+
+expectTypeOf(setComponentTemplate(factory, {})).toEqualTypeOf<object>(); | true |
Other | emberjs | ember.js | fb8fc0222624491abfcc4da6101e6d5ac14f3d0a.json | Correct some public types | types/preview/@ember/application/index.d.ts | @@ -133,16 +133,4 @@ declare module '@ember/application' {
* @deprecated Use `import { setOwner } from '@ember/owner';` instead.
*/
export function setOwner(object: object, owner: Owner): void;
-
- /**
- * Detects when a specific package of Ember (e.g. 'Ember.Application')
- * has fully loaded and is available for extension.
- */
- export function onLoad(name: string, callback: AnyFn): unknown;
-
- /**
- * Called when an Ember.js package (e.g Ember.Application) has finished
- * loading. Triggers any callbacks registered for this event.
- */
- export function runLoadHooks(name: string, object?: {}): unknown;
} | true |
Other | emberjs | ember.js | fb8fc0222624491abfcc4da6101e6d5ac14f3d0a.json | Correct some public types | types/preview/@ember/component/index.d.ts | @@ -106,14 +106,37 @@ declare module '@ember/component' {
object: T
): T;
-/**
- * Takes a component class and returns the template associated with the given component class,
- * if any, or one of its superclasses, if any, or undefined if no template association was found.
- *
- * @param object the component object
- * @return the template factory of the given component
- */
- export function getComponentTemplate(obj: object): TemplateFactory | undefined;
+ /**
+ * Takes a component class and returns the template associated with the given component class,
+ * if any, or one of its superclasses, if any, or undefined if no template association was found.
+ *
+ * @param object the component object
+ * @return the template factory of the given component
+ */
+ export function getComponentTemplate(obj: object): TemplateFactory | undefined;
+
+ export function setComponentTemplate(factory: TemplateFactory, obj: object): object;
+
+ interface ComponentCapabilitiesVersions {
+ '3.4': {
+ asyncLifecycleCallbacks?: boolean;
+ destructor?: boolean;
+ };
+
+ '3.13': {
+ asyncLifecycleCallbacks?: boolean;
+ destructor?: boolean;
+ updateHook?: boolean;
+ };
+ }
+
+ interface ComponentCapabilities extends Capabilities {
+ asyncLifeCycleCallbacks: boolean;
+ destructor: boolean;
+ updateHook: boolean;
+ }
+
+ export function capabilities<Version extends keyof ComponentCapabilitiesVersions>(managerAPI: Version, options?: ComponentCapabilitiesVersions[Version]): ComponentCapabilities;
// In normal TypeScript, these built-in components are essentially opaque tokens
// that just need to be importable. Declaring them with unique interfaces | true |
Other | emberjs | ember.js | 2340d2d99ee7722c38cf888c04b7d3b02e4f3bab.json | Fix another linting issue in `@ember/engine`
This is a bit annoying: the fixer actually makes the declaration *worse*
by some interpretations. But :shrug: | packages/@ember/engine/instance.ts | @@ -10,7 +10,9 @@ import { Registry, privatize as P } from '@ember/-internals/container';
import { guidFor } from '@ember/-internals/utils';
import { ENGINE_PARENT, getEngineParent, setEngineParent } from './lib/engine-parent';
import { ContainerProxyMixin, RegistryProxyMixin } from '@ember/-internals/runtime';
-import Owner, { type FullName, isFactory, InternalOwner } from '@ember/-internals/owner';
+import type { InternalOwner } from '@ember/-internals/owner';
+import type Owner from '@ember/-internals/owner';
+import { type FullName, isFactory } from '@ember/-internals/owner';
import Engine from '@ember/engine';
import type Application from '@ember/application';
import type { BootEnvironment } from '@ember/-internals/glimmer'; | false |
Other | emberjs | ember.js | b2ce803496e1a0943acda75a927c736cc5b21425.json | Fix a type error in CoreObject on TS@next | packages/@ember/object/core.ts | @@ -260,7 +260,7 @@ class CoreObject {
/* globals Proxy Reflect */
self = new Proxy(this, {
- get(target: CoreObject & HasUnknownProperty, property, receiver) {
+ get(target: typeof this & HasUnknownProperty, property, receiver) {
if (property === PROXY_CONTENT) {
return target;
} else if ( | false |
Other | emberjs | ember.js | 7e49f29aab064ec5949e4c7afcdb353899a62152.json | Fix lint errors in Owner packages | packages/@ember/-internals/owner/index.ts | @@ -218,11 +218,6 @@ export interface Factory<T extends object> {
// able to provide a *narrower* interface than "exactly the public fields on
// the class" while still falling back to the "exactly the public fields on
// the class" for the general case. :sigh:
- //
- // We stills upply both signatures because even though the second one means
- // literally anything will *type check*, the first one means that the normal
- // case of calling `.create()` for most implementors of the contract will at
- // least get useful autocomplete.
/**
* A function that will create an instance of the class with any
* dependencies injected. | true |
Other | emberjs | ember.js | 7e49f29aab064ec5949e4c7afcdb353899a62152.json | Fix lint errors in Owner packages | types/preview/@ember/owner/index.d.ts | @@ -212,18 +212,12 @@ declare module '@ember/owner' {
// able to provide a *narrower* interface than "exactly the public fields on
// the class" while still falling back to the "exactly the public fields on
// the class" for the general case. :sigh:
- //
- // We stills upply both signatures because even though the second one means
- // literally anything will *type check*, the first one means that the normal
- // case of calling `.create()` for most implementors of the contract will at
- // least get useful autocomplete.
/**
* A function that will create an instance of the class with any
* dependencies injected.
*
* @param initialValues Any values to set on an instance of the class
*/
- create(initialValues?: Partial<T>): T;
create(initialValues?: object): T;
}
| true |
Other | emberjs | ember.js | 63fb7cf65753b9da192d290948a6b16b9125f2bd.json | Fix white space in comments in `@ember/controller`
Prettier! | packages/@ember/controller/index.ts | @@ -44,7 +44,7 @@ interface ControllerMixin<T> extends ActionHandler {
as part of the application's initialization process. In most cases the
`target` property will automatically be set to the logical consumer of
actions for the controller.
-
+
@property target
@default null
@public
@@ -54,7 +54,7 @@ interface ControllerMixin<T> extends ActionHandler {
/**
The controller's current model. When retrieving or modifying a controller's
model, this property should be used instead of the `content` property.
-
+
@property model
@public
*/
@@ -81,7 +81,7 @@ interface ControllerMixin<T> extends ActionHandler {
```
Available values for the `type` parameter are `'boolean'`, `'number'`, `'array'`, and `'string'`.
If query param type is not specified, it will default to `'string'`.
-
+
@for Ember.ControllerMixin
@property queryParams
@public
@@ -151,7 +151,7 @@ interface ControllerMixin<T> extends ActionHandler {
```
See also [replaceRoute](/ember/release/classes/Ember.ControllerMixin/methods/replaceRoute?anchor=replaceRoute).
-
+
@for Ember.ControllerMixin
@method transitionToRoute
@deprecated Use transitionTo from the Router service instead.
@@ -215,7 +215,7 @@ interface ControllerMixin<T> extends ActionHandler {
aController.replaceRoute('/');
aController.replaceRoute('/blog/post/1/comment/13');
```
-
+
@for Ember.ControllerMixin
@method replaceRoute
@deprecated Use replaceWith from the Router service instead. | false |
Other | emberjs | ember.js | 5658b13a400011d1b946b580565d79df91d65424.json | Update preview types to match the implementation
Updates the preview types to include the `@ember/owner` types
introduced in an earlier commit. Besides updating the other existing
related exports to match the refactored types from the implementation,
the refactoring involved in landing correct types internally result in
a couple of key changes:
1. `getOwner()` always returns `Owner | undefined`. The previous
attempt to make it return `Owner` when working with a "known
object" of some sort runs into significant issues:
- Ember's public API allows the direct construction of many types
which are *normally* managed by the framework. It is legal, if
odd and *not recommended*, to instantiate any given `Factory`
with its `.create()` method:
import Component from '@glimmer/component';
import Session from '../services'
export default class Example extends Component {
session = Session.create();
}
In this example, the `session` property on `Example` will *not*
have an `Owner`, so it is not safe for `session` itself to rely
on that. This is annoying, but type safe, and straightforward
to work around. For example, a helper designed to look up services in templates might do something like this:
import Helper from '@ember/component/helper';
import { getOwner } from '@ember/owner';
import { assert } from '@ember/debug';
class GetService extends Helper {
compute([serviceName]) {
let owner = getOwner(this);
assert('unexpected missing an owner!', !!owner);
return owner.lookup(`service:${name}`);
}
}
Then if someone did `GetService.create()` instead of using
a helper in a template *or* with `invokeHelper()`, they
would get a useful error message.
- For the same reasons we cannot guarantee that contract from a
types perspective, it is actually impossible to *implement* it
in a type safe manner.
2. The service registry now *requires* that its fields be `Service`
subclasses. We added this constraint as part of generalizing the DI
registry system to work well with the `Owner` APIs while avoiding
introducing any circularity into the module graph. This should also
be future-compatible with alternative future designs. This should
not be breaking in practice, because items in the service registry
were always expected to be service classes.
(Note that this cannot be backported to the release because the modules
it represents do not exist until this whole PR lands.) | type-tests/preview/@ember/application-test/index.ts | @@ -12,7 +12,7 @@ declare class MyService extends Service {
withStuff: true;
}
declare let myService: MyService;
-expectTypeOf(getOwner(myService)).toEqualTypeOf<Owner>();
+expectTypeOf(getOwner(myService)).toEqualTypeOf<Owner | undefined>();
// @ts-expect-error
getOwner(); | true |
Other | emberjs | ember.js | 5658b13a400011d1b946b580565d79df91d65424.json | Update preview types to match the implementation
Updates the preview types to include the `@ember/owner` types
introduced in an earlier commit. Besides updating the other existing
related exports to match the refactored types from the implementation,
the refactoring involved in landing correct types internally result in
a couple of key changes:
1. `getOwner()` always returns `Owner | undefined`. The previous
attempt to make it return `Owner` when working with a "known
object" of some sort runs into significant issues:
- Ember's public API allows the direct construction of many types
which are *normally* managed by the framework. It is legal, if
odd and *not recommended*, to instantiate any given `Factory`
with its `.create()` method:
import Component from '@glimmer/component';
import Session from '../services'
export default class Example extends Component {
session = Session.create();
}
In this example, the `session` property on `Example` will *not*
have an `Owner`, so it is not safe for `session` itself to rely
on that. This is annoying, but type safe, and straightforward
to work around. For example, a helper designed to look up services in templates might do something like this:
import Helper from '@ember/component/helper';
import { getOwner } from '@ember/owner';
import { assert } from '@ember/debug';
class GetService extends Helper {
compute([serviceName]) {
let owner = getOwner(this);
assert('unexpected missing an owner!', !!owner);
return owner.lookup(`service:${name}`);
}
}
Then if someone did `GetService.create()` instead of using
a helper in a template *or* with `invokeHelper()`, they
would get a useful error message.
- For the same reasons we cannot guarantee that contract from a
types perspective, it is actually impossible to *implement* it
in a type safe manner.
2. The service registry now *requires* that its fields be `Service`
subclasses. We added this constraint as part of generalizing the DI
registry system to work well with the `Owner` APIs while avoiding
introducing any circularity into the module graph. This should also
be future-compatible with alternative future designs. This should
not be breaking in practice, because items in the service registry
were always expected to be service classes.
(Note that this cannot be backported to the release because the modules
it represents do not exist until this whole PR lands.) | type-tests/preview/@ember/owner-tests.ts | @@ -5,12 +5,18 @@ import Owner, {
RegisterOptions,
Resolver,
KnownForTypeResult,
+ getOwner,
+ setOwner,
} from '@ember/owner';
import Component from '@glimmer/component';
import { expectTypeOf } from 'expect-type';
-// TODO: once we move the runtime export to `@ember/owner`, update this import
-// as well. (That's why it's tested in this module!)
-import { getOwner } from '@ember/application';
+import {
+ getOwner as getOwnerApplication,
+ setOwner as setOwnerApplication,
+} from '@ember/application';
+
+expectTypeOf(getOwnerApplication).toEqualTypeOf(getOwner);
+expectTypeOf(setOwnerApplication).toEqualTypeOf(setOwner);
// Just a class we can construct in the Factory and FactoryManager tests
declare class ConstructThis {
@@ -35,19 +41,19 @@ aFactory.create({
hasProps: false,
});
-// These should be rejected by way of EPC
-// @ts-expect-error
+// NOTE: it would be nice if these could be rejected by way of EPC, but alas: it
+// cannot, because the public contract for `create` allows implementors to
+// define their `create` config object basically however they like. :-/
aFactory.create({ unrelatedNonsense: 'yep yep yep' });
-// @ts-expect-error
aFactory.create({ hasProps: true, unrelatedNonsense: 'yep yep yep' });
// But this should be legal.
const goodPojo = { hasProps: true, unrelatedNonsense: 'also true' };
aFactory.create(goodPojo);
-// while this should be rejected for *type error* reasons, not EPC
+// This should also be rejected, though for *type error* reasons, not EPC; alas,
+// it cannot, for the same reason.
const badPojo = { hasProps: 'huzzah', unrelatedNonsense: 'also true' };
-// @ts-expect-error
aFactory.create(badPojo);
// ----- FactoryManager ----- //
@@ -56,26 +62,29 @@ expectTypeOf(aFactoryManager.class).toEqualTypeOf<Factory<ConstructThis>>();
expectTypeOf(aFactoryManager.create({})).toEqualTypeOf<ConstructThis>();
expectTypeOf(aFactoryManager.create({ hasProps: true })).toEqualTypeOf<ConstructThis>();
expectTypeOf(aFactoryManager.create({ hasProps: false })).toEqualTypeOf<ConstructThis>();
-// @ts-expect-error
+
+// Likewise with these.
aFactoryManager.create({ otherStuff: 'nope' });
-// @ts-expect-error
aFactoryManager.create({ hasProps: true, otherStuff: 'nope' });
expectTypeOf(aFactoryManager.create(goodPojo)).toEqualTypeOf<ConstructThis>();
-// @ts-expect-error
aFactoryManager.create(badPojo);
// ----- Resolver ----- //
declare let resolver: Resolver;
-expectTypeOf<Resolver['normalize']>().toEqualTypeOf<((fullName: FullName) => string) | undefined>();
+expectTypeOf<Resolver['normalize']>().toEqualTypeOf<
+ ((fullName: FullName) => FullName) | undefined
+>();
expectTypeOf<Resolver['lookupDescription']>().toEqualTypeOf<
((fullName: FullName) => string) | undefined
>();
-expectTypeOf(resolver.resolve('some-name')).toEqualTypeOf<object | Factory<object> | undefined>();
+expectTypeOf(resolver.resolve('random:some-name')).toEqualTypeOf<
+ object | Factory<object> | undefined
+>();
const knownForFoo = resolver.knownForType?.('foo');
expectTypeOf(knownForFoo).toEqualTypeOf<KnownForTypeResult<'foo'> | undefined>();
expectTypeOf(knownForFoo?.['foo:bar']).toEqualTypeOf<boolean | undefined>();
-// @ts-expect-error
-knownForFoo?.['blah'];
+// @ts-expect-error -- there is no `blah` on `knownForFoo`, *only* `foo`.
+knownForFoo?.blah;
// This one is last so it can reuse the bits from above!
// ----- Owner ----- //
@@ -88,12 +97,16 @@ expectTypeOf(owner.lookup('type:name')).toEqualTypeOf<unknown>();
owner.lookup('non-namespace-string');
expectTypeOf(owner.lookup('namespace@type:name')).toEqualTypeOf<unknown>();
-declare module '@ember/service' {
- interface Registry {
- 'my-type-test-service': ConstructThis;
+// Arbitrary registration patterns work, as here.
+declare module '@ember/owner' {
+ export interface DIRegistry {
+ etc: {
+ 'my-type-test': ConstructThis;
+ };
}
}
-expectTypeOf(owner.lookup('service:my-type-test-service')).toEqualTypeOf<ConstructThis>();
+
+expectTypeOf(owner.lookup('etc:my-type-test')).toEqualTypeOf<ConstructThis>();
expectTypeOf(owner.register('type:name', aFactory)).toEqualTypeOf<void>();
expectTypeOf(owner.register('type:name', aFactory, {})).toEqualTypeOf<void>();
@@ -117,17 +130,17 @@ expectTypeOf(
owner.register('non-namespace-string', aFactory);
expectTypeOf(owner.register('namespace@type:name', aFactory)).toEqualTypeOf<void>();
-expectTypeOf(owner.factoryFor('type:name')).toEqualTypeOf<FactoryManager<unknown> | undefined>();
-expectTypeOf(owner.factoryFor('type:name')?.class).toEqualTypeOf<Factory<unknown> | undefined>();
-expectTypeOf(owner.factoryFor('type:name')?.create()).toEqualTypeOf<unknown>();
-expectTypeOf(owner.factoryFor('type:name')?.create({})).toEqualTypeOf<unknown>();
-expectTypeOf(
- owner.factoryFor('type:name')?.create({ anythingGoes: true })
-).toEqualTypeOf<unknown>();
+expectTypeOf(owner.factoryFor('type:name')).toEqualTypeOf<FactoryManager<object> | undefined>();
+expectTypeOf(owner.factoryFor('type:name')?.class).toEqualTypeOf<Factory<object> | undefined>();
+expectTypeOf(owner.factoryFor('type:name')?.create()).toEqualTypeOf<object | undefined>();
+expectTypeOf(owner.factoryFor('type:name')?.create({})).toEqualTypeOf<object | undefined>();
+expectTypeOf(owner.factoryFor('type:name')?.create({ anythingGoes: true })).toEqualTypeOf<
+ object | undefined
+>();
// @ts-expect-error
owner.factoryFor('non-namespace-string');
expectTypeOf(owner.factoryFor('namespace@type:name')).toEqualTypeOf<
- FactoryManager<unknown> | undefined
+ FactoryManager<object> | undefined
>();
// Tests deal with the fact that string literals are a special case! `let`
@@ -171,12 +184,12 @@ interface Sig<T> {
class ExampleComponent<T> extends Component<Sig<T>> {
checkThis() {
- expectTypeOf(getOwner(this)).toEqualTypeOf<Owner>();
+ expectTypeOf(getOwner(this)).toEqualTypeOf<Owner | undefined>();
}
}
declare let example: ExampleComponent<string>;
-expectTypeOf(getOwner(example)).toEqualTypeOf<Owner>();
+expectTypeOf(getOwner(example)).toEqualTypeOf<Owner | undefined>();
// ----- Minimal further coverage for POJOs ----- //
// `Factory` and `FactoryManager` don't have to deal in actual classes. :sigh:
@@ -185,7 +198,14 @@ const Creatable = {
};
const pojoFactory: Factory<typeof Creatable> = {
- create(initialValues?) {
+ // If you want *real* safety here, alas: you cannot have it. The public
+ // contract for `create` allows implementors to define their `create` config
+ // object basically however they like. As a result, this is the safest version
+ // possible: Making it be `Partial<Thing>` is *compatible* with `object`, and
+ // requires full checking *inside* the function body. It does not, alas, give
+ // any safety *outside* the class. A future rationalization of this would be
+ // very welcome.
+ create(initialValues?: Partial<typeof Creatable>) {
const instance = Creatable;
if (initialValues) {
if (initialValues.hasProps) { | true |
Other | emberjs | ember.js | 5658b13a400011d1b946b580565d79df91d65424.json | Update preview types to match the implementation
Updates the preview types to include the `@ember/owner` types
introduced in an earlier commit. Besides updating the other existing
related exports to match the refactored types from the implementation,
the refactoring involved in landing correct types internally result in
a couple of key changes:
1. `getOwner()` always returns `Owner | undefined`. The previous
attempt to make it return `Owner` when working with a "known
object" of some sort runs into significant issues:
- Ember's public API allows the direct construction of many types
which are *normally* managed by the framework. It is legal, if
odd and *not recommended*, to instantiate any given `Factory`
with its `.create()` method:
import Component from '@glimmer/component';
import Session from '../services'
export default class Example extends Component {
session = Session.create();
}
In this example, the `session` property on `Example` will *not*
have an `Owner`, so it is not safe for `session` itself to rely
on that. This is annoying, but type safe, and straightforward
to work around. For example, a helper designed to look up services in templates might do something like this:
import Helper from '@ember/component/helper';
import { getOwner } from '@ember/owner';
import { assert } from '@ember/debug';
class GetService extends Helper {
compute([serviceName]) {
let owner = getOwner(this);
assert('unexpected missing an owner!', !!owner);
return owner.lookup(`service:${name}`);
}
}
Then if someone did `GetService.create()` instead of using
a helper in a template *or* with `invokeHelper()`, they
would get a useful error message.
- For the same reasons we cannot guarantee that contract from a
types perspective, it is actually impossible to *implement* it
in a type safe manner.
2. The service registry now *requires* that its fields be `Service`
subclasses. We added this constraint as part of generalizing the DI
registry system to work well with the `Owner` APIs while avoiding
introducing any circularity into the module graph. This should also
be future-compatible with alternative future designs. This should
not be breaking in practice, because items in the service registry
were always expected to be service classes.
(Note that this cannot be backported to the release because the modules
it represents do not exist until this whole PR lands.) | type-tests/preview/ember/ember-module-tests.ts | @@ -48,7 +48,7 @@ expectTypeOf(
Ember.getEngineParent(new Ember.EngineInstance())
).toEqualTypeOf<Ember.EngineInstance>();
// getOwner
-expectTypeOf(Ember.getOwner(new Ember.Component())).toEqualTypeOf<Owner>();
+expectTypeOf(Ember.getOwner(new Ember.Component())).toEqualTypeOf<Owner | undefined>();
// getProperties
expectTypeOf(Ember.getProperties({ z: 23 }, 'z').z).toEqualTypeOf<number>();
expectTypeOf(Ember.getProperties({ z: 23 }, 'z', 'z').z).toEqualTypeOf<number>(); | true |
Other | emberjs | ember.js | 5658b13a400011d1b946b580565d79df91d65424.json | Update preview types to match the implementation
Updates the preview types to include the `@ember/owner` types
introduced in an earlier commit. Besides updating the other existing
related exports to match the refactored types from the implementation,
the refactoring involved in landing correct types internally result in
a couple of key changes:
1. `getOwner()` always returns `Owner | undefined`. The previous
attempt to make it return `Owner` when working with a "known
object" of some sort runs into significant issues:
- Ember's public API allows the direct construction of many types
which are *normally* managed by the framework. It is legal, if
odd and *not recommended*, to instantiate any given `Factory`
with its `.create()` method:
import Component from '@glimmer/component';
import Session from '../services'
export default class Example extends Component {
session = Session.create();
}
In this example, the `session` property on `Example` will *not*
have an `Owner`, so it is not safe for `session` itself to rely
on that. This is annoying, but type safe, and straightforward
to work around. For example, a helper designed to look up services in templates might do something like this:
import Helper from '@ember/component/helper';
import { getOwner } from '@ember/owner';
import { assert } from '@ember/debug';
class GetService extends Helper {
compute([serviceName]) {
let owner = getOwner(this);
assert('unexpected missing an owner!', !!owner);
return owner.lookup(`service:${name}`);
}
}
Then if someone did `GetService.create()` instead of using
a helper in a template *or* with `invokeHelper()`, they
would get a useful error message.
- For the same reasons we cannot guarantee that contract from a
types perspective, it is actually impossible to *implement* it
in a type safe manner.
2. The service registry now *requires* that its fields be `Service`
subclasses. We added this constraint as part of generalizing the DI
registry system to work well with the `Owner` APIs while avoiding
introducing any circularity into the module graph. This should also
be future-compatible with alternative future designs. This should
not be breaking in practice, because items in the service registry
were always expected to be service classes.
(Note that this cannot be backported to the release because the modules
it represents do not exist until this whole PR lands.) | types/preview/@ember/application/index.d.ts | @@ -116,41 +116,23 @@ declare module '@ember/application' {
buildInstance(options?: object): ApplicationInstance;
}
- // Known framework objects, so that `getOwner` can always, accurately, return
- // `Owner` when working with one of these classes, which the framework *does*
- // guarantee will always have an `Owner`. NOTE: this must be kept up to date
- // whenever we add new base classes to the framework. For example, if we
- // introduce a standalone `Service` or `Route` base class which *does not*
- // extend from `EmberObject`, it will need to be added here.
- //
- // NOTE: we use `any` here because we need to make sure *not* to fix the
- // actual GlimmerComponent type; using `unknown` or `{}` or `never` (the
- // obvious alternatives here) results in a version which is too narrow, such
- // that any subclass which applies a signature does not get resolved by the
- // definition of `getOwner()` below.
- type KnownFrameworkObject = EmberObject | GlimmerComponent<any>;
-
/**
* Framework objects in an Ember application (components, services, routes, etc.)
* are created via a factory and dependency injection system. Each of these
* objects is the responsibility of an "owner", which handled its
* instantiation and manages its lifetime.
+ *
+ * @deprecated Use `import { getOwner } from '@ember/owner';` instead.
*/
- // SAFETY: this first overload is, strictly speaking, *unsafe*. It is possible
- // to do `let x = EmberObject.create(); getOwner(x);` and the result will *not*
- // be `Owner` but instead `undefined`. However, that's quite unusual at this
- // point, and more to the point we cannot actually distinguish a `Service`
- // subclass from `EmberObject` at this point: `Service` subclasses `EmberObject`
- // and adds nothing to it. Accordingly, if we want to catch `Service`s with this
- // (and `getOwner(this)` for some service will definitely be defined!), it has
- // to be this way. :sigh:
- export function getOwner(object: KnownFrameworkObject): Owner;
- export function getOwner(object: unknown): Owner | undefined;
+ export function getOwner(object: object): Owner | undefined;
+
/**
* `setOwner` forces a new owner on a given object instance. This is primarily
* useful in some testing cases.
+ *
+ * @deprecated Use `import { setOwner } from '@ember/owner';` instead.
*/
- export function setOwner(object: unknown, owner: Owner): void;
+ export function setOwner(object: object, owner: Owner): void;
/**
* Detects when a specific package of Ember (e.g. 'Ember.Application') | true |
Other | emberjs | ember.js | 5658b13a400011d1b946b580565d79df91d65424.json | Update preview types to match the implementation
Updates the preview types to include the `@ember/owner` types
introduced in an earlier commit. Besides updating the other existing
related exports to match the refactored types from the implementation,
the refactoring involved in landing correct types internally result in
a couple of key changes:
1. `getOwner()` always returns `Owner | undefined`. The previous
attempt to make it return `Owner` when working with a "known
object" of some sort runs into significant issues:
- Ember's public API allows the direct construction of many types
which are *normally* managed by the framework. It is legal, if
odd and *not recommended*, to instantiate any given `Factory`
with its `.create()` method:
import Component from '@glimmer/component';
import Session from '../services'
export default class Example extends Component {
session = Session.create();
}
In this example, the `session` property on `Example` will *not*
have an `Owner`, so it is not safe for `session` itself to rely
on that. This is annoying, but type safe, and straightforward
to work around. For example, a helper designed to look up services in templates might do something like this:
import Helper from '@ember/component/helper';
import { getOwner } from '@ember/owner';
import { assert } from '@ember/debug';
class GetService extends Helper {
compute([serviceName]) {
let owner = getOwner(this);
assert('unexpected missing an owner!', !!owner);
return owner.lookup(`service:${name}`);
}
}
Then if someone did `GetService.create()` instead of using
a helper in a template *or* with `invokeHelper()`, they
would get a useful error message.
- For the same reasons we cannot guarantee that contract from a
types perspective, it is actually impossible to *implement* it
in a type safe manner.
2. The service registry now *requires* that its fields be `Service`
subclasses. We added this constraint as part of generalizing the DI
registry system to work well with the `Owner` APIs while avoiding
introducing any circularity into the module graph. This should also
be future-compatible with alternative future designs. This should
not be breaking in practice, because items in the service registry
were always expected to be service classes.
(Note that this cannot be backported to the release because the modules
it represents do not exist until this whole PR lands.) | types/preview/@ember/engine/-private/container-proxy-mixin.d.ts | @@ -1,17 +1,11 @@
declare module '@ember/engine/-private/container-proxy-mixin' {
- import Owner from '@ember/owner';
+ import { ContainerProxy } from '@ember/owner';
import Mixin from '@ember/object/mixin';
/**
* Given a fullName return a factory manager.
*/
- interface ContainerProxyMixin extends Owner {
- /**
- * Returns an object that can be used to provide an owner to a
- * manually created instance.
- */
- ownerInjection(): {};
- }
+ interface ContainerProxyMixin extends ContainerProxy {}
const ContainerProxyMixin: Mixin;
export default ContainerProxyMixin;
} | true |
Other | emberjs | ember.js | 5658b13a400011d1b946b580565d79df91d65424.json | Update preview types to match the implementation
Updates the preview types to include the `@ember/owner` types
introduced in an earlier commit. Besides updating the other existing
related exports to match the refactored types from the implementation,
the refactoring involved in landing correct types internally result in
a couple of key changes:
1. `getOwner()` always returns `Owner | undefined`. The previous
attempt to make it return `Owner` when working with a "known
object" of some sort runs into significant issues:
- Ember's public API allows the direct construction of many types
which are *normally* managed by the framework. It is legal, if
odd and *not recommended*, to instantiate any given `Factory`
with its `.create()` method:
import Component from '@glimmer/component';
import Session from '../services'
export default class Example extends Component {
session = Session.create();
}
In this example, the `session` property on `Example` will *not*
have an `Owner`, so it is not safe for `session` itself to rely
on that. This is annoying, but type safe, and straightforward
to work around. For example, a helper designed to look up services in templates might do something like this:
import Helper from '@ember/component/helper';
import { getOwner } from '@ember/owner';
import { assert } from '@ember/debug';
class GetService extends Helper {
compute([serviceName]) {
let owner = getOwner(this);
assert('unexpected missing an owner!', !!owner);
return owner.lookup(`service:${name}`);
}
}
Then if someone did `GetService.create()` instead of using
a helper in a template *or* with `invokeHelper()`, they
would get a useful error message.
- For the same reasons we cannot guarantee that contract from a
types perspective, it is actually impossible to *implement* it
in a type safe manner.
2. The service registry now *requires* that its fields be `Service`
subclasses. We added this constraint as part of generalizing the DI
registry system to work well with the `Owner` APIs while avoiding
introducing any circularity into the module graph. This should also
be future-compatible with alternative future designs. This should
not be breaking in practice, because items in the service registry
were always expected to be service classes.
(Note that this cannot be backported to the release because the modules
it represents do not exist until this whole PR lands.) | types/preview/@ember/engine/-private/registry-proxy-mixin.d.ts | @@ -1,54 +1,12 @@
declare module '@ember/engine/-private/registry-proxy-mixin' {
- import Owner from '@ember/owner';
+ import { RegistryProxy } from '@ember/owner';
import Mixin from '@ember/object/mixin';
/**
* RegistryProxyMixin is used to provide public access to specific
* registry functionality.
*/
- interface RegistryProxyMixin extends Owner {
- /**
- * Given a fullName return the corresponding factory.
- */
- resolveRegistration(fullName: string): unknown;
- /**
- * Unregister a factory.
- */
- unregister(fullName: string): unknown;
- /**
- * Check if a factory is registered.
- */
- hasRegistration(fullName: string): boolean;
- /**
- * Register an option for a particular factory.
- */
- registerOption(fullName: string, optionName: string, options: {}): unknown;
- /**
- * Return a specific registered option for a particular factory.
- */
- registeredOption(fullName: string, optionName: string): {};
- /**
- * Register options for a particular factory.
- */
- registerOptions(fullName: string, options: {}): unknown;
- /**
- * Return registered options for a particular factory.
- */
- registeredOptions(fullName: string): {};
- /**
- * Allow registering options for all factories of a type.
- */
- registerOptionsForType(type: string, options: {}): unknown;
- /**
- * Return the registered options for all factories of a type.
- */
- registeredOptionsForType(type: string): {};
- /**
- * Define a dependency injection onto a specific factory or all factories
- * of a type.
- */
- inject(factoryNameOrType: string, property: string, injectionName: string): unknown;
- }
+ interface RegistryProxyMixin extends RegistryProxy {}
const RegistryProxyMixin: Mixin;
export default RegistryProxyMixin;
} | true |
Other | emberjs | ember.js | 5658b13a400011d1b946b580565d79df91d65424.json | Update preview types to match the implementation
Updates the preview types to include the `@ember/owner` types
introduced in an earlier commit. Besides updating the other existing
related exports to match the refactored types from the implementation,
the refactoring involved in landing correct types internally result in
a couple of key changes:
1. `getOwner()` always returns `Owner | undefined`. The previous
attempt to make it return `Owner` when working with a "known
object" of some sort runs into significant issues:
- Ember's public API allows the direct construction of many types
which are *normally* managed by the framework. It is legal, if
odd and *not recommended*, to instantiate any given `Factory`
with its `.create()` method:
import Component from '@glimmer/component';
import Session from '../services'
export default class Example extends Component {
session = Session.create();
}
In this example, the `session` property on `Example` will *not*
have an `Owner`, so it is not safe for `session` itself to rely
on that. This is annoying, but type safe, and straightforward
to work around. For example, a helper designed to look up services in templates might do something like this:
import Helper from '@ember/component/helper';
import { getOwner } from '@ember/owner';
import { assert } from '@ember/debug';
class GetService extends Helper {
compute([serviceName]) {
let owner = getOwner(this);
assert('unexpected missing an owner!', !!owner);
return owner.lookup(`service:${name}`);
}
}
Then if someone did `GetService.create()` instead of using
a helper in a template *or* with `invokeHelper()`, they
would get a useful error message.
- For the same reasons we cannot guarantee that contract from a
types perspective, it is actually impossible to *implement* it
in a type safe manner.
2. The service registry now *requires* that its fields be `Service`
subclasses. We added this constraint as part of generalizing the DI
registry system to work well with the `Owner` APIs while avoiding
introducing any circularity into the module graph. This should also
be future-compatible with alternative future designs. This should
not be breaking in practice, because items in the service registry
were always expected to be service classes.
(Note that this cannot be backported to the release because the modules
it represents do not exist until this whole PR lands.) | types/preview/@ember/engine/instance.d.ts | @@ -1,4 +1,5 @@
declare module '@ember/engine/instance' {
+ import { FullName } from '@ember/owner';
import ContainerProxyMixin from '@ember/engine/-private/container-proxy-mixin';
import RegistryProxyMixin from '@ember/engine/-private/registry-proxy-mixin';
import EmberObject from '@ember/object';
@@ -11,7 +12,7 @@ declare module '@ember/engine/instance' {
/**
* Unregister a factory.
*/
- unregister(fullName: string): unknown;
+ unregister(fullName: FullName): unknown;
/**
* Initialize the `EngineInstance` and return a promise that resolves | true |
Other | emberjs | ember.js | 5658b13a400011d1b946b580565d79df91d65424.json | Update preview types to match the implementation
Updates the preview types to include the `@ember/owner` types
introduced in an earlier commit. Besides updating the other existing
related exports to match the refactored types from the implementation,
the refactoring involved in landing correct types internally result in
a couple of key changes:
1. `getOwner()` always returns `Owner | undefined`. The previous
attempt to make it return `Owner` when working with a "known
object" of some sort runs into significant issues:
- Ember's public API allows the direct construction of many types
which are *normally* managed by the framework. It is legal, if
odd and *not recommended*, to instantiate any given `Factory`
with its `.create()` method:
import Component from '@glimmer/component';
import Session from '../services'
export default class Example extends Component {
session = Session.create();
}
In this example, the `session` property on `Example` will *not*
have an `Owner`, so it is not safe for `session` itself to rely
on that. This is annoying, but type safe, and straightforward
to work around. For example, a helper designed to look up services in templates might do something like this:
import Helper from '@ember/component/helper';
import { getOwner } from '@ember/owner';
import { assert } from '@ember/debug';
class GetService extends Helper {
compute([serviceName]) {
let owner = getOwner(this);
assert('unexpected missing an owner!', !!owner);
return owner.lookup(`service:${name}`);
}
}
Then if someone did `GetService.create()` instead of using
a helper in a template *or* with `invokeHelper()`, they
would get a useful error message.
- For the same reasons we cannot guarantee that contract from a
types perspective, it is actually impossible to *implement* it
in a type safe manner.
2. The service registry now *requires* that its fields be `Service`
subclasses. We added this constraint as part of generalizing the DI
registry system to work well with the `Owner` APIs while avoiding
introducing any circularity into the module graph. This should also
be future-compatible with alternative future designs. This should
not be breaking in practice, because items in the service registry
were always expected to be service classes.
(Note that this cannot be backported to the release because the modules
it represents do not exist until this whole PR lands.) | types/preview/@ember/owner/index.d.ts | @@ -1,50 +1,173 @@
declare module '@ember/owner' {
- import type { Registry } from '@ember/service';
-
/**
* The name for a factory consists of a namespace and the name of a specific
* type within that namespace, like `'service:session'`.
*/
- export type FullName = `${string}:${string}`;
+ export type FullName<
+ Type extends string = string,
+ Name extends string = string
+ > = `${Type}:${Name}`;
/**
- * Framework objects in an Ember application (components, services, routes,
- * etc.) are created via a factory and dependency injection system. Each of
- * these objects is the responsibility of an "owner", which handled its
- * instantiation and manages its lifetime.
+ * A type registry for the DI system, which other participants in the DI system
+ * can register themselves into with declaration merging. The contract for this
+ * type is that its keys are the `Type` from a `FullName`, and each value for a
+ * `Type` is another registry whose keys are the `Name` from a `FullName`. The
+ * mechanic for providing a registry is [declaration merging][handbook].
+ *
+ * [handbook]: https://www.typescriptlang.org/docs/handbook/declaration-merging.html
+ *
+ * For example, Ember's `Service` class uses this :
+ *
+ * ```ts
+ * export default class Service extends EmberObject {}
+ *
+ * // For concrete singleton classes to be merged into.
+ * interface Registry extends Record<string, Service> {}
+ *
+ * declare module '@ember/owner' {
+ * service: Registry;
+ * }
+ * ```
+ *
+ * Declarations of services can then include the registry:
+ *
+ * ```ts
+ * import Service from '@ember/service';
+ *
+ * export default class Session extends Service {
+ * login(username: string, password: string) {
+ * // ...
+ * }
+ * }
+ *
+ * declare module '@ember/service' {
+ * interface Registry {
+ * session: Session;
+ * }
+ * }
+ * ```
+ *
+ * Then users of the `Owner` API will be able to reliably do things like this:
+ *
+ * ```ts
+ * getOwner(this)?.lookup('service:session').login("hello", "1234abcd");
+ * ```
*/
- export default interface Owner {
- /**
- * Given a {@linkcode FullName} return a corresponding instance.
- */
- lookup<Name extends keyof Registry>(fullName: `service:${Name}`): Registry[Name];
- lookup(fullName: FullName): unknown;
+ export interface DIRegistry extends Record<string, Record<string, unknown>> {}
+ // Convenience utilities for pulling a specific factory manager off `DIRegistry`
+ // if one exists, or falling back to the default definition otherwise.
+ type ResolveFactoryManager<
+ Type extends ValidType,
+ Name extends ValidName<Type>
+ > = DIRegistry[Type][Name] extends object
+ ? FactoryManager<DIRegistry[Type][Name]>
+ : FactoryManager<object> | undefined;
+
+ type ResolveFactory<
+ Type extends ValidType,
+ Name extends ValidName<Type>
+ > = DIRegistry[Type][Name] extends object
+ ? Factory<DIRegistry[Type][Name]>
+ : Factory<object> | object | undefined;
+
+ // This type is shared between `Owner` and `RegistryProxy
+ interface BasicRegistry {
/**
- * Registers a factory or value that can be used for dependency injection
- * (with `inject`) or for service lookup. Each factory is registered with a
- * full name including two parts: `'type:name'`.
- *
- * - To override the default of instantiating the class on the `Factory`,
- * pass the `{ instantiate: false }` option. This is useful when you have
- * already instantiated the class to use with this factory.
- * - To override the default singleton behavior and instead create multiple
- * instances, pass the `{ singleton: false }` option.
- */
- // Dear future maintainer: yes, I know that `Factory<unknown> | object` is
- // an exceedingly weird type here. This is how we type it internally in
- // Ember itself. We actually allow more or less *anything* to be passed
+ Registers a factory that can be used for dependency injection (with
+ `inject`) or for service lookup. Each factory is registered with
+ a full name including two parts: `type:name`.
+
+ A simple example:
+
+ ```javascript
+ import Application from '@ember/application';
+ import EmberObject from '@ember/object';
+
+ let App = Application.create();
+
+ App.Orange = EmberObject.extend();
+ App.register('fruit:favorite', App.Orange);
+ ```
+
+ Ember will resolve factories from the `App` namespace automatically.
+ For example `App.CarsController` will be discovered and returned if
+ an application requests `controller:cars`.
+
+ An example of registering a controller with a non-standard name:
+
+ ```javascript
+ import Application from '@ember/application';
+ import Controller from '@ember/controller';
+
+ let App = Application.create();
+ let Session = Controller.extend();
+
+ App.register('controller:session', Session);
+
+ // The Session controller can now be treated like a normal controller,
+ // despite its non-standard name.
+ App.ApplicationController = Controller.extend({
+ needs: ['session']
+ });
+ ```
+
+ Registered factories are **instantiated** by having `create`
+ called on them. Additionally they are **singletons**, each time
+ they are looked up they return the same instance.
+
+ Some examples modifying that default behavior:
+
+ ```javascript
+ import Application from '@ember/application';
+ import EmberObject from '@ember/object';
+
+ let App = Application.create();
+
+ App.Person = EmberObject.extend();
+ App.Orange = EmberObject.extend();
+ App.Email = EmberObject.extend();
+ App.session = EmberObject.create();
+
+ App.register('model:user', App.Person, { singleton: false });
+ App.register('fruit:favorite', App.Orange);
+ App.register('communication:main', App.Email, { singleton: false });
+ App.register('session', App.session, { instantiate: false });
+ ```
+
+ @method register
+ @param fullName {String} type:name (e.g., 'model:user')
+ @param factory {any} (e.g., App.Person)
+ @param options {Object} (optional) disable instantiation or singleton usage
+ @public
+ */
+ // Dear future maintainer: yes, `Factory<object> | object` is an exceedingly
+ // weird type here. We actually allow more or less *anything* to be passed
// here. In the future, we may possibly be able to update this to actually
// take advantage of the `FullName` here to require that the registered
// factory and corresponding options do the right thing (passing an *actual*
// factory, not needing `create` if `options.instantiate` is `false`, etc.)
- // but doing so will require rationalizing Ember's own internals and may
- // need a full Ember RFC.
+ // but doing so will require rationalizing Ember's own internals and may need
+ // a full Ember RFC.
register(
fullName: FullName,
- factory: Factory<unknown> | object,
+ factory: Factory<object> | object,
options?: RegisterOptions
): void;
+ }
+
+ type ValidType = keyof DIRegistry & string;
+ type ValidName<Type extends ValidType> = keyof DIRegistry[Type] & string;
+
+ interface BasicContainer {
+ /**
+ * Given a {@linkcode FullName} return a corresponding instance.
+ */
+ lookup<Type extends ValidType, Name extends ValidName<Type>>(
+ fullName: FullName<Type, Name>,
+ options?: RegisterOptions
+ ): DIRegistry[Type][Name];
/**
* Given a fullName of the form `'type:name'`, like `'route:application'`,
@@ -54,9 +177,19 @@ declare module '@ember/owner' {
* destroyed manually by the caller of `.create()`. Typically, this is done
* during the creating objects own `destroy` or `willDestroy` methods.
*/
- factoryFor(fullName: FullName): FactoryManager<unknown> | undefined;
+ factoryFor<Type extends ValidType, Name extends ValidName<Type>>(
+ fullName: FullName<Type, Name>
+ ): ResolveFactoryManager<Type, Name>;
}
+ /**
+ * Framework objects in an Ember application (components, services, routes,
+ * etc.) are created via a factory and dependency injection system. Each of
+ * these objects is the responsibility of an "owner", which handles its
+ * instantiation and manages its lifetime.
+ */
+ export default interface Owner extends BasicRegistry, BasicContainer {}
+
export interface RegisterOptions {
instantiate?: boolean | undefined;
singleton?: boolean | undefined;
@@ -71,13 +204,27 @@ declare module '@ember/owner' {
* options to the {@linkcode Owner.register} method.
*/
export interface Factory<T> {
+ // NOTE: this does not check against the types of the target object in any
+ // way, unfortunately. However, we actually *cannot* constrain it further than
+ // this without going down a *very* deep rabbit hole (see the historic types
+ // for `.create()` on DefinitelyTyped if you're curious), because we need (for
+ // historical reasons) to support classes which implement this contract to be
+ // able to provide a *narrower* interface than "exactly the public fields on
+ // the class" while still falling back to the "exactly the public fields on
+ // the class" for the general case. :sigh:
+ //
+ // We stills upply both signatures because even though the second one means
+ // literally anything will *type check*, the first one means that the normal
+ // case of calling `.create()` for most implementors of the contract will at
+ // least get useful autocomplete.
/**
* A function that will create an instance of the class with any
* dependencies injected.
*
* @param initialValues Any values to set on an instance of the class
*/
create(initialValues?: Partial<T>): T;
+ create(initialValues?: object): T;
}
/**
@@ -120,11 +267,161 @@ declare module '@ember/owner' {
* `ember-resolver` in the default blueprint.
*/
export interface Resolver {
- resolve: (name: string) => Factory<object> | object | undefined;
+ resolve: <Type extends ValidType, Name extends ValidName<Type>>(
+ name: FullName<Type, Name>
+ ) => ResolveFactory<Type, Name>;
knownForType?: <Type extends string>(type: Type) => KnownForTypeResult<Type>;
lookupDescription?: (fullName: FullName) => string;
makeToString?: (factory: Factory<object>, fullName: FullName) => string;
- normalize?: (fullName: FullName) => string;
+ normalize?: (fullName: FullName) => FullName;
+ }
+
+ /**
+ * Framework objects in an Ember application (components, services, routes, etc.)
+ * are created via a factory and dependency injection system. Each of these
+ * objects is the responsibility of an "owner", which handled its
+ * instantiation and manages its lifetime.
+ *
+ * `getOwner` fetches the owner object responsible for an instance. This can
+ * be used to lookup or resolve other class instances, or register new factories
+ * into the owner.
+ *
+ * For example, this component dynamically looks up a service based on the
+ * `audioType` passed as an argument:
+ *
+ * ```app/components/play-audio.js
+ * import Component from '@glimmer/component';
+ * import { action } from '@ember/object';
+ * import { getOwner } from '@ember/application';
+ *
+ * // Usage:
+ * //
+ * // <PlayAudio @audioType={{@model.audioType}} @audioFile={{@model.file}}/>
+ * //
+ * export default class PlayAudio extends Component {
+ * get audioService() {
+ * return getOwner(this)?.lookup(`service:${this.args.audioType}`);
+ * }
+ *
+ * @action
+ * onPlay() {
+ * this.audioService?.play(this.args.audioFile);
+ * }
+ * }
+ * ```
+ */
+ export function getOwner(object: object): Owner | undefined;
+
+ /**
+ * `setOwner` forces a new owner on a given object instance. This is primarily
+ * useful in some testing cases.
+ *
+ * @param object An object instance.
+ * @param owner The new owner object of the object instance.
+ */
+ export function setOwner(object: object, owner: Owner): void;
+
+ export interface ContainerProxy extends BasicContainer {
+ /**
+ * Returns an object that can be used to provide an owner to a
+ * manually created instance.
+ *
+ * Example:
+ *
+ * ```
+ * import { getOwner } from '@ember/application';
+ *
+ * let owner = getOwner(this);
+ *
+ * User.create(
+ * owner.ownerInjection(),
+ * { username: 'rwjblue' }
+ * )
+ * ```
+ */
+ ownerInjection(): object;
+ }
+
+ export interface RegistryProxy extends BasicRegistry {
+ /**
+ * Given a fullName return the corresponding factory.
+ */
+ resolveRegistration(fullName: FullName): Factory<object> | object | undefined;
+
+ /**
+ * Unregister a factory.
+ *
+ *
+ * ```javascript
+ * import Application from '@ember/application';
+ * import EmberObject from '@ember/object';
+ * let App = Application.create();
+ * let User = EmberObject.extend();
+ * App.register('model:user', User);
+ *
+ * App.resolveRegistration('model:user').create() instanceof User //=> true
+ *
+ * App.unregister('model:user')
+ * App.resolveRegistration('model:user') === undefined //=> true
+ * ```
+ */
+ unregister(fullName: FullName): void;
+
+ /**
+ * Check if a factory is registered.
+ */
+ hasRegistration(fullName: FullName): boolean;
+
+ /**
+ * Return a specific registered option for a particular factory.
+ */
+ registeredOption<K extends keyof RegisterOptions>(
+ fullName: FullName,
+ optionName: K
+ ): RegisterOptions[K] | undefined;
+
+ /**
+ * Register options for a particular factory.
+ */
+ registerOptions(fullName: FullName, options: RegisterOptions): void;
+
+ /**
+ * Return registered options for a particular factory.
+ */
+ registeredOptions(fullName: FullName): RegisterOptions | undefined;
+
+ /**
+ * Allow registering options for all factories of a type.
+ *
+ * ```javascript
+ * import Application from '@ember/application';
+ *
+ * let App = Application.create();
+ * let appInstance = App.buildInstance();
+ *
+ * // if all of type `connection` must not be singletons
+ * appInstance.registerOptionsForType('connection', { singleton: false });
+ *
+ * appInstance.register('connection:twitter', TwitterConnection);
+ * appInstance.register('connection:facebook', FacebookConnection);
+ *
+ * let twitter = appInstance.lookup('connection:twitter');
+ * let twitter2 = appInstance.lookup('connection:twitter');
+ *
+ * twitter === twitter2; // => false
+ *
+ * let facebook = appInstance.lookup('connection:facebook');
+ * let facebook2 = appInstance.lookup('connection:facebook');
+ *
+ * facebook === facebook2; // => false
+ * ```
+ */
+ registerOptionsForType(type: string, options: RegisterOptions): void;
+
+ /**
+ * Return the registered options for all factories of a type.
+ */
+ registeredOptionsForType(type: string): RegisterOptions | undefined;
}
// Don't export things unless we *intend* to. | true |
Other | emberjs | ember.js | 5658b13a400011d1b946b580565d79df91d65424.json | Update preview types to match the implementation
Updates the preview types to include the `@ember/owner` types
introduced in an earlier commit. Besides updating the other existing
related exports to match the refactored types from the implementation,
the refactoring involved in landing correct types internally result in
a couple of key changes:
1. `getOwner()` always returns `Owner | undefined`. The previous
attempt to make it return `Owner` when working with a "known
object" of some sort runs into significant issues:
- Ember's public API allows the direct construction of many types
which are *normally* managed by the framework. It is legal, if
odd and *not recommended*, to instantiate any given `Factory`
with its `.create()` method:
import Component from '@glimmer/component';
import Session from '../services'
export default class Example extends Component {
session = Session.create();
}
In this example, the `session` property on `Example` will *not*
have an `Owner`, so it is not safe for `session` itself to rely
on that. This is annoying, but type safe, and straightforward
to work around. For example, a helper designed to look up services in templates might do something like this:
import Helper from '@ember/component/helper';
import { getOwner } from '@ember/owner';
import { assert } from '@ember/debug';
class GetService extends Helper {
compute([serviceName]) {
let owner = getOwner(this);
assert('unexpected missing an owner!', !!owner);
return owner.lookup(`service:${name}`);
}
}
Then if someone did `GetService.create()` instead of using
a helper in a template *or* with `invokeHelper()`, they
would get a useful error message.
- For the same reasons we cannot guarantee that contract from a
types perspective, it is actually impossible to *implement* it
in a type safe manner.
2. The service registry now *requires* that its fields be `Service`
subclasses. We added this constraint as part of generalizing the DI
registry system to work well with the `Owner` APIs while avoiding
introducing any circularity into the module graph. This should also
be future-compatible with alternative future designs. This should
not be breaking in practice, because items in the service registry
were always expected to be service classes.
(Note that this cannot be backported to the release because the modules
it represents do not exist until this whole PR lands.) | types/preview/@ember/service/index.d.ts | @@ -21,5 +21,12 @@ declare module '@ember/service' {
// A type registry for Ember `Service`s. Meant to be declaration-merged so
// string lookups resolve to the correct type.
- interface Registry {}
+ export interface Registry extends Record<string, Service> {}
+}
+
+declare module '@ember/owner' {
+ import { Registry } from '@ember/service';
+ export interface DIRegistry {
+ service: Registry;
+ }
} | true |
Other | emberjs | ember.js | 52b7330344263db48e01f841a9e45211a1994702.json | Move docs for `getOwner` to `@ember/owner`
This is a TSDoc-friendly/future-proofing change: most of the items which
`@ember/owner` re-exports from `@ember/-internals/owner` can be
documented at the definition site, because they are plain re-exports.
`getOwner` is a bit different, because (as discussed in an earlier
commit) the public `Owner` type it returns has much less detail than our
`InternalOwner` type. We do this via a reassignment of the item, so the
docs need to move to that reassignment to be visible for TS consumers
and, in the future, for TSDoc extraction of docs.
The existing YUIDoc infrastructure will be unaffected by this move. | packages/@ember/owner/index.ts | @@ -31,7 +31,57 @@ interface GetOwner {
(object: object): Owner | undefined;
}
-const getOwner = internalGetOwner as GetOwner;
+// SAFETY: this is *only* safe for public API, because we are promising more
+// than we can actually *totally* guarantee we uphold otherwise. Specifically,
+// users *can* do things (including abusing the `ReliablyHasOwner` type or
+// corresponding interface) to get types which violate this contract. However,
+// doing so is only possible if they break the public API contract! Notably, for
+// our internals, we should *not* provide this.
+/**
+ Framework objects in an Ember application (components, services, routes, etc.)
+ are created via a factory and dependency injection system. Each of these
+ objects is the responsibility of an "owner", which handled its
+ instantiation and manages its lifetime.
+
+ `getOwner` fetches the owner object responsible for an instance. This can
+ be used to lookup or resolve other class instances, or register new factories
+ into the owner.
+
+ For example, this component dynamically looks up a service based on the
+ `audioType` passed as an argument:
+
+ ```app/components/play-audio.js
+ import Component from '@glimmer/component';
+ import { action } from '@ember/object';
+ import { getOwner } from '@ember/application';
+
+ // Usage:
+ //
+ // <PlayAudio @audioType={{@model.audioType}} @audioFile={{@model.file}}/>
+ //
+ export default class extends Component {
+ get audioService() {
+ let owner = getOwner(this);
+ return owner.lookup(`service:${this.args.audioType}`);
+ }
+
+ @action
+ onPlay() {
+ let player = this.audioService;
+ player.play(this.args.audioFile);
+ }
+ }
+ ```
+
+ @method getOwner
+ @static
+ @for @ember/owner
+ @param {Object} object An object with an owner.
+ @return {Object} An owner object.
+ @since 2.3.0
+ @public
+*/
+const getOwner: GetOwner = internalGetOwner;
export { getOwner };
// Everything else, we can directly re-export. | false |
Other | emberjs | ember.js | f85530327875bcb457752ab30f1c226af4959bf0.json | Improve type safety for `.create()`
This attempts to make `.create()` type safe by constraining its
argument to be `Partial<T>`. | packages/@ember/-internals/container/lib/container.ts | @@ -254,7 +254,7 @@ function wrapManagerInDeprecationProxy<T extends object, C extends object | Fact
let m = manager;
let proxiedManager = {
class: m.class,
- create(props?: { [prop: string]: any }) {
+ create(props?: Partial<T>) {
return m.create(props);
},
};
@@ -522,7 +522,7 @@ export class InternalFactoryManager<
return this.madeToString;
}
- create(options?: { [prop: string]: any }) {
+ create(options?: Partial<T>) {
let { container } = this;
if (container.isDestroyed) { | true |
Other | emberjs | ember.js | f85530327875bcb457752ab30f1c226af4959bf0.json | Improve type safety for `.create()`
This attempts to make `.create()` type safe by constraining its
argument to be `Partial<T>`. | packages/@ember/-internals/glimmer/lib/setup-registry.ts | @@ -18,7 +18,9 @@ export function setupApplicationRegistry(registry: Registry): void {
// we need to use bind() to copy the function so factory for
// association won't leak
registry.register('service:-dom-builder', {
- create(props) {
+ // Additionally, we *must* constrain this to require `props` on create, else
+ // we *know* it cannot have an owner.
+ create(props: object) {
let owner = getOwner(props);
assert('DomBuilderService is unexpectedly missing an owner', owner);
let env = owner.lookup('-environment:main') as { _renderMode: string }; | true |
Other | emberjs | ember.js | 6ddeeec3d6cc15d28247c9d7da57e4a9c88be74f.json | Combine some imports for clarity | packages/@ember/-internals/glimmer/lib/component-managers/curly.ts | @@ -1,5 +1,9 @@
-import { getOwner, setOwner } from '@ember/-internals/owner';
-import type { InternalFactory, default as Owner } from '@ember/-internals/owner';
+import {
+ type default as Owner,
+ type InternalFactory,
+ getOwner,
+ setOwner,
+} from '@ember/-internals/owner';
import { enumerableSymbol, guidFor } from '@ember/-internals/utils';
import { addChildView, setElementView, setViewElement } from '@ember/-internals/views';
import { assert, debugFreeze } from '@ember/debug'; | true |
Other | emberjs | ember.js | 6ddeeec3d6cc15d28247c9d7da57e4a9c88be74f.json | Combine some imports for clarity | packages/@ember/engine/type-tests/index.test.ts | @@ -1,13 +1,13 @@
-import type { Factory, Owner, RegisterOptions } from '@ember/-internals/owner';
+import type { ResolverClass } from '@ember/-internals/container/lib/registry';
+import type { default as Owner, RegisterOptions, Factory } from '@ember/owner';
import type Namespace from '@ember/application/namespace';
import type { Initializer } from '@ember/engine';
import Engine from '@ember/engine';
import type EngineInstance from '@ember/engine/instance';
import EmberObject from '@ember/object';
import { expectTypeOf } from 'expect-type';
-// Good enough for tests
-let owner = {} as Owner;
+declare let owner: Owner;
class Foo extends EmberObject {}
class Bar {} | true |
Other | emberjs | ember.js | 18be345ea7cf90f389769f15a0ac4d20ea033aad.json | Distinguish `Factory` and `InternalFactory`
Like with our distinction between `Owner` and `InternalOwner`, the
notion of a `Factory` as we use it internally is somewhat richer than
what we provide as a public interface. Thus, add an `InternalFactory`
type which extends the public `Factory` interface, and update the
internals which previously referred to `Factory` to refer to the new
type instead.
In a future cleanup pass, we can likely remove many of these uses of
`InternalFactory` in favor of using *only* the public API for `Factory`
from instead, and that will help smooth the path to removing many of
these unnecessary extra details. | packages/@ember/-internals/container/lib/container.ts | @@ -1,5 +1,5 @@
import type {
- Factory,
+ InternalFactory,
FactoryClass,
InternalOwner,
RegisterOptions,
@@ -145,7 +145,10 @@ export default class Container {
@param {RegisterOptions} [options]
@return {any}
*/
- lookup(fullName: string, options?: RegisterOptions): Factory<object> | object | undefined {
+ lookup(
+ fullName: string,
+ options?: RegisterOptions
+ ): InternalFactory<object> | object | undefined {
if (this.isDestroyed) {
throw new Error(`Cannot call \`.lookup\` after the owner has been destroyed`);
}
@@ -268,8 +271,8 @@ function isInstantiatable(container: Container, fullName: string) {
function lookup(
container: Container,
fullName: string,
-): Factory<object> | object | undefined {
options: RegisterOptions = {}
+): InternalFactory<object> | object | undefined {
let normalizedName = fullName;
if (
@@ -370,8 +373,8 @@ function instantiateFactory(
container: Container,
normalizedName: string,
fullName: string,
-): Factory<object> | object | undefined {
options: RegisterOptions
+): InternalFactory<object> | object | undefined {
let factoryManager = factoryFor(container, normalizedName, fullName);
if (factoryManager === undefined) {
@@ -450,7 +453,7 @@ export interface LazyInjection {
}
declare interface DebugFactory<T extends object, C extends FactoryClass | object = FactoryClass>
- extends Factory<T, C> {
+ extends InternalFactory<T, C> {
_onLookup?: (fullName: string) => void;
_initFactory?: (factoryManager: FactoryManager<T, C>) => void;
_lazyInjections(): { [key: string]: LazyInjection };
@@ -477,7 +480,7 @@ export class FactoryManager<T extends object, C extends FactoryClass | object =
constructor(
container: Container,
- factory: Factory<T, C>,
+ factory: InternalFactory<T, C>,
fullName: string,
normalizedName: string
) { | true |
Other | emberjs | ember.js | 18be345ea7cf90f389769f15a0ac4d20ea033aad.json | Distinguish `Factory` and `InternalFactory`
Like with our distinction between `Owner` and `InternalOwner`, the
notion of a `Factory` as we use it internally is somewhat richer than
what we provide as a public interface. Thus, add an `InternalFactory`
type which extends the public `Factory` interface, and update the
internals which previously referred to `Factory` to refer to the new
type instead.
In a future cleanup pass, we can likely remove many of these uses of
`InternalFactory` in favor of using *only* the public API for `Factory`
from instead, and that will help smooth the path to removing many of
these unnecessary extra details. | packages/@ember/-internals/container/lib/registry.ts | @@ -1,4 +1,4 @@
-import type { Factory, Resolver, RegisterOptions } from '@ember/-internals/owner';
+import type { InternalFactory, Resolver, RegisterOptions } from '@ember/-internals/owner';
import { dictionary, intern } from '@ember/-internals/utils';
import { assert, deprecate } from '@ember/debug';
import type { set } from '@ember/object';
@@ -58,10 +58,10 @@ export default class Registry implements IRegistry {
readonly _failSet: Set<string>;
resolver: Resolver | null;
readonly fallback: IRegistry | null;
- readonly registrations: Record<string, Factory<object> | object>;
readonly _normalizeCache: Record<string, string>;
- readonly _resolveCache: Record<string, Factory<object> | object>;
+ readonly registrations: Record<string, InternalFactory<object> | object>;
readonly _options: Record<string, RegisterOptions>;
+ readonly _resolveCache: Record<string, InternalFactory<object> | object>;
readonly _typeOptions: Record<string, RegisterOptions>;
set?: typeof set;
@@ -168,12 +168,12 @@ export default class Registry implements IRegistry {
): void;
register<T extends object, C extends FactoryClass | object>(
fullName: string,
- factory: Factory<T, C>,
+ factory: InternalFactory<T, C>,
options?: RegisterOptions
): void;
register(
fullName: string,
- factory: object | Factory<object>,
+ factory: object | InternalFactory<object>,
options: RegisterOptions = {}
): void {
assert('fullName must be a proper full name', this.isValidFullName(fullName));
@@ -252,7 +252,7 @@ export default class Registry implements IRegistry {
@param {String} fullName
@return {Function} fullName's factory
*/
- resolve(fullName: string): Factory<object> | object | undefined {
+ resolve(fullName: string): InternalFactory<object> | object | undefined {
let factory = resolve(this, this.normalize(fullName));
if (factory === undefined && this.fallback !== null) {
factory = this.fallback.resolve(fullName);
@@ -324,7 +324,7 @@ export default class Registry implements IRegistry {
@param {string} fullName
@return {function} toString function
*/
- makeToString(factory: Factory<object>, fullName: string): string {
+ makeToString(factory: InternalFactory<object>, fullName: string): string {
if (this.resolver !== null && this.resolver.makeToString) {
return this.resolver.makeToString(factory, fullName);
} else if (this.fallback !== null) {
@@ -545,7 +545,7 @@ if (DEBUG) {
function resolve(
registry: Registry,
_normalizedName: string
-): Factory<object> | object | undefined {
+): InternalFactory<object> | object | undefined {
let normalizedName = _normalizedName;
let cached = registry._resolveCache[normalizedName];
@@ -556,7 +556,7 @@ function resolve(
return;
}
- let resolved: Factory<object> | object | undefined;
+ let resolved: InternalFactory<object> | object | undefined;
if (registry.resolver) {
resolved = registry.resolver.resolve(normalizedName); | true |
Other | emberjs | ember.js | 18be345ea7cf90f389769f15a0ac4d20ea033aad.json | Distinguish `Factory` and `InternalFactory`
Like with our distinction between `Owner` and `InternalOwner`, the
notion of a `Factory` as we use it internally is somewhat richer than
what we provide as a public interface. Thus, add an `InternalFactory`
type which extends the public `Factory` interface, and update the
internals which previously referred to `Factory` to refer to the new
type instead.
In a future cleanup pass, we can likely remove many of these uses of
`InternalFactory` in favor of using *only* the public API for `Factory`
from instead, and that will help smooth the path to removing many of
these unnecessary extra details. | packages/@ember/-internals/glimmer/lib/component-managers/curly.ts | @@ -1,5 +1,5 @@
import { getOwner, setOwner } from '@ember/-internals/owner';
-import type { Factory, default as Owner } from '@ember/-internals/owner';
+import type { InternalFactory, default as Owner } from '@ember/-internals/owner';
import { enumerableSymbol, guidFor } from '@ember/-internals/utils';
import { addChildView, setElementView, setViewElement } from '@ember/-internals/views';
import { assert, debugFreeze } from '@ember/debug';
@@ -104,7 +104,7 @@ const EMPTY_POSITIONAL_ARGS: Reference[] = [];
debugFreeze(EMPTY_POSITIONAL_ARGS);
-type ComponentFactory = Factory<
+type ComponentFactory = InternalFactory<
Component,
{
create(props?: any): Component; | true |
Other | emberjs | ember.js | 18be345ea7cf90f389769f15a0ac4d20ea033aad.json | Distinguish `Factory` and `InternalFactory`
Like with our distinction between `Owner` and `InternalOwner`, the
notion of a `Factory` as we use it internally is somewhat richer than
what we provide as a public interface. Thus, add an `InternalFactory`
type which extends the public `Factory` interface, and update the
internals which previously referred to `Factory` to refer to the new
type instead.
In a future cleanup pass, we can likely remove many of these uses of
`InternalFactory` in favor of using *only* the public API for `Factory`
from instead, and that will help smooth the path to removing many of
these unnecessary extra details. | packages/@ember/-internals/glimmer/lib/helper.ts | @@ -3,7 +3,7 @@
*/
import type { FactoryManager } from '@ember/-internals/container/lib/container';
-import type { Factory, InternalOwner } from '@ember/-internals/owner';
+import type { InternalFactory, InternalOwner } from '@ember/-internals/owner';
import { setOwner } from '@ember/-internals/owner';
import { FrameworkObject } from '@ember/object/-internals';
import { getDebugName } from '@ember/-internals/utils';
@@ -21,11 +21,11 @@ export type HelperFunction<T, P extends unknown[], N extends Dict<unknown>> = (
named: N
) => T;
-export type SimpleHelperFactory<T, P extends unknown[], N extends Dict<unknown>> = Factory<
+export type SimpleHelperFactory<T, P extends unknown[], N extends Dict<unknown>> = InternalFactory<
SimpleHelper<T, P, N>,
HelperFactory<SimpleHelper<T, P, N>>
>;
-export type ClassHelperFactory = Factory<HelperInstance, HelperFactory<HelperInstance>>;
+export type ClassHelperFactory = InternalFactory<HelperInstance, HelperFactory<HelperInstance>>;
export interface HelperFactory<T> {
isHelperFactory: true; | true |
Other | emberjs | ember.js | 18be345ea7cf90f389769f15a0ac4d20ea033aad.json | Distinguish `Factory` and `InternalFactory`
Like with our distinction between `Owner` and `InternalOwner`, the
notion of a `Factory` as we use it internally is somewhat richer than
what we provide as a public interface. Thus, add an `InternalFactory`
type which extends the public `Factory` interface, and update the
internals which previously referred to `Factory` to refer to the new
type instead.
In a future cleanup pass, we can likely remove many of these uses of
`InternalFactory` in favor of using *only* the public API for `Factory`
from instead, and that will help smooth the path to removing many of
these unnecessary extra details. | packages/@ember/-internals/glimmer/lib/resolver.ts | @@ -1,6 +1,6 @@
import { privatize as P } from '@ember/-internals/container';
import { ENV } from '@ember/-internals/environment';
-import type { Factory, InternalOwner, RegisterOptions } from '@ember/-internals/owner';
+import type { InternalFactory, InternalOwner, RegisterOptions } from '@ember/-internals/owner';
import { isFactory } from '@ember/-internals/owner';
import { EMBER_UNIQUE_ID_HELPER } from '@ember/canary-features';
import { assert } from '@ember/debug';
@@ -55,7 +55,10 @@ function instrumentationPayload(name: string) {
}
let fullName = `component:${name}`;
-function componentFor(name: string, owner: InternalOwner): Option<Factory<object> | object> {
+function componentFor(
+ name: string,
+ owner: InternalOwner
+): Option<InternalFactory<object> | object> {
return owner.factoryFor(fullName) || null;
}
@@ -71,11 +74,11 @@ function layoutFor(
type LookupResult =
| {
- component: Factory<object>;
+ component: InternalFactory<object>;
layout: TemplateFactory;
}
| {
- component: Factory<object>;
+ component: InternalFactory<object>;
layout: null;
}
| { | true |
Other | emberjs | ember.js | 18be345ea7cf90f389769f15a0ac4d20ea033aad.json | Distinguish `Factory` and `InternalFactory`
Like with our distinction between `Owner` and `InternalOwner`, the
notion of a `Factory` as we use it internally is somewhat richer than
what we provide as a public interface. Thus, add an `InternalFactory`
type which extends the public `Factory` interface, and update the
internals which previously referred to `Factory` to refer to the new
type instead.
In a future cleanup pass, we can likely remove many of these uses of
`InternalFactory` in favor of using *only* the public API for `Factory`
from instead, and that will help smooth the path to removing many of
these unnecessary extra details. | packages/@ember/-internals/owner/index.ts | @@ -37,6 +37,32 @@ export interface RegisterOptions {
singleton?: boolean | undefined;
}
+/**
+ * Registered factories are instantiated by having create called on them.
+ * Additionally they are singletons by default, so each time they are looked up
+ * they return the same instance.
+ *
+ * However, that behavior can be modified with the `instantiate` and `singleton`
+ * options to the {@linkcode Owner.register} method.
+ */
+export interface Factory<T extends object> {
+ // NOTE: this does not check against the types of the target object in any
+ // way, unfortunately. However, we actually *cannot* constrain it further than
+ // this without going down a *very* deep rabbit hole (see the historic types
+ // for `.create()` on DefinitelyTyped if you're curious), because we need (for
+ // historical reasons) to support classes which implement this contract to be
+ // able to provide a *narrower* interface than "exactly the public fields on
+ // the class" while still falling back to the "exactly the public fields on
+ // the class" for the general case. :sigh:
+ /**
+ * A function that will create an instance of the class with any
+ * dependencies injected.
+ *
+ * @param initialValues Any values to set on an instance of the class
+ */
+ create(initialValues?: object): T;
+}
+
/**
* A `Resolver` is the mechanism responsible for looking up code in your
* application and converting its naming conventions into the actual classes,
@@ -63,16 +89,16 @@ export interface FactoryClass {
positionalParams?: string | string[] | undefined | null;
}
-export interface Factory<T extends object, C extends FactoryClass | object = FactoryClass> {
+export interface InternalFactory<T extends object, C extends FactoryClass | object = FactoryClass>
+ extends Factory<T> {
class?: C;
name?: string;
- fullName?: string;
+ fullName?: FullName;
normalizedName?: string;
- create(props?: { [prop: string]: any }): T;
}
-export function isFactory(obj: unknown): obj is Factory<object> {
- return obj != null && typeof (obj as Factory<object>).create === 'function';
+export function isFactory(obj: unknown): obj is InternalFactory<object> {
+ return obj != null && typeof (obj as InternalFactory<object>).create === 'function';
}
/** | true |
Other | emberjs | ember.js | 18be345ea7cf90f389769f15a0ac4d20ea033aad.json | Distinguish `Factory` and `InternalFactory`
Like with our distinction between `Owner` and `InternalOwner`, the
notion of a `Factory` as we use it internally is somewhat richer than
what we provide as a public interface. Thus, add an `InternalFactory`
type which extends the public `Factory` interface, and update the
internals which previously referred to `Factory` to refer to the new
type instead.
In a future cleanup pass, we can likely remove many of these uses of
`InternalFactory` in favor of using *only* the public API for `Factory`
from instead, and that will help smooth the path to removing many of
these unnecessary extra details. | packages/@ember/routing/lib/dsl.ts | @@ -1,4 +1,4 @@
-import type { Factory } from '@ember/-internals/owner';
+import type { InternalFactory } from '@ember/-internals/owner';
import { assert } from '@ember/debug';
import type { Option } from '@glimmer/interfaces';
import type { MatchCallback } from 'route-recognizer';
@@ -44,7 +44,7 @@ export interface DSLImplOptions {
enableLoadingSubstates: boolean;
engineInfo?: EngineInfo;
addRouteForEngine(name: string, routeOptions: EngineRouteInfo): void;
- resolveRouteMap(name: string): Factory<any, any>;
+ resolveRouteMap(name: string): InternalFactory<any, any>;
}
export default class DSLImpl implements DSL { | true |
Other | emberjs | ember.js | 18be345ea7cf90f389769f15a0ac4d20ea033aad.json | Distinguish `Factory` and `InternalFactory`
Like with our distinction between `Owner` and `InternalOwner`, the
notion of a `Factory` as we use it internally is somewhat richer than
what we provide as a public interface. Thus, add an `InternalFactory`
type which extends the public `Factory` interface, and update the
internals which previously referred to `Factory` to refer to the new
type instead.
In a future cleanup pass, we can likely remove many of these uses of
`InternalFactory` in favor of using *only* the public API for `Factory`
from instead, and that will help smooth the path to removing many of
these unnecessary extra details. | packages/@ember/routing/lib/generate_controller.ts | @@ -1,5 +1,5 @@
import { get } from '@ember/-internals/metal';
-import type { Factory, default as Owner } from '@ember/-internals/owner';
+import type { InternalFactory, default as Owner } from '@ember/-internals/owner';
import Controller from '@ember/controller';
import { assert, info } from '@ember/debug';
import { DEBUG } from '@glimmer/env';
@@ -16,7 +16,10 @@ import { DEBUG } from '@glimmer/env';
@private
*/
-export function generateControllerFactory(owner: Owner, controllerName: string): Factory<{}> {
+export function generateControllerFactory(
+ owner: Owner,
+ controllerName: string
+): InternalFactory<{}> {
let factoryManager = owner.factoryFor('controller:basic');
assert(
'[BUG] unexpectedly missing a factoryManager for `controller:basic`',
@@ -39,7 +42,7 @@ export function generateControllerFactory(owner: Owner, controllerName: string):
owner.register(fullName, Factory);
- return owner.factoryFor(fullName) as Factory<{}>;
+ return owner.factoryFor(fullName) as InternalFactory<{}>;
}
/** | true |
Other | emberjs | ember.js | 18be345ea7cf90f389769f15a0ac4d20ea033aad.json | Distinguish `Factory` and `InternalFactory`
Like with our distinction between `Owner` and `InternalOwner`, the
notion of a `Factory` as we use it internally is somewhat richer than
what we provide as a public interface. Thus, add an `InternalFactory`
type which extends the public `Factory` interface, and update the
internals which previously referred to `Factory` to refer to the new
type instead.
In a future cleanup pass, we can likely remove many of these uses of
`InternalFactory` in favor of using *only* the public API for `Factory`
from instead, and that will help smooth the path to removing many of
these unnecessary extra details. | packages/internal-test-helpers/lib/test-cases/rendering.ts | @@ -10,7 +10,7 @@ import { ModuleBasedResolver } from '../test-resolver';
import AbstractTestCase from './abstract';
import buildOwner from '../build-owner';
import { runAppend, runDestroy, runTask } from '../run';
-import type { Factory } from '@ember/-internals/owner';
+import type { InternalFactory } from '@ember/-internals/owner';
import type { BootOptions, EngineInstanceOptions } from '@ember/engine/instance';
import type EngineInstance from '@ember/engine/instance';
import type { HelperFunction } from '@ember/-internals/glimmer/lib/helper';
@@ -75,7 +75,7 @@ export default abstract class RenderingTestCase extends AbstractTestCase {
return new ModuleBasedResolver();
}
- add(specifier: string, factory: Factory<object> | object) {
+ add(specifier: string, factory: InternalFactory<object> | object) {
this.resolver.add(specifier, factory);
}
@@ -173,7 +173,7 @@ export default abstract class RenderingTestCase extends AbstractTestCase {
}
}
- registerCustomHelper(name: string, definition: Factory<object>) {
+ registerCustomHelper(name: string, definition: InternalFactory<object>) {
this.owner.register(`helper:${name}`, definition);
}
@@ -194,13 +194,13 @@ export default abstract class RenderingTestCase extends AbstractTestCase {
}
}
- registerModifier(name: string, ModifierClass: Factory<object>) {
+ registerModifier(name: string, ModifierClass: InternalFactory<object>) {
let { owner } = this;
owner.register(`modifier:${name}`, ModifierClass);
}
- registerComponentManager(name: string, manager: Factory<object>) {
+ registerComponentManager(name: string, manager: InternalFactory<object>) {
let owner = this.owner;
owner.register(`component-manager:${name}`, manager);
}
@@ -219,7 +219,7 @@ export default abstract class RenderingTestCase extends AbstractTestCase {
}
}
- registerService(name: string, klass: Factory<object>) {
+ registerService(name: string, klass: InternalFactory<object>) {
this.owner.register(`service:${name}`, klass);
}
| true |
Other | emberjs | ember.js | 18be345ea7cf90f389769f15a0ac4d20ea033aad.json | Distinguish `Factory` and `InternalFactory`
Like with our distinction between `Owner` and `InternalOwner`, the
notion of a `Factory` as we use it internally is somewhat richer than
what we provide as a public interface. Thus, add an `InternalFactory`
type which extends the public `Factory` interface, and update the
internals which previously referred to `Factory` to refer to the new
type instead.
In a future cleanup pass, we can likely remove many of these uses of
`InternalFactory` in favor of using *only* the public API for `Factory`
from instead, and that will help smooth the path to removing many of
these unnecessary extra details. | packages/internal-test-helpers/lib/test-cases/router-non-application.ts | @@ -12,7 +12,7 @@ import buildOwner from '../build-owner';
import { runAppend, runDestroy } from '../run';
import type { BootOptions, EngineInstanceOptions } from '@ember/engine/instance';
import type EngineInstance from '@ember/engine/instance';
-import type { Factory } from '@ember/-internals/owner';
+import type { InternalFactory } from '@ember/-internals/owner';
export default class RouterNonApplicationTestCase extends AbstractTestCase {
owner: EngineInstance;
@@ -59,7 +59,7 @@ export default class RouterNonApplicationTestCase extends AbstractTestCase {
return new ModuleBasedResolver();
}
- add(specifier: string, factory: Factory<object> | object) {
+ add(specifier: string, factory: InternalFactory<object> | object) {
this.resolver.add(specifier, factory);
}
| true |
Other | emberjs | ember.js | 18be345ea7cf90f389769f15a0ac4d20ea033aad.json | Distinguish `Factory` and `InternalFactory`
Like with our distinction between `Owner` and `InternalOwner`, the
notion of a `Factory` as we use it internally is somewhat richer than
what we provide as a public interface. Thus, add an `InternalFactory`
type which extends the public `Factory` interface, and update the
internals which previously referred to `Factory` to refer to the new
type instead.
In a future cleanup pass, we can likely remove many of these uses of
`InternalFactory` in favor of using *only* the public API for `Factory`
from instead, and that will help smooth the path to removing many of
these unnecessary extra details. | packages/internal-test-helpers/lib/test-cases/test-resolver-application.ts | @@ -2,7 +2,7 @@ import AbstractApplicationTestCase from './abstract-application';
import type Resolver from '../test-resolver';
import { ModuleBasedResolver } from '../test-resolver';
import Component from '@ember/component';
-import type { Factory } from '@ember/-internals/owner';
+import type { InternalFactory } from '@ember/-internals/owner';
export default abstract class TestResolverApplicationTestCase extends AbstractApplicationTestCase {
abstract resolver?: Resolver;
@@ -13,7 +13,7 @@ export default abstract class TestResolverApplicationTestCase extends AbstractAp
});
}
- add(specifier: string, factory: Factory<object> | object) {
+ add(specifier: string, factory: InternalFactory<object> | object) {
this.resolver!.add(specifier, factory);
}
| true |
Other | emberjs | ember.js | 18be345ea7cf90f389769f15a0ac4d20ea033aad.json | Distinguish `Factory` and `InternalFactory`
Like with our distinction between `Owner` and `InternalOwner`, the
notion of a `Factory` as we use it internally is somewhat richer than
what we provide as a public interface. Thus, add an `InternalFactory`
type which extends the public `Factory` interface, and update the
internals which previously referred to `Factory` to refer to the new
type instead.
In a future cleanup pass, we can likely remove many of these uses of
`InternalFactory` in favor of using *only* the public API for `Factory`
from instead, and that will help smooth the path to removing many of
these unnecessary extra details. | packages/internal-test-helpers/lib/test-resolver.ts | @@ -1,6 +1,6 @@
import { compile } from 'ember-template-compiler';
-import type { Factory, Resolver as IResolver } from '@ember/-internals/owner';
+import type { InternalFactory, Resolver as IResolver } from '@ember/-internals/owner';
const DELIMITER = '%';
@@ -14,17 +14,17 @@ function serializeKey(specifier: string, source?: unknown, namespace?: unknown)
}
class Resolver implements IResolver {
- _registered: Record<string, Factory<object> | object>;
+ _registered: Record<string, InternalFactory<object> | object>;
constructor() {
this._registered = {};
}
- resolve(specifier: string): Factory<object> | object | undefined {
+ resolve(specifier: string): InternalFactory<object> | object | undefined {
return this._registered[specifier] || this._registered[serializeKey(specifier)];
}
add(
lookup: string | { specifier: string; source: unknown; namespace: unknown },
- factory: Factory<object> | object
+ factory: InternalFactory<object> | object
) {
let key;
switch (typeof lookup) { | true |
Other | emberjs | ember.js | 3b01283c81892959fb4f31dd05b9ff079a1af8eb.json | Fix some incorrect `@module` comments | packages/@ember/routing/lib/controller_for.ts | @@ -1,7 +1,8 @@
import type { Container } from '@ember/-internals/container';
import type { RegisterOptions } from '@ember/owner';
+
/**
-@module ember
+ @module ember/routing
*/
/** | true |
Other | emberjs | ember.js | 3b01283c81892959fb4f31dd05b9ff079a1af8eb.json | Fix some incorrect `@module` comments | packages/@ember/routing/lib/generate_controller.ts | @@ -3,8 +3,9 @@ import type { Factory, Owner } from '@ember/-internals/owner';
import Controller from '@ember/controller';
import { assert, info } from '@ember/debug';
import { DEBUG } from '@glimmer/env';
+
/**
-@module ember
+ @module ember/routing
*/
/** | true |
Other | emberjs | ember.js | 337118e9afef9f2bb497cbcaf037daaf455c7aec.json | squash w/whatever adds KnownForTypeResult | packages/@ember/owner/index.ts | @@ -43,5 +43,6 @@ export {
RegisterOptions,
Factory,
FactoryManager,
+ KnownForTypeResult,
Resolver,
} from '../-internals/owner'; | false |
Other | emberjs | ember.js | cd27b2937803a4ea1073ac7908c910068ae16d6f.json | Move `Resolver` to `@ember/-internals/owner`
This enables it to be re-exported correctly from `@ember/owner` with
reference *only* to `@ember/-internals/owner`, while still providing
it to the other `-internals` packages, which should never depend on
the public packages like `@ember/owner`.
In support of this (and many other changes), introduce a type helper
for `FullName` types. | packages/@ember/-internals/container/index.ts | @@ -5,5 +5,5 @@ The public API, specified on the application namespace should be considered the
@private
*/
-export { default as Registry, Resolver, ResolverClass, privatize } from './lib/registry';
+export { default as Registry, ResolverClass, privatize } from './lib/registry';
export { default as Container, getFactoryFor, setFactoryFor, INIT_FACTORY } from './lib/container'; | true |
Other | emberjs | ember.js | cd27b2937803a4ea1073ac7908c910068ae16d6f.json | Move `Resolver` to `@ember/-internals/owner`
This enables it to be re-exported correctly from `@ember/owner` with
reference *only* to `@ember/-internals/owner`, while still providing
it to the other `-internals` packages, which should never depend on
the public packages like `@ember/owner`.
In support of this (and many other changes), introduce a type helper
for `FullName` types. | packages/@ember/-internals/container/lib/registry.ts | @@ -1,4 +1,4 @@
-import type { Factory } from '@ember/-internals/owner';
+import type { Factory, Resolver } from '@ember/-internals/owner';
import { dictionary, intern } from '@ember/-internals/utils';
import { assert, deprecate } from '@ember/debug';
import type { set } from '@ember/object';
@@ -38,14 +38,6 @@ export interface ResolverClass {
create(...args: unknown[]): Resolver;
}
-export interface Resolver {
- knownForType?: (type: string) => KnownForTypeResult;
- lookupDescription?: (fullName: string) => string;
- makeToString?: (factory: Factory<object>, fullName: string) => string;
- normalize?: (fullName: string) => string;
- resolve(name: string): Factory<object> | object | undefined;
-}
-
export interface RegistryOptions {
fallback?: IRegistry;
registrations?: { [key: string]: object }; | true |
Other | emberjs | ember.js | cd27b2937803a4ea1073ac7908c910068ae16d6f.json | Move `Resolver` to `@ember/-internals/owner`
This enables it to be re-exported correctly from `@ember/owner` with
reference *only* to `@ember/-internals/owner`, while still providing
it to the other `-internals` packages, which should never depend on
the public packages like `@ember/owner`.
In support of this (and many other changes), introduce a type helper
for `FullName` types. | packages/@ember/-internals/owner/index.ts | @@ -7,7 +7,36 @@ import type { IRegistry } from '../runtime/lib/mixins/registry_proxy';
@module @ember/owner
*/
+/**
+ * The name for a factory consists of a namespace and the name of a specific
+ * type within that namespace, like `'service:session'`.
+ *
+ * @for @ember/owner
+ */
+export type FullName = `${string}:${string}`;
+
export { TypeOptions };
+/**
+ * A `Resolver` is the mechanism responsible for looking up code in your
+ * application and converting its naming conventions into the actual classes,
+ * functions, and templates that Ember needs to resolve its dependencies, for
+ * example, what template to render for a given route. It is a system that helps
+ * the app resolve the lookup of JavaScript modules agnostic of what kind of
+ * module system is used, which can be AMD, CommonJS or just plain globals. It
+ * is used to lookup routes, models, components, templates, or anything that is
+ * used in your Ember app.
+ *
+ * This interface represents the contract a custom resolver must implement. Most
+ * apps never need to think about this: the application's resolver is supplied by
+ * `ember-resolver` in the default blueprint.
+ */
+export interface Resolver {
+ resolve: (name: FullName) => Factory<object> | object | undefined;
+ knownForType?: <T extends string>(type: T) => KnownForTypeResult<T>;
+ lookupDescription?: (fullName: FullName) => string;
+ makeToString?: (factory: Factory<object>, fullName: FullName) => string;
+ normalize?: (fullName: FullName) => FullName;
+}
export interface FactoryClass {
positionalParams?: string | string[] | undefined | null; | true |
Other | emberjs | ember.js | cd27b2937803a4ea1073ac7908c910068ae16d6f.json | Move `Resolver` to `@ember/-internals/owner`
This enables it to be re-exported correctly from `@ember/owner` with
reference *only* to `@ember/-internals/owner`, while still providing
it to the other `-internals` packages, which should never depend on
the public packages like `@ember/owner`.
In support of this (and many other changes), introduce a type helper
for `FullName` types. | packages/@ember/debug/container-debug-adapter.ts | @@ -3,7 +3,7 @@ import EmberObject from '@ember/object';
import { typeOf } from '@ember/utils';
import type { Owner } from '@ember/-internals/owner';
import { getOwner } from '@ember/-internals/owner';
-import type { Resolver } from '@ember/-internals/container';
+import type { Resolver } from '@ember/owner';
import Namespace from '@ember/application/namespace';
/** | true |
Other | emberjs | ember.js | cd27b2937803a4ea1073ac7908c910068ae16d6f.json | Move `Resolver` to `@ember/-internals/owner`
This enables it to be re-exported correctly from `@ember/owner` with
reference *only* to `@ember/-internals/owner`, while still providing
it to the other `-internals` packages, which should never depend on
the public packages like `@ember/owner`.
In support of this (and many other changes), introduce a type helper
for `FullName` types. | packages/@ember/owner/index.ts | @@ -39,6 +39,8 @@ export default Owner;
export {
setOwner,
+ FullName,
Factory,
FactoryManager,
+ Resolver,
} from '../-internals/owner'; | true |
Other | emberjs | ember.js | cd27b2937803a4ea1073ac7908c910068ae16d6f.json | Move `Resolver` to `@ember/-internals/owner`
This enables it to be re-exported correctly from `@ember/owner` with
reference *only* to `@ember/-internals/owner`, while still providing
it to the other `-internals` packages, which should never depend on
the public packages like `@ember/owner`.
In support of this (and many other changes), introduce a type helper
for `FullName` types. | packages/internal-test-helpers/lib/test-resolver.ts | @@ -1,7 +1,6 @@
import { compile } from 'ember-template-compiler';
-import type { Resolver as IResolver } from '@ember/-internals/container';
-import type { Factory } from '@ember/-internals/owner';
+import type { Factory, Resolver as IResolver } from '@ember/-internals/owner';
const DELIMITER = '%';
| true |
Other | emberjs | ember.js | 792ca6cc82e28214228a27419d1f9caf370e352b.json | Add v4.9.0-beta.4 to CHANGELOG
(cherry picked from commit 84e32c9234242ea45203409a1ea50e4e4beccc68) | CHANGELOG.md | @@ -1,5 +1,10 @@
# Ember Changelog
+### v4.9.0-beta.4 (November 15, 2022)
+
+- [#20256](https://github.com/emberjs/ember.js/pull/20256) [BUGFIX] Correct types for Ember Arrays
+- [#20257](https://github.com/emberjs/ember.js/pull/20257) [BUGFIX] Fix types for `getOwner` and GlimmerComponent
+
### v4.8.2 (November 3, 2022)
- [#20244](https://github.com/emberjs/ember.js/pull/20244) Add missing type for `getComponentTemplate` to preview types | false |
Other | emberjs | ember.js | df8960d95c6ecdacf8ebcc9fd6cd2dd0d6ef404c.json | Revert behavioral changes | lib/overrides.js | @@ -13,7 +13,9 @@ function* walkAddonTree(project, pathToAddon = []) {
}
}
-const requirementFor = (pkg, deps = {}) => deps[pkg];
+function requirementFor(pkg, deps = {}) {
+ return deps[pkg];
+}
const KNOWN_DORMANT_ADDONS = Object.freeze([
'ember-angle-bracket-invocation-polyfill',
@@ -24,11 +26,13 @@ const KNOWN_DORMANT_ADDONS = Object.freeze([
]);
module.exports = class Overrides {
static for(project, env = process.env) {
- return env.EMBER_ENV === 'production'
- ? new Overrides([])
- : new Overrides(Overrides.addonsInfoFor(project), {
- showAllEmberGlobalDeprecations: env.EMBER_GLOBAL_DEPRECATIONS === 'all',
- });
+ if (env.EMBER_ENV === 'production') {
+ return new Overrides([]);
+ } else {
+ return new Overrides(Overrides.addonsInfoFor(project), {
+ showAllEmberGlobalDeprecations: env.EMBER_GLOBAL_DEPRECATIONS === 'all',
+ });
+ }
}
static *addonsInfoFor(project) {
@@ -84,13 +88,18 @@ module.exports = class Overrides {
}
static printList(list, indent = '') {
- return list.reduce((listString, listItem) => {
- if (Array.isArray(listItem)) {
- listString += `${indent}* ${listItem[0]}\n`;
- listString += Overrides.printList(listItem[1], indent + ' ');
+ let output = '';
+
+ for (let item of list) {
+ if (Array.isArray(item)) {
+ output += `${indent}* ${item[0]}\n`;
+ output += Overrides.printList(item[1], indent + ' ');
+ } else {
+ output += `${indent}* ${item}\n`;
}
- listString += `${indent}* ${listItem}\n`;
- }, '');
+ }
+
+ return output;
}
constructor(addonsInfo, options = {}) {
@@ -301,7 +310,11 @@ module.exports = class Overrides {
}
get buildTimeWarning() {
- return this.hasBuildTimeWarning ? `[DEPRECATION] ${this.globalMessage}` : '';
+ if (this.hasBuildTimeWarning) {
+ return `[DEPRECATION] ${this.globalMessage}`;
+ } else {
+ return '';
+ }
}
toTree() { | false |
Other | emberjs | ember.js | 05fc0bbd4112b1151b768a77c3024dc18d294edc.json | Remove some unnecessary uses of Ember.A | packages/@ember/debug/container-debug-adapter.ts | @@ -1,7 +1,5 @@
import { classify, dasherize } from '@ember/string';
-import type { NativeArray } from '@ember/array';
import EmberObject from '@ember/object';
-import { A as emberA } from '@ember/array';
import { typeOf } from '@ember/utils';
import type { Owner } from '@ember/-internals/owner';
import { getOwner } from '@ember/-internals/owner';
@@ -88,9 +86,9 @@ export default class ContainerDebugAdapter extends EmberObject {
@return {Array} An array of strings.
@public
*/
- catalogEntriesByType(type: string): NativeArray<string> {
- let namespaces = emberA(Namespace.NAMESPACES);
- let types = emberA<string>();
+ catalogEntriesByType(type: string): string[] {
+ let namespaces = Namespace.NAMESPACES;
+ let types: string[] = [];
let typeSuffixRegex = new RegExp(`${classify(type)}$`);
namespaces.forEach((namespace) => { | true |