TS2322: Type 'string' is not assignable to type '"union" | "of" | "strings"'

TypeScript is complaining TS2322: Type ‘{ clientSecret: string; loader: string; }’ is not assignable to type ‘StripeElementsOptions’.    Types of property ‘loader’ are incompatible.      Type ‘string’ is not assignable to type ‘"always" | "auto" | "never"’. Where the object is defined as const options = { clientSecret: paymentIntent.clientSecret, loader: "always", } The error goes… Read More TS2322: Type 'string' is not assignable to type '"union" | "of" | "strings"'

Generic C# Repository, service and controller design

Im learning about generics and was wondering about how a generic controller, service and ef core repo design would look like. My case: lets say an incomming post request to add Smartphone and keyboard object to smartphone and keyboard tables My repository setup is public class GenericRepository<TEntity> : IGenericRepository<TEntity> where TEntity : class, IProductGenericEntities {… Read More Generic C# Repository, service and controller design

IWriterConfiguration.ReferenceHeaderPrefix equivalent in newer versions of CsvHelper

What is the equivalent of csvWriter.Configuration.ReferenceHeaderPrefix in the newer version of CsvHelper? Trying this csvWriter.Configuration.ReferenceHeaderPrefix = (memberType, memberName) => $"{memberName}_"; but its not let me because ReferenceHeaderPrefix has only get method after version 20.0.0 >Solution : The usual workflow is to construct an instance of the CsvConfiguration class and pass that into the constructor for… Read More IWriterConfiguration.ReferenceHeaderPrefix equivalent in newer versions of CsvHelper

NullReferenceException when passing Arg.Any<int>() as argument using NSubstitute

I have a customer class which accepts an IDbGateway interface as a constructor parameter. I need to write a unit test CalculateWage_HourlyPayed_ReturnsCorrectWage for the class using NUnit and NSubstitute. My unit test works fine when I pass anyId. But I want to pass Arg.Any<int>() instead of anyId. At the moment my test fails because decimal… Read More NullReferenceException when passing Arg.Any<int>() as argument using NSubstitute

Specifying Typescript return type that implements interface with additional fields

So I have a function that returns an object which extends the FooInterface class. I want to restrict the return type to classes that implement FooInterface but also have an additional field. interface FooInterface { readonly banana: string } function doThing() : FooInterface { return { banana: ‘blah’, additionalField: ‘blah2’, // Must have } }… Read More Specifying Typescript return type that implements interface with additional fields