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

Prevent duplicate variable declaration error. #68

Merged
merged 1 commit into from
Jan 25, 2023

Conversation

ray-lee
Copy link
Contributor

@ray-lee ray-lee commented Jan 24, 2023

Description

This fixes a TypeScript compilation error that occurs because we now have both Mocha and Jest in the project. Both projects declare certain global variables with the same names, such as describe, it, and test, but different types. The fix configures TypeScript not to check every type definition file in node_modules/@types. Instead, it only checks the types that are imported by our source files. See https://www.typescriptlang.org/tsconfig#skipLibCheck.

Motivation and Context

Since we added Jest tests, the npm run build-docs script produces errors like:

node_modules/@types/mocha/index.d.ts:2733:13 - error TS2403: Subsequent variable declarations must have the same type.  Variable 'test' must be of type 'It', but here has type 'TestFunction'.

2733 declare var test: Mocha.TestFunction;
                 ~~~~

  node_modules/@types/jest/index.d.ts:43:13
    43 declare var test: jest.It;
                   ~~~~
    'test' was also declared here.

How Has This Been Tested?

The npm run build-docs should run without error. All other npm scripts should also contuinue to run without error.

Checklist:

  • I have updated the documentation accordingly.
  • All new and existing tests passed.

@ray-lee ray-lee marked this pull request as ready for review January 24, 2023 23:14
@ray-lee ray-lee requested a review from tdilauro January 24, 2023 23:14
Copy link
Contributor

@tdilauro tdilauro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested. Looks good! 🥇

@ray-lee ray-lee merged commit 451935f into main Jan 25, 2023
@ray-lee ray-lee deleted the bugfix/ts-dupe-var-decl branch January 25, 2023 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants