Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Trying to implement Logic using the the type-system #35320

Copy link
Copy link
@damodharanj

Description

@damodharanj
Issue body actions
type Bool = 'true' | 'false'

type Or<A extends Bool, B extends Bool> = A extends 'true' ? 'true' : B;

type And<A extends Bool, B extends Bool> = A extends 'true' ? B extends 'true' ? 'true' : 'false' : 'false';

type Not<T extends Bool> = T extends 'true' ? 'false' : 'true';

type Test = Not<'true'>

type Test1 = Not<'false'>

type Test3 = Not<Or<'true', 'false'>>

type Test4 = And<Not<'true'>, Not<'false'>>

function test(a: Bool): Not <typeof a> {
    switch (a) {
        case 'false': return 'false';
        case 'true': return 'true';
    }
}

The test function is supposed to return 'true' for input 'false' and vice-versa. But I don't get a error for the above implementation.

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.