jae-hyeon-and-children / sponer

스포너
4 stars 0 forks source link

Type 'IResponse' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value. #14

Open Ujaa opened 3 months ago

Ujaa commented 3 months ago
          ```

Type 'IResponse' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value.


```ts
async function getProducts(): IResponse<IProduct[]> {
  try {
    const productsDocSnap = await getDocs(
      query(
        collection(fireStore, COLLECTION_NAME_PRODUCT),
        orderBy("createdAt", "desc")
      )
    );
    const products = [];

    for (const product of productsDocSnap.docs) {
      const convertedProduct = ProductConverter.fromFirestore(product);
      products.push(convertedProduct);
    }

    return { status: 200, success: true, data: products };
  } catch (error) {
    return {
      status: 200,
      success: false,
      message: `Error white fetching products: ${error}`,
    };
  }
}
import { IProduct } from "./product";

export interface IResponse<T> {
  status: number;
  success: boolean;
  message?: string;
  data?: T;
}

Originally posted by @Ujaa in https://github.com/jae-hyeon-and-children/sponer/issues/3#issuecomment-2120921954

Ujaa commented 3 months ago
"target": "ES2020",

@ruehan 님이 알려줌