Closed
Description
openedon Oct 4, 2017
TypeScript Version: nightly (2.6.0-dev.20171004)
Code
Many things broke (on unchanged code) when using lodash type definitions with latest nightly. The inferring is kinda broken (and it's not allowing parameters to be overloaded)
Expected behavior:
To work:
[].forEach((field: keyof Data.AddressDataSetMixin) => {
//...
})
//...
_.reduce(citizens, (name, citizen) => {
if (citizen.address && citizen.address.id === address.id) {
return citizen.name
}
return ''
}, '')
//...
const findBase = (field: string) => {
return _.find(definitions, (def) => def.field === field)!.id
}
Actual behavior:
Doesnt:
[].forEach((field: keyof Data.AddressDataSetMixin) => {
//...
/*
[ts]
Argument of type '(field: "number" | "id" | "name" | "date" | "type" | "street" | "full" | "picture" | "cadastrador...' is not assignable to parameter of type '(value: string, index: number, array: string[]) => void'.
Types of parameters 'field' and 'value' are incompatible.
Type 'string' is not assignable to type '"number" | "id" | "name" | "date" | "type" | "street" | "full" | "picture" | "cadastrador" | "las...'.
*/
})
//...
_.reduce(citizens, (name, citizen) => {
/*
Argument of type '(name: string, citizen: RemoteArrayProxy<CitizenDataSet>) => string | undefined' is not assignable to parameter of type 'MemoIterator<RemoteArrayProxy<CitizenDataSet>, string | undefined>'.
Types of parameters 'name' and 'prev' are incompatible.
Type 'string | undefined' is not assignable to type 'string'.
Type 'undefined' is not assignable to type 'string'.'
*/
if (citizen.address && citizen.address.id === address.id) {
return citizen.name
}
return ''
}, '')
// ...
const findBase = (field: string) => {
/*
Property 'field' does not exist on type '{}'
*/
return _.find(definitions, (def) => def.field === field)!.id
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment