-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Strict bind, call, and apply methods on functions #27028
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
46bd405
Better scheme for choosing between co- and contra-variant inferences
ahejlsberg df83784
Accept new baselines
ahejlsberg 22a384d
New --strictBindCallApply flag in compiler
ahejlsberg 55b6513
New CallableFunction and NewableFunction types in es5.d.ts
ahejlsberg a85b896
Accept new baselines
ahejlsberg b687d90
Add CallableFunction/NewableFunction to virtual file system
ahejlsberg 1e3625c
Accept new baselines
ahejlsberg a5dece3
Update declarations
ahejlsberg d069da2
Update getAugmentedPropertiesOfType
ahejlsberg e9679f0
Add tests
ahejlsberg 8a41f5f
Accept new baselines
ahejlsberg 91123fc
Minor fix
ahejlsberg b67a261
Merge branch 'master' into typedBindCallApply
ahejlsberg 0226b66
Accept new baselines
ahejlsberg 52293ed
Fix inference when source and target both have rest parameters
ahejlsberg 2e17deb
Prefer error candidates with no rest parameters over those with
ahejlsberg df1e33a
Add 'bind' overloads for rest parameter arrays
ahejlsberg 339f310
Accept new baselines
ahejlsberg 9414fbe
Merge branch 'master' into typedBindCallApply
ahejlsberg 5510e07
Merge branch 'master' into typedBindCallApply
ahejlsberg b6e66c2
Accept new baselines
ahejlsberg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
tests/baselines/reference/booleanLiteralsContextuallyTypedFromUnion.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
error TS2318: Cannot find global type 'CallableFunction'. | ||
error TS2318: Cannot find global type 'NewableFunction'. | ||
|
||
|
||
!!! error TS2318: Cannot find global type 'CallableFunction'. | ||
!!! error TS2318: Cannot find global type 'NewableFunction'. | ||
==== tests/cases/compiler/booleanLiteralsContextuallyTypedFromUnion.tsx (0 errors) ==== | ||
interface A { isIt: true; text: string; } | ||
interface B { isIt: false; value: number; } | ||
type C = A | B; | ||
const isIt = Math.random() > 0.5; | ||
const c: C = isIt ? { isIt, text: 'hey' } : { isIt, value: 123 }; | ||
const cc: C = isIt ? { isIt: isIt, text: 'hey' } : { isIt: isIt, value: 123 }; | ||
|
||
type ComponentProps = | ||
| { | ||
optionalBool: true; | ||
mandatoryFn: () => void; | ||
} | ||
| { | ||
optionalBool: false; | ||
}; | ||
|
||
let Funk = (_props: ComponentProps) => <div>Hello</div>; | ||
|
||
let Fail1 = () => <Funk mandatoryFn={() => { }} optionalBool={true} /> | ||
let Fail2 = () => <Funk mandatoryFn={() => { }} optionalBool={true as true} /> | ||
let True = true as true; | ||
let Fail3 = () => <Funk mandatoryFn={() => { }} optionalBool={True} /> | ||
let attrs2 = { optionalBool: true as true, mandatoryFn: () => { } } | ||
let Success = () => <Funk {...attrs2} /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably shouldn’t get an error here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't want to update the private lib.d.ts used by the tests as I suspect that'll cause some really noisy baseline changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, just wanted to make sure this error wouldn't show up in some public-facing scenario.