Improve quality of Typescripting (#25232)

pull/25286/head
Michael Telatynski 2023-05-05 09:08:36 +01:00 committed by GitHub
parent c0e070934a
commit 9e6467c684
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 19 additions and 8 deletions

View File

@ -30,7 +30,7 @@ const CompatibilityView: React.FC<IProps> = ({ onAccept }) => {
const brand = SdkConfig.get("brand"); const brand = SdkConfig.get("brand");
const mobileBuilds = SdkConfig.get("mobile_builds"); const mobileBuilds = SdkConfig.get("mobile_builds");
let ios = null; let ios: JSX.Element | undefined;
const iosCustomUrl = mobileBuilds?.ios; const iosCustomUrl = mobileBuilds?.ios;
if (iosCustomUrl !== null) { if (iosCustomUrl !== null) {
// could be undefined or a string // could be undefined or a string

View File

@ -27,7 +27,7 @@ const VectorAuthFooter = (): ReactElement => {
{ text: "GitHub", url: "https://github.com/vector-im/element-web" }, { text: "GitHub", url: "https://github.com/vector-im/element-web" },
]; ];
const authFooterLinks = []; const authFooterLinks: JSX.Element[] = [];
for (const linkEntry of links) { for (const linkEntry of links) {
authFooterLinks.push( authFooterLinks.push(
<a href={linkEntry.url} key={linkEntry.text} target="_blank" rel="noreferrer noopener"> <a href={linkEntry.url} key={linkEntry.text} target="_blank" rel="noreferrer noopener">

View File

@ -49,7 +49,7 @@ export default class Favicon {
private readonly params: IParams; private readonly params: IParams;
private readonly canvas: HTMLCanvasElement; private readonly canvas: HTMLCanvasElement;
private readonly baseImage: HTMLImageElement; private readonly baseImage: HTMLImageElement;
private context: CanvasRenderingContext2D; private context!: CanvasRenderingContext2D;
private icons: HTMLLinkElement[]; private icons: HTMLLinkElement[];
private isReady = false; private isReady = false;

View File

@ -19,6 +19,7 @@ limitations under the License.
*/ */
import { logger } from "matrix-js-sdk/src/logger"; import { logger } from "matrix-js-sdk/src/logger";
import { extractErrorMessageFromError } from "matrix-react-sdk/src/components/views/dialogs/ErrorDialog";
// These are things that can run before the skin loads - be careful not to reference the react-sdk though. // These are things that can run before the skin loads - be careful not to reference the react-sdk though.
import { parseQsFromFragment } from "./url_utils"; import { parseQsFromFragment } from "./url_utils";
@ -194,7 +195,7 @@ async function start(): Promise<void> {
await loadConfigPromise; await loadConfigPromise;
} catch (error) { } catch (error) {
// Now that we've loaded the theme (CSS), display the config syntax error if needed. // Now that we've loaded the theme (CSS), display the config syntax error if needed.
if (error.err && error.err instanceof SyntaxError) { if (error instanceof SyntaxError) {
// This uses the default brand since the app config is unavailable. // This uses the default brand since the app config is unavailable.
return showError(_t("Your Element is misconfigured"), [ return showError(_t("Your Element is misconfigured"), [
_t( _t(
@ -202,7 +203,7 @@ async function start(): Promise<void> {
"Please correct the problem and reload the page.", "Please correct the problem and reload the page.",
), ),
_t("The message from the parser is: %(message)s", { _t("The message from the parser is: %(message)s", {
message: error.err.message || _t("Invalid JSON"), message: error.message || _t("Invalid JSON"),
}), }),
]); ]);
} }
@ -231,7 +232,7 @@ async function start(): Promise<void> {
// Like the compatibility page, AWOOOOOGA at the user // Like the compatibility page, AWOOOOOGA at the user
// This uses the default brand since the app config is unavailable. // This uses the default brand since the app config is unavailable.
await showError(_t("Your Element is misconfigured"), [ await showError(_t("Your Element is misconfigured"), [
err.translatedMessage || _t("Unexpected error preparing the app. See console for details."), extractErrorMessageFromError(err, _t("Unexpected error preparing the app. See console for details.")),
]); ]);
} }
} }

View File

@ -28,7 +28,7 @@ import Favicon from "../../favicon";
* Vector-specific extensions to the BasePlatform template * Vector-specific extensions to the BasePlatform template
*/ */
export default abstract class VectorBasePlatform extends BasePlatform { export default abstract class VectorBasePlatform extends BasePlatform {
protected _favicon: Favicon; protected _favicon?: Favicon;
public async getConfig(): Promise<IConfigOptions | undefined> { public async getConfig(): Promise<IConfigOptions | undefined> {
return getVectorConfig(); return getVectorConfig();

View File

@ -18,5 +18,15 @@
"strictBindCallApply": true, "strictBindCallApply": true,
"noImplicitThis": true "noImplicitThis": true
}, },
"include": ["./src/**/*.ts", "./src/**/*.tsx", "./test/**/*.ts", "./test/**/*.tsx"] "include": [
"./node_modules/matrix-js-sdk/src/@types/*.d.ts",
"./node_modules/matrix-react-sdk/src/@types/diff-dom.d.ts",
"./node_modules/matrix-react-sdk/src/@types/opus-recorder.d.ts",
"./node_modules/matrix-react-sdk/src/@types/png-chunks-extract.d.ts",
"./node_modules/matrix-react-sdk/src/@types/sanitize-html.d.ts",
"./src/**/*.ts",
"./src/**/*.tsx",
"./test/**/*.ts",
"./test/**/*.tsx"
]
} }