I have seen this error mentioned in regards to string arrays but not actual strings. I have a TypeScript file with the line
if (!bus.lineInfo.PublishedLineName.includes(input)) {
This gives me an error of
TS2339: Property 'includes' does not exist on type 'string'.
bus
is a variable that implements the bus
interface:
interface bus {
"lineInfo": {
"PublishedLineName": string,
"DestinationName": string, // The headsign of the bus
"Color": string,
"TextColor": boolean | string // false if this is "FFFFFF", otherwise it's the color
},
"warnings": boolean | busWarnings
"marker"?: google.maps.Marker,
"result"?: JQuery // The search result that appears in the sidebar
}
lineInfo.PublishedLineName
is declared as a string
, and String.prototype.includes()
is a function according to MDN, so why does the TypeScript compiler complain about the missing property/method?