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

(regressions) Property 'something' does not exist on type '{}' and Types of parameters 'field' and 'value' are incompatible #18941

Closed
pocesar opened this issue Oct 4, 2017 · 2 comments
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug

Comments

@pocesar
Copy link

pocesar commented 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
}
@ghost
Copy link

ghost commented Oct 4, 2017

Was probably broken by #18654? See if setting "strictFunctionTypes": false works.

@mhegazy mhegazy added the Needs More Info The issue still hasn't been fully clarified label Oct 4, 2017
@pocesar
Copy link
Author

pocesar commented Oct 4, 2017

yes, it works

@pocesar pocesar closed this as completed Oct 4, 2017
@ghost ghost added Working as Intended The behavior described is the intended behavior; this is not a bug and removed Needs More Info The issue still hasn't been fully clarified labels Oct 4, 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
Working as Intended The behavior described is the intended behavior; this is not a bug
Projects
None yet
Development

No branches or pull requests

2 participants