[js/python] don't generate require/import for types that are not directly used by non-extern code (closes #3050)