javascript - ฉันจะหาค่า metadataKey ที่ใช้ใน reflect-metadata ได้จากที่ไหน
ฉันกำลังใช้ TypeScript และ Angular (2.4.7)
reflect-metadata หมายถึงสตริงเวทย์มนตร์ ฉันหาที่มาของมันว่ามันคืออะไรและถูกกำหนดไว้ที่ไหนได้จากที่ไหนบ้าง? ตัวอย่างเช่น "design:type"
function Type(type) { return Reflect.metadata("design:type", type); }
function ParamTypes(...types) { return Reflect.metadata("design:paramtypes", types); }
function ReturnType(type) { return Reflect.metadata("design:returntype", type); }
คำตอบ #1
มันมาจากคอมไพเลอร์ TypeScript ที่เปิดใช้งานตัวเลือก emitDecoratorMetadata
https://github.com/Microsoft/TypeScript/blob/ef25b25c1fb64602f99a6278f24d42c1b6d53d90/src/compiler/transformers/ts.ts#L1360-L1376
https://github.com/Microsoft/TypeScript/blob/ef25b25c1fb64602f99a6278f24d42c1b6d53d90/src/compiler/transformers/ts.ts#L1498-L1528
