Skip to content

Re-enable typechecking - #1313

Open
jhuleatt wants to merge 6 commits into
mainfrom
typescript-issues
Open

jhuleatt wants to merge 6 commits into
mainfrom
typescript-issues

Conversation

@jhuleatt

Copy link
Copy Markdown
Contributor

#1291 accidentally flipped checkJs to false, which turned off type checking in all JS samples. This turns it back on, and fixes broken types in samples.

@jhuleatt jhuleatt changed the title Typescript issues Re-enable typechecking Sep 14, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates several Firebase Cloud Functions to use modular imports from the Firebase Admin SDK (e.g., importing from 'firebase-admin/app' and 'firebase-admin/auth' instead of the monolithic 'firebase-admin' package). It also enables JavaScript type checking ('checkJs': true) in the TypeScript configuration template, adding JSDoc type imports and a Mocha reference directive to support this. Regarding feedback, calling initializeApp() without arguments in the Remote Config sample will prevent app.options.projectId from being populated, leading to a runtime failure when constructing the Remote Config API URL. A suggestion has been provided to explicitly pass the project ID from the environment.

Comment thread Node/remote-config-diff/functions/index.js Outdated
- Migrate legacy admin namespace calls (admin.auth(), admin.database(), admin.firestore(), admin.storage(), admin.messaging(), admin.machineLearning(), admin.credential) to modular Firebase Admin SDK imports.
- Update elasticsearch and typesense client configurations in fulltext-search-firestore.
- Replace lodash require with Object.assign in image-maker clock.js.
- Correct bad-words named Filter import in text-moderation.
- Fix Stripe constructor import and apiVersion in stripe sample.
- Add missing declarations in instagram-auth and linkedin-auth.
…hCasesInSwitch, allowUnreachableCode, allowUnusedLabels)
- Replace (video: any) with youtube_v3.Schema in Node/youtube.
- Replace any[] in JSDoc for sliceIntoChunks with generic @template T in Node/instrument-with-opentelemetry.
- Replace /** @type {any} */ on sharp requires with /** @type {import('sharp').SharpConstructor} */ in 1st-gen and 2nd-gen thumbnails quickstarts.
@jhuleatt
jhuleatt marked this pull request as ready for review September 14, 2026 20:57
@jhuleatt
jhuleatt requested a review from ajperel September 14, 2026 20:58

//library for resizing images
const sharp = require('sharp');
const sharp = /** @type {import('sharp').SharpConstructor} */ (/** @type {unknown} */ (require('sharp')));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems pretty high on TypeScript magic. Is there a better way to do whatever it's doing?

/**
* Deletes one inactive user from the list.
* @param {admin.auth.UserRecord[]} inactiveUsers
* @param {import("firebase-admin/auth").UserRecord[]} inactiveUsers

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is quite an awkward way to get the type and repeated below. Can it be imported once above and used throughout.


// Get the templates
const responses = await Promise.all(templatePromises);
const results = responses.map((r) => r.json());

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated to your PR but FYI, while looking at it AI says this line isn't quite right:

const results = responses.map((r) => r.json()); maps to Promises. It should be: const results = await Promise.all(responses.map((r) => r.json()));

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants