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

It is not possible compile to typescript #247

Open
wazzu3000 opened this issue Dec 2, 2024 · 2 comments
Open

It is not possible compile to typescript #247

wazzu3000 opened this issue Dec 2, 2024 · 2 comments
Labels
Needs: Author Feedback Issues awaiting author feedback

Comments

@wazzu3000
Copy link

wazzu3000 commented Dec 2, 2024

Version info

firebase-functions-test: 3.3.0

firebase-functions: 6.1.1

firebase-admin: 12.1.0

typescript: 4.9.0

Test case

At try to run any typescript compilation; I share with you a tiny example from my unit test code

My test script with Mocha

import firebaseFunctionsTest from 'firebase-functions-test';

describe('onCreateUser', () => {

  before(() => {
    firebaseFunctionsTest();
  });

  it('Hello world', async () => {
    // Test stuff
  });
});

tsconfig.json file

{
  "compilerOptions": {
    "module": "commonjs",
    "noImplicitReturns": true,
    "noUnusedLocals": true,
    "outDir": "lib",
    "sourceMap": true,
    "strict": true,
    "esModuleInterop": true,
    "target": "es2017",
    "typeRoots": [
      "node_modules/@types"
    ]
  },
  "compileOnSave": true,
  "include": [
    "src"
  ]
}

Steps to reproduce

  1. Create some test script using typescript
  2. run tsc

Expected behavior

The compilation should finish without errors

Actual behavior

The tsc returns the follow error messages, as you can see all of them are from firebase-functions-test definition files.

node_modules/firebase-functions-test/lib/main.d.ts:1:44 - error TS2305: Module '"firebase-functions"' has no exported member 'HttpsFunction'.

1 import { CloudFunction as CloudFunctionV1, HttpsFunction, Runnable } from 'firebase-functions';
                                             ~~~~~~~~~~~~~

node_modules/firebase-functions-test/lib/main.d.ts:1:59 - error TS2305: Module '"firebase-functions"' has no exported member 'Runnable'.   

1 import { CloudFunction as CloudFunctionV1, HttpsFunction, Runnable } from 'firebase-functions';
                                                            ~~~~~~~~

node_modules/firebase-functions-test/lib/main.d.ts:10:64 - error TS2344: Type 'T' does not satisfy the constraint 'CloudEvent<unknown>'.   

10 export declare function wrap<T>(cloudFunction: CloudFunctionV1<T>): WrappedScheduledFunction | WrappedFunction<T>;
                                                                  ~

  node_modules/firebase-functions-test/lib/main.d.ts:10:30
    10 export declare function wrap<T>(cloudFunction: CloudFunctionV1<T>): WrappedScheduledFunction | WrappedFunction<T>;
                                    ~
    This type parameter might need an `extends CloudEvent<unknown>` constraint.

node_modules/firebase-functions-test/lib/providers/analytics.d.ts:1:10 - error TS2305: Module '"firebase-functions"' has no exported member 'analytics'.

1 import { analytics } from 'firebase-functions';
           ~~~~~~~~~

node_modules/firebase-functions-test/lib/providers/auth.d.ts:1:10 - error TS2305: Module '"firebase-functions"' has no exported member 'auth'.

1 import { auth } from 'firebase-functions';
           ~~~~

node_modules/firebase-functions-test/lib/providers/pubsub.d.ts:11:5 - error TS2314: Generic type 'Message<T>' requires 1 type argument(s). 

11 }): pubsub.Message;
       ~~~~~~~~~~~~~~

node_modules/firebase-functions-test/lib/providers/pubsub.d.ts:19:5 - error TS2314: Generic type 'Message<T>' requires 1 type argument(s). 

19 }): pubsub.Message;
       ~~~~~~~~~~~~~~

node_modules/firebase-functions-test/lib/providers/pubsub.d.ts:21:43 - error TS2314: Generic type 'Message<T>' requires 1 type argument(s).

21 export declare function exampleMessage(): pubsub.Message;
                                             ~~~~~~~~~~~~~~

node_modules/firebase-functions-test/lib/providers/storage.d.ts:7:13 - error TS2694: Namespace '"C:/Users/RaulMendoza/Documents/JS/gasto-smart/functions/node_modules/firebase-functions/lib/v2/providers/storage"' has no exported member 'ObjectMetadata'.

7 }): storage.ObjectMetadata;
              ~~~~~~~~~~~~~~

node_modules/firebase-functions-test/lib/providers/storage.d.ts:9:58 - error TS2694: Namespace '"C:/Users/RaulMendoza/Documents/JS/gasto-smart/functions/node_modules/firebase-functions/lib/v2/providers/storage"' has no exported member 'ObjectMetadata'.

9 export declare function exampleObjectMetadata(): storage.ObjectMetadata;
                                                           ~~~~~~~~~~~~~~

node_modules/firebase-functions-test/lib/v1.d.ts:1:25 - error TS2305: Module '"firebase-functions"' has no exported member 'HttpsFunction'.

1 import { Change, https, HttpsFunction, Runnable } from 'firebase-functions';
                          ~~~~~~~~~~~~~

node_modules/firebase-functions-test/lib/v1.d.ts:1:40 - error TS2305: Module '"firebase-functions"' has no exported member 'Runnable'.

1 import { Change, https, HttpsFunction, Runnable } from 'firebase-functions';
@wazzu3000 wazzu3000 changed the title It is not possible compile from typescript It is not possible compile to typescript Dec 10, 2024
@wazzu3000
Copy link
Author

I think you could just update the imports from firebase-functions used into .d.ts files according the lastest firebase-functions version. This should fix the issue.

@CorieW
Copy link

CorieW commented Dec 20, 2024

Hey @wazzu3000,

Do you still get this issue when using 3.4.0?

@CorieW CorieW added the Needs: Author Feedback Issues awaiting author feedback label Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs: Author Feedback Issues awaiting author feedback
Projects
None yet
Development

No branches or pull requests

2 participants