-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Array.length type guard for array spreading #28837
Copy link
Copy link
Open
Labels
Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featureThis means we'd like to hear from more people who would be helped by this featureSuggestionAn idea for TypeScriptAn idea for TypeScript
Description
TypeScript Version: 3.3.0-dev.20181204
Search Terms: array length type guard spread
Code
const timeString = '09:00';
const date = new Date();
const timeParts = timeString.split(':').map((part) => parseInt(part, 10));
if (timeParts.length > 0) {
date.setHours(...timeParts);
}Expected behavior: No errors
Actual behavior: TS2556: Expected 1-4 arguments, but got 0 or more.
Related Issues: None
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featureThis means we'd like to hear from more people who would be helped by this featureSuggestionAn idea for TypeScriptAn idea for TypeScript