```js
var typeName = type.name || type.toString().match(/^function\s*([^\s(]+)/)[1];
```