tslint

Firebase cloud function typescript error “Not all code paths return a value”

前提是你 提交于 2021-01-27 23:48:39
问题 I am using firebase cloud function and firestore transaction to decrease the available quantity of product based on purchases. At the time of deploy it returns the error "error TS7030: Not all code paths return a value" Here is the code import * as functions from 'firebase-functions'; import * as admin from 'firebase-admin'; admin.initializeApp(); const db = admin.firestore() exports.newOrder = functions.firestore .document('orders/{orderId}') .onCreate(async (snap, context) => { try { const

How to use `@ts-ignore` for a block

泄露秘密 提交于 2020-12-27 08:07:53
问题 The // @ts-ignore comment enables the Typescript compiler to ignore the line below it. How can one ignore a whole block of code with Typescript? 回答1: You can't. This is an open issue in TypeScript: https://github.com/Microsoft/TypeScript/issues/19573 回答2: You can't. As a workaround you can use a // @ts-nocheck comment at the top of a file to disable type-checking for that file: https://devblogs.microsoft.com/typescript/announcing-typescript-3-7-beta/ So to disable checking for a block