sebastiannm
sebastiannm

Reputation: 565

Error TS2339 [property * does not exist on type] with relative file;

I'm trying to create my own UMD library with typescript and webpack, and when importing a file I get the error TS2339 (Property 'makeRequest' does not exist on type 'typeof Utils'). Both files are in the same folder

My two files

assets.ts

'use strict';

import Utils from './utils';

export default class Assets {

  constructor() {}

  search(api: any, query: any) {
    let request = {
      path: `/assets`,
      type: 'POST',
      data: query
    };
    return Utils.makeRequest(api, request);
  }

}

utils.ts

'use strict';

export default class Utils {

  makeRequest(api: any, request: any): void {}

}

Upvotes: 0

Views: 2212

Answers (1)

hagner
hagner

Reputation: 1050

You could use 2 ways to call your makeRequest method:

  1. Mark the method as static:

    static makeRequest(api: any, request: any): void { }
  2. Create a new instance of the utils class and then call the method:

    let util = new Utils();
    return util.makeRequest(api, request);

Upvotes: 1

Related Questions