From bd7bd755692947184d60e41aae1041193cc6a87f Mon Sep 17 00:00:00 2001 From: Stephen Niedzielski Date: Mon, 9 Mar 2020 12:31:36 -0600 Subject: [PATCH] [JavaScript] Validate types Lift the mists of confusion by checking that all JavaScript types align. No ignores! This is the JavaScript equivalent to Phan. This patch adds the necessary infrastructure for verifying typing and fixes the few flaws found. Bug: T239262 Change-Id: I2557471421196ea46cd13dfb786a52968fbfcc97 --- .eslintrc.json | 6 +- includes/templates/Portal.mustache | 8 +- package-lock.json | 84 ++++++++++---------- package.json | 7 +- resources/CollapsibleTabsPlugin.d.ts | 34 ++++++++ resources/mediawiki.d.ts | 20 +++++ resources/skins.vector.js/collapsibleTabs.js | 57 +++++++------ resources/skins.vector.js/vector.js | 7 +- stories/Portal.stories.data.js | 23 +++++- stories/rawLoader.d.ts | 4 + stories/utils.js | 5 ++ tsconfig.json | 19 +++++ 12 files changed, 193 insertions(+), 81 deletions(-) create mode 100644 resources/CollapsibleTabsPlugin.d.ts create mode 100644 resources/mediawiki.d.ts create mode 100644 stories/rawLoader.d.ts create mode 100644 tsconfig.json diff --git a/.eslintrc.json b/.eslintrc.json index c498c3d..44f9aa8 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -4,5 +4,9 @@ "wikimedia/client", "wikimedia/jquery", "wikimedia/mediawiki" - ] + ], + "rules": { + // Interferes with @type annotations. + "one-var": "off" + } } diff --git a/includes/templates/Portal.mustache b/includes/templates/Portal.mustache index 62a25e8..853e925 100644 --- a/includes/templates/Portal.mustache +++ b/includes/templates/Portal.mustache @@ -3,11 +3,11 @@ Each portal has the following composition: string portal-id string html-tooltip string msg-label-id - string|null html-userlangattributes - string msg-label} + string? html-userlangattributes + string msg-label string html-portal-content - string|null html-after-portal - string|null html-hook-vector-after-toolbox is deprecated and used by the toolbox portal. + string? html-after-portal + string? html-hook-vector-after-toolbox is deprecated and used by the toolbox portal. }}