Skip to content

'use strict'; declared in firebase function samples #562

Description

@ColtonIdle

Posting this here as per @CodingDoug's suggestion.

https://groups.google.com/forum/#!topic/firebase-talk/xCSiEP82kf0

I've noticed that 'use strict';is declared at the top of a lot of files in https://github.com/firebase/functions-samples but yet, when I watch different firebase videos on youtube from the firebase team, they don't use it there. I've googled what it actually means, and it makes sense that I would enable this so called "strict mode" on my production grade project, but I was wondering if anyone could shed any light on why it's not included in the videos/every sample. Maybe I'm just being anal. Maybe it's just me being a Java dev for so long that I don't understand what it is (new to this server/nodejs world of things. I also get that this probably has nothing to do with firebase as well.

It sounds like @CodingDoug was saying that TS files don't need use strict; for strict mode.

In the sample TS function on the github page it does include this line. Are you saying that the sample TS file is incorrect?

https://github.com/firebase/functions-samples/blob/master/typescript-getting-started/functions/src/index.ts

Apologies if this is a dumb question and that this is a bit all over the place.

Activity

  1. jhuleatt commented on Oct 7, 2026

    @jhuleatt
    Contributor

    'use strict' is a CommonJS habit from when these samples were written: it makes some mistakes throw instead of failing silently, and it has no effect on how Cloud Functions runs your code. ES modules and TypeScript are strict by default, which is why newer samples don't have it. Closing.

  2. ColtonIdle commented on Oct 9, 2026

    @ColtonIdle
    Author

    7 years later for an answer. I salute you 🫡
    appreciate it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions