Throw when invalid parameter hint label is passed in (#161125)

Fixes #161055

I'm fairly sure that our code is correct if everything has the expected types. However extensions may be passing us invalid data so that the types are runtime don't match what we expect
This commit is contained in:
Matt Bierner 2022-09-16 10:16:40 -07:00 committed by GitHub
parent f05eb4af4f
commit b12b061b7e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1134,6 +1134,10 @@ export namespace CompletionItem {
export namespace ParameterInformation {
export function from(info: types.ParameterInformation): languages.ParameterInformation {
if (typeof info.label !== 'string' && !Array.isArray(info.label)) {
throw new TypeError('Invalid label');
}
return {
label: info.label,
documentation: MarkdownString.fromStrict(info.documentation)