Skip to content

Conversation

tavelli
Copy link
Contributor

@tavelli tavelli commented Feb 17, 2018

causes compilation failure when using typescript

causes compilation failure when using typescript
@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed, please reply here (e.g. I signed it!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address on your commit. Check your existing CLA data and verify that your email is set on your git commits.
  • If your company signed a CLA, they designated a Point of Contact who decides which employees are authorized to participate. You may need to contact the Point of Contact for your company and ask to be added to the group of authorized contributors. If you don't know who your Point of Contact is, direct the project maintainer to go/cla#troubleshoot. The email used to register you as an authorized contributor must be the email used for the Git commit.
  • In order to pass this check, please resolve this problem and have the pull request author add another comment and the bot will run again. If the bot doesn't comment, it means it doesn't think anything has changed.

@tavelli
Copy link
Contributor Author

tavelli commented Feb 17, 2018

i signed it

@googlebot
Copy link

CLAs look good, thanks!

@nicolasgarnier
Copy link
Contributor

@tavelli Could you tell us a little more about the error that you are seeing with Typescript? (e.g. could you paste the error here?)

We added an ESLint rule to all projects that makes having a return statement inside promises mandatory to avoid some common errors that developer face when writing these return promises (e.g. forgetting to return a Promise or a chained/sub promise).

cc/ @inlined @tinaliang

@nicolasgarnier
Copy link
Contributor

FYI we added this as part of #306

@tavelli
Copy link
Contributor Author

tavelli commented Feb 19, 2018

@nicolasgarnier my bad i's actually tslint error not compile error, but it will cause deploy firebase deploy to fail if using default tslint config created during firebase init.

the lint error is:
ERROR: Expression has type void. Put it on its own line as a statement.

so it can also resolved by just moving return statement onto separate line after the console.log

return streamAsPromise.then(() => {
    console.log('Thumbnail created successfully');
    return;
})

@tavelli
Copy link
Contributor Author

tavelli commented Feb 19, 2018

or maybe log and return null similar to other statements above it? may also be good to catch and log in case of an error

return streamAsPromise
    .then(() => {
      console.log('Thumbnail created successfully');
      return null;
    })
    .catch(error => {
      console.log('Error creating thumbnail');
      return null;
    })

@inlined
Copy link
Member

inlined commented Feb 21, 2018

That looks good to me. I'd also accept inlined expressions as well (they're exempt from the always-return linter rule):

return streamAsPromise
    .then(() => console.log('Thumbnail created successfully'))
    .catch(err => console.error('Error creating thumbnail', err));

As some minor other fixes from my sample: always print your errors and print them to stderr.

@nicolasgarnier
Copy link
Contributor

I just added the return null; to your PR. Let's merge!

Thanks @tavelli !

@nicolasgarnier nicolasgarnier merged commit 39a6e09 into firebase:master Feb 27, 2018
@tavelli
Copy link
Contributor Author

tavelli commented Feb 27, 2018

Thanks!

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.

4 participants