[BUGFIX stable] Fix types for Resolver contract #20489
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We need
Resolver
implementors (e.g.ember-resolver
) to be able to provide a class which can satisfy this contract, which means we need to support either a static.create()
method or a constructor (with a strong preference for the constructor). This is likely to be a common issue with this kind of assignability of classic classes, because it ultimately comes down to the definition ofFactory
andCoreObject
.To resolve this, add two overloads for
CoreObject.prototype.create
:These two overloads also improve the type safety of
.create()
more generally, allowing us to handle a couple cases which the types did not previously account for (and indeed had given up handling).This also adds a smoke test for something shaped like the
app.ts
file generated for every Ember app, so that we can be sure that the code we emit when generating an app actually works. For now, this simply copies over the types fromember-resolver
,ember-load-initializers
, and a basicenvironment
.Fixes #20486.