Comments (15)
@MikeRalphson
You must (for a definition of it) try Typescript, it really improves the dev experience.
Also, (biased & personal) I tend to discard non Typescript projects as I find using Typescript is a good indicator of verifiable quality (not saying non Typescript projects are all of bad quality, here).
from openapi-codegen.
Pros? You tell me :)
Cons:
- I don't know typescript, though I am interested in it
- What if it goes the way of coffeescript?
- I don't like build steps, they take away one of the best things about javascript
- Javascript is a dynamically-typed language, and that's one of the reasons I choose to use it
- Third-party typings for dependencies are not always up-to-date and cause spurious warnings/errors
- Apparently breaking changes between Typescript
v2.6.1
and2.8.x
which should not happen - The pool of TypeScript programmers (and thus contributors) is smaller than the pool of Javascript programmers
That said, I'm always looking for feedback and collaborators.
from openapi-codegen.
@MikeRalphson you'll find some bugs with typescript for sure (tons).
However I've heard that using Typescript as js + annotations delivers less than directly using *.ts files (More effort, much pain, lots of false errors, less value).
Not sure the best is to make an idea of what TS could bring to a project just from that approach.
from openapi-codegen.
It does seem to be a lot more popular than coffeescript based on google trends.
I meant, coffeescript was all the rage at one time, and was going to be the future of typed javascript, but now it's practically dead.
I may try Typescript on some new project to try it out, but at the moment, nothing above is compelling me to move this project to it.
from openapi-codegen.
@sledorze Improves in what way(s)? I'm struggling to find numbers on what percentage of npm packages use Typescript, but I think you may be ignoring some quality packages there. 😁
from openapi-codegen.
@chauey apart from reformatting some if
s, and a sprinkling of any
s, I can see very few differences between the .js
and .ts
source here. Is this really enough to get much of the benefit(s) of using Typescript? Plus a command-line build step (npm script) would also be required.
Maybe a good first step would be adding Typescript-checking declarations to the Javascript source? E.g.:
// @ts-check
and fixing the resultant warnings.
from openapi-codegen.
Update: I've added // @ts-check
to the Javascript source.
Pros:
- It appears to have found one actual bug.
Cons:
- All the other warnings/errors look like noise to me.
An example (and another 'Con'), typings held externally to dependent packages get out of date and throw spurious warnings. See https://github.com/debitoor/safe-json-stringify
from openapi-codegen.
@sledorze doesn't look like it's going to be "tons" based on what tsc has found so far. But as you say, probably more false positives and less real insight than if the codebase had been written in Typescript from the start, or was properly converted.
from openapi-codegen.
Main things I can think of:
- static type checking, class based objects
- autocomplete/intellisense
- ideally will produce less-bugs/better-quality
May enjoy more this way after trying it.
Can cast things to "any" if don't want the typing.
It does seem to be a lot more popular than coffeescript based on google trends.
I've used things like generics, inheritance and interfaces also, and looking into union types at the moment. Would not want to use these without TypeScript. It is easier and less/cleaner code also.
A video I found about TypeScript
https://www.youtube.com/watch?v=rAy_3SIqT-E
Main website: https://www.typescriptlang.org/index.html
After using Typescript, it's hard to go back, but I don't use non-Typescript much so I can't readily list all the pros and cons. Hope you have time to give it a try, you may like it.
Thanks
from openapi-codegen.
Was playing with some code, and wondering if "default" and "nullable" are valid properties of "param" here. And also if "form" is a valid "param.in" value. These are the type of potential bugs it may help find I believe.
I'm still weighing pros and cons also, trying it out
from openapi-codegen.
I pushed some updates to https://github.com/chauey/openapi-codegen/tree/typescript-conversion, experimenting.
converted the OAS 3.0 schema to typescript interfaces, created classes for it, added the typing for an operation parameter, then casted or checked "instanceof" of the variables/properties.
For this code to run correctly, I'm guessing the JSON/YAML OpenApi doc would be need to be parsed into the correct objects if using "instanceof" codes. More testing and learning needed...
I have never used union types and instanceof before... very cool
from openapi-codegen.
@chauey you may be interested in these projects
I'm really interested in specific reasons for moving this project to TypeScript, not general information about it as a language which I'm fine finding for myself.
I will take a look at the potential issues you spotted.
from openapi-codegen.
@chauey are you by any chance still interested?
from openapi-codegen.
@MikeRalphson interested, yes, but I do not know when I would be able to get around to it with current workload. Can't commit, so please proceed without me, maybe someone(s) else can take a shot at it ;)
BTW: I wonder if this would come in handy to add types https://github.com/urish/typewiz
from openapi-codegen.
Closing due to inactivity - but please feel free to reopen the issue if necessary.
from openapi-codegen.
Related Issues (20)
- Unable to use config file from in current working directory or with explicit extension using CLI HOT 2
- $ref not supported in api (path) params
- nodejs template: kebab-case component schema name creates invalid JavaScript HOT 1
- We can use new URL() or const {url} = require('url'); and parse the URL HOT 1
- Error in getReferenceSchema when namespace contains a dot character
- An in-range update of webpack is breaking the build 🚨 HOT 2
- YAMLException: unacceptable kind of an object to dump [object Undefined] HOT 5
- Loading openapi-definition from Url is not possible HOT 4
- Add npx command to README HOT 3
- Ability to call swagger-codegen / openapi-generator APIs directly
- An in-range update of yargs is breaking the build 🚨 HOT 4
- enumVars.name breaks python code
- An in-range update of yaml is breaking the build 🚨 HOT 5
- An in-range update of webpack is breaking the build 🚨 HOT 24
- Error: Cannot find module '<currentpath>\configs\htmlDocs2.json HOT 3
- Different template engine HOT 12
- Exception on `cg --list` HOT 2
- `oneOf` support via Discriminated Unions HOT 1
- schema $refs to objects broken? HOT 5
- model object doesn't have isEnum property
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from openapi-codegen.