Skip to content

Commit 587f9e2

Browse files
🤖 Merge PR DefinitelyTyped#73953 fix: linkSort and nodeSort argument typing by @alexfauquette
1 parent 1e4e3e8 commit 587f9e2

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

‎types/d3-sankey/d3-sankey-tests.ts‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -278,17 +278,19 @@ num = slgDAG.iterations();
278278

279279
// test multiple definitions
280280
slgDAG = slgDAG.nodeSort((node: SNode) => (node.index === 0 ? 1 : -1));
281-
slgDAG = slgDAG.nodeSort(() => undefined);
282-
slgDAG = slgDAG.nodeSort((node: SNode) => (node.name === "test" ? null : undefined));
281+
slgDAG = slgDAG.nodeSort(undefined);
282+
slgDAG = slgDAG.nodeSort(null);
283+
slgDAG = slgDAG.nodeSort((node: SNode) => (node.name === "test" ? 0 : -1));
283284

284285
// ---------------------------------------------------------------------------
285286
// LinkSort
286287
// ---------------------------------------------------------------------------
287288

288289
// test multiple definitions
289290
slgDAG = slgDAG.linkSort((link: SLink) => (link.index === 0 ? 1 : -1));
290-
slgDAG = slgDAG.linkSort(() => undefined);
291-
slgDAG = slgDAG.linkSort((link: SLink) => (link.source > link.target ? null : undefined));
291+
slgDAG = slgDAG.linkSort(undefined);
292+
slgDAG = slgDAG.linkSort(null);
293+
slgDAG = slgDAG.linkSort((link: SLink) => (link.source > link.target ? 0 : -1));
292294

293295
// ---------------------------------------------------------------------------
294296
// Node Id

‎types/d3-sankey/index.d.ts‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -341,26 +341,26 @@ export interface SankeyLayout<Data, N extends SankeyExtraProperties, L extends S
341341
/**
342342
* Returns the node comparison function which defaults to undefined.
343343
*/
344-
nodeSort(): ((a: SankeyNode<N, L>, b: SankeyNode<N, L>) => number) | undefined;
344+
nodeSort(): ((a: SankeyNode<N, L>, b: SankeyNode<N, L>) => number) | undefined | null;
345345

346346
/**
347347
* Set the node comparison function and return this Sankey layout generator.
348348
*
349-
* @param compare Node comparison function.
349+
* @param compare Node comparison function. If `null`, the order is fixed by the input.
350350
*/
351-
nodeSort(compare: (a: SankeyNode<N, L>, b: SankeyNode<N, L>) => number | undefined | null): this;
351+
nodeSort(compare: ((a: SankeyNode<N, L>, b: SankeyNode<N, L>) => number) | undefined | null): this;
352352

353353
/**
354354
* Returns the link comparison function which defaults to undefined.
355355
*/
356-
linkSort(): ((a: SankeyLink<N, L>, b: SankeyLink<N, L>) => number) | undefined;
356+
linkSort(): ((a: SankeyLink<N, L>, b: SankeyLink<N, L>) => number) | undefined | null;
357357

358358
/**
359359
* Set the link comparison function and return this Sankey layout generator.
360360
*
361-
* @param compare Link comparison function.
361+
* @param compare Link comparison function. If `null`, the order is fixed by the input.
362362
*/
363-
linkSort(compare: (a: SankeyLink<N, L>, b: SankeyLink<N, L>) => number | undefined | null): this;
363+
linkSort(compare: ((a: SankeyLink<N, L>, b: SankeyLink<N, L>) => number) | undefined | null): this;
364364
}
365365

366366
/**

0 commit comments

Comments
 (0)