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

Incorrect Typescript Indentation for Generic Functions Call #5764

Open
Miloas opened this issue Dec 5, 2023 · 2 comments
Open

Incorrect Typescript Indentation for Generic Functions Call #5764

Miloas opened this issue Dec 5, 2023 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@Miloas
Copy link

Miloas commented Dec 5, 2023

Describe the bug

The indentation of generic function call is not correct.

To Reproduce

  1. Create a index.ts file with the following content:
function applyF<T>(arg: T, f: Function): T {
  return f(arg);
}

applyF<{
  body: string
}>({ body: 'hello'}, () => {})
  1. Type enter in second applyF argument function body. It will result in the following output:
function applyF<T>(arg: T, f: Function): T {
  return f(arg);
}

applyF<{
  body: string
}>({ body: 'hello'}, () => {
    
  })

Expected behavior

function applyF<T>(arg: T, f: Function): T {
  return f(arg);
}

applyF<{
  body: string
}>({ body: 'hello'}, () => {
  
})

Output of :checkhealth nvim-treesitter

==============================================================================
nvim-treesitter: require("nvim-treesitter.health").check()

Installation ~
- OK `tree-sitter` found 0.20.8 (parser generator, only needed for :TSInstallFromGrammar)
- OK `node` found v21.3.0 (only needed for :TSInstallFromGrammar)
- OK `git` executable found.
- OK `cc` executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl", "zig" }
  Version: Apple clang version 15.0.0 (clang-1500.1.0.2.5)
- OK Neovim was compiled with tree-sitter runtime ABI version 14 (required >=13). Parsers must be compatible with runtime ABI.

OS Info:
{
  machine = "arm64",
  release = "23.2.0",
  sysname = "Darwin",
  version = "Darwin Kernel Version 23.2.0: Wed Nov 15 22:11:37 PST 2023; root:xnu-10002.61.2.505.1~2/RELEASE_ARM64_T8103"
} ~

Parser/Features         H L F I J
  - bash                ✓ ✓ ✓ . ✓
  - c                   ✓ ✓ ✓ ✓ ✓
  - go                  ✓ ✓ ✓ ✓ ✓
  - html                ✓ ✓ ✓ ✓ ✓
  - javascript          ✓ ✓ ✓ ✓ ✓
  - json                ✓ ✓ ✓ ✓ .
  - lua                 ✓ ✓ ✓ ✓ ✓
  - markdown            ✓ . ✓ ✓ ✓
  - markdown_inline     ✓ . . . ✓
  - python              ✓ ✓ ✓ ✓ ✓
  - query               ✓ ✓ ✓ ✓ ✓
  - rust                ✓ ✓ ✓ ✓ ✓
  - svelte              ✓ . ✓ ✓ ✓
  - swift               ✓ ✓ . ✓ .
  - tsx                 ✓ ✓ ✓ ✓ ✓
  - typescript          ✓ ✓ ✓ ✓ ✓
  - vim                 ✓ ✓ ✓ . ✓
  - vimdoc              ✓ . . . ✓
  - yaml                ✓ ✓ ✓ ✓ ✓
  - zig                 ✓ . ✓ ✓ ✓

  Legend: H[ighlight], L[ocals], F[olds], I[ndents], In[j]ections
         +) multiple parsers found, only one will be used
         x) errors found in the query, try to run :TSUpdate {lang} ~

Output of nvim --version

nvim --version
NVIM v0.9.4
Build type: Release
LuaJIT 2.1.1700008891

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/opt/homebrew/Cellar/neovim/0.9.4/share/nvim"

Run :checkhealth for more info

Additional context

No response

@Miloas Miloas added the bug Something isn't working label Dec 5, 2023
@Miloas
Copy link
Author

Miloas commented Dec 5, 2023

The indentation is correct if I remove the generic

function applyF(arg: any, f: Function): any {
  return f(arg);
}

applyF({ body: 'hello'}, () => {
  
})

This also is correct

function applyF<T>(arg: T, f: Function): T {
  return f(arg);
}

type Arg = {
  body: string
}

applyF<Arg>({ body: 'hello'}, () => {
  
})

@lucario387 lucario387 self-assigned this Dec 5, 2023
@lucario387
Copy link
Member

lucario387 commented Dec 5, 2023

encountered and is messed aroudn with it. Will try to improve

Edit: Don't expect much progress on this before Christmas 🙇 as there are more important things for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants