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

TS not indicating type missmatches #12914

Closed
glazar opened this issue Dec 14, 2016 · 2 comments
Closed

TS not indicating type missmatches #12914

glazar opened this issue Dec 14, 2016 · 2 comments
Labels
Duplicate An existing issue was already created

Comments

@glazar
Copy link

glazar commented Dec 14, 2016

TypeScript Version: 2.1.1 / nightly (2.2.0-dev.201xxxxx)

Code

interface Input {
  text?: string;
}

const test = (input: Input): string => {
  return "";
};

test("test");

Expected behavior:
Type mismatch indicated.
It works if I make the Input Interface text member non-optional.
Actual behavior:
No type mismatch indicated.
It works if I make the Input Interface text member non-optional.

@normalser
Copy link

It's because string is assignable to {}

const a:{} = "test"

Hence it is assignable to:

const a: { text?: string } = "test"

You might be interested in #12501 #1809

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Dec 14, 2016
@RyanCavanaugh
Copy link
Member

Duplicate #9841, etc.

Which search terms did you use before logging this? We're trying to reduce duplicates/questions and are curious what people are searching (and why they're not finding the existing issues) when logging bugs. Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

4 participants