Closed Bug 1869678 Opened 7 months ago Closed 6 months ago

Improve JSDocs to help with type inference

Categories

(WebExtensions :: General, task, P3)

task

Tracking

(firefox123 fixed)

RESOLVED FIXED
123 Branch
Tracking Status
firefox123 --- fixed

People

(Reporter: zombie, Assigned: zombie)

References

(Blocks 1 open bug)

Details

(Whiteboard: [addons-jira])

Attachments

(3 files, 1 obsolete file)

We have documented many of our functions and classes using JSDocs, but because no system actually tries to use (or test) those types, many of them are often slightly "wrong".

These fall under 5 main categories:

  1. Declare and/or initialize all class fiels in the constructor.
    (general good practise)

  2. Use real getters and redefineLazyGetter instead of defineLazyGetter.
    (also keeps related code closer together)

  3. When subclassing, don't override class fields with getters (or vice versa).
    https://github.com/microsoft/TypeScript/pull/33509

  4. Declare and assign object literals at the same time, not separatelly.
    (don't use let foo; at the top of the file, use var foo = {)

  5. Don't re-use local variables unnecesarily with different types.
    (general good practise, local variables are "free")

Depends on D196385

Assignee: nobody → tomica
Status: NEW → ASSIGNED
Attachment #9368577 - Attachment description: WIP: Bug 1869678 - Fixup and improve JSDocs for better type inference → Bug 1869678 - Fixup and improve JSDocs for better type inference
Attachment #9368578 - Attachment description: WIP: Bug 1869678 - Use more idiomatic code patterns for better type inference → Bug 1869678 - Use more idiomatic code patterns for better type inference
Attachment #9368579 - Attachment description: WIP: Bug 1869678 - Fix misc bugs identified by type inference → Bug 1869678 - Fix misc bugs identified by type inference
Attachment #9368580 - Attachment description: WIP: Bug 1869678 - Add tsconfig, basic types, and fix or ignore remaining type errors → Bug 1869678 - Add tsconfig, basic types, and fix or ignore remaining type errors
Attachment #9368580 - Attachment description: Bug 1869678 - Add tsconfig, basic types, and fix or ignore remaining type errors → WIP: Bug 1869678 - Add tsconfig, basic types, and fix or ignore remaining type errors
Attachment #9368580 - Attachment description: WIP: Bug 1869678 - Add tsconfig, basic types, and fix or ignore remaining type errors → Bug 1869678 - Add tsconfig, basic types, and fix or ignore remaining type errors
Attachment #9368577 - Attachment description: Bug 1869678 - Fixup and improve JSDocs for better type inference → Bug 1869678 - Fixup and improve JSDocs for better type inference r?rpl,robwu
Attachment #9368578 - Attachment description: Bug 1869678 - Use more idiomatic code patterns for better type inference → Bug 1869678 - Use more idiomatic code patterns for better type inference r?rpl,robwu
Attachment #9368579 - Attachment description: Bug 1869678 - Fix misc bugs identified by type inference → Bug 1869678 - Fix misc bugs identified by type inference r?rpl,robwu
Attachment #9368580 - Attachment description: Bug 1869678 - Add tsconfig, basic types, and fix or ignore remaining type errors → Bug 1869678 - Add tsconfig, basic types, and fix or ignore remaining type errors r?rpl,robwu
Severity: -- → N/A
Priority: -- → P3
See Also: → 1862464
Whiteboard: [addons-jira]
Blocks: 1871094
Blocks: 1871127

Comment on attachment 9368580 [details]
Bug 1869678 - Add tsconfig, basic types, and fix or ignore remaining type errors r?rpl,robwu

Revision D196388 was moved to bug 1871127. Setting attachment 9368580 [details] to obsolete.

Attachment #9368580 - Attachment is obsolete: true
Pushed by tjovanovic@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/1c6e48c2b096
Fixup and improve JSDocs for better type inference r=robwu
https://hg.mozilla.org/integration/autoland/rev/8e768446e17c
Use more idiomatic code patterns for better type inference r=robwu
https://hg.mozilla.org/integration/autoland/rev/81e9c0d20939
Fix misc bugs identified by type inference r=robwu
Status: ASSIGNED → RESOLVED
Closed: 6 months ago
Resolution: --- → FIXED
Target Milestone: --- → 123 Branch
Pushed by mkmelin@iki.fi:
https://hg.mozilla.org/comm-central/rev/3b127f7cce0f
adjust Thunderbird jsdoc to be valid after bug 1869678. rs=eslint
Regressions: 1870959
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: