Category : typescript

I have the following code: const utility = { data: ‘test’, foo() { console.log(‘foo’) return this } } const main = { bar() { console.log(‘bar’) return this } } const schema = Object.assign(utility, main) schema.bar().foo() console.log(schema.data) Everything works perfectly in execution, the problem is that I am trying to build a form validation library and ..

Read more

I am trying to set up some typescript aliases to optimize my imports without using babel or webpack on a node.js project. my current tsconfig.json: { "compilerOptions": { "baseUrl": ".", "target": "es6", "module": "CommonJS", "moduleResolution": "node", "allowJs": false, "esModuleInterop": true, "noImplicitAny": true, "resolveJsonModule": true, "outDir": "./build", "strict": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, "typeRoots": [ "node_modules/@types", ..

Read more

i have added code to add client to mongodb collection however http://localhost:9001/saveClients returning the bad request error 400, any idea what could possibly implemented wrong here ? console.log("CLIENTS POST >>>>>", req.body); printing empty object controller.ts public static async save (req: Request, res: Response): Promise<any> { try { console.log("CLIENTS POST >>>>>", req.body); const clientData = req.body; ..

Read more

So I’m trying to figure out how to compare two dates in Typescript. I have the user inputted date: const oldestDateString = this.address[0].since + ‘-01′; const oldestDate = new Date(oldestDateString); And the date that’s three years in the past (36 months): const threeYearsAgo = new Date().setMonth(new Date().getMonth() – 36); So I go to compare these ..

Read more

Part 2 of wanting to absolutely die while learning React/TS. So I’m in some code that looks like this. Basically I’ve tried in 3 different ways to set a variable. Closure. It doesn’t work. This is really a remarkable feat of engineering to break JS basics like this. Literally every single line of code is ..

Read more