Skip to content

Commit a43c2b2

Browse files
authored
chore(monorepo): Check typescript in test files too (#3273)
1 parent 1d2496d commit a43c2b2

File tree

35 files changed

+79
-78
lines changed

35 files changed

+79
-78
lines changed

packages/compass-aggregations/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"webpack": "webpack-compass",
2121
"start": "npm run webpack serve -- --mode development",
2222
"analyze": "npm run webpack -- --mode production --analyze",
23-
"typecheck": "tsc --noEmit",
23+
"typecheck": "tsc -p tsconfig-lint.json --noEmit",
2424
"depcheck": "compass-scripts check-peer-deps && depcheck",
2525
"eslint": "eslint",
2626
"lint": "npm run eslint .",

packages/compass-aggregations/src/components/pipeline-explain/index.spec.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ const renderPipelineExplain = (
1616
isModalOpen={true}
1717
onCancelExplain={() => {}}
1818
onCloseModal={() => {}}
19-
onRunExplain={() => {}}
2019
{...props}
2120
/>
2221
);
@@ -33,7 +32,7 @@ describe('PipelineExplain', function () {
3332
expect(within(modal).getByTestId('pipeline-explain-cancel')).to.exist;
3433
expect(onCancelExplainSpy.callCount).to.equal(0);
3534

36-
userEvent.click(within(modal).getByText(/cancel/gi), null, {
35+
userEvent.click(within(modal).getByText(/cancel/gi), undefined, {
3736
skipPointerEventsCheck: true,
3837
});
3938
expect(onCancelExplainSpy.callCount).to.equal(1);

packages/compass-aggregations/src/components/pipeline-toolbar/index.spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ describe('PipelineToolbar', function () {
7878
expect(
7979
within(settings)
8080
.getByTestId('pipeline-name')
81-
.textContent.trim()
81+
?.textContent?.trim()
8282
.toLowerCase(),
8383
'shows untitled as default name'
8484
).to.equal('untitled');

packages/compass-aggregations/src/components/pipeline-toolbar/pipeline-header/pipeline-actions.spec.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ describe('PipelineActions', function () {
6868
it('calls onToggleOptions on click', function () {
6969
const button = screen.getByTestId('pipeline-toolbar-options-button');
7070
expect(button).to.exist;
71-
expect(button.textContent.toLowerCase().trim()).to.equal('less options');
71+
expect(button?.textContent?.toLowerCase().trim()).to.equal('less options');
7272
expect(within(button).getByLabelText('Caret Down Icon')).to.exist;
7373

7474
userEvent.click(button);
@@ -101,7 +101,7 @@ describe('PipelineActions', function () {
101101
it('toggle options action button', function () {
102102
const button = screen.getByTestId('pipeline-toolbar-options-button');
103103
expect(button).to.exist;
104-
expect(button.textContent.toLowerCase().trim()).to.equal('more options');
104+
expect(button?.textContent?.toLowerCase().trim()).to.equal('more options');
105105
expect(within(button).getByLabelText('Caret Right Icon')).to.exist;
106106

107107
userEvent.click(button);

packages/compass-aggregations/src/components/pipeline-toolbar/pipeline-settings/pipeline-name.spec.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { PipelineName } from './pipeline-name';
77
describe('PipelineName', function () {
88
it('renders Untitled as default name', function () {
99
render(<PipelineName name={''} isModified={false} />);
10-
expect(screen.getByTestId('pipeline-name').textContent.trim()).to.equal(
10+
expect(screen.getByTestId('pipeline-name')?.textContent?.trim()).to.equal(
1111
'Untitled'
1212
);
1313
});
@@ -17,14 +17,14 @@ describe('PipelineName', function () {
1717
expect(
1818
screen
1919
.getByTestId('pipeline-name')
20-
.textContent.trim()
20+
?.textContent?.trim()
2121
.replace(/\u00a0/g, ' ')
2222
).to.equal('Untitled – modified');
2323
});
2424

2525
it('renders pipeline name', function () {
2626
render(<PipelineName name={'Hello'} isModified={false} />);
27-
expect(screen.getByTestId('pipeline-name').textContent.trim()).to.equal(
27+
expect(screen.getByTestId('pipeline-name')?.textContent?.trim()).to.equal(
2828
'Hello'
2929
);
3030
});
@@ -34,7 +34,7 @@ describe('PipelineName', function () {
3434
expect(
3535
screen
3636
.getByTestId('pipeline-name')
37-
.textContent.trim()
37+
?.textContent?.trim()
3838
.replace(/\u00a0/g, ' ')
3939
).to.equal('Name changed – modified');
4040
});

packages/compass-aggregations/src/modules/auto-preview.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ describe('auto preview module', function () {
3030
close: spy(),
3131
};
3232
const dataServiceMock = new class {
33-
aggregate(...args) {
33+
aggregate(...args: any[]) {
3434
const callback = args[args.length - 1];
3535
callback(null, cursorMock);
3636
}

packages/compass-aggregations/src/modules/explain.spec.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import reducer, {
1313
} from './explain';
1414
import configureStore from '../stores/store';
1515
import { DATA_SERVICE_CONNECTED } from './data-service';
16+
import type { IndexInfo } from './indexes';
1617

1718
describe('explain module', function () {
1819
describe('#reducer', function () {
@@ -130,9 +131,9 @@ describe('explain module', function () {
130131
});
131132

132133
it('maps indexes correctly', function () {
133-
const collectionIndexes = [
134-
{ ns: 'test.users', name: '_id_', key: { _id: 1 } },
135-
{ ns: 'test.users', name: '_location_', key: { _address: '2dsphere' } }
134+
const collectionIndexes: IndexInfo[] = [
135+
{ ns: 'test.users', name: '_id_', key: { _id: 1 }, extra: {} },
136+
{ ns: 'test.users', name: '_location_', key: { _address: '2dsphere' }, extra: {} }
136137
];
137138
const explainIndexes = [
138139
{ index: '_id_', shard: 'shard01' },

packages/compass-aggregations/src/modules/explain.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Reducer } from 'redux';
1+
import type { AnyAction, Reducer } from 'redux';
22
import type { AggregateOptions, Document } from 'mongodb';
33
import type { ExplainExecuteOptions } from 'mongodb-data-service';
44
import type { ThunkAction } from 'redux-thunk';
@@ -74,7 +74,7 @@ export const INITIAL_STATE: State = {
7474
isModalOpen: false,
7575
};
7676

77-
const reducer: Reducer<State, Actions> = (state = INITIAL_STATE, action) => {
77+
const reducer: Reducer<State, AnyAction> = (state = INITIAL_STATE, action) => {
7878
switch (action.type) {
7979
case ActionTypes.ExplainStarted:
8080
return {

packages/compass-aggregations/src/modules/index.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { combineReducers } from 'redux';
2-
import type { AnyAction } from 'redux';
2+
import type { AnyAction , Reducer } from 'redux';
33
import type { ThunkAction } from 'redux-thunk';
44
import { ObjectId } from 'bson';
55
import isEmpty from 'lodash.isempty';
@@ -577,14 +577,14 @@ const MAPPINGS = {
577577
/**
578578
* The root reducer.
579579
*
580-
* @param {Object} state - The state.
581-
* @param {Object} action - The action.
580+
* @param state - The state.
581+
* @param action - The action.
582582
*
583-
* @returns {Object} The new state.
583+
* @returns The new state.
584584
*/
585-
const rootReducer = (state: RootState, action: AnyAction): RootState => {
585+
const rootReducer: Reducer<RootState, AnyAction> = (state, action): RootState => {
586586
const fn = MAPPINGS[action.type];
587-
return fn ? fn(state, action) : appReducer(state, action);
587+
return (state && fn) ? fn(state, action) : appReducer(state, action);
588588
};
589589

590590
export default rootReducer;

packages/compass-collection/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"test-watch": "npm run test -- --watch",
5353
"test-ci": "npm run test-cov",
5454
"test-ci-electron": "npm run test-electron",
55-
"typecheck": "tsc --noEmit",
55+
"typecheck": "tsc -p tsconfig-lint.json --noEmit",
5656
"reformat": "npm run prettier -- --write ."
5757
},
5858
"peerDependencies": {

0 commit comments

Comments
 (0)