Skip to content

Commit

Permalink
chore: add noImplicitOverride check (#12648)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrazauskas authored Apr 8, 2022
1 parent 420ba45 commit 40ac384
Show file tree
Hide file tree
Showing 25 changed files with 104 additions and 100 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
run: yarn build
- name: test typings
run: yarn test-types
- name: verify TypeScript@4.2 compatibility
- name: verify TypeScript@4.3 compatibility
run: yarn verify-old-ts

lint:
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
### Chore & Maintenance

- `[*]` [**BREAKING**] Drop support for Node v10 and v15 and target first LTS `16.13.0` ([#12220](https://github.com/facebook/jest/pull/12220))
- `[*]` [**BREAKING**] Drop support for `typescript@3.8`, minimum version is now `4.2` ([#11142](https://github.com/facebook/jest/pull/11142))
- `[*]` [**BREAKING**] Drop support for `typescript@3.8`, minimum version is now `4.3` ([#11142](https://github.com/facebook/jest/pull/11142), [#12648](https://github.com/facebook/jest/pull/12648))
- `[*]` Bundle all `.d.ts` files into a single `index.d.ts` per module ([#12345](https://github.com/facebook/jest/pull/12345))
- `[*]` Use `globalThis` instead of `global` ([#12447](https://github.com/facebook/jest/pull/12447))
- `[babel-jest]` [**BREAKING**] Only export `createTransformer` ([#12407](https://github.com/facebook/jest/pull/12407))
Expand Down
16 changes: 8 additions & 8 deletions packages/expect/src/asymmetricMatchers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class Any extends AsymmetricMatcher<any> {
return 'Any';
}

getExpectedType() {
override getExpectedType() {
if (this.sample == String) {
return 'string';
}
Expand All @@ -155,7 +155,7 @@ class Any extends AsymmetricMatcher<any> {
return fnNameFor(this.sample);
}

toAsymmetricMatcher() {
override toAsymmetricMatcher() {
return `Any<${fnNameFor(this.sample)}>`;
}
}
Expand All @@ -171,7 +171,7 @@ class Anything extends AsymmetricMatcher<void> {

// No getExpectedType method, because it matches either null or undefined.

toAsymmetricMatcher() {
override toAsymmetricMatcher() {
return 'Anything';
}
}
Expand Down Expand Up @@ -203,7 +203,7 @@ class ArrayContaining extends AsymmetricMatcher<Array<unknown>> {
return `Array${this.inverse ? 'Not' : ''}Containing`;
}

getExpectedType() {
override getExpectedType() {
return 'array';
}
}
Expand Down Expand Up @@ -240,7 +240,7 @@ class ObjectContaining extends AsymmetricMatcher<Record<string, unknown>> {
return `Object${this.inverse ? 'Not' : ''}Containing`;
}

getExpectedType() {
override getExpectedType() {
return 'object';
}
}
Expand All @@ -263,7 +263,7 @@ class StringContaining extends AsymmetricMatcher<string> {
return `String${this.inverse ? 'Not' : ''}Containing`;
}

getExpectedType() {
override getExpectedType() {
return 'string';
}
}
Expand All @@ -286,7 +286,7 @@ class StringMatching extends AsymmetricMatcher<RegExp> {
return `String${this.inverse ? 'Not' : ''}Matching`;
}

getExpectedType() {
override getExpectedType() {
return 'string';
}
}
Expand Down Expand Up @@ -326,7 +326,7 @@ class CloseTo extends AsymmetricMatcher<number> {
return `Number${this.inverse ? 'Not' : ''}CloseTo`;
}

getExpectedType() {
override getExpectedType() {
return 'number';
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/expect/src/jestMatchersObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ export const setMatchers = (
return `${this.inverse ? 'not.' : ''}${key}`;
}

getExpectedType() {
override getExpectedType() {
return 'any';
}

toAsymmetricMatcher() {
override toAsymmetricMatcher() {
return `${this.toString()}<${this.sample.map(String).join(', ')}>`;
}
}
Expand Down
34 changes: 17 additions & 17 deletions packages/jest-console/src/BufferedConsole.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default class BufferedConsole extends Console {
private _timers: LogTimers = {};
private _groupDepth = 0;

Console: typeof Console = Console;
override Console: typeof Console = Console;

constructor() {
super({
Expand Down Expand Up @@ -71,82 +71,82 @@ export default class BufferedConsole extends Console {
);
}

assert(value: unknown, message?: string | Error): void {
override assert(value: unknown, message?: string | Error): void {
try {
assert(value, message);
} catch (error: any) {
this._log('assert', error.toString());
}
}

count(label: string = 'default'): void {
override count(label: string = 'default'): void {
if (!this._counters[label]) {
this._counters[label] = 0;
}

this._log('count', format(`${label}: ${++this._counters[label]}`));
}

countReset(label: string = 'default'): void {
override countReset(label: string = 'default'): void {
this._counters[label] = 0;
}

debug(firstArg: unknown, ...rest: Array<unknown>): void {
override debug(firstArg: unknown, ...rest: Array<unknown>): void {
this._log('debug', format(firstArg, ...rest));
}

dir(firstArg: unknown, options: InspectOptions = {}): void {
override dir(firstArg: unknown, options: InspectOptions = {}): void {
const representation = inspect(firstArg, options);
this._log('dir', formatWithOptions(options, representation));
}

dirxml(firstArg: unknown, ...rest: Array<unknown>): void {
override dirxml(firstArg: unknown, ...rest: Array<unknown>): void {
this._log('dirxml', format(firstArg, ...rest));
}

error(firstArg: unknown, ...rest: Array<unknown>): void {
override error(firstArg: unknown, ...rest: Array<unknown>): void {
this._log('error', format(firstArg, ...rest));
}

group(title?: string, ...rest: Array<unknown>): void {
override group(title?: string, ...rest: Array<unknown>): void {
this._groupDepth++;

if (title || rest.length > 0) {
this._log('group', chalk.bold(format(title, ...rest)));
}
}

groupCollapsed(title?: string, ...rest: Array<unknown>): void {
override groupCollapsed(title?: string, ...rest: Array<unknown>): void {
this._groupDepth++;

if (title || rest.length > 0) {
this._log('groupCollapsed', chalk.bold(format(title, ...rest)));
}
}

groupEnd(): void {
override groupEnd(): void {
if (this._groupDepth > 0) {
this._groupDepth--;
}
}

info(firstArg: unknown, ...rest: Array<unknown>): void {
override info(firstArg: unknown, ...rest: Array<unknown>): void {
this._log('info', format(firstArg, ...rest));
}

log(firstArg: unknown, ...rest: Array<unknown>): void {
override log(firstArg: unknown, ...rest: Array<unknown>): void {
this._log('log', format(firstArg, ...rest));
}

time(label: string = 'default'): void {
override time(label: string = 'default'): void {
if (this._timers[label]) {
return;
}

this._timers[label] = new Date();
}

timeEnd(label: string = 'default'): void {
override timeEnd(label: string = 'default'): void {
const startTime = this._timers[label];

if (startTime) {
Expand All @@ -157,7 +157,7 @@ export default class BufferedConsole extends Console {
}
}

timeLog(label = 'default', ...data: Array<unknown>): void {
override timeLog(label = 'default', ...data: Array<unknown>): void {
const startTime = this._timers[label];

if (startTime) {
Expand All @@ -167,7 +167,7 @@ export default class BufferedConsole extends Console {
}
}

warn(firstArg: unknown, ...rest: Array<unknown>): void {
override warn(firstArg: unknown, ...rest: Array<unknown>): void {
this._log('warn', format(firstArg, ...rest));
}

Expand Down
34 changes: 17 additions & 17 deletions packages/jest-console/src/CustomConsole.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default class CustomConsole extends Console {
private _timers: LogTimers = {};
private _groupDepth = 0;

Console: typeof Console = Console;
override Console: typeof Console = Console;

constructor(
stdout: NodeJS.WriteStream,
Expand All @@ -49,82 +49,82 @@ export default class CustomConsole extends Console {
);
}

assert(value: unknown, message?: string | Error): asserts value {
override assert(value: unknown, message?: string | Error): asserts value {
try {
assert(value, message);
} catch (error: any) {
this._logError('assert', error.toString());
}
}

count(label: string = 'default'): void {
override count(label: string = 'default'): void {
if (!this._counters[label]) {
this._counters[label] = 0;
}

this._log('count', format(`${label}: ${++this._counters[label]}`));
}

countReset(label: string = 'default'): void {
override countReset(label: string = 'default'): void {
this._counters[label] = 0;
}

debug(firstArg: unknown, ...args: Array<unknown>): void {
override debug(firstArg: unknown, ...args: Array<unknown>): void {
this._log('debug', format(firstArg, ...args));
}

dir(firstArg: unknown, options: InspectOptions = {}): void {
override dir(firstArg: unknown, options: InspectOptions = {}): void {
const representation = inspect(firstArg, options);
this._log('dir', formatWithOptions(options, representation));
}

dirxml(firstArg: unknown, ...args: Array<unknown>): void {
override dirxml(firstArg: unknown, ...args: Array<unknown>): void {
this._log('dirxml', format(firstArg, ...args));
}

error(firstArg: unknown, ...args: Array<unknown>): void {
override error(firstArg: unknown, ...args: Array<unknown>): void {
this._logError('error', format(firstArg, ...args));
}

group(title?: string, ...args: Array<unknown>): void {
override group(title?: string, ...args: Array<unknown>): void {
this._groupDepth++;

if (title || args.length > 0) {
this._log('group', chalk.bold(format(title, ...args)));
}
}

groupCollapsed(title?: string, ...args: Array<unknown>): void {
override groupCollapsed(title?: string, ...args: Array<unknown>): void {
this._groupDepth++;

if (title || args.length > 0) {
this._log('groupCollapsed', chalk.bold(format(title, ...args)));
}
}

groupEnd(): void {
override groupEnd(): void {
if (this._groupDepth > 0) {
this._groupDepth--;
}
}

info(firstArg: unknown, ...args: Array<unknown>): void {
override info(firstArg: unknown, ...args: Array<unknown>): void {
this._log('info', format(firstArg, ...args));
}

log(firstArg: unknown, ...args: Array<unknown>): void {
override log(firstArg: unknown, ...args: Array<unknown>): void {
this._log('log', format(firstArg, ...args));
}

time(label: string = 'default'): void {
override time(label: string = 'default'): void {
if (this._timers[label]) {
return;
}

this._timers[label] = new Date();
}

timeEnd(label: string = 'default'): void {
override timeEnd(label: string = 'default'): void {
const startTime = this._timers[label];

if (startTime) {
Expand All @@ -135,7 +135,7 @@ export default class CustomConsole extends Console {
}
}

timeLog(label = 'default', ...data: Array<unknown>): void {
override timeLog(label = 'default', ...data: Array<unknown>): void {
const startTime = this._timers[label];

if (startTime) {
Expand All @@ -145,7 +145,7 @@ export default class CustomConsole extends Console {
}
}

warn(firstArg: unknown, ...args: Array<unknown>): void {
override warn(firstArg: unknown, ...args: Array<unknown>): void {
this._logError('warn', format(firstArg, ...args));
}

Expand Down
28 changes: 14 additions & 14 deletions packages/jest-console/src/NullConsole.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@
import CustomConsole from './CustomConsole';

export default class NullConsole extends CustomConsole {
assert(): void {}
debug(): void {}
dir(): void {}
error(): void {}
info(): void {}
log(): void {}
time(): void {}
timeEnd(): void {}
timeLog(): void {}
trace(): void {}
warn(): void {}
group(): void {}
groupCollapsed(): void {}
groupEnd(): void {}
override assert(): void {}
override debug(): void {}
override dir(): void {}
override error(): void {}
override info(): void {}
override log(): void {}
override time(): void {}
override timeEnd(): void {}
override timeLog(): void {}
override trace(): void {}
override warn(): void {}
override group(): void {}
override groupCollapsed(): void {}
override groupEnd(): void {}
}
2 changes: 1 addition & 1 deletion packages/jest-core/src/TestNamePatternPrompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default class TestNamePatternPrompt extends PatternPrompt {
super(pipe, prompt, 'tests');
}

protected _onChange(pattern: string, options: ScrollOptions): void {
protected override _onChange(pattern: string, options: ScrollOptions): void {
super._onChange(pattern, options);
this._printPrompt(pattern);
}
Expand Down
Loading

0 comments on commit 40ac384

Please sign in to comment.