Object possibly undefined 您需要一个谓词作为返回类型 function checkLineCharts( lineChart: InstanceType<typeof chart> | undefined,): lineChart is InstanceType<typeof chart>{ if (!lineChart) { console.warn( "No linechart found. Probably navigated away before this function ended" ); return false...