Conversation
|
Hi @donaldpipowitch, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution! TTYL, MSBOT; |
|
Related to #12870? |
|
Thanks for the PR. but as discussed in #12870, we do not believe this is a good change. |
|
Thank you for the fast reply, but I'm very sad to hear this. It makes working with const foo = {
bar: 'bar',
baz: 'baz'
};
Object.keys(foo).forEach(key => console.log(foo[key].length)); // error with noImplicitAnyTo fix this you need to write |
|
@mhegazy I can't really follow the arguments from #12870 and I'm not sure that is what I want in most cases. Can you give me an example written in TypeScript where my PR would behave bad? And if I want this behaviour wouldn't it be easier to do this than?: const foo = {
bar: 'bar',
baz: 'baz'
};
Object.keys(foo).forEach(key => console.log(foo[key as string].length)); |
function printProperties(foo: {}) {
Object.keys(foo).forEach(key => console.log(key.toString())); // Error toString does not exisit on `never`
}There is code that looks like this today. changing this would be a breaking change, and would not really provide much value. you can define your function: const keys = <{ <T>(o: T): Array<keyof T> }>Object.keys; |
function printProperties(foo: {}) {
Object.keys(foo).forEach(key => console.log(key.toString())); // Error toString does not exisit on `never`
}So if I say my But I'd argue that function printProperties(foo: { [s: string]: any; }) {
Object.keys(foo).forEach(key => console.log(key.toString()));
}I'd say that is more explicit and more correct.
Granted... if that is the case and you want to avoid a breaking change here, this PR could be postponed. But I'm still not convinced that this "works as intended" as labeled in #12870. |
|
@mhegazy Just would like to give some feedback. We use Are there proposals to add some kind of modifier or mapping to certain types? So I can map Or would it be possible to invent some special Or a totally different question: Currently it seems that my PR wasn't merged, because it could be a breaking change. Are there already plans for TypeScript 3.0 and maybe some lists where possible breaking changes could be collected and introduced? |
Before:
Now: