Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deploying firebase cloud function in typescript

I'm trying to deploy the very first cloud function. It works perfectly fine, but when I try to deploy it in terminal, it sets out warning saying that "functions is declared but it's value is never read".

Is this some common starting mistake, as I am new to this subject? Thank you.

I tried both imports , deploy erros remains same

 // const functions = require('firebase-functions');
import * as functions from 'firebase-functions' 

Errors message

index.ts file code here

like image 235
Alam Avatar asked Feb 04 '26 19:02

Alam


1 Answers

Your code doesn't declare any Cloud Functions yet, so eslint warns you that you're importing functions but not using it.

The message will disappear when you declare a Cloud Function in your index.js/index.ts. For example, the documentation on getting started contains this example:

exports.addMessage = functions.https.onRequest((req, res) => {
  const original = req.query.text;
  return admin.database().ref('/messages').push({original: original}).then((snapshot) => {
    return res.redirect(303, snapshot.ref.toString());
  });
});

As you can see, this code uses functions in its first line. So if you add this (or any other Cloud Functions declaration) to your code, you're using functions and eslint will no longer warn you about it not being used.

like image 117
Frank van Puffelen Avatar answered Feb 06 '26 16:02

Frank van Puffelen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!