Tags

TSpythonsoftware đŸ’»JSappleđŸ“±aws☁reactsoftwarecss 💅styled-componentsđŸ’…đŸŒbackend

What I learnt

ProblemDifference between using a Generic Type that extends another type (let’s call it TypeA), and define TypeA and use it directly

Solution Generic binding asks TypeScript compiler to compute the type based on the input passed and checks it against definition, while when you pass the type, it is only checks the type. That’s why Generic Types binding allows you to know the exact returned value instead of the type definition in this example .

linksLink[1]

TS

ProblemSQLAlchemy: What's the difference between flush() and commit()?

Solution The session object registers transaction operations with  session.add() , but doesn't yet communicate them to the database until  session.flush()  is called. session.flush()  communicates a series of operations to the database (insert, update, delete). The database maintains them as pending operations in a transaction. The changes aren't persisted permanently to disk, or visible to other transactions until the database receives a COMMIT for the current transaction (which is what  session.commit()  does). session.commit()  commits (persists) those changes to the database. flush()  is  always  called as part of a call to  commit()

pythonsoftware đŸ’»

ProblemHow to decide when to write a test

Solution I agree with Kent Beck answer here: https://stackoverflow.com/questions/153234/how-deep-are-your-unit-tests/153565#153565

linksLink[1]

software đŸ’»

Problemdatabase IDs are assigned random numbers in JS land

Solution convert the ID before it reaches JS or use string as the type of your db column id

JSTSsoftware đŸ’»

ProblemOther team members not fulfilling your decisions

Solution Don't make decisions that creates work for others you wouldn't do yourself

ProblemTS Runtime issue

Solution A function declared using method shorthand syntax is bivariant . It can accept properties that don't exist at runtime. So a function that accepts a and b can also declare c, without an error.

linksLink[1]

TSsoftware đŸ’»

Problemsend a put/post request using fetch fails ‘cuz of content-type set to plain/text

Solution specify the content headers (fetch keeps the default ones for all requests): { Accept: 'application/json', 'Content-Type': 'application/json', }

JSTS

Problempromise is not await’ed in a forEach loop

Solution forEach doesn’t support Promises. Use a loop that doesn’t use a callBack. For details see link .

linksLink[1]

JSTS

Problemnew release not accepted by testflight because of a a version of a dependency

Solution make sure the dependency is using a semantic versioning

software đŸ’»appleđŸ“±

ProblemLambda is timing out with no meaningful error

Solution check lambda’s vpc configuration, you probably missed to allow outbound traffic.

aws☁

ProblemTrigger a func from child to parent, then pass result back to child and do something with

Solution Forget about this! React is all about data flowing down, not up! Refactor your code!

JSTSreactsoftware

ProblemPort 5000 is used by a process you didn’t run

Solution System Preferences > Sharing > uncheck AirPlay Receiver

appleđŸ“±

Problemreact-select component not rendering options correctling

Solution parent components have overflow-y: hidden → you should override that

reactcss 💅software đŸ’»

Problemno sleep func

Solution const sleep = ms => { return new Promise(resolve => setTimeout(resolve, ms)) }

JSTS

Problemstyled-component type error when using with nextjs 13

Solution no solution yet!!!! “ can be used only with client side”

TSJSreactstyled-componentsđŸ’…đŸŒ

ProblemCORS error persists even after enabling it

Solution Make sure your requests isn’t being redirected. for example from “mydomain.com” → “www.mydomain.com”. if so, fix your request to use full domain name.

softwarebackend

ProblemUnion of Readonly const object with another ‘partial’ object of same type causes the result type to error

Solution You are defining your types as generics, with generic binding of such a scenario the result of this union is fields with ‘never’ as their value → refactor your code to make only one of the types generic .

linksLink[1]

TS