-
-
Notifications
You must be signed in to change notification settings - Fork 67
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
dfa9bc0
commit 168de40
Showing
9 changed files
with
66 additions
and
1 deletion.
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
6 changes: 6 additions & 0 deletions
6
source/test/fixtures/expect-error/enabled-exact-optional-property-types/index.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,6 @@ | ||
export type OptionalProperty = { | ||
requiredProp: 'required'; | ||
optionalProp?: 'optional'; | ||
}; | ||
|
||
export function setWithOptionalProperty(obj: OptionalProperty): any; |
3 changes: 3 additions & 0 deletions
3
source/test/fixtures/expect-error/enabled-exact-optional-property-types/index.js
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; | ||
}; |
21 changes: 21 additions & 0 deletions
21
source/test/fixtures/expect-error/enabled-exact-optional-property-types/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,21 @@ | ||
import {expectError} from '../../../..'; | ||
import {OptionalProperty, setWithOptionalProperty} from '.'; | ||
|
||
expectError(() => { | ||
const obj: OptionalProperty = { | ||
requiredProp: 'required', | ||
// ts2375 - setting optional property to undefined | ||
optionalProp: undefined, | ||
}; | ||
}); | ||
|
||
expectError(setWithOptionalProperty({ | ||
requiredProp: 'required', | ||
// ts2379 - setting optional property to undefined in a parameter | ||
optionalProp: undefined, | ||
})); | ||
|
||
const obj: OptionalProperty = { requiredProp: 'required' }; | ||
|
||
// ts2412 - setting optional property to undefined by access | ||
expectError(obj.optionalProp = undefined); |
8 changes: 8 additions & 0 deletions
8
source/test/fixtures/expect-error/enabled-exact-optional-property-types/package.json
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 @@ | ||
{ | ||
"name": "foo", | ||
"tsd": { | ||
"compilerOptions": { | ||
"exactOptionalPropertyTypes": true | ||
} | ||
} | ||
} |
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