"TypeScript has automatically widened the 'val' from 'val' to a string. If you want to prevent that widening, you can declare the object as const"
If I want to preserve the type of some literal variable (because otherwise code assist does not work) but also want to make sure the variable assignable to some type
The best I can do is
function assertType<AssertedType> (val: AssertedType) {
}