Skip to content

Commit

Permalink
Fix types.
Browse files Browse the repository at this point in the history
  • Loading branch information
sainthkh committed Nov 8, 2021
1 parent 7c5a5f8 commit 07b7cb3
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 11 deletions.
4 changes: 4 additions & 0 deletions packages/driver/src/cy/assertions.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @ts-nocheck

import _ from 'lodash'
import Promise from 'bluebird'

Expand Down Expand Up @@ -48,6 +50,8 @@ const isDomSubjectAndMatchesValue = (value, subject) => {
// and that all the els are the same
return isDomTypeFn(subject) && allElsAreTheSame()
}

return false
}

// Rules:
Expand Down
6 changes: 4 additions & 2 deletions packages/driver/src/cy/commands/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,16 +246,18 @@ export default (Commands, Cypress, cy, state) => {
if (_.isString(presetOrWidth) && _.isBlank(presetOrWidth)) {
$errUtils.throwErrByPath('viewport.empty_string', { onFail: options._log })
} else if (_.isString(presetOrWidth)) {
const getPresetDimensions = (preset) => {
const getPresetDimensions = (preset): number[] => {
try {
return _.map(viewports[presetOrWidth].split('x'), Number)
} catch (e) {
const presets = _.keys(viewports).join(', ')

return $errUtils.throwErrByPath('viewport.missing_preset', {
$errUtils.throwErrByPath('viewport.missing_preset', {
onFail: options._log,
args: { preset, presets },
})

return [] // dummy code to silence TS
}
}

Expand Down
8 changes: 4 additions & 4 deletions packages/driver/src/cy/net-stubbing/add-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ export function addCommand (Commands, Cypress: Cypress.Cypress, cy: Cypress.cy,
staticResponse = handler as StaticResponse
} else if (!_.isUndefined(handler)) {
// a handler was passed but we dunno what it's supposed to be
return $errUtils.throwErrByPath('net_stubbing.intercept.invalid_handler', { args: { handler } })
$errUtils.throwErrByPath('net_stubbing.intercept.invalid_handler', { args: { handler } })
}

const routeMatcher = annotateMatcherOptionsTypes(matcher)
Expand All @@ -211,7 +211,7 @@ export function addCommand (Commands, Cypress: Cypress.Cypress, cy: Cypress.cy,
}

if (routeMatcher.middleware && !hasInterceptor) {
return $errUtils.throwErrByPath('net_stubbing.intercept.invalid_middleware_handler', { args: { handler } })
$errUtils.throwErrByPath('net_stubbing.intercept.invalid_middleware_handler', { args: { handler } })
}

const frame: NetEvent.ToServer.AddRoute<BackendStaticResponseWithArrayBuffer> = {
Expand Down Expand Up @@ -257,11 +257,11 @@ export function addCommand (Commands, Cypress: Cypress.Cypress, cy: Cypress.cy,
// url, mergeRouteMatcher, handler
// @ts-ignore
if (handler.url) {
return $errUtils.throwErrByPath('net_stubbing.intercept.no_duplicate_url')
$errUtils.throwErrByPath('net_stubbing.intercept.no_duplicate_url')
}

if (!arg2) {
return $errUtils.throwErrByPath('net_stubbing.intercept.handler_required')
$errUtils.throwErrByPath('net_stubbing.intercept.handler_required')
}

checkExtraArguments(['url', 'mergeRouteMatcher', 'handler'])
Expand Down
4 changes: 2 additions & 2 deletions packages/driver/src/cy/net-stubbing/events/before-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ export const onBeforeRequest: HandlerFn<CyHttpMessages.IncomingRequest> = (Cypre
},
on (eventName, handler) {
if (!validEvents.includes(eventName)) {
return $errUtils.throwErrByPath('net_stubbing.request_handling.unknown_event', {
$errUtils.throwErrByPath('net_stubbing.request_handling.unknown_event', {
args: {
validEvents,
eventName,
Expand All @@ -176,7 +176,7 @@ export const onBeforeRequest: HandlerFn<CyHttpMessages.IncomingRequest> = (Cypre
}

if (!_.isFunction(handler)) {
return $errUtils.throwErrByPath('net_stubbing.request_handling.event_needs_handler')
$errUtils.throwErrByPath('net_stubbing.request_handling.event_needs_handler')
}

subscribe(eventName, handler)
Expand Down
2 changes: 2 additions & 0 deletions packages/driver/src/cy/video-recorder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export const initVideoRecorder = (Cypress) => {
mimeType: 'video/webm',
}

// TODO: update TypeScript to 4.4+.
// @ts-ignore
const mediaRecorder = new window.MediaRecorder(stream, options)

mediaRecorder.start(200)
Expand Down
5 changes: 2 additions & 3 deletions packages/driver/src/cypress/cy.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @ts-nocheck

/* eslint-disable prefer-rest-params */
import _ from 'lodash'
import Promise from 'bluebird'
Expand Down Expand Up @@ -195,9 +197,6 @@ class $Cy implements ITimeouts, IStability, IAssertions, IRetries, IJQuery, ILoc
interceptFocus: ReturnType<typeof createFocused>['interceptFocus']
interceptBlur: ReturnType<typeof createFocused>['interceptBlur']

// temporary -> should be removed
focused: any

constructor (specWindow, Cypress, Cookies, state, config) {
this.id = _.uniqueId('cy')
this.state = state
Expand Down

0 comments on commit 07b7cb3

Please sign in to comment.