Я пытаюсь установить Mocha и Jest с типами в одном проекте. Мы используем строгую проверку типов, поэтому я получаю ошибки, связанные с конфликтом типов глобалов.
Я пытался создать неоднозначное объявление модуля, определяя только Mocha в types
в tsconfig
. Я пытался убрать заявление Джеста - но это частично поможет. Отключение строгой проверки типов или проверки lib не допускается.
Я ожидал, что он будет работать правильно, но вместо этого получил следующие ошибки.
node_modules/@types/jest/index.d.ts(29,13): error TS2403: Subsequent variable declarations must have the same type. Variable 'beforeEach' must be of type 'HookFunction', but here has type 'Lifecycle'.
node_modules/@types/jest/index.d.ts(31,13): error TS2403: Subsequent variable declarations must have the same type. Variable 'afterEach' must be of type 'HookFunction', but here has type 'Lifecycle'.
node_modules/@types/jest/index.d.ts(32,13): error TS2403: Subsequent variable declarations must have the same type. Variable 'describe' must be of type 'SuiteFunction', but here has type 'Describe'.
node_modules/@types/jest/index.d.ts(34,13): error TS2403: Subsequent variable declarations must have the same type. Variable 'xdescribe' must be of type 'PendingSuiteFunction', but here has type 'Describe'.
node_modules/@types/jest/index.d.ts(35,13): error TS2403: Subsequent variable declarations must have the same type. Variable 'it' must be of type 'TestFunction', but here has type 'It'.
node_modules/@types/jest/index.d.ts(37,13): error TS2403: Subsequent variable declarations must have the same type. Variable 'xit' must be of type 'PendingTestFunction', but here has type 'It'.
node_modules/@types/jest/index.d.ts(38,13): error TS2403: Subsequent variable declarations must have the same type. Variable 'test' must be of type 'TestFunction', but here has type 'It'.
node_modules/@types/node/globals.d.ts(926,15): error TS2430: Interface 'Global' incorrectly extends interface 'MochaGlobals'.
Types of property 'describe' are incompatible.
Type 'Describe' is not assignable to type 'SuiteFunction'.
Types of property 'only' are incompatible.
Type 'DescribeBase' is not assignable to type 'ExclusiveSuiteFunction'.
Type 'void' is not assignable to type 'Suite'.
Даже удаление всех типов из Jest приводит меня к этой ошибке:
node_modules/@types/node/globals.d.ts(926,15): error TS2430: Interface 'Global' incorrectly extends interface 'MochaGlobals'.
Types of property 'describe' are incompatible.
Type 'Describe' is not assignable to type 'SuiteFunction'.
Types of property 'only' are incompatible.
Type 'DescribeBase' is not assignable to type 'ExclusiveSuiteFunction'.
Type 'void' is not assignable to type 'Suite'.