的参数,我有以下表现:打字稿:类型RegExpMatchArray'的参数是不能分配给类型“字符串”
import { persistState } from 'redux-devtools';
const enhancer = compose(
applyMiddleware(thunk, router, logger),
DevTools.instrument(),
persistState(
window.location.href.match(/[?&]debug_session=([^&]+)\b/)
)
);
我得到一个swiggly的参数,下面的错误
匹配功能'RegExpMatchArray'类型的参数不可分配给参数 类型'string'。与正则表达式匹配字符串,并返回包含该搜索结果的数组。 (方法) String.match(正则表达式:正则表达式):RegExpMatchArray(1过载)
在VSCode所述PEEK定义表示:
match(regexp: string): RegExpMatchArray;
/**
* Matches a string with a regular expression, and returns an array containing the results of that search.
* @param regexp A regular expression object that contains the regular expression pattern and applicable flags.
*/
match(regexp: RegExp): RegExpMatchArray;
/**
* Replaces text in a string, using a regular expression or search string.
* @param searchValue A string that represents the regular expression.
* @param replaceValue A string containing the text to replace for every successful match of searchValue in this string.
*/
正如我看到的那样,参数的类型的正则表达式定义中的参数也是如此。那为什么这个错误?
你在做什么与比赛的结果? –
请提供[MCVE](http://stackoverflow.com/help/mcve)。 –