Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error TS2315: Type 'Int32Array' is not generic. #1664

Open
pixelsnis opened this issue Jan 20, 2025 · 25 comments · May be fixed by firebase/firebase-tools#8194
Open

Error TS2315: Type 'Int32Array' is not generic. #1664

pixelsnis opened this issue Jan 20, 2025 · 25 comments · May be fixed by firebase/firebase-tools#8194
Assignees
Labels
dependencies Pull requests that update a dependency file type: bug

Comments

@pixelsnis
Copy link

Related issues

None that I could find

[REQUIRED] Version info

"firebase-admin": "^12.1.0"
"firebase-functions": "^5.0.0"

node:

v20.16.0

firebase-functions:

12.1.0

firebase-tools:

13.16.0

firebase-admin:

12.1.0

[REQUIRED] Test case

Initialize Firebase functions using firebase init functions. Write any function and try deploying with firebase deploy --only functions.

[REQUIRED] Steps to reproduce

Same as test case

[REQUIRED] Expected behavior

Deployment should go through normally

[REQUIRED] Actual behavior

Deployment fails with this error:

node_modules/@google-cloud/storage/build/cjs/src/crc32c.d.ts:115:45 - error TS2315: Type 'Int32Array' is not generic.

Were you able to successfully deploy your functions?

No, but by modifying the mentioned file manually and changing Int32Array<ArrayBuffer> to Int32Array fixes it temporarily. Function deploys after that.

@google-oss-bot
Copy link
Collaborator

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

@nickgiarraputo
Copy link

This is a new problem for sure. Just initialized a new firebase project and it won't even build with it's own default code.

@nickgiarraputo
Copy link

nickgiarraputo commented Jan 20, 2025

Want to also add that your fix does work for me as well. Reverting Int32Array<ArrayBuffer> to simply Int32Array. I'm not sure why this was changed.

@tdcolvin
Copy link

Same issue using:
"firebase-admin": "^13.0.2",
"firebase-functions": "^6.2.0"
... and node 22.13.0

@tdcolvin
Copy link

The problem seems to be an outdated version of Typescript which is installed by default in the project created using firebase init. For me it installed Typescript 4.9.0.
Running npm i typescript@latest upgraded it to v5.7.3 and that seemed to solve the issue.

@jimmy-chiang
Copy link

Encounter this issue too.
I can confirm that @tdcolvin solution can solve this error.

@fransiska
Copy link

"firebase-admin": "^13.0.2",
"firebase-functions": "^6.2.0",
"typescript": "^5.7.3"
... and node 20.18.1

still has the same error, only solved by changing the source file manually

@Padreco-lbr
Copy link

Can confirm that upgrading typescript solved the issue for me as well, as per @tdcolvin.

@imanabu
Copy link

imanabu commented Jan 22, 2025

Confirmed: Upgrade TypeScript to 5.7.3 will fix this issue.

yarn add -D typescript@latest

@ItsTeccs
Copy link

Built fine yesterday, had issues today. Can confirm as well that updating TypeScript to latest fixed the issue immediately.

@imanabu
Copy link

imanabu commented Jan 26, 2025

Also, this message should be updated if TS 5.7.3 is indeed required.

WARNING: You are currently running a version of TypeScript which is not officially supported by @typescript-eslint/typescript-estree.

You may find that it works just fine, or you may not.

SUPPORTED TYPESCRIPT VERSIONS: >=4.7.4 <5.5.0

YOUR TYPESCRIPT VERSION: 5.7.3

@SamJbori
Copy link

Same issue

 "dependencies": {
    "firebase-admin": "^13.0.2",
    "firebase-functions": "^6.3.0",
  },
  "devDependencies": {
    "@typescript-eslint/eslint-plugin": "^5.62.0",
    "@typescript-eslint/parser": "^5.62.0",
    "eslint": "^8.57.1",
    "eslint-config-google": "^0.14.0",
    "eslint-plugin-import": "^2.31.0",
    "firebase-functions-test": "^3.4.0",
    "typescript": "^5.5.4"
  },

@tdcolvin
Copy link

Also, this message should be updated if TS 5.7.3 is indeed required.

WARNING: You are currently running a version of TypeScript which is not officially supported by @typescript-eslint/typescript-estree.

You may find that it works just fine, or you may not.

SUPPORTED TYPESCRIPT VERSIONS: >=4.7.4 <5.5.0

YOUR TYPESCRIPT VERSION: 5.7.3

I don't know if this message is caused by out-of-date firebase-tools running the build, or out-of-date firebase-admin / firebase-functions dependencies used during the build. But my experience is that by upgrading all three of these, the message no longer appears.

@kkig
Copy link

kkig commented Feb 3, 2025

"@google-cloud/storage": "^7.15.0"
"firebase-admin": "^13.0.2"
"firebase-functions": "^6.3.1"
"typescript": "^4.9.0"

node_modules/@google-cloud/storage/build/cjs/src/crc32c.d.ts:6:39 - error TS2315: Type 'Int32Array' is not generic.
declare const CRC32C_EXTENSION_TABLE: Int32Array<ArrayBuffer>;
                                        ~~~~~~~~~~~~~~~~~~~~~~~
