iTowns / itowns

A Three.js-based framework written in Javascript/WebGL for visualizing 3D geospatial data
http://www.itowns-project.org
Other
1.09k stars 296 forks source link

[Proposal] Migration from JavaScript to TypeScript #2396

Open Desplandis opened 6 days ago

Desplandis commented 6 days ago

This issue is a feature proposal. Feel free to upvote (with :+1: ), comment and provide your use-cases if you're interested by this feature.

Context

The iTowns codebase is currently written in Javascript, with JSDoc comments providing a loose form of type-checking that isn't enforced (but in practice used by the LSP of our code editors). This lack of type safety has led to side-effects creeping into the project, making maintenance and debugging more challenging and causing unpredictable behavior in certain areas of the code.

This proposal outlines a migration path to TypeScript, which will enforce type safety, simplify the refactoring of complex or difficult-to-maintain parts of the code, and enable developers to take full advantage of modern tooling and best practices.

Description of the proposal

This proposal details the steps for migrating iTowns from JavaScript to TypeScript. The migration will follow a systematic, bottom-to-top approach, beginning with simpler, independent modules before tackling more complex and interdependent ones.

Along the way, we will take the opportunity to refactor key components to improve clarity and maintainability. These refactorings will be addressed through separate proposals and pull requests.

This issue will primarily serve as a tracker for the migration process and a space to discuss each phase of the migration (see tracking section below).

Implementation

Tooling

The migration will necessitate some changes on our tooling:

Code migration

The migration process will be gradual, but the following steps could serve as a good start:

Along the way

We could on our migration path rework certain parts of iTowns, those are some thoughts for now and they have not yet been formalized.

Potential Problems

Documentation

Tracking list

The tracking list will be written from our discussions, as a list of pair (Migration step, reference to issue and/or PR).

Final note

Feel free to extend and refine each of these points.

I will open a test PR on this subject to further explore the logistics of the migration and identify any overlooked aspects or missing steps.

mgermerie commented 6 days ago

On the documentation matter, do JSDoc and TypeDoc share a documentation generated format or will we need need a temporary template (for the duration of the migration) that supports both generated documentations ?

Desplandis commented 6 days ago

It does not support old JSDoc templates (unfortunately or not?). There seems to have a well-defined API to hooks some plugins as well as themes which seems to be collections of plugins + hooks on the generated HTML and styling.