-
-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add parameter inference for passing as argument, getting a property f…
…rom and calling
- Loading branch information
1 parent
e69e2c5
commit d4142fe
Showing
19 changed files
with
383 additions
and
250 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,45 @@ | ||
Currently implementing: | ||
|
||
> This file is for work-in-progress and can help separating features that are being implemented to regressions | ||
### Constraint inference | ||
|
||
> Aka backwards inference | ||
#### From argument | ||
|
||
```ts | ||
function cos(a) { | ||
return Math.cos(a) | ||
} | ||
|
||
cos satisfies (a: number) => number; | ||
cos(2); | ||
cos("hi") | ||
``` | ||
|
||
- Argument of type "hi" is not assignable to parameter of type number | ||
|
||
#### Property access | ||
|
||
```ts | ||
function printName(a) { | ||
return a.name | ||
} | ||
|
||
printName satisfies string; | ||
``` | ||
|
||
- Expected string, found (a: { name: any }) => any | ||
|
||
#### Function call | ||
|
||
```ts | ||
function printName(a) { | ||
return a(1, 2) | ||
} | ||
|
||
printName satisfies string; | ||
``` | ||
|
||
- Expected string, found (a: (a: 1, b: 2) => any) => any |
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
Oops, something went wrong.