FlowFuse / FlowFuse/flowfuse

Better DX for backend

Open
#4,490 0 comments 0 reactions 0 assignees View on GitHub
size:XL task
Dominant language
JavaScript
Stars
400
Forks
89
Avg merge
1d 21h
Merged PRs (30d)
146

Description

### Description

Currently, we have runtime bound `app.this`, `app.this.that` and other parts of the code base with zero inference.

This leads to difficult code navigation, avoidable errors and too much context switching trying to find the right parameters or properties for a given thing.

As the code base grows, this will become more and more of a problem. Especially for new developers who are not familiar with the code base.

The goal of this task is to make the code base more maintainable and easier to work with by adding type hints to the code base.
Benefits we can expect from this are:
* design time error checking
* better code completion and parameter hints which will lead to less errors
* faster navigation (which is especially important in a large code base)
* better refactoring support (e.g. renaming a variable)
* better patterns for easier testing

In this journey, it is expected that code patterns that provide full type inference will emerge and should used as a marker for any new work.

It is proposed that this will be done in several phases to minimise disruption and to make the work more manageable.
1. Add basic typedoc definitions to the code base to provide type hints for the first level of `app` objects.
1. These will provide a first level of code completion for the `app` object.
2. Add type hints for the second level of `app` objects - I propose the `auditLog.application` object as a starting point.
1. This will give full code completion and parameter hints for `a.pp.auditLog.application.x.y.z` object properties.
1. This will require a level of refactoring to ensure that the `auditLog.application` object is always correctly typed as new properties are added.

### Task List
- [ ] Add basic typedoc definitions to the code base to provide type hints for the first level of `app` objects.
- e.g. Add type doc for the `app` object inclidng all known 1st level objects like `app.auditLog`, `app.config`, `app.db`, etc
- [ ] Add type hints for the second level of `app` objects - I propose the `auditLog.application` object as a starting point.
- [ ] todo

### NOTES:
* This is the initial write up and will be refined as we progress.
* This task list is a work in progress and will be updated as we progress and patterns emerge.

### Epic/Story

_No response_

### Have you provided an initial effort estimate for this issue?

I have provided an initial effort estimate

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.