dprint / dprint-plugin-typescript

TypeScript and JavaScript code formatting plugin for dprint.
https://dprint.dev/plugins/typescript
MIT License
247 stars 50 forks source link

Option for functional programming style type declarations #543

Open scarf005 opened 11 months ago

scarf005 commented 11 months ago

I'm aware this might be a niche style, so it's perfectly okay if this suggestion is declined. However, I'm interested in how I could implement type declarations in the style of Haskell or other functional programming languages with dprint. Here's what I had in mind:

  1. NewLineAfterTypeInFunctionDeclaration

    const add
    : (a: number) => (b: number) => number = (a) => (b) => a + b
  2. NewLineBeforeInitializerInVariableDeclaration

    const add : (a: number) => (b: number) => number
    = (a) => (b) => a + b
  3. Using both

    const add
    : (a: number) => (b: number) => number
    = (a) => (b) => a + b

Any pointers on where to start or which parts of the codebase I should look into would be greatly appreciated. Thanks!

adrian-gierakowski commented 11 months ago

Have a look at https://github.com/dprint/dprint-plugin-typescript/pull/396