“Тип стиля TypeScript” Ответ

Тип стиля TypeScript

type ComponentProps = {
	styles: React.CSSProperties 
}
Ofir Salem

Руководство по стилю типографии

Casing:
  Long: easier to read throug in lists
    MACRO_CASE: constants, enums 
  
    kebap-case: file names, paths
  
    snake_case: API I/O, object properties, variables, function/method attributes. 

  Short: less characters allow us to fit more meaning; e.g. when we extend or scope an entity (both good practices) the name tends to grow 
    camelCase: functions, methods, GraphQL actions
    
    PascalCase for classes and interfaces, cloud infrastructure resource names

Grammar
  variable: a noun (an object or a collection of objects)
  
  function: a verb (an action) against a noun with optional adjunct (e.g. ...FromSomewhere, ...BySomeCriteria)
    When the input attributes are more than two => nest them in a `config` object for readability.
    Prefix private methods with an underscore to be easily distingushable from non-private methods.
    
  interface: descirption of a noun and/or a verb 
    Not putting commas at the end ot each attribute make it an interface declaration easily distinguishable from a an object declaration

  enum: a list of limited options
    key - capital case with underscore
    value - kebap case; If needed we can switch to short casing at any time with simple util like `toPascalCase()`
Friendly Finch

Ответы похожие на “Тип стиля TypeScript”

Вопросы похожие на “Тип стиля TypeScript”

Больше похожих ответов на “Тип стиля TypeScript” по TypeScript

Смотреть популярные ответы по языку

Смотреть другие языки программирования