-
-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add expectAssignable expectation - fixes #39
- Loading branch information
1 parent
206573b
commit 0968824
Showing
7 changed files
with
49 additions
and
0 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
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,12 @@ | ||
import * as path from 'path'; | ||
import test from 'ava'; | ||
import {verify} from './fixtures/utils'; | ||
import tsd from '..'; | ||
|
||
test('assignable', async t => { | ||
const diagnostics = await tsd({cwd: path.join(__dirname, 'fixtures/assignability/assignable')}); | ||
|
||
verify(t, diagnostics, [ | ||
[8, 26, 'error', 'Argument of type \'string\' is not assignable to parameter of type \'boolean\'.'] | ||
]); | ||
}); |
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,6 @@ | ||
declare const concat: { | ||
(foo: string, bar: string): string; | ||
(foo: number, bar: number): number; | ||
}; | ||
|
||
export default concat; |
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,3 @@ | ||
module.exports.default = (foo, bar) => { | ||
return foo + bar; | ||
}; |
8 changes: 8 additions & 0 deletions
8
source/test/fixtures/assignability/assignable/index.test-d.ts
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,8 @@ | ||
import {expectAssignable} from '../../../..'; | ||
import concat from '.'; | ||
|
||
expectAssignable<string | number>(concat('foo', 'bar')); | ||
expectAssignable<string | number>(concat(1, 2)); | ||
expectAssignable<any>(concat(1, 2)); | ||
|
||
expectAssignable<boolean>(concat('unicorn', 'rainbow')); |
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,6 @@ | ||
{ | ||
"name": "foo", | ||
"dependencies": { | ||
"rxjs": "^6.5.3" | ||
} | ||
} |