Skip to content

Commit

Permalink
Merge pull request #931 from matrix-org/bs/ts-3.7
Browse files Browse the repository at this point in the history
Typescript 3.7
  • Loading branch information
Half-Shot authored Jan 6, 2020
2 parents 667735d + b222753 commit a859735
Show file tree
Hide file tree
Showing 12 changed files with 115 additions and 50 deletions.
1 change: 1 addition & 0 deletions changelog.d/931.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Use Typescript 3.7 and fix build issues.
121 changes: 90 additions & 31 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,21 @@
"@sentry/node": "^5.9.0"
},
"devDependencies": {
"@types/bluebird": "^3.5.27",
"@types/express": "^4.17.2",
"@types/extend": "^3.0.1",
"@types/bluebird": "^3.5.27",
"@types/he": "^1.1.0",
"@types/nedb": "^1.8.9",
"@types/nopt": "^3.0.29",
"@types/pg": "^7.11.1",
"@types/sanitize-html": "^1.20.2",
"@typescript-eslint/eslint-plugin": "^2.2.0",
"@typescript-eslint/parser": "^2.2.0",
"@typescript-eslint/eslint-plugin": "^2.14.0",
"@typescript-eslint/parser": "^2.14.0",
"eslint": "^5.16.0",
"jasmine": "^3.1.0",
"nyc": "^14.1.1",
"prom-client": "^11.5.3",
"proxyquire": "^1.4.0",
"typescript": "^3.6.3",
"prom-client": "^11.5.3"
"typescript": "^3.7.3"
}
}
4 changes: 2 additions & 2 deletions src/bridge/AdminRoomHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ export class AdminRoomHandler {
});
for (const r of matrixRooms) {
const userMustJoin = (
key || server.shouldSyncMembershipToIrc("incremental", r.getId())
key ?? server.shouldSyncMembershipToIrc("incremental", r.getId())
);
if (!userMustJoin) {
continue;
Expand All @@ -283,7 +283,7 @@ export class AdminRoomHandler {
for (let i = 0; i < matrixRooms.length; i++) {
const m = matrixRooms[i];
const userMustJoin = (
key || server.shouldSyncMembershipToIrc("incremental", m.getId())
key ?? server.shouldSyncMembershipToIrc("incremental", m.getId())
);
if (userMustJoin) {
// force join then break out (we only ever join once no matter how many
Expand Down
2 changes: 1 addition & 1 deletion src/bridge/IrcBridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export class IrcBridge {
});
}
// Dependency graph
this.matrixHandler = new MatrixHandler(this, this.config.matrixHandler);
this.matrixHandler = new MatrixHandler(this, this.config.matrixHandler || {});
if (!this.config.database && this.config.ircService.databaseUri) {
log.warn("ircService.databaseUri is a deprecated config option." +
"Please use the database configuration block");
Expand Down
4 changes: 1 addition & 3 deletions src/bridge/MatrixHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,7 @@ export class MatrixHandler {
// maintain a list of room IDs which are being processed invite-wise. This is
// required because invites are processed asyncly, so you could get invite->msg
// and the message is processed before the room is created.
config = config || {}
this.eventCacheMaxSize = config.eventCacheSize === undefined ?
DEFAULT_EVENT_CACHE_SIZE : config.eventCacheSize;
this.eventCacheMaxSize = config.eventCacheSize ?? DEFAULT_EVENT_CACHE_SIZE;
// The media URL to use to transform mxc:// URLs when handling m.room.[file|image]s
this.mediaUrl = ircBridge.config.homeserver.media_url || ircBridge.config.homeserver.url;
this.adminHandler = new AdminRoomHandler(ircBridge, this);
Expand Down
2 changes: 1 addition & 1 deletion src/irc/ClientPool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ export class ClientPool {
return undefined;
}
const cli = this.virtualClients[server.domain].nicks[nick];
if (!cli || cli.isDead()) {
if (cli?.isDead()) {
return undefined;
}
return cli;
Expand Down
2 changes: 1 addition & 1 deletion src/irc/ConnectionInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export class ConnectionInstance {

return new Bluebird((resolve) => {
// close the connection
this.client.disconnect(ircReason, () => {});
this.client.disconnect(ircReason, () => { /* This is needed for tests */ });
// remove timers
if (this.pingRateTimerId) {
clearTimeout(this.pingRateTimerId);
Expand Down
12 changes: 10 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,16 @@ const log = logging.get("main");
http.globalAgent.maxSockets = 1000;
https.globalAgent.maxSockets = 1000;

process.on("unhandledRejection", (reason?: Error) => {
log.error((reason ? reason.stack : undefined) || "No reason given");
// eslint-disable-next-line @typescript-eslint/no-explicit-any
process.on("unhandledRejection", (reason: any) => {
let reasonStr = "No reason given";
if (reason && reason.stack) {
reasonStr = reason.stack
}
else if (typeof(reason) === "string") {
reasonStr = reason;
}
log.error(reasonStr);
});

const _toServer = (domain: string, serverConfig: any, homeserverDomain: string) => {
Expand Down
2 changes: 1 addition & 1 deletion src/models/IrcAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class IrcAction {
}
if (matrixAction.htmlText) {
const text = ircFormatting.htmlToIrc(matrixAction.htmlText);
const ircText = text !== null ? text : matrixAction.text; // fallback if needed.
const ircText = text ?? matrixAction.text; // fallback if needed.
if (ircText === null) {
throw Error("ircText is null");
}
Expand Down
4 changes: 1 addition & 3 deletions src/scripts/migrate-db-to-pgres.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,6 @@ async function main() {
log.info("Finished migration at %sms", Date.now() - time);
}

main().then(() => {

}).catch((ex) => {
main().catch((ex) => {
log.error("Failed to run migration script: %s", ex);
})
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"composite": false,
"strict": true,
"esModuleInterop": true,
"strictNullChecks": true,
"typeRoots": [
"./types"
]
Expand Down

0 comments on commit a859735

Please sign in to comment.