Skip to content

Commit

Permalink
feat: fix ts test
Browse files Browse the repository at this point in the history
  • Loading branch information
selfrefactor committed Nov 5, 2024
1 parent 1f6850e commit ff18e9d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"test:all": "jest source/*.spec.js -u --bail=false",
"test:ci": "jest source/*.spec.js --coverage --no-cache -w 1",
"test:typings": "dtslint --localTs ./node_modules/typescript/lib --expectOnly ./source",
"ts": "yarn test:typings",
"usedby": "cd ../rambda-scripts && yarn usedby",
"x": "yarn populatedocs:x && yarn populatereadme:x && yarn immutable:x"
},
Expand Down
15 changes: 7 additions & 8 deletions source/groupBy-spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { groupBy } from 'rambda';
import { prop } from 'ramda';
import { groupBy, prop } from 'rambda';

interface Thing {
name: string;
Expand All @@ -16,20 +15,20 @@ const things = [
describe('R.groupBy', () => {
it('happy', () => {
const groupByFn = (x: string) => String(x.length);
const list = ['foo', 'barr'];
const list = ['foo', 'bar'];

const result = groupBy(groupByFn, list);
result; // $ExpectType { [index: string]: string[]; }
result; // $ExpectType Partial<Record<string, string[]>>

const curriedResult = groupBy(groupByFn)(list);
curriedResult; // $ExpectType { [index: string]: string[]; }
curriedResult; // $ExpectType Partial<Record<string, string[]>>
});
it('with one explicit types', () => {
const groupByPosition = groupBy<Thing>(prop('position'));

const result = groupByPosition(things);
result; // $ExpectType { [index: string]: Thing[]; }
result[9]; // $ExpectType Thing[]
result.foo; // $ExpectType Thing[]
result; // $ExpectType Partial<Record<string, Thing[]>>
result[9]; // $ExpectType Thing[] | undefined
result.foo; // $ExpectType Thing[] | undefined
});
});

0 comments on commit ff18e9d

Please sign in to comment.