Skip to content

Commit

Permalink
Allow mixed args to string.prototype.concat()
Browse files Browse the repository at this point in the history
According to MDN docs for the `concat()` method of the `String` type: 

> If the arguments are not of the type string, they are converted to string
> values before concatenating.

Passing numbers, objects, etc to `String.prototype.concat` is is valid JS
behavior but causes an error in Flow. It's also blocking 
facebook/react#22064.

This commit changes the arg type: `Array<string>` -> `Array<mixed>`.
  • Loading branch information
justingrant authored Aug 16, 2021
1 parent f9afdbc commit 35426e0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -1103,9 +1103,11 @@ declare class String {
codePointAt(index: number): number;
/**
* Returns a string that contains the concatenation of two or more strings.
* @param strings The strings to append to the end of the string.
* If the arguments are not of the type string, they are converted to string values before
* concatenating.
* @param values The values to append to the end of the string.
*/
concat(...strings: Array<string>): string;
concat(...values: Array<mixed>): string;
constructor(value?: mixed): void;
/**
* Returns true if the sequence of elements of searchString converted to a String is the
Expand Down

0 comments on commit 35426e0

Please sign in to comment.