-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(Attribute): значение атрибута не должно быть undefined
- Loading branch information
Showing
3 changed files
with
90 additions
and
5 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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { expectType, expectNotType } from 'tsd' | ||
import { Attribute, AttributePatch, AttributeType } from '../../src' | ||
|
||
const t10_1 = {} as Attribute | ||
|
||
if (t10_1.type === AttributeType.Boolean) { | ||
expectType<boolean>(t10_1.value) | ||
} | ||
|
||
const t11_1 = {} as AttributePatch | ||
|
||
expectType<'attributemetadata'>(t11_1.meta.type) | ||
|
||
// @ts-expect-error value maybe undefined if file specified | ||
t11_1.value | ||
|
||
if ('value' in t11_1) { | ||
// @ts-expect-error Поле `file` не определено если указано `value` | ||
t11_1.file | ||
|
||
// value не должен быть undefined, если он указан | ||
expectType<never>({} as any as Extract<typeof t11_1['value'], undefined>) | ||
|
||
expectType<null>({} as any as Extract<typeof t11_1['value'], null>) | ||
} | ||
|
||
if ('file' in t11_1) { | ||
// @ts-expect-error Поле `value` не определено если указано `file` | ||
t11_1.value | ||
|
||
// value не должен быть undefined, если он указан | ||
expectType<never>({} as any as Extract<typeof t11_1['file'], undefined>) | ||
|
||
expectType<null>({} as any as Extract<typeof t11_1['file'], null>) | ||
} |
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