Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Typescript strict null checks pt1 #6583

Closed
wants to merge 1 commit into from

Conversation

Palid
Copy link
Contributor

@Palid Palid commented Aug 8, 2021

Removed some unused variables (mostly private ones) and changed the types accordingly to strictNullCheck in tsconfig.

Please don't mind failing eslint so far, we need to figure this out slightly better. Maybe change APIs in case of the SettingsStore too (make new API and deprecate current one?)

Related to element-hq/element-web#21967


This change is marked as an internal change (Task), so will not be included in the changelog.

@Palid Palid requested a review from a team as a code owner August 8, 2021 18:28
@turt2live turt2live marked this pull request as draft August 8, 2021 19:06
@turt2live turt2live removed the request for review from a team August 8, 2021 19:06
@Palid Palid force-pushed the dx/typescript-strict-null/pt1 branch from b51cf4f to 84cad17 Compare August 9, 2021 08:41
private dispatcherRef: string | null = null;
private supportsPstnProtocol = false;
private pstnSupportPrefixed = false; // True if the server only support the prefixed pstn protocol
private supportsSipNativeVirtual = false; // im.vector.protocol.sip_virtual and im.vector.protocol.sip_native
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These started off as null because we only have a definitive yes/no answer after we've checked with the server, so we're losing this info.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The question is: do we need this info, or just falling back by default to it being turned off isn't enough?

const timeUntilTurnCresExpire = turnServersExpiry - Date.now();
console.log("Current turn creds expire in " + timeUntilTurnCresExpire + " ms");
} else {
if (process.env.NODE_ENV === 'development') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't really growing on me. I'd rather get loglevel in to do things like this, or wrap it up in an assert() that's a nop in production mode or something.

Moreover, in this case, I forget how this works exactly, but what happens when the client can't get turn creds (in which case we should be attempting the call anyway).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In some cases it just looked like we aren't properly checking for failures and I honestly have no idea what should happen here. This seemed like the best way to do it without breaking current experience, but it doesn't sound correct.

@@ -848,6 +853,8 @@ export default class CallHandler extends EventEmitter {
const call = payload.call as MatrixCall;

const mappedRoomId = CallHandler.sharedInstance().roomIdForCall(call);
// Leave early if can't figure out room id.
if (!mappedRoomId) return;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In what circumstances does this happen?

@@ -901,6 +910,7 @@ export default class CallHandler extends EventEmitter {
}

const call = this.calls.get(payload.room_id);
if (!call) return;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

log please

// setting invalid content removes it
WidgetUtils.setRoomWidget(roomId, w.id);
});
if (roomInfo) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

log please

<div className="mx_CallEvent_sender">
{ sender }
<div style={{backgroundColor: 'red'}}>
this actually works.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming this was something else :p

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, a leftover from hmr testing. Stash fail. 😅

@@ -221,7 +221,7 @@ export function replaceByRegexes(text: string, mapping: Tags): React.ReactNode;
export function replaceByRegexes(text: string, mapping: IVariables | Tags): string | React.ReactNode {
// We initially store our output as an array of strings and objects (e.g. React components).
// This will then be converted to a string or a <span> at the end
const output = [text];
const output: Array<string | React.ReactNode> = [text];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't ReactNode supposed to be either a react element or a string?

@@ -438,6 +438,7 @@ export default class SettingsStore {
settingName = setting.invertedSettingName;
value = !value;
}
if (!roomId) return;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't it just not be optional?

Copy link
Contributor Author

@Palid Palid Aug 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should, but half of the usages have roomId as optional, so we need to change the API here. The question is: can we safely rework this API without deprecation, or do we need to properly deprecate it with old params?

@Palid
Copy link
Contributor Author

Palid commented Sep 2, 2021

It seems that @SimonBrandner wants to take over this one, so please do! 😄

@SimonBrandner
Copy link
Contributor

I don't have the time to handle this atm

@SimonBrandner SimonBrandner removed their assignment Jan 7, 2022
@MadLittleMods MadLittleMods added Z-Community-PR Issue is solved by a community member's PR T-Task Refactoring, enabling or disabling functionality, other engineering tasks labels Jun 1, 2022
@t3chguy
Copy link
Member

t3chguy commented Feb 3, 2023

Thanks for this but it has rotted beyond usability, some of these sites have already been fixed, rest will be addressed as part of element-hq/element-web#21967

@t3chguy t3chguy closed this Feb 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
T-Task Refactoring, enabling or disabling functionality, other engineering tasks Z-Community-PR Issue is solved by a community member's PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants