Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interface stop working after passing an optional function attribute #43142

Open
Char2sGu opened this issue Mar 8, 2021 · 0 comments
Open

Interface stop working after passing an optional function attribute #43142

Char2sGu opened this issue Mar 8, 2021 · 0 comments
Labels
Bug A bug in TypeScript
Milestone

Comments

@Char2sGu
Copy link

Char2sGu commented Mar 8, 2021

Bug Report

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried.

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

interface Options<Self extends Options<Self>> {
    attr1: Record<string, null>;
    attr2: keyof Self["attr1"];
    attr3?: (arg: any) => any;
}

function test<T extends Options<T>>(options: T) {
    return options
}

test({
    attr1: {
        a: null,
    },
    attr2: "a", // here I got the expected auto-completion hint and the type is `a`.
});

test({
    attr1: {
        a: null,
    },
    attr2: "a", // here the type is `never` and a problem is caused
    attr3: (arg) => arg,
});

πŸ™ Actual behavior

πŸ™‚ Expected behavior

@RyanCavanaugh RyanCavanaugh added the Bug A bug in TypeScript label Mar 8, 2021
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Mar 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript
Projects
None yet
Development

No branches or pull requests

2 participants