Merge pull request #9020 from overleaf/bg-decaff-guard

decaff cleanup of __guard__ calls

GitOrigin-RevId: 0d61e4d44a2fda19285674040ba92e500deae78d
This commit is contained in:
Brian Gough
2022-07-29 08:03:23 +00:00
committed by Copybot
parent ac9cd2c96b
commit 8960e56e20
10 changed files with 13 additions and 133 deletions
@@ -9,7 +9,6 @@
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* DS103: Rewrite code to no longer use __guard__
* DS207: Consider shorter variations of null checks
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
@@ -133,10 +132,7 @@ module.exports = ExportsHandler = {
project: {
id: project_id,
rootDocPath: rootDoc[1] != null ? rootDoc[1].fileSystem : undefined,
historyId: __guard__(
project.overleaf != null ? project.overleaf.history : undefined,
x => x.id
),
historyId: project.overleaf?.history?.id,
historyVersion,
v1ProjectId:
project.overleaf != null ? project.overleaf.id : undefined,
@@ -287,9 +283,3 @@ module.exports = ExportsHandler = {
)
},
}
function __guard__(value, transform) {
return typeof value !== 'undefined' && value !== null
? transform(value)
: undefined
}
@@ -9,7 +9,6 @@
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* DS103: Rewrite code to no longer use __guard__
* DS207: Consider shorter variations of null checks
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
@@ -56,16 +55,7 @@ const ProjectHistoryHandler = {
if (err != null) {
return callback(err)
} // n.b. getDetails returns an error if the project doesn't exist
return callback(
null,
__guard__(
__guard__(
project != null ? project.overleaf : undefined,
x1 => x1.history
),
x => x.id
)
)
return callback(null, project?.overleaf?.history?.id)
}
)
},
@@ -195,11 +185,5 @@ const ProjectHistoryHandler = {
},
}
function __guard__(value, transform) {
return typeof value !== 'undefined' && value !== null
? transform(value)
: undefined
}
ProjectHistoryHandler.promises = promisifyAll(ProjectHistoryHandler)
module.exports = ProjectHistoryHandler
+1 -11
View File
@@ -8,7 +8,6 @@
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* DS103: Rewrite code to no longer use __guard__
* DS207: Consider shorter variations of null checks
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
@@ -41,10 +40,7 @@ module.exports = V1Handler = {
{
email,
isValid,
v1UserId: __guard__(
body != null ? body.user_profile : undefined,
x => x.id
),
v1UserId: body?.user_profile?.id,
},
'[V1Handler] got response from v1 login api'
)
@@ -93,9 +89,3 @@ module.exports = V1Handler = {
)
},
}
function __guard__(value, transform) {
return typeof value !== 'undefined' && value !== null
? transform(value)
: undefined
}