-
Notifications
You must be signed in to change notification settings - Fork 206
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
035f66c
commit ee9d00b
Showing
2 changed files
with
25 additions
and
29 deletions.
There are no files selected for viewing
34 changes: 16 additions & 18 deletions
34
...-plugin/test/__file_snapshots__/types/expect-error-range/expect-error-range-tests.ts.lint
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,39 +1,37 @@ | ||
types/expect-error-range/expect-error-range-tests.ts | ||
7:7 error [email protected] compile error: | ||
7:7 error [email protected] compile error: | ||
Type 'string | undefined' is not assignable to type 'string'. | ||
Type 'undefined' is not assignable to type 'string' @definitelytyped/expect | ||
9:7 error TypeScript@5.4, 5.5 compile error: | ||
Property 'trim' does not exist on type 'never' @definitelytyped/expect | ||
10:7 error [email protected] compile error: | ||
Type 'string' is not assignable to type 'never' @definitelytyped/expect | ||
|
||
✖ 2 problems (2 errors, 0 warnings) | ||
|
||
==== types/expect-error-range/expect-error-range-tests.ts ==== | ||
|
||
// In TypeScript <5.5, elem will have type "string", | ||
// but 5.5 it will be "string | number". | ||
const elem = ["value", undefined].filter(x => x != null)[0]; | ||
declare const test: typeof elem & undefined | ||
|
||
|
||
// These should give expect errors: | ||
|
||
const isStringNoIgnore: string = elem; | ||
~~~~~~~~~~~~~~~~ | ||
// This should error in 5.4, but not 5.5. | ||
const test1a: string = elem; | ||
~~~~~~ | ||
!!! @definitelytyped/expect: [email protected] compile error: | ||
!!! : Type 'string | undefined' is not assignable to type 'string'. | ||
!!! : Type 'undefined' is not assignable to type 'string'. | ||
|
||
test?.trim(); | ||
~~~~ | ||
!!! @definitelytyped/expect: [email protected], 5.5 compile error: | ||
!!! : Property 'trim' does not exist on type 'never'. | ||
|
||
// This should error in 5.5, but not 5.4. | ||
const test1b: undefined extends typeof elem ? typeof elem : never = elem; | ||
~~~~~~ | ||
!!! @definitelytyped/expect: [email protected] compile error: | ||
!!! : Type 'string' is not assignable to type 'never'. | ||
|
||
|
||
// These should give expect these should not: | ||
|
||
// None of these expects should error. | ||
|
||
// @ts-expect-error <5.5 | ||
const isStringIgnore: string = elem; | ||
|
||
const test2a: string = elem; | ||
|
||
// @ts-expect-error >=5.5 | ||
test?.trim(); | ||
const test2b: undefined extends typeof elem ? typeof elem : never = elem; |
20 changes: 9 additions & 11 deletions
20
packages/eslint-plugin/test/fixtures/types/expect-error-range/expect-error-range-tests.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 |
---|---|---|
@@ -1,21 +1,19 @@ | ||
// In TypeScript <5.5, elem will have type "string", | ||
// but 5.5 it will be "string | number". | ||
const elem = ["value", undefined].filter(x => x != null)[0]; | ||
declare const test: typeof elem & undefined | ||
|
||
|
||
// These should give expect errors: | ||
// This should error in 5.4, but not 5.5. | ||
const test1a: string = elem; | ||
|
||
const isStringNoIgnore: string = elem; | ||
// This should error in 5.5, but not 5.4. | ||
const test1b: undefined extends typeof elem ? typeof elem : never = elem; | ||
|
||
test?.trim(); | ||
|
||
|
||
|
||
// These should give expect these should not: | ||
|
||
// None of these expects should error. | ||
|
||
// @ts-expect-error <5.5 | ||
const isStringIgnore: string = elem; | ||
|
||
const test2a: string = elem; | ||
|
||
// @ts-expect-error >=5.5 | ||
test?.trim(); | ||
const test2b: undefined extends typeof elem ? typeof elem : never = elem; |