From 8f91b2d461764b8e2c0064963bc23d1e72266f8a Mon Sep 17 00:00:00 2001 From: Christina Holland Date: Mon, 23 Jun 2025 14:34:19 -0700 Subject: [PATCH 1/4] Specify a minimum TypeScript version using typesVersions --- .changeset/cuddly-apes-check.md | 6 ++++++ packages/app/package.json | 5 +++++ packages/app/rollup.config.js | 9 +++++++++ packages/app/typescript-not-supported.d.ts | 3 +++ 4 files changed, 23 insertions(+) create mode 100644 .changeset/cuddly-apes-check.md create mode 100644 packages/app/typescript-not-supported.d.ts diff --git a/.changeset/cuddly-apes-check.md b/.changeset/cuddly-apes-check.md new file mode 100644 index 00000000000..de3c011ab1b --- /dev/null +++ b/.changeset/cuddly-apes-check.md @@ -0,0 +1,6 @@ +--- +'@firebase/app': minor +'firebase': minor +--- + +Specify a minimum TypeScript version using the `typesVersions` field. Shows an error message if below. diff --git a/packages/app/package.json b/packages/app/package.json index 3d6a0ca5dca..d37cb8160e3 100644 --- a/packages/app/package.json +++ b/packages/app/package.json @@ -7,6 +7,10 @@ "browser": "dist/esm/index.esm2017.js", "module": "dist/esm/index.esm2017.js", "react-native": "dist/index.cjs.js", + "typesVersions": { + ">=4.5.0": { "*": ["./dist/app-public.d.ts"] }, + "<4.5.0": { "*": ["./dist/typescript-not-supported.d.ts"] } + }, "exports": { ".": { "types": "./dist/app-public.d.ts", @@ -49,6 +53,7 @@ "devDependencies": { "@rollup/plugin-json": "6.1.0", "rollup": "2.79.2", + "rollup-plugin-copy": "3.5.0", "rollup-plugin-replace": "2.2.0", "rollup-plugin-typescript2": "0.36.0", "rollup-plugin-dts": "5.3.1", diff --git a/packages/app/rollup.config.js b/packages/app/rollup.config.js index 8314734a746..5eae22eee4c 100644 --- a/packages/app/rollup.config.js +++ b/packages/app/rollup.config.js @@ -15,6 +15,7 @@ * limitations under the License. */ +import copy from 'rollup-plugin-copy'; import typescriptPlugin from 'rollup-plugin-typescript2'; import replace from 'rollup-plugin-replace'; import typescript from 'typescript'; @@ -53,6 +54,14 @@ const esmBuilds = [ external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), plugins: [ ...buildPlugins, + copy({ + targets: [ + { + src: './typescript-not-supported.d.ts', + dest: 'dist/' + } + ] + }), replace({ ...generateBuildTargetReplaceConfig('esm', 2017), '__RUNTIME_ENV__': '' diff --git a/packages/app/typescript-not-supported.d.ts b/packages/app/typescript-not-supported.d.ts new file mode 100644 index 00000000000..c6bab929966 --- /dev/null +++ b/packages/app/typescript-not-supported.d.ts @@ -0,0 +1,3 @@ +// Empty typings file to log an error message for unsupported TS versions + +"Typescript must be version 4.5 or greater."; \ No newline at end of file From b073d97b4f161aad1b7c7391e84fa6b995fcc7c4 Mon Sep 17 00:00:00 2001 From: Christina Holland Date: Mon, 23 Jun 2025 14:51:19 -0700 Subject: [PATCH 2/4] fix correct app typings path --- packages/app/package.json | 2 +- packages/app/typescript-not-supported.d.ts | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/packages/app/package.json b/packages/app/package.json index d37cb8160e3..3726f3d531a 100644 --- a/packages/app/package.json +++ b/packages/app/package.json @@ -8,7 +8,7 @@ "module": "dist/esm/index.esm2017.js", "react-native": "dist/index.cjs.js", "typesVersions": { - ">=4.5.0": { "*": ["./dist/app-public.d.ts"] }, + ">=4.5.0": { "*": ["./dist/app/src/index.d.ts"] }, "<4.5.0": { "*": ["./dist/typescript-not-supported.d.ts"] } }, "exports": { diff --git a/packages/app/typescript-not-supported.d.ts b/packages/app/typescript-not-supported.d.ts index c6bab929966..df54ce4e5d0 100644 --- a/packages/app/typescript-not-supported.d.ts +++ b/packages/app/typescript-not-supported.d.ts @@ -1,3 +1,20 @@ +/** + * @license + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // Empty typings file to log an error message for unsupported TS versions -"Typescript must be version 4.5 or greater."; \ No newline at end of file +'Typescript must be version 4.5 or greater.'; From 146da9c0f8a50d76734fdcf6c15985962de8a483 Mon Sep 17 00:00:00 2001 From: Christina Holland Date: Tue, 24 Jun 2025 09:58:51 -0700 Subject: [PATCH 3/4] get rid of weird import in app-check test --- packages/app-check/test/util.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/app-check/test/util.ts b/packages/app-check/test/util.ts index 4255c89cc98..9ba0e99a069 100644 --- a/packages/app-check/test/util.ts +++ b/packages/app-check/test/util.ts @@ -35,7 +35,6 @@ import { } from '@firebase/component'; import { AppCheckService } from '../src/factory'; import { AppCheck, CustomProvider } from '../src'; -import { HeartbeatService } from '@firebase/app/dist/app/src/types'; export const FAKE_SITE_KEY = 'fake-site-key'; @@ -112,7 +111,7 @@ export function getFakeHeartbeatServiceProvider( () => ({ getHeartbeatsHeader: () => Promise.resolve(fakeLogString) - } as HeartbeatService), + } as any), ComponentType.PRIVATE ) ); From f54d039050808337ef420794604fd26add19c68c Mon Sep 17 00:00:00 2001 From: Christina Holland Date: Wed, 25 Jun 2025 09:50:16 -0700 Subject: [PATCH 4/4] change docgen script to avoid ts restriction --- scripts/docgen/docgen.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/scripts/docgen/docgen.ts b/scripts/docgen/docgen.ts index 811570decd1..074995884ef 100644 --- a/scripts/docgen/docgen.ts +++ b/scripts/docgen/docgen.ts @@ -65,6 +65,7 @@ const PREFERRED_PARAMS = [ let authApiReportOriginal: string; let authApiConfigOriginal: string; +let appPkgOriginal: string; yargs .command( @@ -119,6 +120,14 @@ function cleanup() { authApiReportOriginal ); } + // Restore original app/package.json + if (authApiConfigOriginal) { + console.log(`Restoring original app/package.json contents.`); + fs.writeFileSync( + `${projectRoot}/packages/app/package.json`, + appPkgOriginal + ); + } for (const excludedPackage of EXCLUDED_PACKAGES) { if (fs.existsSync(`${projectRoot}/temp/${excludedPackage}.skip`)) { console.log( @@ -198,11 +207,26 @@ async function generateDocs( `"mainEntryPointFilePath": "/dist/esm2017/index.doc.d.ts"` ); + console.log(`Temporarily modifying packages/app/package.json for docgen.`); + // Remove typesVersions restriction just for docgen + appPkgOriginal = fs.readFileSync( + `${projectRoot}/packages/app/package.json`, + 'utf8' + ); + const appPkgModified = appPkgOriginal.replace( + `./dist/typescript-not-supported.d.ts`, + `./dist/app/src/index.d.ts` + ); + try { fs.writeFileSync( `${projectRoot}/packages/auth/api-extractor.json`, authApiConfigModified ); + fs.writeFileSync( + `${projectRoot}/packages/app/package.json`, + appPkgModified + ); if (skipBuild) { await spawn('yarn', ['api-report'], {