fix one bug found by abortive typescript port attempt