Closed slifty closed 9 months ago
@slifty When I try to follow the instructions, I get all the way to npm run build
(note: I needed to npm i
before that), then I get an error about a missing tsconfig.json
:
➜ typescript git:(2-create-typescript-templates) npm run build
> @pdc/sdk@0.0.0 build
> npm run cleanup && npm run build:node
> @pdc/sdk@0.0.0 cleanup
> rimraf dist
> @pdc/sdk@0.0.0 build:node
> tsc -p tsconfig.json
error TS5058: The specified path does not exist: 'tsconfig.json'.
And the dist/
directory is not created.
Is this known/expected? How should I proceed?
@reefdog ah HA -- that file was missed -- hooray for code reviews!
I'll fix and re-run it all tomorrow morning and ping you when ready for a new review
@reefdog fixed up and ready for re-review!
Okay, after ./gradlew clean
and regenerating, we got farther! But now I'm seeing:
➜ typescript git:(2-create-typescript-templates) npm run build
> @pdc/sdk@0.0.0 build
> npm run cleanup && npm run build:node
> @pdc/sdk@0.0.0 cleanup
> rimraf dist
> @pdc/sdk@0.0.0 build:node
> tsc -p tsconfig.json
src/types/BulkUpload.ts:8:20 - error TS2702: 'BulkUpload' only refers to a type, but is being used as a namespace here.
8 readonly status?: BulkUpload.StatusEnum;
~~~~~~~~~~
src/types/BulkUpload.ts:8:20 - error TS4033: Property 'status' of exported interface has or is using private name 'BulkUpload'.
8 readonly status?: BulkUpload.StatusEnum;
~~~~~~~~~~
Found 2 errors in the same file, starting at: src/types/BulkUpload.ts:8
So that's fun!
I'm using an older swagger spec for our API that didn't have enums; the generators handle enums differently somehow, so I'll need to improve the templates.
This raises a meta concept though: as we update our swagger spec we may well accidentally break the generators. Ideally there'd be a way to test them / test the resulting code / etc.
Tapped into the enum support.
The generated enum is not exactly how I would want to create it, but the effort in changing their naming convention is... large and definitely not worth it:
export namespace BulkUpload {
export enum StatusEnum {
Pending = 'pending',
InProgress = 'in_progress',
Completed = 'completed',
Failed = 'failed',
Canceled = 'canceled'
}
}
So accessing these enums would involve BulkUpload.StatusEnum.Pending
Had we defined this manually I'd have preferred something like Statuses.PENDING
Anyway, @reefdog I think this is ready for you once more!
@slifty I don't see any new commits (or force-pushes) since the last review, and I'm getting the same results as before. Did you forget to push some changes, or do I need to do something new in my testing, or…?
@reefdog ugh I guess I should push it so you can actually view it (sorry about that)
@reefdog I hear you, though to some extent I don't know if that's possible to fit in a review (the templates are a UX and we'll iterate on them, but we won't be able to really know what enhancements are needed until after getting user feedback, including our own user feedback).
The best we can do is review the proposed interfaces that are generated!
This PR implements an initial TypeScript sdk generator which provides type definitions based on a swagger specification.
The PR does NOT do the following:
I would like to add these enhancements in future PRs instead of trying to do it all here.
To test, you will need a local java runtime environment and local node / nvm. From there you can:
build/typescript
. CD to there.npm run build
)build/typescript/dist
which you could in theory place in anode_modules
and use as type definitions!Resolves #2