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

Commit

Permalink
strict null check
Browse files Browse the repository at this point in the history
  • Loading branch information
germain-gg committed Nov 21, 2022
1 parent 8e1f8da commit 8a5a8a2
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Rooms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export function getDisplayAliasForRoom(room: Room): string {

// The various display alias getters should all feed through this one path so
// there's a single place to change the logic.
export function getDisplayAliasForAliasSet(canonicalAlias: string, altAliases: string[]): string {
export function getDisplayAliasForAliasSet(canonicalAlias?: string, altAliases?: string[]): string {
if (AliasCustomisations.getDisplayAliasForAliasSet) {
return AliasCustomisations.getDisplayAliasForAliasSet(canonicalAlias, altAliases);
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/structures/SpaceHierarchy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ export const showRoom = (cli: MatrixClient, hierarchy: RoomHierarchy, roomId: st
}
}

const roomAlias = getDisplayAliasForAliasSet(room.canonical_alias, room.aliases) || undefined;
const roomAlias = getDisplayAliasForAliasSet(room?.canonical_alias, room?.aliases) || undefined;

defaultDispatcher.dispatch<ViewRoomPayload>({
action: Action.ViewRoom,
Expand Down
2 changes: 1 addition & 1 deletion src/customisations/Alias.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

function getDisplayAliasForAliasSet(canonicalAlias: string, altAliases: string[]): string {
function getDisplayAliasForAliasSet(canonicalAlias?: string, altAliases?: string[]): string {

This comment has been minimized.

Copy link
@t3chguy

t3chguy Nov 21, 2022

Member

Changing this is a breaking change, no? These customisation signatures are used by other projects to modify Element

This comment has been minimized.

Copy link
@germain-gg

germain-gg Nov 21, 2022

Author Contributor

Not a breaking change, this is fully backwards compatible. And required as otherwise the strict null check CI is shouting at me.

This comment has been minimized.

Copy link
@t3chguy

t3chguy Nov 21, 2022

Member

If an external project has their own getDisplayAliasForAliasSet which gets passed into the value which is typed ?: typeof getDisplayAliasForAliasSet then this will cause it to fail their typing, no?

This comment has been minimized.

Copy link
@t3chguy

t3chguy Nov 21, 2022

Member

Seems more like the caller should not call with invalid values?

// E.g. prefer one of the aliases over another
return null;
}
Expand Down

0 comments on commit 8a5a8a2

Please sign in to comment.