@ctrip/bbk-typescript-definition
Bbk component repositories.
- Convert
JSON
contract to typescript definition. - tsd - java contract - convert
Snapshot
Installation
npm install @ctrip/bbk-typescript-definition -g
Usage
- open a terminal and goto your project root path
- create config file
.tsdbbk.js
to your project root path - input commander
bbk-cli tsd
and sendEnter
to generate tsd file - for help please input
bbk-cli -h
bbk-cli tsd
configuration file
- config file name
.bbktsd.js
- below are config values
moduleexports = rootTypeName: 'BBK_TYPE' // data type interface name typeMap: String: 'string' // mapping contract data type to typescript type unknowType: 'any' // define unknow type to any contractPath: './__data__/data.ts' // contract data path outDir: './aaa/bbb/ccc.ts' // build file path
typeMap
default let tsTypeMap = true: 'boolean' false: 'boolean' string: 'string' success: 'string' boolean: 'boolean' number: 'number' date: 'Date' any: 'any';
Input ( JSON contract define )
moduleexports = baseResponse: isSuccess: false code: "String" returnMsg: "String" requestId: "String" cost: 0 showMessage: "String" extMap: key: "String" apiResCode: "String" ResponseStatus: Timestamp: "/Date(1576072578649+0800)/" Ack: "Success" Errors: Message: "String" ErrorCode: "String" StackTrace: "String" SeverityCode: "Error" ErrorFields: FieldName: "String" ErrorCode: "String" Message: "String" ErrorClassification: "ServiceError" Build: "String" Version: "String" Extension: Id: "String" Version: "String" ContentType: "String" Value: "String"
Output