Calling properly TypeScript code from JavaScript

后端 未结 5 1586
生来不讨喜
生来不讨喜 2020-12-03 11:36

On our big enterprise project we faced a situation that seems not to be very well described in the articles and the posts available in the Internet.

We need to integ

5条回答
  •  一个人的身影
    2020-12-03 12:23

    I think is not a Typescript problem.

    You could see the same 'issue' (issue,not a problem) with Cofeescript , dart, traceur , or any other transpiler.

    Javascript as a platfom, is very susceptible to devs's experience, language understanding and skills. (like any other language? )

    If someone has a hardtime reading the TS generated JS (that IMMO is pretty human friendly ) I don't think it will have better luck reading hand-coded messy JS.

    Plus, you always have the TS's source code with the interfaces and more natural OOP manners.

    the benefits of incorporating OOP and structure outweight the cons(if there is any).

    IDE support is great (Webstorm , Visual Studio) , you can actually refactor!

    And you have scoped lambdas :)

    The next iteration EcmaScript will be very much like what is TS today (without optional type saftey and a few niceties).

    What is gonna happen if somebody in the 'Js team' jump to ES6 with traceour or whatever other thing, will you care?. You will simply stick to the api provided by the module and work with that.

    Interfaces and Generics and washed up no trace of them on the JS side. its *optional design time help.

    And regarding the budling and minification thing, it will be the same as with JS , no difference , + you could jump one step with TS copilling everything to 1 outputfile

    IMMO the solution is level-up , modularize(serioulsy), tests(very helpful if written with self documenting puprposes) and Documentation.

提交回复
热议问题