UNPKG

prettier-plugin-solidity

Version:

A Prettier Plugin for automatically formatting your Solidity code.

36 lines (28 loc) 904 B
import type * as ast from '@nomicfoundation/slang/ast'; import type { AstPath, Doc } from 'prettier'; import type { AstNode, Comment } from './slang-nodes/types.d.ts'; // Adding our own options to prettier's `ParserOptions` interface. declare module 'prettier' { interface ParserOptions { compiler: string; } } interface CollectedMetadata { offsets: Map<number, number>; comments: Comment[]; } interface Location { start: number; end: number; } interface AstLocation extends Location { outerStart: number; outerEnd: number; } type PrintFunction = (path: AstPath<AstNode>) => Doc; // This the union of all the types in the namespace `ast`. type TypeOfAst = typeof ast; type KeyOfAst = keyof TypeOfAst; type ValuesOf<E> = E[keyof E]; type SlangAstNode = { [k in KeyOfAst]: ValuesOf<TypeOfAst[k]> }[KeyOfAst]; type SlangAstNodeClass = { [k in KeyOfAst]: TypeOfAst[k] }[KeyOfAst];