title: libphonenumber-js: 'Uncaught TypeError: A text for parsing must be a string'
body: <p>I want to use the libphonenumber-js package (<a href="https://www.npmjs.com/package/libphonenumber-js" rel="nofollow noreferrer">https://www.npmjs.com/package/libphonenumber-js</a>) with Vuejs but I have a problem that I don't understand.</p>
  
  <p>I import the package:</p>
  
  <pre><code>import { parsePhoneNumberFromString } from 'libphonenumber-js';
  
  Vue.use(parsePhoneNumberFromString);
  </code></pre>
  
  <p>And in my component, I try to format the phone number of the user with this computed:</p>
  
  <pre><code>phoneNumberFormatting: function() {
    const rawPhoneNumber = parsePhoneNumberFromString(this.phoneNumber);
    return rawPhoneNumber;
  }
  </code></pre>
  
  <p><code>phoneNumber</code> is here:</p>
  
  <pre><code>function defaultData() {
    return {
      open:            false,
      maxLength:       25,
      playlisName:     '',
      loader:          false,
      userCreated:     false,
      step:            'login',
      phoneNumber:     '',
      formattedNumber: ''
    }
  }
  </code></pre>
  
  <p>And, currently, I just want to display the formatted number:</p>
  
  <pre><code>              &lt;div class="input-group"&gt;
                &lt;input v-model="phoneNumber" id="phoneNumber" placeholder="+33 (0) 123456789" class="form-control"&gt;
                  &lt;div class="input-group-append"&gt;
                    &lt;span class="input-group-text"&gt;{{phoneNumberFormatting}}&lt;/span&gt;
                  &lt;/div&gt;
                &lt;/div&gt;
  </code></pre>
  
  <p><strong>But in my javascript console, I have an error:</strong></p>
  
  <p><code>Uncaught TypeError: A text for parsing must be a string.</code></p>
  
  <p>This is where there's a problem in parsePhoneNumber.js:</p>
  
  <pre><code>export function normalizeArguments(args) {
      var _Array$prototype$slic = Array.prototype.slice.call(args),
          _Array$prototype$slic2 = _slicedToArray(_Array$prototype$slic, 4),
          arg_1 = _Array$prototype$slic2[0],
          arg_2 = _Array$prototype$slic2[1],
          arg_3 = _Array$prototype$slic2[2],
          arg_4 = _Array$prototype$slic2[3];
  
      var text = void 0;
      var options = void 0;
      var metadata = void 0;
  
      // If the phone number is passed as a string.
      // `parsePhoneNumber('88005553535', ...)`.
      if (typeof arg_1 === 'string') {
          text = arg_1;
      } else throw new TypeError('A text for parsing must be a string.');
  
      // If "default country" argument is being passed then move it to `options`.
      // `parsePhoneNumber('88005553535', 'RU', [options], metadata)`.
      if (!arg_2 || typeof arg_2 === 'string') {
          if (arg_4) {
              options = arg_3;
              metadata = arg_4;
          } else {
              options = undefined;
              metadata = arg_3;
          }
  
          if (arg_2) {
              options = _extends({ defaultCountry: arg_2 }, options);
          }
      }
      // `defaultCountry` is not passed.
      // Example: `parsePhoneNumber('+78005553535', [options], metadata)`.
      else if (isObject(arg_2)) {
              if (arg_3) {
                  options = arg_2;
                  metadata = arg_3;
              } else {
                  metadata = arg_2;
              }
          } else throw new Error('Invalid second argument: ' + arg_2);
  
      return {
          text: text,
          options: options,
          metadata: metadata
      };
  }
  </code></pre>
  
  <p>So here:</p>
  
  <pre><code>    // If the phone number is passed as a string.
      // `parsePhoneNumber('88005553535', ...)`.
      if (typeof arg_1 === 'string') {
          text = arg_1;
      } else throw new TypeError('A text for parsing must be a string.');
  </code></pre>
  
  <p>I don't understand because, even if I replace</p>
  
  <pre><code>const rawPhoneNumber = parsePhoneNumberFromString(this.phoneNumber);
  return rawPhoneNumber;
  </code></pre>
  
  <p>by</p>
  
  <pre><code>const rawPhoneNumber = parsePhoneNumberFromString('+12133734253')
  return rawPhoneNumber.number;
  </code></pre>
  
  <p>Like in the documentation, I still have the error.</p>
  
  <p>Any idea?</p>