Repository navigation
chore: release - #8
Merged
Merged
Conversation
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR was opened by the Changesets release GitHub action. When you're ready to do a release, you can merge this and publish to npm yourself or setup this action to publish automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated.
Releases
sandly@4.0.0
Major Changes
c1053aa: Sandly 4: containers are built from one provider per tag, singletons are enforced, and missing dependencies are named in type errors.
Breaking Changes
Container.from,ScopedContainer.from,childFrom,layer.apply) applies each layer object once, however many composition paths reach it. Previously a shared layer was re-applied on every path and the last registration silently won.DuplicateProviderErrorat build time, naming both definition sites. Bindings of one tag to the same value (Layer.value/Layer.mock, compared withObject.is) count as one provider.ContainerBuilder.add/ScopedContainerBuilder.addthrowDuplicateProviderErrorfor a tag already registered in the same builder. A child scope may still shadow a parent's tag.Container.from,ScopedContainer.fromandchildFrominfer the layer's requirements and check them with a branded type, so a type error names only the missing tags (MissingDependencies<typeof Config>) instead of comparing the full layer types. A generic function that passes its layer parameter on to one of them must type it asRootLayer<TRequires, TProvides>orChildLayer<TRequires, TProvides, TParentTags>to forward the check.container.use(tag, fn)is renamed tocontainer.useOnce(tag, fn), since it destroys the container afterwards.useOncethrows and a finalizer throws too,useOncerejects with aSuppressedErrorwhoseerroris theDependencyFinalizationErrorand whosesuppressedis the original error, asawait usingdoes. Previously the finalization error replaced the original error.ScopedContainerno longer extendsContainer; both extend a shared base class, so each declares its own staticbuilder,emptyandfrom. AScopedContaineris still assignable to aContainertype, butscopedContainer instanceof Containeris nowfalse. The published type declarations no longer report an error in projects that type-check library files (skipLibCheck: false).AsyncDisposableandSymbol.asyncDispose, which come from@types/node(or Bun's types) or fromesnext.disposableinlib(TypeScript 5.2+).New
layer.override(replacement)replaces providers anywhere in the composition, regardless of nesting depth or position. ThrowsDuplicateOverrideErrorfor two overrides of one tag andOverrideTargetNotFoundErrorfor an override with nothing to replace.Layer.unused(...tags)satisfies requirements left behind by an override with placeholders that throwUnusedDependencyResolvedErrorif resolved.Layer.singleton(class, deps, options?)andLayer.singleton(layer)declare a dependency that is built only into a root container. The layer requiresRoot<typeof X>, which onlyContainer.fromandScopedContainer.fromsatisfy, sochildFromrejects any layer containing a singleton at compile time (SingletonInChildScope<typeof X>). Building one into a child scope also throwsSingletonInChildScopeError.Layer.values([tag, value], ...)binds several tags to values in one layer.Symbol.asyncDispose:await using container = Container.from(layer)destroys the container when the scope exits.RootLayer,ChildLayer,Root,MissingDependencies,SingletonInChildScope.Migration
DuplicateProviderError, remove one provider, or keep the intended one withoverride()(typically a test stub that previously lost to a provider nested in the production layer).childFromadd a requirements type parameter and type the layer asChildLayer<TRequires, TProvides, TParentTags>.Layer<never, T>add a requirements type parameter and type the layer asRootLayer<TRequires, T>, which also accepts singleton layers.container.use(...)calls tocontainer.useOnce(...).AsyncDisposable, install@types/nodeor addesnext.disposabletolib.