Skip to content

Commit d681f33

Browse files
committed
Use default tsconfig for tests
1 parent 67cfc70 commit d681f33

File tree

8 files changed

+40
-27
lines changed

8 files changed

+40
-27
lines changed

__tests__/Conversion.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ describe('Conversion', () => {
113113
});
114114

115115
it('Converts deep JSON with custom conversion', () => {
116-
const seq = fromJS(js, function (key, sequence) {
116+
const seq = fromJS(js, function (this, key, sequence) {
117117
if (key === 'point') {
118118
// @ts-expect-error -- to convert to real typing
119119
return new Point(sequence);
@@ -129,13 +129,17 @@ describe('Conversion', () => {
129129
it('Converts deep JSON with custom conversion including keypath if requested', () => {
130130
const paths: Array<Array<string | number> | undefined> = [];
131131
// eslint-disable-next-line @typescript-eslint/no-unused-vars
132-
const seq1 = fromJS(js, function (key, sequence, keypath) {
133-
expect(arguments.length).toBe(3);
134-
paths.push(keypath);
135-
return Array.isArray(this[key])
136-
? sequence.toList()
137-
: sequence.toOrderedMap();
138-
});
132+
const seq1 = fromJS(
133+
js,
134+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
135+
function (this: typeof js, key: any, sequence, keypath) {
136+
expect(arguments.length).toBe(3);
137+
paths.push(keypath);
138+
return Array.isArray(this[key])
139+
? sequence.toList()
140+
: sequence.toOrderedMap();
141+
}
142+
);
139143
expect(paths).toEqual([
140144
[],
141145
['deepList'],

__tests__/KeyedSeq.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { describe, expect, it } from '@jest/globals';
22
import { Range, Seq } from 'immutable';
33
import fc from 'fast-check';
4+
import invariant from '../src/utils/invariant';
45

56
describe('KeyedSeq', () => {
67
it('iterates equivalently', () => {
@@ -39,6 +40,10 @@ describe('KeyedSeq', () => {
3940
const [indexed0, indexed1] = seq
4041
.partition(isEven)
4142
.map((part) => part.skip(10).take(5));
43+
44+
invariant(indexed0, 'indexed0 is not undefined');
45+
invariant(indexed1, 'indexed0 is not undefined');
46+
4247
expect(indexed0.entrySeq().toArray()).toEqual([
4348
[0, 21],
4449
[1, 23],
@@ -67,6 +72,10 @@ describe('KeyedSeq', () => {
6772
const [keyed0, keyed1] = keyed
6873
.partition(isEven)
6974
.map((part) => part.skip(10).take(5));
75+
76+
invariant(keyed0, 'keyed0 is not undefined');
77+
invariant(keyed1, 'keyed1 is not undefined');
78+
7079
expect(keyed0.entrySeq().toArray()).toEqual([
7180
[21, 21],
7281
[23, 23],

__tests__/Map.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ describe('Map', () => {
471471

472472
it('uses toString on keys and values', () => {
473473
class A extends Record({ x: null as number | null }) {
474-
toString() {
474+
override toString() {
475475
return this.x;
476476
}
477477
}

__tests__/Seq.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ describe('Seq', () => {
3939
});
4040

4141
it('accepts arbitrary objects', () => {
42-
function Foo() {
42+
function Foo(this: { bar: string; baz: string }) {
4343
this.bar = 'bar';
4444
this.baz = 'baz';
4545
}

__tests__/Set.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ describe('Set', () => {
305305
Symbol('a'),
306306
Symbol('b'),
307307
Symbol('c'),
308-
];
308+
] as const;
309309

310310
const symbolSet = Set(manySymbols);
311311
expect(symbolSet.size).toBe(12);

__tests__/merge.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -242,15 +242,18 @@ describe('merge', () => {
242242
).toBe(true);
243243
});
244244

245-
const map = { type: 'Map', value: Map({ b: 5, c: 9 }) };
246-
const object = { type: 'object', value: { b: 7, d: 12 } };
245+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
246+
type TypeValue = { type: any; value: any };
247+
248+
const map: TypeValue = { type: 'Map', value: Map({ b: 5, c: 9 }) };
249+
const object: TypeValue = { type: 'object', value: { b: 7, d: 12 } };
247250
const RecordFactory = Record({ a: 1, b: 2 });
248-
const record = { type: 'Record', value: RecordFactory({ b: 3 }) };
249-
const list = { type: 'List', value: List(['5']) };
250-
const array = { type: 'array', value: ['9'] };
251-
const set = { type: 'Set', value: Set('3') };
251+
const record: TypeValue = { type: 'Record', value: RecordFactory({ b: 3 }) };
252+
const list: TypeValue = { type: 'List', value: List(['5']) };
253+
const array: TypeValue = { type: 'array', value: ['9'] };
254+
const set: TypeValue = { type: 'Set', value: Set('3') };
252255

253-
const incompatibleTypes = [
256+
const incompatibleTypes: Array<[TypeValue, TypeValue]> = [
254257
[map, list],
255258
[map, array],
256259
[map, set],

__tests__/tsconfig.json

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
{
2+
"extends": "../tsconfig.json",
23
"compilerOptions": {
3-
"noEmit": true,
4-
// TODO: add additional strictness
5-
"strictNullChecks": true,
6-
"strictFunctionTypes": true,
7-
"target": "esnext",
8-
"moduleResolution": "node",
9-
"skipLibCheck": true,
4+
// TODO remove those "false" value that make the code less strict
5+
"noImplicitAny": false,
6+
"verbatimModuleSyntax": false,
107
"paths": {
118
"immutable": ["../type-definitions/immutable.d.ts"]
129
}

resources/jestPreprocessor.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ const makeSynchronous = require('make-synchronous');
33

44
const TYPESCRIPT_OPTIONS = {
55
noEmitOnError: true,
6-
target: typescript.ScriptTarget.ES2015,
6+
target: typescript.ScriptTarget.ES2022,
77
module: typescript.ModuleKind.CommonJS,
8-
strictNullChecks: true,
98
sourceMap: true,
109
inlineSourceMap: true,
10+
esModuleInterop: true,
1111
};
1212

1313
function transpileTypeScript(src, path) {

0 commit comments

Comments
 (0)