node_modules/@google-cloud/storage/build/cjs/src/crc32c.d.ts:115:45 - error TS2315: Type 'Int32Array' is not generic.
static readonly CRC32C_EXTENSION_TABLE: Int32Array<ArrayBuffer>;

Updating typescript to 5.7.3 fixed this issue. Can confirm @tdcolvin solution works!

@anmelegov
Copy link

Facing the same issue on Typescript 5.7.3. Is it possible to write a backend using normal programming languages? Why do you drag these stillborn technologies into your projects? I can understand why they are used on the frontend, but there are plenty of alternatives for the backend

@CorieW
Copy link

CorieW commented Feb 10, 2025

Hi @pixelsnis,

Thanks for reporting this issue! We’ve received it and are reviewing it. We’ll provide updates as soon as possible.

@CorieW CorieW added type: bug dependencies Pull requests that update a dependency file and removed needs-triage labels Feb 10, 2025
@lukaszciastko
Copy link

Updating TypeScript solves one error but I am still seeing this:

node_modules/long/umd/index.d.ts:1:22 - error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../types.js")' call instead.

1 import { Long } from '../types.js';
                       ~~~~~~~~~~~~~

[8:36:43 PM] Found 1 error. Watching for file changes.

It's very annoying - I just created a new project and imported firebase admin. I would expect it to work.

@lukaszciastko
Copy link

Changing the default "module": "NodeNext" to "module": "commonjs" helped.

@stevecode21
Copy link

commonjs

Thx, and do not forget to also change "moduleResolution" value to "node",

@MarioLunaSG
Copy link

MarioLunaSG commented Feb 19, 2025

Updating TypeScript solves one error but I am still seeing this:

node_modules/long/umd/index.d.ts:1:22 - error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../types.js")' call instead.

1 import { Long } from '../types.js';
                       ~~~~~~~~~~~~~

[8:36:43 PM] Found 1 error. Watching for file changes.

It's very annoying - I just created a new project and imported firebase admin. I would expect it to work.

I soved it with TS 5.7.2, editing the index.d.ts, long file.

from this:
import { Long } from '../types.js';

to this:
import type * as Long from '../types.js' with {'resolution-mode': 'import'};

This is a crappy solution, but i need to deploy those functions

@atharvajohri
Copy link

atharvajohri commented Feb 21, 2025

still getting the same error after updating typescript, firebase tools, admin and cloud storage locally. it works fine when i run it as a github action in my pipeline.

"dependencies": {
    "@google-cloud/secret-manager": "^5.6.0",
    "@google/generative-ai": "^0.17.2",
    "@supabase/supabase-js": "^2.48.1",
    "body-parser": "^1.20.2",
    "express": "^4.21.2",
    "@google-cloud/storage": "^7.15.0",
    "firebase-admin": "^13.0.2",
    "firebase-functions": "^6.3.2",
    "joi": "^17.13.3",
    "lodash": "^4.17.21",
    "node-fetch": "^3.3.2",
    "prom-client": "^15.1.3",
    "uuidv4": "^6.2.13"
  },
  "devDependencies": {
    "@types/dotenv": "^8.2.3",
    "@types/jest": "^29.5.14",
    "@types/node": "^22.13.4",
    "@types/supertest": "^6.0.2",
    "@typescript-eslint/eslint-plugin": "^5.62.0",
    "@typescript-eslint/parser": "^5.62.0",
    "concurrently": "^8.2.2",
    "dotenv": "^16.4.7",
    "eslint": "^8.57.1",
    "eslint-config-google": "^0.14.0",
    "eslint-config-prettier": "^9.1.0",
    "eslint-plugin-import": "^2.31.0",
    "eslint-plugin-prettier": "^5.2.3",
    "firebase-functions-test": "^3.4.0",
    "jest": "^29.7.0",
    "jest-diff": "^29.7.0",
    "rimraf": "^6.0.1",
    "supertest": "^7.0.0",
    "ts-jest": "^29.2.5",
    "ts-node": "^10.9.2",
    "ts-node-dev": "^2.0.0",
    "typescript": "^5.7.3"
  },

@denfrancis
Copy link

I also had to update my global TypeScript version. npm install -g typescript

Double check that the global version is the same (mine was still 5.5.0) - tsc --version

@alessiortu
Copy link

Guys, you didn't specify that the package.json with the latest version of typescript to update is the one contained in the "functions" folder. For those like me who have a project with various tools, it has a parent package.json, and then child folders. Among these child folders there is the "functions" folder, which contains the package.json to update. This is the only way I managed to solve it.

@Jared-Prime
Copy link

Jared-Prime commented Feb 27, 2025

I continued having trouble after following the advice above. In my case, I discovered the firebase init tool created a stale TypeScript dependency. Changing that dependency to the correct ^5.7.3, and verifying I had updated the rest of the node packages, fixed the deployment.

I also got the warning mentioned above, which probably needs to be addressed.

@Walmircsanto
Copy link

O problema parece ser uma versão desatualizada do Typescript que é instalada por padrão no projeto criado usando firebase init. Para mim, ele instalou o Typescript 4.9.0. Executar npm i typescript@latesto upgrade para a v5.7.3 pareceu resolver o problema.

Esse método funcionou para mim também

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.