I am new to TypeScript and have a little problem with an optional argument in a function. I got the following error in Visual Studio code for an argument query(see screenshot). I really don't understand this error because I defined the type as string. So why am I getting this error?
message: string "Type argument" | undefined 'is not assigned to a parameter of type' string '. The type 'undefined' is not assigned to the type 'string'

public async fetchPut<T>(requestURL: string, body: TBody, query?: string): Promise<T> {
const finalRequestOption: IFetchOption = Object.assign({
method: 'PUT',
headers: this.headers
}, { body });
const response: Response = await this.httpClient.fetch(
this.getRequestURL(requestURL, query),
finalRequestOption);
return response.json();
}
source
share