My opinion is that understand the basic concepts of programming. Always ask WHY while writing any code statement. Every statement has a reason.
A common example: most beginners working with C++ would write the first line as "#include<iostream>" without even understanding what it is and why it is being used.
Learning about basic terminologies like 'compilers' will give you an insight about how languages work and will help you better understand it.
To code without memorising, you need to think how the code is evaluated by the compiler at every step and how you can incorporate your logic into code using tools at hand.
But it will all come through practice. I suggest pick any language you like, preferably C++, and work your way up slowly. Start from the basic "hello world" program, then go with basic operations, conditional statements, loops etc.
I believe it's important to go slow in the beginning so you can master the basic concepts. Learning the advanced ones then will just be a piece of cake.
Hope it helps!!
Most IDEs will tell you about the syntax errors. And for the third party libraries, you always keep a reference to them. with passage of time, you sure will memorize most of these things(that you constantly work with) as muscle memory.
Don’t undermine yourself if you dont remember syntax or library methods. Concentrate on whether you can solve a problem or not.