Firebase-tools: firebase init: could TypeScript be an option on project setup for functions?

Created on 28 May 2017  路  11Comments  路  Source: firebase/firebase-tools

was a bit surprised not to see anything in the docs about writing Functions with TypeScript.

I found this helpful article: https://medium.com/@wcandillon/writing-cloud-functions-with-typescript-61d86e282752

It would be wonderful if firebase init had an option to set up functions for TypeScript

Most helpful comment

Fixed =D

All 11 comments

In case anyone is looking, I wrote up full instructions and a sample project here: https://github.com/ultrasaurus/firebase-functions-typescript

Fixed =D

I'm running into an issue where initialising Cloud Functions (firebase init functions) with Typescript and TSLint with the latest version of firebase-tools (3.16.0) yields a tslint error: Module 'firebase-functions' is not listed as dependency in package.json".

Disabling the "no-implicit-dependencies" rule in tslint.json removes this error.

Is this a bug with the default project or an issue with my system?

I can't repro with the newest version of firebase-tools. Perhaps you kept an old package.json? You can reenable the linter rule and fix the bug by running the following inside your functions directory:

npm install --save firebase-functions

Still observing the issue.

I installed the latest version of firebase-tools, then ran firebase init functions, then ran npm i -S firebase-functions in the functions directory.

Sublime Text 3 (with SublimeLinter-contrib-tslint installed) is still complaining "Module 'firebase-functions' is not listed as dependency in package.json" on line 1 of the newly-created index.ts file.

Attached is the project structure on the left, index.ts, and package.json in the newly-initialised project.

2018-01-03 14 05 04

Interesting. Does npm run lint complain or just Sublime? I wonder if Sublime is confused and expecting a package.json in the lumi folder.

I don't have npm run lint set up in package.json, but running npm run build seems to lint code properly and it runs fine, so the issue must be Sublime-specific.

I moved package.json from the functions folder to the test folder and Sublime stops complaining. Any idea why this might be the case?

Unfortunately I don't use sublime so I don't know how to help. Does this issue show up automatically or after you try to run a command? I just downloaded Sublime, installed the TypeScript plugin, and tried to repro the issue without success.

Interesting. With Sublime (I'm using Sublime 3) I installed TypeScript, SublimeLinter and SublimeLinter-contrib-tslint packages with Package Control. Sublime highlights the import line as soon as i run firebase init functions in a fresh directory (choosing to enable tslint), and then open index.ts in Sublime.

Out of curiosity, what editor are you using?

I have updated to the latest firebase-tools with npm i -g firebase-tools and when I do firebase init I am not given an option for TypeScript. It just goes ahead and initializes with Javascript. Have they removed this option?

Just verified that the feature still exists. I noticed though that I had a private build linked in npm. You can double check with npm unlink firebase and which firebase.

Was this page helpful?
0 / 5 - 0 ratings