Search code examples
typescriptfirebaserequiregoogle-cloud-functions

How to import ts file on js file firebase-functions


I am trying to import my ts file on some js file, when I am doing deploy I am getting error:

Error: Error parsing triggers: Cannot find module 'EmailData'

My code:

the js file:

var EmailDataClass = require("EmailData");

the ts file:

class EmailData {}
export EmailData;

Solution

  • good introduction: link node_modules folder. But only the index.js file is executed, you can reconfigure a main file through the main field of functions/package.json. You can see the source code from link