in , ,

ceilingIsBeingRaised

ceilingIsBeingRaised | code-memes, engineer-memes, array-memes, arrays-memes, try-memes, string-memes, perl-memes, object-memes, recursive-memes, IT-memes, feature-memes | ProgrammerHumor.io
code-memes, engineer-memes, array-memes, arrays-memes, try-memes, string-memes, perl-memes, object-memes, recursive-memes, IT-memes, feature-memes | ProgrammerHumor.io

Content

Got Dunked by 2.5m people Why I still think it’s good code, link in the comments Atai Barkai (Qacc) ataiiam ceiling is being raised. cursor’s copilot helped us write "superhuman code" for a critical feature. We can read this code, but VERY few engineers out there could write it from scratch. Took lots of convincing too. "come on, this must be possible, try harder". and obviously- done in parts 37 38 39 41 42 43 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 type MappedParameterTypesT extends Parameter Check if the parameter has an ‘enum’ defined P in Tnumber as P’name": P extends enum: Arrayinfer E ? E extends string Ensure the enum values are strings ? P"required extends false Check if the parameter is optional ? E I undefined If so, include ‘undefined’ in the type : E Otherwise, use the enum type directly never This case should not occur since ‘enum’ implies string values Handle parameters defined as ‘object’ with specified attributes ‘ extends type: "object"; attributes: infer Attributes ? Attributes extends Parameter ? MappedParameterTypesAttributes Recursively map the attributes of the object never If ‘attributes’ is not an array of Parameters, this is invalid : Handle parameters defined as ‘object ‘ without specified attributes extends type: "object "; attributes?: never ? any Default to ‘any’ for arrays of objects without specific attributes : Handle parameters defined as ‘object ‘ with specified attributes P extends type: "object"; attributes: infer Attributes ? Attributes extends Parameter1 ? MappedParameterTypesAttributes Recursively map each object in the array : any Default to ‘any’ if attributes are not properly defined Handle all other parameter types P"required" extends false ? Include ‘undefined’ for optional parameters TypeMa P "type" extends keyof TypeMap ? P"type" : "string" undefined : Use the direct mapping from ‘TypeMap’ for the parameter’s type P "type" extends keyof ? P"type" : "string"; 1:57 AM Mar 6, 2024 2.1M Views ProdrammerHumor io