visual studio code - Typescript: Argument of type 'RegExpMatchArray' is not assignable to parameter of type 'string' -


i have following expression:

import { persiststate } 'redux-devtools';  const enhancer = compose(   applymiddleware(thunk, router, logger),   devtools.instrument(),   persiststate(     window.location.href.match(/[?&]debug_session=([^&]+)\b/)   ) ); 

i swiggly on argument match function following error

argument of type 'regexpmatcharray' not assignable parameter of type 'string'. matches string regular expression, , returns array containing results of search. (method) string.match(regexp: regexp): regexpmatcharray (+1 overload)

the peek definition in vscode shows:

match(regexp: string): regexpmatcharray; /**   * matches string regular expression, , returns array containing results of search.   * @param regexp regular expression object contains regular expression pattern , applicable flags.   */ match(regexp: regexp): regexpmatcharray;  /**   * replaces text in string, using regular expression or search string.   * @param searchvalue string represents regular expression.   * @param replacevalue string containing text replace every successful match of searchvalue in string.   */ 

as see it, argument of type regexp , parameter in definition. why error?

@nitzantomer right. it's not match functions parameter has type mismatch. try store return value of match function in string typed variable / return :string function / pass string parameter.


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -