2

のパラメータに割り当てられない私には、以下の式があります。活字体:型の引数は、「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. 
    */ 

、引数の型は正規表現であります定義内のパラメータも同様です。それではなぜエラー?

+1

あなたは試合の結果をどうしていますか? –

+0

[MCVE](http://stackoverflow.com/help/mcve)を入力してください。 –

答えて

1

@NitzanTomerが正しいです。型の不一致を持つのは、一致関数のパラメータではありません。文字列型の変数に一致関数の戻り値を格納するか、:string関数から返すか、stringパラメータとして渡してください。

+1

私はそれがVSCode intellisenseの問題だと思います。 swigglyは一致する引数だけであり、文全体のwindow.location.href.match(/ [?&] debug_session =([^&] +)\ b /) 'はスウィグリを持つ必要があります。 VSCodeを再起動すると修正されました。 –

+0

ありがとう@KushagraSharma、vscodeを再起動することも確かに私の解決策でした。このバグが報告されているかどうか分かりますか? – MaximeBernard

+0

@MaximeBernard問題が報告されているかどうかわかりません。 –

関連する問題