tomblachut / svelte-intellij

Svelte components in WebStorm and friends
MIT License
482 stars 38 forks source link

Method expression is not of Function type error #201

Closed btakita closed 3 years ago

btakita commented 3 years ago

Using a type that defines a function type with generics, causes the "Method expression is not of Function type" error. Defining a function type directly will cause the error to go away.

export type FN_type<O> = (arg:object)=>O
export type output_type = string
export function my_fn<O>(out:O):FN_type<O> {
  return (arg:object)=>out
}
export const my_str:FN_type<string> = my_fn('my string')

The following will have a "Method expression is not of Function type" error.

<script lang=ts>
const fn = my_str({})
</script>

If the my_str type is defined directly as a Function, then there is no error.

export type FN_type<O> = (arg:object)=>O
export type output_type = string
export function my_fn<O>(out:O):FN_type<O> {
  return (arg:object)=>out
}
export const my_str:(arg:object)=>string = my_fn('my string')
btakita commented 3 years ago

I moved this issue to https://youtrack.jetbrains.com/issue/IDEA-263809