Skip to content

Weak Type Detection - not being detected with const #18250

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

Closed
alan-agius4 opened this issue Sep 5, 2017 · 1 comment
Closed

Weak Type Detection - not being detected with const #18250

alan-agius4 opened this issue Sep 5, 2017 · 1 comment
Labels
Question An issue which isn't directly actionable in code

Comments

@alan-agius4
Copy link
Contributor

alan-agius4 commented Sep 5, 2017

TypeScript Version: 2.5.2

Code

function foo(_opts: Options) {
    // do something;
    return;
}

interface Options {
    data?: any;
    show?: boolean;
}

interface OptionsExtended extends Options {
    title?: string;
}

const opts = {
    show: true,
    title: "title"
};

// this works
foo(opts);

// this doesn't
foo({
    show: true,
    title: "title"
});

Expected behavior:
Both of them to emit an error

Actual behavior:
the first one works and doesn't emit an error

@kitsonk
Copy link
Contributor

kitsonk commented Sep 5, 2017

This doesn't have to do with weak type detection. This has to do with excess property checks between fresh object literals and inferred types. I just explained it here.

@RyanCavanaugh RyanCavanaugh added the Question An issue which isn't directly actionable in code label Sep 5, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Question An issue which isn't directly actionable in code
Projects
None yet
Development

No branches or pull requests

3 participants