如果引用类型是泛型的父类,为什么不能将对派生类的引用分配给变量?
You have an error in your SQL syntax check the manual that corresponds to your MariaDB server version for the right syntax to use near 'as id FROM INNER JOIN departments ON .department_id=departments.id ORDER BY .id' at line 1<br />
<b>Warning</b>: Invalid argument supplied for foreach() in <b>/opt/lampp/htdocs/contacts/export.php</b> on line <b>23</b><br />
最后一行错误:
$flag = false;
foreach($query_result as $row) {
if(!$flag) {
// display field/column names as first row
echo implode("\t", array_keys($row)) . "\r\n";
$flag = true;
}
array_walk($row, __NAMESPACE__ . '\cleanData');
echo implode("\t", array_values($row)) . "\r\n";
}
function cleanData(&$str) {
$str = preg_replace("/\t/", "\\t", $str);
$str = preg_replace("/\r?\n/", "\\n", $str);
if(strstr($str, '"')) $str = '"' . str_replace('"', '""', $str) . '"';
}
答案 0 :(得分:0)
当您将变量键入为typeof Model
时,该类将保持通用,例如,您可以编写:
let a: typeof Model;
new a<IConcretModel>(null)
因此不能将非通用类分配给变量。 typeof
语法不支持为类指定通用参数,因此这是无效的typeof Model<IModel>
。
最简单的解决方法是改用构造函数签名:
let a: new (data: IModel) => Model<IModel>;
a = ConcretModel;