Is there a way to pass types to transport function props?
javapyscript opened this issue · 1 comments
javapyscript commented
Firstly, I would like to thank for such a nice much-needed library in the react-native world. Has been a breeze to set up and use.
The only thing I am not clear about is if there is a way to pass types to the custom transport function props. Currently, the props has the following type:
This means I lose the type for the log levels, the type for the msg and raw msg etc. Some transports need data filtration before sending, and doing it with any
s feels a bit risky.
Is there something obvious that I am missing in the documentation?
Thank you.
alessandro-bottamedi commented
Thanks!
You can define your own transportFunctionType interface:
interface transportFunctionType {
(props: {
msg: string; // set the type you have for msg
rawMsg: Object; // set the type you have for rawMsg
level: {
severity: number;
text: string;
};
extension: string;
options: {
filePath: string;
fileName: string;
colors: {
info: string;
warn: string;
error: string;
};
//other typed options
};
}): void;
}
const myTransport: transportFunctionType = (props) => {
consoleTransport(props);
// other stuff
};