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

Allow multiple twoslash assertions on one line? #139

Open
danvk opened this issue Sep 8, 2023 · 0 comments
Open

Allow multiple twoslash assertions on one line? #139

danvk opened this issue Sep 8, 2023 · 0 comments

Comments

@danvk
Copy link
Owner

danvk commented Sep 8, 2023

Should something this be allowed?

function callWithRandomNumbers(fn: (n1: number, n2: number) => void) {
  fn(Math.random(), Math.random());
}

callWithRandomNumbers((a, b) => {
  //                   ^? (parameter) a: number
  //                      ^? (parameter) b: number
  console.log(a + b);
});

This isn't supported in TwoSlash:

image

But I do support an equivalent for errors.

The workaround now is to put the second type assertion on another line:

function callWithRandomNumbers(fn: (n1: number, n2: number) => void) {
  fn(Math.random(), Math.random());
}

callWithRandomNumbers((a, b) => {
  //                   ^? (parameter) a: number
  console.log(a + b);
  //              ^? (parameter) b: number
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant