Skip to content

Commit

Permalink
Fix misused promises in TypeScript (#1435)
Browse files Browse the repository at this point in the history
  • Loading branch information
bartfeenstra committed May 1, 2024
1 parent e91faf4 commit 0a773e3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ class Search {

this.queryElement.addEventListener(
'keyup',
async () => { // eslint-disable-line @typescript-eslint/no-misused-promises
await this.perform(this.queryElement.value)
() => {
void (async () :Promise<void> => {
await this.perform(this.queryElement.value)
})()
}
)

Expand Down Expand Up @@ -178,8 +180,10 @@ class Search {

document.addEventListener(
'DOMContentLoaded',
async () => { // eslint-disable-line @typescript-eslint/no-misused-promises
const search = new Search()
await search.initialize()
() => {
void (async () :Promise<void> => {
const search = new Search()
await search.initialize()
})()
}
)
20 changes: 11 additions & 9 deletions playwright/tests/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,17 @@ class Server implements Disposable {
this.wwwDirectoryPath = wwwDirectoryPath

this.httpServer = createServer(
async (request: IncomingMessage, response: ServerResponse) => { // eslint-disable-line @typescript-eslint/no-misused-promises
const responseMeta = await this.prepareFile(request.url)
response.writeHead(
responseMeta.code,
{
'Content-Type': responseMeta.contentType
}
)
responseMeta.content.pipe(response)
(request: IncomingMessage, response: ServerResponse) => {
void (async () :Promise<void> => {
const responseMeta = await this.prepareFile(request.url)
response.writeHead(
responseMeta.code,
{
'Content-Type': responseMeta.contentType
}
)
responseMeta.content.pipe(response)
})()
}
)
this.httpServer.on('error', (error) => {
Expand Down

0 comments on commit 0a773e3

Please sign in to comment.