Coder Social home page Coder Social logo

Comments (15)

sledorze avatar sledorze commented on June 16, 2024 3

@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.

MikeRalphson avatar MikeRalphson commented on June 16, 2024 1

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 and 2.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.

sledorze avatar sledorze commented on June 16, 2024 1

@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.

MikeRalphson avatar MikeRalphson commented on June 16, 2024 1

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.

MikeRalphson avatar MikeRalphson commented on June 16, 2024

@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.

MikeRalphson avatar MikeRalphson commented on June 16, 2024

@chauey apart from reformatting some ifs, and a sprinkling of anys, 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.

MikeRalphson avatar MikeRalphson commented on June 16, 2024

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.

MikeRalphson avatar MikeRalphson commented on June 16, 2024

@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.

chauey avatar chauey commented on June 16, 2024

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.

chauey avatar chauey commented on June 16, 2024

image

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.

chauey avatar chauey commented on June 16, 2024

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.

MikeRalphson avatar MikeRalphson commented on June 16, 2024

@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.

MikeRalphson avatar MikeRalphson commented on June 16, 2024

@chauey are you by any chance still interested?

from openapi-codegen.

chauey avatar chauey commented on June 16, 2024

@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.

MikeRalphson avatar MikeRalphson commented on June 16, 2024

Closing due to inactivity - but please feel free to reopen the issue if necessary.

from openapi-codegen.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.