Skip to content

cannot enforce type shape when assigned to a conjunction #28642

Description

TypeScript Version: 3.1.6, 3.2.0-rc, 3.3.0-dev.20181121

Search Terms:
conjunction assignable wrong type

Code

declareconsta: {a: string;b: number}declareconstb: {a: string}&{b: number}declarefunctionf(x: {[k: string]: string}): voidf(a)// errorf(b)// NO error

Expected behavior:
Errors on both f(a) and f(b)

Actual behavior:
Errors only on f(a)

Playground Link:http://www.typescriptlang.org/play/#src=declare%20const%20a%3A%20%7B%20a%3A%20string%3B%20b%3A%20number%20%7D%0D%0Adeclare%20const%20b%3A%20%7B%20a%3A%20string%20%7D%20%26%20%7B%20b%3A%20number%20%7D%0D%0Adeclare%20function%20f(x%3A%20%7B%20%5Bk%3A%20string%5D%3A%20string%20%7D)%3A%20void%0D%0Af(a)%20%2F%2F%20error%0D%0Af(b)%20%2F%2F%20NO%20error

Related Issues:gcanti/io-ts#234 (comment)
gcanti/fp-ts-routing#37

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    In DiscussionNot yet reached consensusSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions