emberjs / emberjs/ember-string

Calling capitalize() on undefined returns an unhelpful error message

Open
#253 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
4
Forks
14
PR merge metrics
No merged PRs in 30d

Description

- [Twiddle here](https://ember-twiddle.com/d8daff02715f5fbb46972140d967f5f0?openFiles=controllers.application%5C.js%2C) - you need to look into devtools console

## The problem

When calling `capitalize()` on `undefined`:

```js
import { capitalize } from '@ember/string';

return capitalize(undefined);
```

One will get a weird error:

```
Uncaught TypeError: Cannot read property 'replace' of undefined
at Cache.func (ember.debug.js:41546)
at Cache.get (ember.debug.js:30881)
at Object.capitalize (ember.debug.js:41770)
at ApplicationController.get foo [as foo] (about:srcdoc:35)
at getPossibleMandatoryProxyValue (ember.debug.js:14419)
at get (ember.debug.js:14485)
at ember.debug.js:46909
at runInAutotrackingTransaction (ember.debug.js:54899)
at track (ember.debug.js:55486)
at PropertyReference.value (ember.debug.js:46908)
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.