2
votes

I'm using an existing js library that uses AMD modules in my typescript code. I want to use a Javascript class as the base for my Typescript class. This is what I'm trying to do:

famous.js

define('famous/core/View',['require','exports','module'],function(require, exports, module) {

    function View() {
        ...
    }

    ...

    module.exports = View;
});

View.d.ts

declare module "famous/core/View" {

}

AppView.ts

import View = require('famous/core/View');

class AppView extends View {

}

export = AppView;

But it says "Cannot find name 'View'". I suppose it's logical it doesn't work since a module is not a class, but I don't know another way.

2

2 Answers

1
votes

You need to define a class and use export = in View.d.ts. For example:

declare module "famous/core/View" {
   class View {
      // TODO define members of View
   }
   export = View;
}
0
votes

On further analysis it seems like purely a require configuration problem. It shouldn't have anything to do with class vs module. Are you sure your paths are correct and you have a config.ts require configuration file?