Oct 22, 2016
If there is one thing the TypeScript people should improve, it's documentation. I just went through a small Odyssey trying to convert a project to TypeScript 2.0 and the new way of getting definition files. Hint: Look at how the Rust project does documentation.
Go into your package.json
, set TypeScript to version 2.something
and run
npm install
. Done. Try to compile your project, it probably won't because the
compiler is a bit more strict. The error messages, however, should give you an
idea what needs to be changed, go and fix your code. Visual Studio Code uses
the globally installed TypeScript version, update that one as well by running
npm install -g
- yes, not update, don't ask why. I make this mistake every.
single. time.
You can now install type definitions via npm, typings/tsd are no longer needed. Installation goes like this:
npm install --save @types/react
All DefinitelyTyped definitions are available, so you might as well do this now. After installing all typings, remove the reference path to the old definitions, try to build and observe how TypeScript cannot resolve a single module. First, we have to tell TypeScript that we're using node modules:
// tsconfig.json
{
"compilerOptions": {
"moduleResolution": "node"
}
}
Now, you might actually be able to compile. Unless you're using any global
non-standard functions like require
or core-js shims. Remember that you
had to explicitly load typings using the reference path before? This is no
longer necessary, but this also means TypeScript has no idea what typings are
available. When you import
something, they are loaded automatically, but if
something should always be loaded, you need to configure that:
// tsconfig.json
{
"compilerOptions": {
"types": [
"node", "mocha", "core-js"
]
}
}
Done, now your project should work as usual and with one less tool required.
May 13, 2016
I've been running a home server for a few years, but my upload is just too poor to do anything serious with it, so I got myself a cheap dedicated server. Installed FreeBSD so I could try bhyve, their new-ish hypervisor.
The default "frontend" to bhyve is quite complex, so I used vm-bhyve instead, which is similar to Docker in ease of use.
Let's install it. The package is often outdated, so I prefer installation from source.
# if you don't have the ports tree yet
portsnap fetch extract
cd /usr/ports/sysutils/vm-bhyve && make install clean
If you plan to run anything other than FreeBSD, you'll also need grub2-bhyve
:
cd /usr/ports/sysutils/grub2-bhyve && make install clean
Some initial config:
mkdir /var/vm
zfs create -o mountpoint=/var/vm zroot/vm
echo 'vm_enable="YES"' >> /etc/rc.conf
echo 'vm_dir="zfs:zroot/vm"' >> /etc/rc.conf
vm init
cp /usr/local/share/examples/vm-bhyve/* /var/vm/.templates/
This is enough to be able to launch VMs, but we want networking as well.
echo 'net.inet.ip.forwarding=1' >> /etc/sysctl.conf
echo 'pf_enable="YES"' >> /etc/rc.conf
vm switch create public
vm switch add public em0
vm switch nat public on
pkg install dnsmasq
echo 'dnsmasq_enable="YES"' >> /etc/rc.conf
mv /usr/local/etc/dnsmasq.conf.bhyve /usr/local/etc/dnsmasq.conf
service dnsmasq start
vm-bhyve will add an include line to /etc/pf.conf
, you might
have to move it up a bit (check with pfctl -f /etc/pf.conf
).
Now, we need an ISO, which vm-bhyve can download for us:
vm iso ftp://ftp.freebsd.org/pub/FreeBSD/releases/amd64/amd64/ISO-IMAGES/10.3/FreeBSD-10.3-RELEASE-amd64-disc1.iso
If you want to download ISO's manually, put them in /var/vm/.iso/
.
Let's launch a VM:
vm create -t freebsd-zpool -s 50G freebsd1
vm install freebsd1 FreeBSD-10.3-RELEASE-amd64-disc1.iso
vm console freebsd1
Now just go through the installer as usual. Easy!