Update typecheck.py

Add support for derived types.