我正在阅读环回4文档。我也已经阅读了打字教程。但我不明白这个语法:
module.exports = <ModelCrudRestApiConfig>{
model: Product,
pattern: 'CrudRest', // make sure to use this pattern
dataSource: 'db',
basePath: '/products',
};
这个符号是什么意思:
<Stuff>{ a: 1, c:2 }
还有这个
const ProductController = defineCrudRestController<
Product,
typeof Product.prototype.id,
'id'
>(Product, {basePath: '/products'});
从这里:https://loopback.io/doc/en/lb4/Creating-crud-rest-apis.html
另外,它是从环回还是从打字?
谢谢,
这是Typescript类型断言(换句话说,你告诉编译器你比它更了解类型(。
基本上这些东西是一样的,只是语法不同:
const stuff = <Stuff>{ a: 1, c:2 };
const stuff = { a: 1, c:2 } as Stuff;
更多信息请点击此处:https://basarat.gitbook.io/typescript/type-system/type-assertion