Skip to content

Add type helpers only when used #992

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

Merged
merged 1 commit into from
Nov 16, 2022

Conversation

imagoiq
Copy link
Contributor

@imagoiq imagoiq commented Nov 15, 2022

Fix #976 by checking if OneOf type is added to the schema. The fix uses the easiest path, but perhaps not the best for long term (if there are other type helpers added especially). Perhaps, the context should be aware if type helpers are required? (if it's not already the case and that I miss something).

});
});

describe("OneOf type helpers", () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

👏 Awesome test!

Copy link
Contributor

@drwpow drwpow left a comment

Choose a reason for hiding this comment

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

LGTM! Yeah in general I’d like to avoid scanning text if possible, but profiling this it seems to be fast enough to not have any real performance impacts even on big schemas, so this works for me!

But if more things were added to text scanning we might want to move a boolean flag into global context or something; this is fine but some other text scanning methods may have serious performance concerns.

@drwpow drwpow merged commit 95aa4cb into openapi-ts:main Nov 16, 2022
@drwpow
Copy link
Contributor

drwpow commented Nov 16, 2022

@all-contributors please add @imagoiq for code, test, bug

@allcontributors
Copy link
Contributor

@drwpow

I've put up a pull request to add @imagoiq! 🎉

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

Successfully merging this pull request may close these issues.

Type helpers + @typescript-eslint/no-unused-vars
2 participants