Skip to content
This repository has been archived by the owner on Apr 19, 2023. It is now read-only.

TS2403: Subsequent variable declarations must have the same type #1

Closed
Svish opened this issue Jan 30, 2020 · 0 comments
Closed

TS2403: Subsequent variable declarations must have the same type #1

Svish opened this issue Jan 30, 2020 · 0 comments
Labels
bug Something isn't working help wanted Extra attention is needed wontfix This will not be worked on

Comments

@Svish
Copy link
Owner

Svish commented Jan 30, 2020

When importing useCypressTag or cypressTag into non-cypress files, I get a bunch of TS2403 errors from jest. No clue why, or how to fix it yet... please let me know if you do... 😕

The Cypress side of things work great, and everything works fine within this project. So it's only when I try to use the useCypressTag helper function in the application code of a different Typescript project (in a React component of a create-react-app project) 🤷‍♂️

Workaround

Either just don't use the useCypressTag helper, write your own, or simply copy the following helper function into your own project and import it from there instead of from cypress-helper-getcy.

// E.g. in src/util/useCypressTag.ts

export interface DataCyProp {
  'data-cy'?: string;
}

const combineParts = (...part: (string | undefined)[]): string =>
  part.filter(p => typeof p === 'string').join('/');

export default function useCypressTag(
  ...namespace: string[]
): (name?: string) => DataCyProp {
  if ('Cypress' in window)
    return name => ({
      'data-cy': combineParts(...namespace, name),
    });
  else return () => ({});
}
@Svish Svish added bug Something isn't working help wanted Extra attention is needed labels Jan 30, 2020
@Svish Svish closed this as completed Apr 19, 2023
@Svish Svish added the wontfix This will not be worked on label Apr 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working help wanted Extra attention is needed wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

1 participant