Skip to content
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

misc: ensure 'its' function type excludes null and undefined (#28872) #28904

Merged
merged 12 commits into from
Apr 23, 2024
3 changes: 2 additions & 1 deletion cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ _Released 2/27/2024 (PENDING)_

**Bugfixes:**

- Changed RequestBody type to allow for boolean and null literals to be passed as body values. [#28789](https://github.com/cypress-io/cypress/issues/28789)
- Changed RequestBody type to allow for boolean and null literals to be passed as body values. Fixes [#28789](https://github.com/cypress-io/cypress/issues/28789).
- `.its()` type now excludes null and undefined. Fixes [#28872](https://github.com/cypress-io/cypress/issues/28872).

## 13.6.6

Expand Down
49 changes: 24 additions & 25 deletions cli/types/cypress.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -592,14 +592,13 @@ declare namespace Cypress {
/**
* Add a custom parent command
* @see https://on.cypress.io/api/commands#Parent-Commands
*/
add<T extends keyof Chainable>(name: T, options: CommandOptions & {prevSubject: false}, fn: CommandFn<T>): void
*/add<T extends keyof Chainable>(name: T, options: CommandOptions & { prevSubject: false }, fn: CommandFn<T>): void
AkshatHotCode marked this conversation as resolved.
Show resolved Hide resolved

/**
* Add a custom child command
* @see https://on.cypress.io/api/commands#Child-Commands
*/
add<T extends keyof Chainable, S = any>(name: T, options: CommandOptions & {prevSubject: true}, fn: CommandFnWithSubject<T, S>): void
add<T extends keyof Chainable, S = any>(name: T, options: CommandOptions & { prevSubject: true }, fn: CommandFnWithSubject<T, S>): void

/**
* Add a custom child or dual command
Expand Down Expand Up @@ -627,7 +626,7 @@ declare namespace Cypress {
* Add one or more custom parent commands
* @see https://on.cypress.io/api/commands#Parent-Commands
*/
addAll<T extends keyof Chainable>(options: CommandOptions & {prevSubject: false}, fns: CommandFns): void
addAll<T extends keyof Chainable>(options: CommandOptions & { prevSubject: false }, fns: CommandFns): void

/**
* Add one or more custom child commands
Expand Down Expand Up @@ -822,7 +821,7 @@ declare namespace Cypress {
* Trigger action
* @private
*/
action: <T = (any[] | void)>(action: string, ...args: any[]) => T
action: <T = (any[] | void) >(action: string, ...args: any[]) => T

/**
* Load files
Expand All @@ -834,8 +833,8 @@ declare namespace Cypress {
type CanReturnChainable = void | Chainable | Promise<unknown>
type ThenReturn<S, R> =
R extends void ? Chainable<S> :
R extends R | undefined ? Chainable<S | Exclude<R, undefined>> :
Chainable<S>
R extends R | undefined ? Chainable<S | Exclude<R, undefined>> :
Chainable<S>

/**
* Chainable interface for non-array Subjects
Expand Down Expand Up @@ -950,7 +949,7 @@ declare namespace Cypress {
*
* @see https://on.cypress.io/clearallcookies
*/
clearAllCookies(options?: Partial<Loggable & Timeoutable>): Chainable<null>
clearAllCookies(options?: Partial<Loggable & Timeoutable>): Chainable<null>

/**
* Get local storage for all origins.
Expand Down Expand Up @@ -983,7 +982,7 @@ declare namespace Cypress {
*
* @see https://on.cypress.io/clearallsessionstorage
*/
clearAllSessionStorage(options?: Partial<Loggable>): Chainable<null>
clearAllSessionStorage(options?: Partial<Loggable>): Chainable<null>

/**
* Clear data in local storage for the current origin.
Expand Down Expand Up @@ -1518,7 +1517,7 @@ declare namespace Cypress {
* // Drill into nested properties by using dot notation
* cy.wrap({foo: {bar: {baz: 1}}}).its('foo.bar.baz')
*/
its<K extends keyof Subject>(propertyName: K, options?: Partial<Loggable & Timeoutable>): Chainable<Subject[K]>
its<K extends keyof Subject>(propertyName: K, options?: Partial<Loggable & Timeoutable>): Chainable<NonNullable<Subject[K]>>
its(propertyPath: string, options?: Partial<Loggable & Timeoutable>): Chainable

/**
Expand Down Expand Up @@ -2542,8 +2541,8 @@ declare namespace Cypress {

type ChainableMethods<Subject = any> = {
[P in keyof Chainable<Subject>]: Chainable<Subject>[P] extends ((...args: any[]) => any)
? Chainable<Subject>[P]
: never
? Chainable<Subject>[P]
: never
}

interface SinonSpyAgent<A extends sinon.SinonSpy> {
Expand Down Expand Up @@ -3244,7 +3243,7 @@ declare namespace Cypress {
/**
* Hosts mappings to IP addresses.
*/
hosts: null | {[key: string]: string}
hosts: null | { [key: string]: string }
/**
* Whether Cypress was launched via 'cypress open' (interactive mode)
*/
Expand Down Expand Up @@ -3519,7 +3518,7 @@ declare namespace Cypress {
type DevServerFn<ComponentDevServerOpts = any> = (cypressDevServerConfig: DevServerConfig, devServerConfig: ComponentDevServerOpts) => ResolvedDevServerConfig | Promise<ResolvedDevServerConfig>

type ConfigHandler<T> = T
| (() => T | Promise<T>)
| (() => T | Promise<T>)

type DevServerConfigOptions = {
bundler: 'webpack'
Expand Down Expand Up @@ -3561,7 +3560,7 @@ declare namespace Cypress {
/**
* Hosts mappings to IP addresses.
*/
hosts?: null | {[key: string]: string}
hosts?: null | { [key: string]: string }
}

interface PluginConfigOptions extends ResolvedConfigOptions, RuntimeConfigOptions {
Expand Down Expand Up @@ -3759,7 +3758,7 @@ declare namespace Cypress {
validate?: SessionOptions['validate']
}

interface ServerSessionData extends Omit<SessionData, 'setup' |'validate'> {
interface ServerSessionData extends Omit<SessionData, 'setup' | 'validate'> {
setup: string
validate?: string
}
Expand Down Expand Up @@ -6406,15 +6405,15 @@ declare namespace Cypress {
}

type TypedArray =
| Int8Array
| Uint8Array
| Uint8ClampedArray
| Int16Array
| Uint16Array
| Int32Array
| Uint32Array
| Float32Array
| Float64Array
| Int8Array
| Uint8Array
| Uint8ClampedArray
| Int16Array
| Uint16Array
| Int32Array
| Uint32Array
| Float32Array
| Float64Array

type FileReference = string | BufferType | FileReferenceObject | TypedArray
interface FileReferenceObject {
Expand Down
Loading