To discover the inferred type, simply hover over a value in your IDE and view the tooltip. In this case, it would be: RegExpMatchArray | null
.
If you want to delve deeper, try going to the definition by Alt + clicking (this shortcut may vary depending on your IDE). You might need to manually input the text for the link to be clickable, like so:
type R = RegExpMatchArray;
// ---------------- now you can Alt + click this
This example showcases two definitions:
// from lib.es5.d.ts
interface RegExpMatchArray extends Array<string> {
/**
* The index of the search at which the result was found.
*/
index?: number;
/**
* A copy of the search string.
*/
input?: string;
/**
* The first match. This will always be present because `null` will be returned if there are no matches.
*/
0: string;
}
// from lib.es2018.regexp.d.ts
interface RegExpMatchArray {
groups?: {
[key: string]: string
}
}
With interface merging, RegExpMatchArray
is expected to exhibit both behaviors.
You should now have the tools to explore further.