-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Open
Labels
Needs ProposalThis issue needs a plan that clarifies the finer details of how it could be implemented.This issue needs a plan that clarifies the finer details of how it could be implemented.SuggestionAn idea for TypeScriptAn idea for TypeScript
Description
TypeScript Version: 2.7.0-dev.201xxxxx
Code
// An object to hold all the possible options
type AllOptions = {
startDate: Date
endDate: Date
author: number
}
// Any combination of startDate, endDate can be used
type DateOptions =
| Pick<AllOptions, 'startDate'>
| Pick<AllOptions, 'endDate'>
| Pick<AllOptions, 'startDate' | 'endDate'>
type AuthorOptions = Pick<AllOptions, 'author'>
type AllowedOptions = DateOptions | AuthorOptions
const options: AllowedOptions = {
startDate: new Date(),
author: 1
}
Expected behavior:
An error that options
cannot be coerced into type AllowedOptions
because startDate
and author
cannot appear in the same object.
Actual behavior:
It compiles fine.
topaxi, falsandtru, thisBrian, danvk, JasonGore and 45 more
Metadata
Metadata
Assignees
Labels
Needs ProposalThis issue needs a plan that clarifies the finer details of how it could be implemented.This issue needs a plan that clarifies the finer details of how it could be implemented.SuggestionAn idea for TypeScriptAn idea for TypeScript