improv(parser): export InferOutput from public types entry point#5175
Open
yashar-new10 wants to merge 1 commit intoaws-powertools:mainfrom
Open
improv(parser): export InferOutput from public types entry point#5175yashar-new10 wants to merge 1 commit intoaws-powertools:mainfrom
yashar-new10 wants to merge 1 commit intoaws-powertools:mainfrom
Conversation
|
Thanks a lot for your first contribution! Please check out our contributing guidelines and don't hesitate to ask whatever you need. |
|
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.



Summary
Exports
InferOutputfrom the public@aws-lambda-powertools/parser/typesentry point.Changes
TypeScript enforces that all types appearing in a function's inferred return type must be nameable via public package exports (see TS2742 / TS2883 — the latter is a variant that also reports the source module path). This check becomes harder to avoid in TypeScript 6 because the compiler is stricter about declaration emit portability.
When using the
parsermiddleware withsafeParse: true, the return type of the wrapping function includesInferOutput<TSchema>. BecauseInferOutputwas only exported from the internal pathlib/esm/types/parser.jsand not from any public entry point, TypeScript 6 could not generate a valid declaration file and raised:Consumers hitting this error were forced to add explicit type casts or annotations as a workaround.
Fix
Add
InferOutputto the existing re-exports inpackages/parser/src/types/index.ts. This is a one-line, type-only change with no runtime impact. OnceInferOutputis available at@aws-lambda-powertools/parser/types, TypeScript can reference it in generated.d.tsfiles automatically and the error is resolved without any changes required on the consumer side.Testing
Verified locally by:
InferOutputto the builtlib/esm/types/index.d.tsIssue number: closes #5174
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.