svelte-adapter-firebase icon indicating copy to clipboard operation
svelte-adapter-firebase copied to clipboard

bug: 'ssrServerServer' implicitly has type 'any'

Open slifty opened this issue 3 years ago • 2 comments

Describe the Bug

When I build the /functions directory in a project that is configured to use typescript and use the recommended CLI output I face type issues:


$ yarn --cwd ./functions run build
$ tsc
src/index.ts:6:5 - error TS7034: Variable 'ssrServerServer' implicitly has type 'any' in some locations where its type cannot be determined.

6 let ssrServerServer;
      ~~~~~~~~~~~~~~~

src/index.ts:8:7 - error TS7005: Variable 'ssrServerServer' implicitly has an 'any' type.

8  if (!ssrServerServer) {
        ~~~~~~~~~~~~~~~

Found 2 errors in the same file, starting at: src/index.ts:

This is due to the fact that the default CLI code is doing a few unsafe things (for one thing it's referencing a file that does not exist until after compile!). Even if I do move the file over it's a js file without type definitions.

Steps to Reproduce

  1. Create a typescript sveltekit project
  2. Set up firebase init for functions with typescript enabled
  3. Run build; follow CLI insertion instructions
  4. Build the functions

Expected Behaviour

I would expect the inserted ssrServer code to either (A) be written in TypeScript or (B) include type definitions.

svelte-adapter-firebase version

0.14.4

sveltejs/kit version

1.0.0-next.488

slifty avatar Oct 10 '22 19:10 slifty

I did fix this locally by changing

let ssrServerServer;

to

let ssrServerServer: Function;

Though this still feels pretty unsafe to me and it would be excellent typescript was more directly supported (I see #8 is already open)

slifty avatar Oct 10 '22 19:10 slifty

TypeScript Functions is not yet supported by the adapter. Thanks for sharing your solution. Unfortunately, I have no ETA on TS support.

jthegedus avatar Dec 14 '22 11:12 jthegedus