Skip to content

Commit 4488721

Browse files
committed
Tag all TypeScript issues as FIXMEs
1 parent 31eaaee commit 4488721

22 files changed

+76
-76
lines changed

cypress.config.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ export default defineConfig({
4343
},
4444
GetFromMemories (property: string) {
4545
for (const memory of config.get<Memory[]>('memories')) {
46-
// @ts-expect-error any type issue
46+
// @ts-expect-error FIXME any type issue
4747
if (memory[property]) {
48-
// @ts-expect-error any type issue
48+
// @ts-expect-error FIXME any type issue
4949
return memory[property]
5050
}
5151
}

data/mongodb.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* SPDX-License-Identifier: MIT
44
*/
55

6-
// @ts-expect-error due to non-existing type definitions for MarsDB
6+
// @ts-expect-error FIXME due to non-existing type definitions for MarsDB
77
import MarsDB = require('marsdb')
88

99
const reviews = new MarsDB.Collection('posts')

lib/antiCheat.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export const totalCheatScore = () => {
8686
}
8787

8888
function areCoupled (challenge: Challenge, previousChallenge: Challenge) {
89-
// @ts-expect-error any type issues
89+
// @ts-expect-error FIXME any type issues
9090
return coupledChallenges[challenge.key]?.indexOf(previousChallenge.key) > -1 || coupledChallenges[previousChallenge.key]?.indexOf(challenge.key) > -1
9191
}
9292

lib/challengeUtils.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export const sendNotification = function (challenge: { difficulty?: number, key:
5151
notifications.push(notification)
5252

5353
if (global.io && (isRestore || !wasPreviouslyShown)) {
54-
// @ts-expect-error global type safety issues
54+
// @ts-expect-error FIXME global type safety issues
5555
global.io.emit('challenge solved', notification)
5656
}
5757
}
@@ -64,7 +64,7 @@ export const sendCodingChallengeNotification = function (challenge: { key: strin
6464
codingChallengeStatus: challenge.codingChallengeStatus
6565
}
6666
if (global.io) {
67-
// @ts-expect-error global type safety issues
67+
// @ts-expect-error FIXME global type safety issues
6868
global.io.emit('code challenge solved', notification)
6969
}
7070
}

lib/insecurity.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import * as utils from './utils'
1616

1717
/* jslint node: true */
1818
// eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
19-
// @ts-expect-error no typescript definitions for z85 :(
19+
// @ts-expect-error FIXME no typescript definitions for z85 :(
2020
import * as z85 from 'z85'
2121

2222
export const publicKey = fs ? fs.readFileSync('encryptionkeys/jwt.pub', 'utf8') : 'placeholder-public-key'

lib/startup/registerWebsocketEvents.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ let firstConnectedSocket: any = null
1515

1616
const registerWebsocketEvents = (server: any) => {
1717
const io = new Server(server, { cors: { origin: 'http://localhost:4200' } })
18-
// @ts-expect-error issue with global type safety
18+
// @ts-expect-error FIXME issue with global type safety
1919
global.io = io
2020

2121
io.on('connection', (socket: any) => {

lib/startup/validateConfig.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ const checkMinimumRequiredNumberOfProducts = (products: Product[]) => {
7373
const checkUnambiguousMandatorySpecialProducts = (products: Product[]) => {
7474
let success = true
7575
specialProducts.forEach(({ name, key }) => {
76-
// @ts-expect-error Ignoring any type issue on purpose
76+
// @ts-expect-error FIXME Ignoring any type issue on purpose
7777
const matchingProducts = products.filter((product) => product[key])
7878
if (matchingProducts.length === 0) {
7979
logger.warn(`No product is configured as ${colors.italic(name)} but one is required (${colors.red('NOT OK')})`)
@@ -89,9 +89,9 @@ const checkUnambiguousMandatorySpecialProducts = (products: Product[]) => {
8989
const checkNecessaryExtraKeysOnSpecialProducts = (products: Product[]) => {
9090
let success = true
9191
specialProducts.forEach(({ name, key, extra = {} }) => {
92-
// @ts-expect-error implicit any type issue
92+
// @ts-expect-error FIXME implicit any type issue
9393
const matchingProducts = products.filter((product) => product[key])
94-
// @ts-expect-error implicit any type issue
94+
// @ts-expect-error FIXME implicit any type issue
9595
if (extra.key && matchingProducts.length === 1 && !matchingProducts[0][extra.key]) {
9696
logger.warn(`Product ${colors.italic(matchingProducts[0].name)} configured as ${colors.italic(name)} does't contain necessary ${colors.italic(`${extra.name}`)} (${colors.red('NOT OK')})`)
9797
success = false
@@ -103,7 +103,7 @@ const checkNecessaryExtraKeysOnSpecialProducts = (products: Product[]) => {
103103
const checkUniqueSpecialOnProducts = (products: Product[]) => {
104104
let success = true
105105
products.forEach((product) => {
106-
// @ts-expect-error any type issue
106+
// @ts-expect-error FIXME any type issue
107107
const appliedSpecials = specialProducts.filter(({ key }) => product[key])
108108
if (appliedSpecials.length > 1) {
109109
logger.warn(`Product ${colors.italic(product.name)} is used as ${appliedSpecials.map(({ name }) => `${colors.italic(name)}`).join(' and ')} but can only be used for one challenge (${colors.red('NOT OK')})`)
@@ -125,7 +125,7 @@ const checkMinimumRequiredNumberOfMemories = (memories: Memory[]) => {
125125
const checkUnambiguousMandatorySpecialMemories = (memories: Memory[]) => {
126126
let success = true
127127
specialMemories.forEach(({ name, keys }) => {
128-
// @ts-expect-error any type issue
128+
// @ts-expect-error FIXME any type issue
129129
const matchingMemories = memories.filter((memory) => memory[keys[0]] && memory[keys[1]])
130130
if (matchingMemories.length === 0) {
131131
logger.warn(`No memory is configured as ${colors.italic(name)} but one is required (${colors.red('NOT OK')})`)
@@ -141,7 +141,7 @@ const checkUnambiguousMandatorySpecialMemories = (memories: Memory[]) => {
141141
const checkSpecialMemoriesHaveNoUserAssociated = (memories: Memory[]) => {
142142
let success = true
143143
specialMemories.forEach(({ name, user, keys }) => {
144-
// @ts-expect-error any type issue
144+
// @ts-expect-error FIXME any type issue
145145
const matchingMemories = memories.filter((memory) => memory[keys[0]] && memory[keys[1]] && memory.user && memory.user !== user)
146146
if (matchingMemories.length > 0) {
147147
logger.warn(`Memory configured as ${colors.italic(name)} must belong to user ${colors.italic(user)} but was linked to ${colors.italic(matchingMemories[0].user)} user (${colors.red('NOT OK')})`)
@@ -154,7 +154,7 @@ const checkSpecialMemoriesHaveNoUserAssociated = (memories: Memory[]) => {
154154
const checkUniqueSpecialOnMemories = (memories: Memory[]) => {
155155
let success = true
156156
memories.forEach((memory) => {
157-
// @ts-expect-error any type issue
157+
// @ts-expect-error FIXME any type issue
158158
const appliedSpecials = specialMemories.filter(({ keys }) => memory[keys[0]] && memory[keys[1]])
159159
if (appliedSpecials.length > 1) {
160160
logger.warn(`Memory ${colors.italic(memory.caption)} is used as ${appliedSpecials.map(({ name }) => `${colors.italic(name)}`).join(' and ')} but can only be used for one challenge (${colors.red('NOT OK')})`)

lib/utils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export const trunc = function (str: string, length: number) {
7474

7575
export const version = (module?: string) => {
7676
if (module) {
77-
// @ts-expect-error Ignoring any type issue on purpose
77+
// @ts-expect-error FIXME Ignoring any type issue on purpose
7878
return packageJson.dependencies[module]
7979
} else {
8080
return packageJson.version

models/relations.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const relationsInit = (_sequelize: Sequelize) => {
4141
name: 'BasketId'
4242
}
4343
})
44-
// @ts-expect-error type mismatch
44+
// @ts-expect-error FIXME type mismatch
4545
makeKeyNonUpdatable(BasketItemModel, 'BasketId')
4646

4747
CardModel.belongsTo(UserModel, {
@@ -94,7 +94,7 @@ const relationsInit = (_sequelize: Sequelize) => {
9494
name: 'ProductId'
9595
}
9696
})
97-
// @ts-expect-error type mismatch
97+
// @ts-expect-error FIXME type mismatch
9898
makeKeyNonUpdatable(BasketItemModel, 'ProductId')
9999

100100
QuantityModel.belongsTo(ProductModel, {

routes/profileImageFileUpload.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ module.exports = function fileUpload () {
2727
if (loggedInUser) {
2828
fs.open(`frontend/dist/frontend/assets/public/images/uploads/${loggedInUser.data.id}.${uploadedFileType.ext}`, 'w', function (err, fd) {
2929
if (err != null) logger.warn('Error opening file: ' + err.message)
30-
// @ts-expect-error buffer has unexpected type
30+
// @ts-expect-error FIXME buffer has unexpected type
3131
fs.write(fd, buffer, 0, buffer.length, null, function (err) {
3232
if (err != null) logger.warn('Error writing file: ' + err.message)
3333
fs.close(fd, function () { })

routes/showProductReviews.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const security = require('../lib/insecurity')
1313
const db = require('../data/mongodb')
1414

1515
// Blocking sleep function as in native MongoDB
16-
// @ts-expect-error Type safety broken for global object
16+
// @ts-expect-error FIXME Type safety broken for global object
1717
global.sleep = (time: number) => {
1818
// Ensure that users don't accidentally dos their servers for too long
1919
if (time > 2000) {

server.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ restoreOverwrittenFilesWithOriginals().then(() => {
217217
/* Create middleware to change paths from the serve-index plugin from absolute to relative */
218218
const serveIndexMiddleware = (req: Request, res: Response, next: NextFunction) => {
219219
const origEnd = res.end
220-
// @ts-expect-error assignment broken due to seemingly void return value
220+
// @ts-expect-error FIXME assignment broken due to seemingly void return value
221221
res.end = function () {
222222
if (arguments.length) {
223223
const reqPath = req.originalUrl.replace(/\?.*$/, '')
@@ -234,7 +234,7 @@ restoreOverwrittenFilesWithOriginals().then(() => {
234234
return 'a href="' + relativePath + '"'
235235
})
236236
}
237-
// @ts-expect-error passed argument has wrong type
237+
// @ts-expect-error FIXME passed argument has wrong type
238238
origEnd.apply(this, arguments)
239239
}
240240
next()
@@ -281,7 +281,7 @@ restoreOverwrittenFilesWithOriginals().then(() => {
281281

282282
app.use(bodyParser.text({ type: '*/*' }))
283283
app.use(function jsonParser (req: Request, res: Response, next: NextFunction) {
284-
// @ts-expect-error intentionally saving original request in this property
284+
// @ts-expect-error FIXME intentionally saving original request in this property
285285
req.rawBody = req.body
286286
if (req.headers['content-type']?.includes('application/json')) {
287287
if (!req.body) {

test/api/2faSpec.ts

+22-22
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const API_URL = 'http://localhost:3000/api'
1717
const jsonHeader = { 'content-type': 'application/json' }
1818

1919
async function login ({ email, password, totpSecret }: { email: string, password: string, totpSecret?: string }) {
20-
// @ts-expect-error promise return handling broken
20+
// @ts-expect-error FIXME promise return handling broken
2121
const loginRes = await frisby
2222
.post(REST_URL + '/user/login', {
2323
email,
@@ -30,7 +30,7 @@ async function login ({ email, password, totpSecret }: { email: string, password
3030
})
3131

3232
if (loginRes.json.status && loginRes.json.status === 'totp_token_required') {
33-
// @ts-expect-error promise return handling broken
33+
// @ts-expect-error FIXME promise return handling broken
3434
const totpRes = await frisby
3535
.post(REST_URL + '/2fa/verify', {
3636
tmpToken: loginRes.json.data.tmpToken,
@@ -44,7 +44,7 @@ async function login ({ email, password, totpSecret }: { email: string, password
4444
}
4545

4646
async function register ({ email, password, totpSecret }: { email: string, password: string, totpSecret?: string }) {
47-
// @ts-expect-error promise return handling broken
47+
// @ts-expect-error FIXME promise return handling broken
4848
const res = await frisby
4949
.post(API_URL + '/Users/', {
5050
email,
@@ -59,7 +59,7 @@ async function register ({ email, password, totpSecret }: { email: string, passw
5959
if (totpSecret) {
6060
const { token } = await login({ email, password })
6161

62-
// @ts-expect-error promise return handling broken
62+
// @ts-expect-error FIXME promise return handling broken
6363
await frisby.post(
6464
REST_URL + '/2fa/setup',
6565
{
@@ -103,7 +103,7 @@ describe('/rest/2fa/verify', () => {
103103

104104
const totpToken = otplib.authenticator.generate('IFTXE3SPOEYVURT2MRYGI52TKJ4HC3KH')
105105

106-
// @ts-expect-error promise return handling broken
106+
// @ts-expect-error FIXME promise return handling broken
107107
await frisby.post(REST_URL + '/2fa/verify', {
108108
headers: jsonHeader,
109109
body: {
@@ -131,7 +131,7 @@ describe('/rest/2fa/verify', () => {
131131

132132
const totpToken = otplib.authenticator.generate('THIS9ISNT8THE8RIGHT8SECRET')
133133

134-
// @ts-expect-error promise return handling broken
134+
// @ts-expect-error FIXME promise return handling broken
135135
await frisby.post(REST_URL + '/2fa/verify', {
136136
headers: jsonHeader,
137137
body: {
@@ -150,7 +150,7 @@ describe('/rest/2fa/verify', () => {
150150

151151
const totpToken = otplib.authenticator.generate('IFTXE3SPOEYVURT2MRYGI52TKJ4HC3KH')
152152

153-
// @ts-expect-error promise return handling broken
153+
// @ts-expect-error FIXME promise return handling broken
154154
await frisby.post(REST_URL + '/2fa/verify', {
155155
headers: jsonHeader,
156156
body: {
@@ -170,7 +170,7 @@ describe('/rest/2fa/status', () => {
170170
totpSecret: 'IFTXE3SPOEYVURT2MRYGI52TKJ4HC3KH'
171171
})
172172

173-
// @ts-expect-error promise return handling broken
173+
// @ts-expect-error FIXME promise return handling broken
174174
await frisby.get(
175175
REST_URL + '/2fa/status',
176176
{
@@ -195,7 +195,7 @@ describe('/rest/2fa/status', () => {
195195
password: '0Y8rMnww$*9VFYE§59-!Fg1L6t&6lB'
196196
})
197197

198-
// @ts-expect-error promise return handling broken
198+
// @ts-expect-error FIXME promise return handling broken
199199
await frisby.get(
200200
REST_URL + '/2fa/status',
201201
{
@@ -219,7 +219,7 @@ describe('/rest/2fa/status', () => {
219219
})
220220

221221
it('GET should return 401 when not logged in', async () => {
222-
// @ts-expect-error promise return handling broken
222+
// @ts-expect-error FIXME promise return handling broken
223223
await frisby.get(REST_URL + '/2fa/status')
224224
.expect('status', 401)
225225
})
@@ -235,7 +235,7 @@ describe('/rest/2fa/setup', () => {
235235
await register({ email, password })
236236
const { token } = await login({ email, password })
237237

238-
// @ts-expect-error promise return handling broken
238+
// @ts-expect-error FIXME promise return handling broken
239239
await frisby.post(
240240
REST_URL + '/2fa/setup',
241241
{
@@ -254,7 +254,7 @@ describe('/rest/2fa/setup', () => {
254254
})
255255
.expect('status', 200)
256256

257-
// @ts-expect-error promise return handling broken
257+
// @ts-expect-error FIXME promise return handling broken
258258
await frisby.get(
259259
REST_URL + '/2fa/status',
260260
{
@@ -281,7 +281,7 @@ describe('/rest/2fa/setup', () => {
281281
await register({ email, password })
282282
const { token } = await login({ email, password })
283283

284-
// @ts-expect-error promise return handling broken
284+
// @ts-expect-error FIXME promise return handling broken
285285
await frisby.post(
286286
REST_URL + '/2fa/setup',
287287
{
@@ -310,7 +310,7 @@ describe('/rest/2fa/setup', () => {
310310
await register({ email, password })
311311
const { token } = await login({ email, password })
312312

313-
// @ts-expect-error promise return handling broken
313+
// @ts-expect-error FIXME promise return handling broken
314314
await frisby.post(
315315
REST_URL + '/2fa/setup',
316316
{
@@ -339,7 +339,7 @@ describe('/rest/2fa/setup', () => {
339339
await register({ email, password })
340340
const { token } = await login({ email, password })
341341

342-
// @ts-expect-error promise return handling broken
342+
// @ts-expect-error FIXME promise return handling broken
343343
await frisby.post(
344344
REST_URL + '/2fa/setup',
345345
{
@@ -366,7 +366,7 @@ describe('/rest/2fa/setup', () => {
366366

367367
const { token } = await login({ email, password, totpSecret })
368368

369-
// @ts-expect-error promise return handling broken
369+
// @ts-expect-error FIXME promise return handling broken
370370
await frisby.post(
371371
REST_URL + '/2fa/setup',
372372
{
@@ -396,14 +396,14 @@ describe('/rest/2fa/disable', () => {
396396
await register({ email, password, totpSecret })
397397
const { token } = await login({ email, password, totpSecret })
398398

399-
// @ts-expect-error promise return handling broken
399+
// @ts-expect-error FIXME promise return handling broken
400400
await getStatus(token)
401401
.expect('status', 200)
402402
.expect('json', {
403403
setup: true
404404
})
405405

406-
// @ts-expect-error promise return handling broken
406+
// @ts-expect-error FIXME promise return handling broken
407407
await frisby.post(
408408
REST_URL + '/2fa/disable',
409409
{
@@ -417,7 +417,7 @@ describe('/rest/2fa/disable', () => {
417417
}
418418
).expect('status', 200)
419419

420-
// @ts-expect-error promise return handling broken
420+
// @ts-expect-error FIXME promise return handling broken
421421
await getStatus(token)
422422
.expect('status', 200)
423423
.expect('json', {
@@ -433,14 +433,14 @@ describe('/rest/2fa/disable', () => {
433433
await register({ email, password, totpSecret })
434434
const { token } = await login({ email, password, totpSecret })
435435

436-
// @ts-expect-error promise return handling broken
436+
// @ts-expect-error FIXME promise return handling broken
437437
await getStatus(token)
438438
.expect('status', 200)
439439
.expect('json', {
440440
setup: true
441441
})
442442

443-
// @ts-expect-error promise return handling broken
443+
// @ts-expect-error FIXME promise return handling broken
444444
await frisby.post(
445445
REST_URL + '/2fa/disable',
446446
{
@@ -454,7 +454,7 @@ describe('/rest/2fa/disable', () => {
454454
}
455455
).expect('status', 401)
456456

457-
// @ts-expect-error promise return handling broken
457+
// @ts-expect-error FIXME promise return handling broken
458458
await getStatus(token)
459459
.expect('status', 200)
460460
.expect('json', {

test/api/chatBotSpec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const API_URL = `${URL}/api/`
1616
let trainingData: { data: any[] }
1717

1818
async function login ({ email, password }: { email: string, password: string }) {
19-
// @ts-expect-error promise return handling broken
19+
// @ts-expect-error FIXME promise return handling broken
2020
const loginRes = await frisby
2121
.post(REST_URL + '/user/login', {
2222
email,

0 commit comments

Comments
 (0)