hosseinmd / prettier-plugin-jsdoc

A Prettier plugin to format JSDoc comments.
MIT License
228 stars 29 forks source link

Typescript 4.7 syntax error on Instantiation Expressions #171

Closed chrisui closed 2 years ago

chrisui commented 2 years ago

Repro

https://github.com/chrisui/prettier-repros

npm ci
npx prettier index.ts
SyntaxError: Unexpected token (2:1)
  1 | const okStr = ok<string>
> 2 | const errnum = error<number>
    | ^

See original bug report in prettier/prettier https://github.com/prettier/prettier/issues/13225

hosseinmd commented 2 years ago

This is not about plugin

chrisui commented 2 years ago

@hosseinmd Can we please re-open this? I've shown in the linked repro and issue that the issue only occurs when this plugin is used.

What is the issue if it is not this plugin?

hosseinmd commented 2 years ago

You have syntax error. "ok" and "error" are function, they aren't type, we could add generic to function just when calling them, but for your use case change your code to this

type OkType = typeof ok;
type ErrorType = typeof error

const okStr: OkType<string> = ok
const errnum: ErrorType<number> = error