question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Gradually migrating to TypeScript

See original GitHub issue

Is your feature request related to a problem? Please describe. As I don’t encounter any bugs at the moment, I am slightly worried about future maintenance of Leaflet, as I want to use Leaflet in my applications for at least a couple of years. I’ve noticed that the code in some files are still written in old JS syntax and types need to be maintained separately. A mismatch between the types and the actual code could introduce some issues.

Describe the solution you’d like Gradually migrating to TypeScript would be a solution to start with. Why?

  • Able to use modern syntax while still supporting older browsers
  • All the benefits of TypeScript
  • If everything is converted to TS, the @types/leaflet package is no longer needed
  • Overal better development experience

Describe alternatives you’ve considered A solution with minimal impact on the build process and code. Being able to actually use TypeScript and converting existing JS files to TS would be a good start. I’ve quickly tried something out, seems that the build output is almost the same https://github.com/chrisvanmook/Leaflet/pull/1/files.

I would like to know if you, the maintainers / contributors of leaflet, would be open for a similar change like this? In that case I will work on a pull-request, I might need some help with getting karma and leafdoc to work with TS.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:7
  • Comments:29 (4 by maintainers)

github_iconTop GitHub Comments

8reactions
jonkoopscommented, Jun 23, 2021

Not to be mean, but really, TS has become the bully on the playground.

It solves genuine problems that people experience, but if it’s a good fit for this project is a different discussion. The fact is that the Leaflet types are downloaded over 225.000 times a week, which is half of the downloads of Leaflet itself. This means that 50% of the Leaflet (NPM) user-base is also using TypeScript in one way or another so they seem to think it’s pretty useful.

Adding type definitions (not TypeScript itself) to the NPM package will make it easier for that 50% to do their job, and it has no impact whatsoever for those who do not use it. In fact even if it was decided to allow TypeScript in the code itself, it would still not impact you, since the compiled code is in fact just plain JavaScript.

When it is supported by browsers, then yup.

This will never happen, and should not be a criteria for getting compile time guarantees about the correctness of code.

6reactions
IvanSanchezcommented, Jun 4, 2021

I would like to know if you, the maintainers / contributors of leaflet, would be open for a similar change like this?

I’m very wary of TS. Specially when some of the Leaflet code still works around browser quirks, and I fear that TS will try to enforce a strict definition of properties available in document, window and so on. The little I’ve had to work with TS, it got in my way and felt like a burden.

Ideally I’d like work to be done on browser-loadable ESM modules (developing without needing to run a bundling toolchain feels so good), move the examples to <script type=module> and deprecate IE10 functionality (along with L.SVG.VML). I’m personally against complicating the toolchain.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Gradually Migrating To Typescript | Keeping Up To Date
If you have a large project, it may not be feasible to move to TypeScript all in one go. Gradually migrating provides more...
Read more >
Documentation - Migrating from JavaScript - TypeScript
During our JS to TS migration, we'll need to separate our input files to prevent TypeScript from overwriting them. If your output files...
Read more >
10 Strategies for migrating to TypeScript - Exploring JS
These are three strategies for migrating to TypeScript: We can support a mix of JavaScript and TypeScript files for our code base.
Read more >
Gradually migrating to typescript across multiple js codebases ...
Gradually migrating to typescript across multiple javascript codebases with a mid-size team.
Read more >
Migrating from ES5 to TS gradually - javascript - Stack Overflow
ts-migrate is a tool for helping migrate code to TypeScript. It takes a JavaScript, or a partial TypeScript, project in and gives a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found