Skip to content

chore: update github definition#31

Merged
mnahkies merged 1 commit intomasterfrom
mn/chore/update-github-definition
Apr 16, 2023
Merged

chore: update github definition#31
mnahkies merged 1 commit intomasterfrom
mn/chore/update-github-definition

Conversation

@mnahkies
Copy link
Owner

@mnahkies mnahkies commented Apr 10, 2023

Was failing due to the zod schema's being output in sorted order and referencing each other:

typescript-koa: src/api.github.com.yaml/schemas.ts(13399,11): error TS2448: Block-scoped variable 's_simple_user' used before its declaration.
typescript-koa: src/api.github.com.yaml/schemas.ts(13399,11): error TS2454: Variable 's_simple_user' is used before being assigned.
typescript-koa: src/api.github.com.yaml/schemas.ts(13400,14): error TS2448: Block-scoped variable 's_simple_user' used before its declaration.
typescript-koa: src/api.github.com.yaml/schemas.ts(13400,14): error TS2454: Variable 's_simple_user' is used before being assigned.

Fixed via #37

@mnahkies mnahkies force-pushed the mn/chore/update-github-definition branch from 8695833 to 43adf52 Compare April 15, 2023 09:57
mnahkies added a commit that referenced this pull request Apr 16, 2023
previously we output schemas in alphabetically sorted order, same as we
do for types.

this is problematic as the schemas are runtime code, and if the order is
incorrect this causes "use before declaration" type errors.

after this change we instead group the scheams based on their
dependencies and sort each group such that depended on schemas are
output before the schemas that depend on them.

the implementation isn't perfect - there are a few edge cases that it
doesn't cover, but it's a big improvement on the previous behavior.

as a bonus, also adjusted things such that more scheams will be
extracted to the schemas.ts file rather than inlined, making them
reusuable and the code easier to read.

this will fix the build problems on #31
as it was failing due to the ordering issue
mnahkies added a commit that referenced this pull request Apr 16, 2023
previously we output schemas in alphabetically sorted order, same as we
do for types.

this is problematic as the schemas are runtime code, and if the order is
incorrect this causes "use before declaration" type errors.

after this change we instead group the scheams based on their
dependencies and sort each group such that depended on schemas are
output before the schemas that depend on them.

the implementation isn't perfect - there are a few edge cases that it
doesn't cover, but it's a big improvement on the previous behavior.

as a bonus, also adjusted things such that more scheams will be
extracted to the schemas.ts file rather than inlined, making them
reusuable and the code easier to read.

this will fix the build problems on
#31 as it was
failing due to the ordering issue
@mnahkies mnahkies force-pushed the mn/chore/update-github-definition branch from 43adf52 to 3b148f8 Compare April 16, 2023 09:52
@mnahkies mnahkies marked this pull request as ready for review April 16, 2023 09:53
@mnahkies mnahkies enabled auto-merge (squash) April 16, 2023 09:54
@mnahkies mnahkies merged commit b14460d into master Apr 16, 2023
@mnahkies mnahkies deleted the mn/chore/update-github-definition branch April 16, 2023 09:54
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.

1 participant