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

Weak type detection only works with object literals being passed #17656

Copy link
Copy link
@ownerer

Description

@ownerer
Issue body actions

TypeScript Version: 2.4.0

Code

interface ITest {
    optional?: string;
}

function test(param: ITest): void {

}

class Test {

}

test({ whatever: 0, optional: "" }); //<-- compiler doesn't allow this
test(test); //<-- compiler allows this
test(Test); //<-- compiler allows this
test(new Test()); //<-- compiler allows this

Expected behavior:
Passing any object of any type that doesn't match with at least one of the properties defined in the weak type, should fail.

Actual behavior:
Only object literals that don't at least partially match are not allowed to be passed.

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue

    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.