Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion types/string.prototype.matchall/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @param str string to match
* @param regexp A variable name or string literal containing the regular expression pattern and flags.
*/
declare function matchAll(str: string, regexp: string | RegExp): IterableIterator<RegExpMatchArray>;
declare function matchAll(str: string, regexp: string | RegExp): IterableIterator<RegExpExecArray>;

declare namespace matchAll {
function shim(): void;
Expand Down
7 changes: 7 additions & 0 deletions types/string.prototype.matchall/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"private": true,
"types": "index",
"typesVersions": {
"<=5.2": { "*": ["ts5.2/*"] }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ const str = 'aabc';
const nonRegexStr = 'ab';
const globalRegex = /[ac]/g;

matchAll(str, nonRegexStr); // $ExpectType IterableIterator<RegExpMatchArray>
matchAll(str, new RegExp(nonRegexStr, 'g')); // $ExpectType IterableIterator<RegExpMatchArray>
matchAll(str, globalRegex); // $ExpectType IterableIterator<RegExpMatchArray>
matchAll(str, nonRegexStr); // $ExpectType IterableIterator<RegExpExecArray>
matchAll(str, new RegExp(nonRegexStr, 'g')); // $ExpectType IterableIterator<RegExpExecArray>
matchAll(str, globalRegex); // $ExpectType IterableIterator<RegExpExecArray>
matchAll.shim(); // $ExpectType void
str.matchAll(globalRegex); // $ExpectType IterableIterator<RegExpMatchArray>
str.matchAll(new RegExp(nonRegexStr, 'g')); // $ExpectType IterableIterator<RegExpMatchArray>
str.matchAll(globalRegex); // $ExpectType IterableIterator<RegExpExecArray>
str.matchAll(new RegExp(nonRegexStr, 'g')); // $ExpectType IterableIterator<RegExpExecArray>
13 changes: 13 additions & 0 deletions types/string.prototype.matchall/ts5.2/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* Matches a string with a regular expression, and returns an iterable of matches
* containing the results of that search.
* @param str string to match
* @param regexp A variable name or string literal containing the regular expression pattern and flags.
*/
declare function matchAll(str: string, regexp: string | RegExp): IterableIterator<RegExpMatchArray>;

declare namespace matchAll {
function shim(): void;
}

export = matchAll;
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import matchAll = require('string.prototype.matchall');

const str = 'aabc';
const nonRegexStr = 'ab';
const globalRegex = /[ac]/g;

matchAll(str, nonRegexStr); // $ExpectType IterableIterator<RegExpMatchArray>
matchAll(str, new RegExp(nonRegexStr, 'g')); // $ExpectType IterableIterator<RegExpMatchArray>
matchAll(str, globalRegex); // $ExpectType IterableIterator<RegExpMatchArray>
matchAll.shim(); // $ExpectType void
str.matchAll(globalRegex); // $ExpectType IterableIterator<RegExpMatchArray>
str.matchAll(new RegExp(nonRegexStr, 'g')); // $ExpectType IterableIterator<RegExpMatchArray>
23 changes: 23 additions & 0 deletions types/string.prototype.matchall/ts5.2/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"ES2020"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../../",
"typeRoots": [
"../../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"string.prototype.matchall-tests.ts"
]
}
1 change: 1 addition & 0 deletions types/string.prototype.matchall/ts5.2/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "extends": "@definitelytyped/dtslint/dt.json" }