title: Migrating an AngularJS factory to TypeScript
body: <p>I am in the process of preparing to migrate an AngularJS app to Angular. I am currently looking at converting the JS code to TS. I haven't had any issues with components and services but factories. I can't figure out how to convert factories to use TypeScript.</p>
  
  <p>Here's an example:</p>
  
  <pre><code>(function() {
      'use strict';
  
      angular.module('MyApp')
        .factory('Fruit', Fruit);
  
      /** @ngInject */
      function Fruit() {
  
        var Fruit = function(dto) {
          // dto properties
          this.id = "";
          this.name = "";
          this.type = "Orange";
          this.color = "#000000";
  
          //--------------
          // Create from API response DTO
          if (dto) {
            this.id = dto.id;
            this.name = dto.data.name;
            this.type = dto.data.type;
            this.color = dto.data.color;
          }
        };
  
        return Fruit;
      }
  })();
  </code></pre>
  
  <p>I've tried this but doesn't work. I get dto -> dtoProvider not found.</p>
  
  <pre><code>(function() {
      'use strict';
  
      angular.module('MyApp')
        .factory('Fruit', class Fruit {
  
          // dto properties
          public id = "";
          public name = "";
          public type = "Orange";
          public color = "#000000";
          constructor (private dto: any) {
            // Create from API response DTO
            if (dto) {
              this.id = dto.id;
              this.name = dto.data.name;
              this.type = dto.data.type;
              this.color = dto.data.color;
            }
          }
        })
      })();
  </code></pre>
  
  <p>P.S. i do not have the ability to import/export classes yet.</p>