(TypeScript) Generic is not picked up properly
See original GitHub issueDescribe the issue
Which language seems to have the issue?
typescript, no auto-detection
Are you using highlight
or highlightAuto
?
I don’t know what this means.
Sample Code to Reproduce
I tried to reproduce the issue using your jsfiddle, but the typescript generic is not even displaying there ¯\(ツ)/¯.
~~https://jsfiddle.net/x3nzp2rf/~~
updated: https://jsfiddle.net/sm706vyd/2/
I have this code on StackOverflow.
first observed issue here: https://stackoverflow.com/questions/72794594/typescript-interface-merging-to-make-an-external-libs-interface-property-more-s/73527814#73527814
```lang-ts
import { useWeb3React as useWeb3React_ } from '@web3-react/core'
export const useWeb3React: <T = any>(key?: string) => Modify<
ReturnType<typeof useWeb3React_<T>>,
{ chainId: SupportedChainIds }
> = useWeb3React_ as any
declare global {
type SupportedChainIds = 1 | 4
}
```
Which produces incorrect syntax highlight
import { useWeb3React as useWeb3React_ } from '@web3-react/core'
export const useWeb3React: <T = any>(key?: string) => Modify<
ReturnType<typeof useWeb3React_<T>>,
{ chainId: SupportedChainIds }
> = useWeb3React_ as any
declare global {
type SupportedChainIds = 1 | 4
}
After a tweak I achieve correct syntax highlight
import { useWeb3React as useWeb3React_ } from '@web3-react/core'
export const useWeb3React: < T = any >(key?: string) => Modify<
ReturnType<typeof useWeb3React_<T>>,
{ chainId: SupportedChainIds }
> = useWeb3React_ as any
declare global {
type SupportedChainIds = 1 | 4
}
This is the tweak:
- export const useWeb3React: <T = any>(key?: string) => Modify<
+ export const useWeb3React: < T = any >(key?: string) => Modify<
Expected behavior
(without the spaces around < T = any >
- correct is: <T = any>
)
Actual behavior
Additional context
Issue Analytics
- State:
- Created a year ago
- Comments:10 (5 by maintainers)
As you see from the other issue it seems like if we add the
=
case that I think now we’re covering all the bases?#3604 might be a reasonable fix. Thoughts?