Closed Bug 2079376 Opened 1 month ago Closed 1 month ago

Fix more newtab/lib TypeScript errors so 11 more files can be type-checked

Categories

(Firefox :: New Tab Page, task)

task

Tracking

()

RESOLVED FIXED
160 Branch
Tracking Status
firefox160 --- fixed

People

(Reporter: jaws, Assigned: jaws)

References

Details

(Whiteboard: [hnt])

Attachments

(10 external files)

tsc can only check a file in browser/extensions/newtab/lib once it has no errors, so 16 files are still on the exclude list in browser/extensions/newtab/tsconfig.json. These patches fix the errors in 11 of them, mostly wrong or missing JSDoc, and take those files off the list. Four of the patches fix small real problems that tsc found, such as an error message that dropped the scheme it was meant to report.

The scheme was passed as the second argument to new Error, which is ErrorOptions, so the logged message ended in "but got " with nothing after it; tsc reported this as TS2559, and the file now leaves the tsconfig exclude list.

willDoomOnShutdown used Array.prototype.find, so it returned the matching nsIURI or undefined rather than the documented boolean; every current caller only tests it for truthiness, so this changes no behavior, but tsc reported it as TS2322 and using some makes the return value match the contract.

WeatherFeed.fetch takes no arguments, so the isStartup flag that init passed to loadWeather and that loadWeather forwarded to fetch was never read; tsc reported the extra argument as TS2554, and the file now leaves the tsconfig exclude list.

Bug 1953330 changed BUILT_IN_SECTIONS to take no arguments, but SectionsManager.init and addBuiltInSection kept reading the newtab and pocketNewtab Nimbus variables to pass to it; tsc reported the extra argument as TS2554, and the file now leaves the tsconfig exclude list.

skipMain is only passed by OnlyToOneContent, so the other callers in NewTabInit and WebNotificationsFeed were flagged for passing two of three arguments; NewTabInit now leaves the tsconfig exclude list.

The JSDoc for these functions omitted properties the code reads or passes: manifest in RemoteRenderer's content objects, endpointUrl in two TemporaryMerinoClientShim fetches, the options of WebNotificationsFeed._dismissAll and skipNightlyDefault on WidgetRegistryEntry, while AdsClient.uninit's client was documented as a string; AdsClient, TemporaryMerinoClientShim and RemoteRenderer now leave the tsconfig exclude list.

STORIES_REGION_LOCALE_DEFAULT is now typed as RegionLocaleEntries, with a cast on its Nightly-only spread since tsc infers that conditional array as nested string arrays rather than tuples, and normalizeDiskEntry casts its accumulator because id is copied in from DISK_PASSTHROUGH_FIELDS after construction; WebNotificationsFeed now leaves the tsconfig exclude list.

widgetLabels is passed WIDGET_REGISTRY entries, whose prefsL10nId is optional because retired entries omit it, so the hand-written { id, prefsL10nId } type rejected them; AboutPreferences now leaves the tsconfig exclude list.

The constructor copies DEFAULT_OPTIONS and its options argument onto the instance with Object.assign, so tsc never saw dispatch, pageURL or the message names as members and required callers such as Store to pass every option the defaults already supply; the options are now documented as optional, the four members are declared as typed class fields, and onMessage's JSDoc names msg.data instead of msg.action, the property it actually reads. ActivityStreamMessageChannel and Store now leave the tsconfig exclude list.

The constructor destructured an undocumented options object that defaults to {}, and the impression and allocatedTask typedefs marked as required the timestamps and DAP task fields that onAttributionEvent's default impression never has; the file stays excluded for the ObjectStore.get error that comes from wrapMethods in toolkit/modules/IndexedDB.sys.mjs.

Pushed by jwein@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/a21daf02bb9d https://hg.mozilla.org/integration/autoland/rev/2e07df63abc5 Include the unexpected scheme in the MozNewTabRemoteRendererProtocolParent error message since it was being passed as the Error options argument r=mconley https://github.com/mozilla-firefox/firefox/commit/ecdae613be6c https://hg.mozilla.org/integration/autoland/rev/e801f5b337da Return a boolean from RemoteRenderer.willDoomOnShutdown as documented instead of the matching nsIURI r=mconley https://github.com/mozilla-firefox/firefox/commit/a44877a73caf https://hg.mozilla.org/integration/autoland/rev/bffb3b7e7537 Remove the unused isStartup argument from WeatherFeed.loadWeather and the fetch call that it was forwarded to r=mconley https://github.com/mozilla-firefox/firefox/commit/3807487a596c https://hg.mozilla.org/integration/autoland/rev/48fed745891d Remove the unused Nimbus featureConfig from SectionsManager since BUILT_IN_SECTIONS stopped taking it in bug 1953330 r=mconley https://github.com/mozilla-firefox/firefox/commit/f1f5ddf97f8b https://hg.mozilla.org/integration/autoland/rev/481cd2bcd711 Fix TypeScript errors for calls to AlsoToOneContent without skipMain (TS2554) by marking it optional in its JSDoc r=mconley https://github.com/mozilla-firefox/firefox/commit/c7af261f3949 https://hg.mozilla.org/integration/autoland/rev/49ac54118a35 Fix TypeScript errors for properties missing from JSDoc object types (TS2339, TS2353) in newtab/lib r=mconley https://github.com/mozilla-firefox/firefox/commit/2db18a8dfcd2 https://hg.mozilla.org/integration/autoland/rev/bace8a49d8f9 Fix TypeScript errors for object and array literals that tsc cannot infer as their documented types (TS2322, TS2741) in newtab/lib r=mconley https://github.com/mozilla-firefox/firefox/commit/c3af2f95e76b https://hg.mozilla.org/integration/autoland/rev/ed3409e32a59 Fix the TypeScript error for widgetLabels' parameter type (TS2345) in newtab/lib AboutPreferences by typing it as WidgetRegistryEntry[] r=mconley https://github.com/mozilla-firefox/firefox/commit/5bd552ee5260 https://hg.mozilla.org/integration/autoland/rev/518569a24916 Fix TypeScript errors for ActivityStreamMessageChannel's options (TS2339, TS2345, TS2739) by declaring the members its constructor copies from them r=mconley https://github.com/mozilla-firefox/firefox/commit/225c5ddea92a https://hg.mozilla.org/integration/autoland/rev/211b9baed96a Fix TypeScript errors for NewTabAttributionService's constructor options and stored impression typedefs (TS2339, TS2345, TS2739) r=mconley
QA Whiteboard: [qa-triage-done-c161/b160]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size:

⌂