#TS7053 Element implicitly has an 'any' type

26 messages · Page 1 of 1 (latest)

covert crown
#

Hello, i need help for this code :

function sortByColumnKey(column: IdentifiantColumn) {
  column.order = !column.order;
  computedIdentifiantManager.value.identifiants.sort(
    (a: Identifiant, b: Identifiant) => {
      const columnKey: keyof Identifiant = column.code as keyof Identifiant;
      const aValue = a[columnKey].toString();
      const bValue = b[columnKey].toString();
      return column.order
        ? aValue.localeCompare(bValue)
        : bValue.localeCompare(aValue);
    }
  );
}

On the build it always explode with this message twice :

  No index signature with a parameter of type 'string' was found on type 'Identifiant'.```

I typed everything and i cannot understand how the f** it throw this error of compilation...
I know it come from the A and B value key, but why ?
i tried all solution of casting to any everything it never change
#

TS7053 Element implicitly has an 'any' type

fringe robin
#

i tried to reproduce your error but was unable to. i had to stub out some stuff though. maybe you can take a look at this and adjust it to be more like your real code so that it demonstrates that error?

gloomy jungleBOT
#
mkantor#0

Preview:```ts
type IdentifiantColumn = {
type: "IdentifiantColumn"
code: unknown
order: boolean
}
type Identifiant = {type: "Identifiant"}
declare const computedIdentifiantManager: {
value: {identifiants: Identifiant[]}
}

function sortByColumnKey(column: IdentifiantColumn) {
...```

gloomy jungleBOT
#
zelytra#0

Preview:```ts
interface IdentifiantColumn {
label: string
code: keyof Identifiant
visible: boolean
order: boolean
tooltip: string
}

interface Identifiant {
key: string
display: string
field: string
id: string
}

declare const computedIdentifiantManager: {
value: {identifiants: Identifiant[]}
}
...```

covert crown
#

i have any error on execution, it just dont work on compilation

fringe robin
#

@covert crown there's no error in that playground though?

covert crown
#

no error

#

i dont understand why on compilation it throw me this

fringe robin
#

but you do have an error from typescript on your machine?

covert crown
#

nop

fringe robin
#

the playground uses tsc

covert crown
#

no ide error or wraning

fringe robin
#

how are you compiling exactly? like what command are you running?

covert crown
#

"build": "vue-tsc && vite build",

fringe robin
#

and the error comes vue-tsc? like if you just run that you see the error?

covert crown
#

i try

#

same error

#

with only vue-tsc

fringe robin
#

i need to step away for a bit, but i would suggest also trying to just run tsc and see if that also produces the error. if not then there's some difference between what happens with the official compiler vs whatever vue-tsc does (maybe different typescript versions or different configuration). if you also see the error with tsc then there's some difference between what happens with the compiler when you run it outside of your IDE vs the TS language services in your IDE

covert crown
#

Only using TSC, print a bunch of error related to vue language. i continue investigation thank you for your help

stone coyote
#

I think you need to add on the columnKey's value as keyof typeof Identifiant

#

Because if you don't use the variable columnKey and instead use directly column.code you will need to specify as keyof typeof

covert crown
#

You know what ? I restar the computer and it work...

severe lion
#

!resolve