add optional type parameter to workspaceToCode

this allows the app to bind event handlers to various top-level blocks of code