-
Notifications
You must be signed in to change notification settings - Fork 234
Remove superfluous promises #1892
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: quasar-upgrade
Are you sure you want to change the base?
Remove superfluous promises #1892
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added a couple of comments but it has a bunch of IDE errors so I'll stop reviewing for now.
This is what it looks like in WebStorm (partly due to .catch(return false)
):


You'd need to change the type definitions in NodeFsProvider however I don't entirely agree with the type definition changes.
The reason we say we're returning Promise<X>
on all of these is because that's quite literally the return type. An async
method will always return a Promise regardless and it's somewhat misleading IMO to say that our method isn't returning the same as what it actually is. This is a snippet from MDN to make it a bit clearer:

Basically async x(...): string
is always converted implicitly to async x(...): Promise<string>
and so we might as well make it clear. Specifying that return type doesn't cause the method to return Promise<Promise<string>>
src/providers/generic/file/NodeFs.ts
Outdated
async exists(path: string): boolean { | ||
await NodeFs.lock.acquire(path, async () => { | ||
const result = await fs.promises.access(path, fs.constants.F_OK).catch(return false); | ||
return true; | ||
}).catch(return false); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- You can't have
return false
as a value inside a catch block. A method invocation is required. This would mean it becomes:.catch(() => false)
in both cases - Is the second catch block necessary? Why can we not just:
async exists(path: string): boolean { | |
await NodeFs.lock.acquire(path, async () => { | |
const result = await fs.promises.access(path, fs.constants.F_OK).catch(return false); | |
return true; | |
}).catch(return false); | |
} | |
await NodeFs.lock.acquire(path, async () => { | |
return await fs.promises.access(path, fs.constants.F_OK).catch(() => false); | |
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hadn't seen these comments. I'll fix them when I've got a minute.
Although, maybe in the long run it'd be better to rethrow/convert to your custom error class?
src/providers/generic/file/NodeFs.ts
Outdated
} | ||
async mkdirs(path: string): void { | ||
await NodeFs.lock.acquire(path, async () => { | ||
await fs.promises.mkdir(path, { recursive: true }).catch (e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.catch( ... throw)
does the exact same thing as not having a catch block in the first place. You don't need the catch block.
56c13d3
to
558a346
Compare
- Also updated tsconfig.json to allowSyntheticDefaultImports
- Removed some broken package usages.
32873cc
to
5f770df
Compare
5f770df
to
73be6ae
Compare
Quasar Upgrade: Tests
Signed-off-by: Gregorio Litenstein <g.litenstein@gmail.com>
Signed-off-by: Gregorio Litenstein <g.litenstein@gmail.com>
On macOS, running via `npm run` makes `moveToNextScreen` go down the linux instead of the darwin branch, which eventually leads to `getLaunchArgs is not a function` error. Signed-off-by: Gregorio Litenstein <g.litenstein@gmail.com>
Signed-off-by: Gregorio Litenstein <g.litenstein@gmail.com>
fd05d48
to
5cf8d7f
Compare
Weird, I was sure I had fixed them before. Signed-off-by: Gregorio Litenstein <g.litenstein@gmail.com>
0fd6bcf
to
48fb868
Compare
777cfe4
to
dad6801
Compare
Removed most if not all unnecessary promises from the FS api. Note, this was tested by running the app on a new profile but my setup isn't giving me any real errors for some reason, so check and/or correct accordingly.