Skip to content

[BUG] Fix Type Error in Slack postReplyInThread Method #3895

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

Open
2 tasks done
YashGupt29 opened this issue Mar 15, 2025 · 0 comments · May be fixed by #3896
Open
2 tasks done

[BUG] Fix Type Error in Slack postReplyInThread Method #3895

YashGupt29 opened this issue Mar 15, 2025 · 0 comments · May be fixed by #3896
Labels

Comments

@YashGupt29
Copy link

Describe the bug.

The postReplyInThread method in netlify/functions/save-discussion-background/Slack.ts has a TypeScript error due to incompatible types in the Slack Web API call:

Argument of type '{ channel: string; text: string; as_user: true; thread_ts: string; icon_url: string; }' is not assignable to parameter of type 'ChatPostMessageArguments'.
  Types of property 'icon_url' are incompatible.
    Type 'string' is not assignable to type 'undefined'.

Current Behavior

  • When posting a reply in a Slack thread, we're trying to set both as_user: true and icon_url
  • This causes a type error because when posting as a user (as_user: true), Slack automatically uses the user's profile picture
  • The code currently attempts to override this with a custom icon URL, which is not allowed by the API

Expected behavior

  • Messages should be posted as the authenticated user with their profile picture
  • No type errors in the TypeScript compilation

Screenshots

Image

How to Reproduce

View Error:

# Run TypeScript check on the specific file
npx tsc netlify/functions/save-discussion-background/Slack.ts --noEmit

The type error will appear:

Error: Argument of type '{ channel: string; text: string; as_user: true; thread_ts: string; icon_url: string; }' is not assignable to parameter of type 'ChatPostMessageArguments'.
Types of property 'icon_url' are incompatible.
 Type 'string' is not assignable to type 'never'.

🥦 Browser

None

👀 Have you checked for similar open issues?

  • I checked and didn't find similar issue

🏢 Have you read the Contributing Guidelines?

Are you willing to work on this issue ?

Yes I am willing to submit a PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant