Skip to content

Commit 07d37f0

Browse files
committed
feedbacks.
1 parent 11bbdb5 commit 07d37f0

File tree

5 files changed

+22
-19
lines changed

5 files changed

+22
-19
lines changed

packages/driver/src/cy/commands/connectors.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import $dom from '../../dom'
55
import $utils from '../../cypress/utils'
66
import $errUtils, { CypressError } from '../../cypress/error_utils'
77

8-
const returnFalseIfThenable = (key, ...args) => {
8+
const returnFalseIfThenable = (key, ...args): boolean => {
99
if ((key === 'then') && _.isFunction(args[0]) && _.isFunction(args[1])) {
1010
// https://github.com/cypress-io/cypress/issues/111
1111
// if we're inside of a promise then the promise lib will naturally

packages/driver/src/cy/commands/navigation.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ import debugFn from 'debug'
1313
const debug = debugFn('cypress:driver:navigation')
1414

1515
let id = null
16-
let previousDomainVisited: boolean | null = null
17-
let hasVisitedAboutBlank: boolean | null = null
18-
let currentlyVisitingAboutBlank: boolean | null = null
19-
let knownCommandCausedInstability: boolean | null = null
16+
let previousDomainVisited: boolean = false
17+
let hasVisitedAboutBlank: boolean = false
18+
let currentlyVisitingAboutBlank: boolean = false
19+
let knownCommandCausedInstability: boolean = false
2020

2121
const REQUEST_URL_OPTS = 'auth failOnStatusCode retryOnNetworkFailure retryOnStatusCodeFailure retryIntervals method body headers'
2222
.split(' ')
@@ -675,12 +675,10 @@ export default (Commands, Cypress, cy, state, config) => {
675675
case 'forward': return goNumber(1)
676676
case 'back': return goNumber(-1)
677677
default:
678-
$errUtils.throwErrByPath('go.invalid_direction', {
678+
return $errUtils.throwErrByPath('go.invalid_direction', {
679679
onFail: options._log,
680680
args: { str },
681681
})
682-
683-
return // Error is thrown above, it exists to satisfy typescript
684682
}
685683
}
686684

@@ -692,9 +690,7 @@ export default (Commands, Cypress, cy, state, config) => {
692690
return goString(numberOrString)
693691
}
694692

695-
$errUtils.throwErrByPath('go.invalid_argument', { onFail: options._log })
696-
697-
return // Error is thrown above, it exists to satisfy typescript
693+
return $errUtils.throwErrByPath('go.invalid_argument', { onFail: options._log })
698694
},
699695

700696
// TODO: Change the type of `any` to `Partial<Cypress.VisitOptions>`.

packages/driver/src/cypress/browser.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,15 @@ const _isBrowser = (browser, matcher, errPrefix) => {
3636
}
3737

3838
// TODO: change the type of `any` to `IsBrowserMatcher`
39-
const isBrowser = (config, obj: any = '', errPrefix = '`Cypress.isBrowser()`') => {
39+
const isBrowser = (config, obj: any = '', errPrefix: string = '`Cypress.isBrowser()`') => {
4040
return _
4141
.chain(obj)
4242
.concat([])
4343
.map((matcher) => _isBrowser(config.browser, matcher, errPrefix))
44-
.reduce((a: null | { isMatch: boolean, exclusive: boolean }, b) => {
44+
.reduce((
45+
a: null | { isMatch: boolean, exclusive: boolean },
46+
b: { isMatch: boolean, exclusive: boolean },
47+
) => {
4548
if (!a) return b
4649

4750
if (a.exclusive && b.exclusive) {

packages/driver/src/cypress/cookies.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const defaults: any = {
1414

1515
const warnOnWhitelistRenamed = (obj, type) => {
1616
if (obj.whitelist) {
17-
return $errUtils.throwErrByPath('cookies.whitelist_renamed', { args: { type } })
17+
$errUtils.throwErrByPath('cookies.whitelist_renamed', { args: { type } })
1818
}
1919
}
2020

packages/driver/src/cypress/error_utils.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ const isChaiValidationErr = (err: Error) => {
6969
return _.startsWith(err.message, 'Invalid Chai property')
7070
}
7171

72-
const isCypressErr = (err: Error) => {
72+
const isCypressErr = (err: Error): boolean => {
7373
return err.name === 'CypressError'
7474
}
7575

@@ -195,7 +195,7 @@ const makeErrFromObj = (obj) => {
195195
return err2
196196
}
197197

198-
const throwErr = (err, options: any = {}) => {
198+
const makeErrFromErr = (err, options: any = {}) => {
199199
if (_.isString(err)) {
200200
err = cypressErr({ message: err })
201201
}
@@ -222,10 +222,14 @@ const throwErr = (err, options: any = {}) => {
222222
_.extend(err, errProps)
223223
}
224224

225-
throw err
225+
return err
226+
}
227+
228+
const throwErr = (err, options: any = {}): never => {
229+
throw makeErrFromErr(err, options)
226230
}
227231

228-
const throwErrByPath = (errPath, options: any = {}) => {
232+
const throwErrByPath = (errPath, options: any = {}): never => {
229233
const err = errByPath(errPath, options.args)
230234

231235
if (options.stack) {
@@ -235,7 +239,7 @@ const throwErrByPath = (errPath, options: any = {}) => {
235239
Error.captureStackTrace(err, throwErrByPath)
236240
}
237241

238-
throwErr(err, options)
242+
throw makeErrFromErr(err, options)
239243
}
240244

241245
const warnByPath = (errPath, options: any = {}) => {

0 commit comments

Comments
 (0)