You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In #1446, I improved the type inference on the detect function by checking if it extends undefined; however, this means that the type inference only works when the detect property does not use the object-function shorthand syntax.
For example, this works:
const[rule]=sensitiveInfo({mode: "LIVE",allow: ["custom","CREDIT_CARD_NUMBER"],// Notice the `:` and arrow functiondetect: (tokens: string[])=>{returntokens.map((token)=>{if(token==="[email protected]"){return"custom";}});},contextWindowSize: 1,});
But this does not work:
const[rule]=sensitiveInfo({mode: "LIVE",allow: ["custom","CREDIT_CARD_NUMBER"],// Notice the shorthand syntaxdetect(tokens: string[]){returntokens.map((token)=>{if(token==="[email protected]"){return"custom";}});},contextWindowSize: 1,});
I'm not good enough with TypeScript to know how to solve this inference for both cases.
Additionally, it seems that not specifying tokens: string[] causes the inference to not work either. I'm not sure why when it infers the arguments correctly for me.
The text was updated successfully, but these errors were encountered:
In #1446, I improved the type inference on the
detect
function by checking if it extendsundefined
; however, this means that the type inference only works when thedetect
property does not use the object-function shorthand syntax.For example, this works:
But this does not work:
I'm not good enough with TypeScript to know how to solve this inference for both cases.
Additionally, it seems that not specifying
tokens: string[]
causes the inference to not work either. I'm not sure why when it infers the arguments correctly for me.The text was updated successfully, but these errors were encountered: