Roman Veselý Software Engineer from Slovakia. Somewhere between trees and bytes of code.

Learning Log #4

More JavaScript and TypeScript stuff, tips for GitHub and offline world.

Sidenote: now, you can find the content of all my Learning Log together in one place. It should be easier for me to add new pieces more frequently. I can also transclude the content of any individual log anywhere where a React component can be used thanks to the new <Log /> component. RSS may come later is also available.

You can push your console.log()-driven development to a more advanced level with console.group() method. It creates a new inline group, indenting all following output. To move back, use console.groupEnd(). Check this article about advanced logging.

In TypeScript, the difference between union types and intersection types can be counter-intuitive at first glance. Ryan Cavanaugh gave a great explanation: “the union of the domain of values produces an intersected set of properties and vice versa.”

DefinitelyTyped is the repository for TypeScript type definitions. We may call it the official repository now, but that has not always been the case. When Boris created a repository for this project nobody knew TypeScript will become so widely-used. Read its whole story from zero to hero.

While resolving import statements, @types directory is significant for TypeScript compiler, as it looks there for type declarations before it reaches the actual package node_modules directory. The logic behind this behavior is that if the package itself had type declarations, you wouldn’t have installed it from DefinitelyTyped.

GitHub Tip

In GitHub, you can highlight not only the code syntax but also a differences, just like with git diff command. It may be very helpful while providing some step by step guides in READMEs or issues.

Here’s the syntax:

```diff
+foo
-bar
baz
```

that results in:

+foo
-bar
baz

Unfortunately, it’s not possible to use both language syntax and diff highlighting together.

Offline Behaviour

Besides learning new stuff, networking is another crucial part of conferences or other events. But, it can be hard to join the discussion of the group of people one doesn’t know. That’s where the Pac-man rule comes in. When standing as a group of people, always leave room for 1 person to join your group.

That’s enough for now, see you next time!