-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
String literal not assignable to type of the same value, forcing me to cast #16259
Comments
Duplicate of #10570. I do appreciate that you tried to look it up. It wasn't easy for me to dig up either. 😄 |
I have a very similar problem, although not related to implementing Interfaces, just to compatibility between string literal type and string literal values. See this very simple example:
|
type MyType = {
myLiteral: 'yas' | 'nope';
};
function doSomething(productData: MyType): void {}
doSomething({
myLiteral: 'yas'
}); This is because TypeScript can easily statically determine that the const data: MyType = {
myLiteral: 'yas'
};
type MyType = {
myLiteral: 'yas' | 'nope';
};
function doSomething(productData: MyType): void {}
doSomething(data); These sort of general questions are better asked on StackOverflow or in Gitter. |
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed. |
Unfortunately the referenced duplicate seems to have gone dead. Any chance it can get attention? |
I'm not sure if this has been brought up already and I'm just not plugging in the right search terms, but I feel like the compiler is forcing me to do a possibly redundant type annotation with string literal types.
TypeScript Version: 2.3.3
Expected behavior: Basically I expect that
action
in myBusReducer
subtype not require its type be explicitly declared as the interface contains everything the lookup should need to successfully match on the constant value.The text was updated successfully, but these errors were encountered: