Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fix: generate types from JSDoc #377

Merged
merged 4 commits into from
May 14, 2024
Merged

fix: generate types from JSDoc #377

merged 4 commits into from
May 14, 2024

Conversation

wkillerud
Copy link
Contributor

Expand the typing/JSDoc internally in the module as well

@@ -91,15 +121,15 @@ export default class PodiumClient extends EventEmitter {
});

this.#metrics = new Metrics();
this.#metrics.on('error', error => {
this.#metrics.on('error', (error) => {
log.error(
'Error emitted by metric stream in @podium/client module',
error,
);
});

this[Symbol.iterator] = () => ({
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this Symbol.iterator API is possible to type

@@ -227,6 +252,7 @@ export default class PodletClientContentResolver {
if (outgoing.redirectable && statusCode >= 300) {
outgoing.redirect = {
statusCode,
// @ts-expect-error TODO: look into what happens if the podlet returns more than one location header
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TS highlighted this as a potential error, but I didn't want to make a decision there now


/**
* Filter assets array based on scope.
* If scope property is not present, asset will be included (backwards compatibility)
* If scope property is set to "all", asset will be included.
* If scope is set to "content" and asset scope property is set to "fallback", asset will not be included
* If scope is set to "fallback" and asset scope property is set to "content", asset will not be included
* @template {import("@podium/utils").AssetCss | import("@podium/utils").AssetJs} T[]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaced with generics so the type is kept untouched on the Response class itself

@trygve-lie trygve-lie self-requested a review May 14, 2024 13:41
@wkillerud
Copy link
Contributor Author

Tested with local linking via @podium/layout, and it looks like the types are working as expected.

Copy link
Contributor

@trygve-lie trygve-lie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm 👍

wkillerud added 2 commits May 14, 2024 15:43
Reexport some types that were missing from the client export
@wkillerud wkillerud merged commit d798b20 into master May 14, 2024
7 checks passed
@wkillerud wkillerud deleted the jsdoc-types branch May 14, 2024 14:08
Copy link

🎉 This PR is included in version 5.0.21 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants