swagger-api / swagger-api/swagger-codegen
[typescript-angular] errors with @types/node
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
I have a project called achievibit, and I tried generating some SDKs from that project's swagger.json.
This worked as intended:
swagger-codegen generate -i ../server/swagger-spec.json -l typescript-axios -o ./node -c ./option.json
and generated the code. I was able to run npm run build to build it and use it.
But this:
swagger-codegen generate -i ../server/swagger-spec.json -l typescript-angular -o ./angular-client
Generated the project, but when running npm run build, I get typescript compilation errors because of @types/node.
I'm not sure what's wrong here. didn't change anything in the generated code
Swagger-codegen version
3.0.26
Swagger declaration file content or url
https://gist.github.com/Thatkookooguy/e19d5357dfa8ad53f8451e5d73f51f8f
(I also included my options.json in the same gist)
Command line used for generation
swagger-codegen generate -i ../server/swagger-spec.json -l typescript-angular -o ./angular-client
Steps to reproduce
- Download
swagger-spec.jsonandoptions.jsonfiles from the gist - Run the command
swagger-codegen generate -i ./swagger-spec.json -l typescript-angular -o ./angular-clientto create an angular SDK - go into
./angular-clientand runnpm install - run
npm run buildto build the project. You'll see the error attached bellow:
> @kibibit/sample-webapi@1.0.0 build
> ng-packagr -p ng-package.json
Building Angular Package
Building entry point '@kibibit/sample-webapi'
Rendering Stylesheets
Rendering Templates
Compiling TypeScript sources through ngc
BUILD ERROR
node_modules/@types/node/assert.d.ts(3,68): error TS1144: '{' or ';' expected.
node_modules/@types/node/assert.d.ts(57,68): error TS1144: '{' or ';' expected.
node_modules/@types/node/assert.d.ts(66,94): error TS1144: '{' or ';' expected.
node_modules/@types/node/assert.d.ts(66,101): error TS1005: ';' expected.
node_modules/@types/node/assert.d.ts(66,104): error TS1005: ';' expected.
node_modules/@types/node/assert.d.ts(68,98): error TS1144: '{' or ';' expected.
node_modules/@types/node/assert.d.ts(68,105): error TS1005: ';' expected.
node_modules/@types/node/assert.d.ts(68,108): error TS1005: ';' expected.
node_modules/@types/node/assert.d.ts(76,47): error TS1144: '{' or ';' expected.
node_modules/@types/node/assert.d.ts(76,53): error TS1005: ';' expected.
node_modules/@types/node/assert.d.ts(76,56): error TS1005: ';' expected.
node_modules/@types/node/assert.d.ts(106,61): error TS1005: ';' expected.
node_modules/@types/node/base.d.ts(10,1): error TS1084: Invalid 'reference' directive syntax.
node_modules/@types/node/base.d.ts(11,1): error TS1084: Invalid 'reference' directive syntax.
node_modules/@types/node/base.d.ts(12,1): error TS1084: Invalid 'reference' directive syntax.
node_modules/@types/node/base.d.ts(13,1): error TS1084: Invalid 'reference' directive syntax.
node_modules/@types/node/ts3.6/base.d.ts(10,1): error TS1084: Invalid 'reference' directive syntax.
node_modules/@types/node/ts3.6/base.d.ts(11,1): error TS1084: Invalid 'reference' directive syntax.
node_modules/@types/node/ts3.6/base.d.ts(12,1): error TS1084: Invalid 'reference' directive syntax.
node_modules/@types/node/ts3.6/base.d.ts(13,1): error TS1084: Invalid 'reference' directive syntax.
Error: node_modules/@types/node/assert.d.ts(3,68): error TS1144: '{' or ';' expected.
node_modules/@types/node/assert.d.ts(57,68): error TS1144: '{' or ';' expected.
node_modules/@types/node/assert.d.ts(66,94): error TS1144: '{' or ';' expected.
node_modules/@types/node/assert.d.ts(66,101): error TS1005: ';' expected.
node_modules/@types/node/assert.d.ts(66,104): error TS1005: ';' expected.
node_modules/@types/node/assert.d.ts(68,98): error TS1144: '{' or ';' expected.
node_modules/@types/node/assert.d.ts(68,105): error TS1005: ';' expected.
node_modules/@types/node/assert.d.ts(68,108): error TS1005: ';' expected.
node_modules/@types/node/assert.d.ts(76,47): error TS1144: '{' or ';' expected.
node_modules/@types/node/assert.d.ts(76,53): error TS1005: ';' expected.
node_modules/@types/node/assert.d.ts(76,56): error TS1005: ';' expected.
node_modules/@types/node/assert.d.ts(106,61): error TS1005: ';' expected.
node_modules/@types/node/base.d.ts(10,1): error TS1084: Invalid 'reference' directive syntax.
node_modules/@types/node/base.d.ts(11,1): error TS1084: Invalid 'reference' directive syntax.
node_modules/@types/node/base.d.ts(12,1): error TS1084: Invalid 'reference' directive syntax.
node_modules/@types/node/base.d.ts(13,1): error TS1084: Invalid 'reference' directive syntax.
node_modules/@types/node/ts3.6/base.d.ts(10,1): error TS1084: Invalid 'reference' directive syntax.
node_modules/@types/node/ts3.6/base.d.ts(11,1): error TS1084: Invalid 'reference' directive syntax.
node_modules/@types/node/ts3.6/base.d.ts(12,1): error TS1084: Invalid 'reference' directive syntax.
node_modules/@types/node/ts3.6/base.d.ts(13,1): error TS1084: Invalid 'reference' directive syntax.
at Object.<anonymous> (/Users/thatkookooguy/Development/kibibit/sdks/angular-client/node_modules/ng-packagr/lib/ngc/compile-source-files.js:53:68)
at Generator.next (<anonymous>)
at /Users/thatkookooguy/Development/kibibit/sdks/angular-client/node_modules/ng-packagr/lib/ngc/compile-source-files.js:7:71
at new Promise (<anonymous>)
at __awaiter (/Users/thatkookooguy/Development/kibibit/sdks/angular-client/node_modules/ng-packagr/lib/ngc/compile-source-files.js:3:12)
at Object.compileSourceFiles (/Users/thatkookooguy/Development/kibibit/sdks/angular-client/node_modules/ng-packagr/lib/ngc/compile-source-files.js:19:12)
at Object.<anonymous> (/Users/thatkookooguy/Development/kibibit/sdks/angular-client/node_modules/ng-packagr/lib/ng-v5/entry-point/ts/compile-ngc.transform.js:26:32)
at Generator.next (<anonymous>)
at /Users/thatkookooguy/Development/kibibit/sdks/angular-client/node_modules/ng-packagr/lib/ng-v5/entry-point/ts/compile-ngc.transform.js:7:71
at new Promise (<anonymous>)
Related issues/PRs
Suggest a fix/enhancement
Probably related to peerDependencies? I tried this both with node 14+ and node 12+ to make sure it's not related to the node version I'm using. I get the same error
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue by generating the angular-client with the provided swagger.json and options.json, installing dependencies, and running npm run build. Inspect ng-package.json and the reported @types/node compilation errors; done means the generated typescript-angular project builds successfully without these errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- angular, node.js, typescript
- Domain
- build-system, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100