We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
https://replit.com/join/cwiubczice-kdevay
interface Message { text: string; isBot: boolean; } interface ConversationProps { messages?: Message[]; } const Conversation: React.FC<ConversationProps> = ({ messages }) => { return ( <div id="conversation" className="flex flex-col gap-2 h-conversation overflow-y-scroll text-white" > {Boolean(messages && messages.length) && messages.map((message, index) => ( <div key={index} className="flex flex-row w-full" > <div> `${message.isBot ? '🤖' : 'you'}: ${message.text}` </div> </div> ))} </div> ); }; export default Conversation;
I am seeing a red squiggle on messages.map stating that it is possibly undefined
messages.map
I should not see any error, because I performed this check: Boolean(messages && messages.length) .
Boolean(messages && messages.length)
I do not see an error message when I add the check without the Boolean constructor, like
{(messages && messages.length) && messages.map((message, index) => (
TypeScript Version 5.4.3
Visual Studio Code Version: 1.89.0 (Universal) Commit: b58957e67ee1e712cebf466b995adf4c5307b2bd Date: 2024-05-01T02:10:10.196Z Electron: 28.2.8 ElectronBuildId: 27744544 Chromium: 120.0.6099.291 Node.js: 18.18.2 V8: 12.0.267.19-electron.0 OS: Darwin arm64 23.4.0
My Machine Model: Macbook pro Chip: Apple M2 OS: Sonoma 14.4
The text was updated successfully, but these errors were encountered:
More or less the same as #16655
Sorry, something went wrong.
This issue has been marked as "Duplicate" and has seen no recent activity. It has been automatically closed for house-keeping purposes.
No branches or pull requests
🔎 Search Terms
🕗 Version & Regression Information
⏯ Playground Link
https://replit.com/join/cwiubczice-kdevay
💻 Code
🙁 Actual behavior
I am seeing a red squiggle on

messages.map
stating that it is possibly undefined🙂 Expected behavior
I should not see any error, because I performed this check:
Boolean(messages && messages.length)
.I do not see an error message when I add the check without the Boolean constructor, like
Additional information about the issue
TypeScript
Version 5.4.3
Visual Studio Code
Version: 1.89.0 (Universal)
Commit: b58957e67ee1e712cebf466b995adf4c5307b2bd
Date: 2024-05-01T02:10:10.196Z
Electron: 28.2.8
ElectronBuildId: 27744544
Chromium: 120.0.6099.291
Node.js: 18.18.2
V8: 12.0.267.19-electron.0
OS: Darwin arm64 23.4.0
My Machine
Model: Macbook pro
Chip: Apple M2
OS: Sonoma 14.4
The text was updated successfully, but these errors were encountered: