Iv'e been researching these kind of educational and cognitive topics for some time and it's quite obvious that writing code and writing fiction or non-fiction narratives are cognitively different tasks. However, further scientific research is necessary to obtain evidence whether or not retyping narrative (or even code, I might argue) is a good method.
Cognitively speaking handwriting and typing are different tasks and thus have different results on the learning process, which may or may not vary individually.
I think the best method to learn coding highly depends on the learning style of the person.