Javascript: encode boolean properly in TypeScript