Skip to content

Latest commit

 

History

History
68 lines (55 loc) · 1.62 KB

unnecessary-typeof-type.md

File metadata and controls

68 lines (55 loc) · 1.62 KB

unnecessaryTypeofType

Suggests replacing typeof Schema.Type style annotations with the matching named type when available

Property Value
Category Style
Default severity suggestion
Fixable Yes
Effect versions v3, v4
Diagnostic codes TS377090
Language Service name unnecessaryTypeofType
Oxlint name effecttsgo/unnecessary-typeof-type

Preview

import { Schema } from "effect"

export namespace UsersRepo {
  export const User = Schema.Struct({ id: Schema.Finite })
  export type User = typeof User.Type
}

export const preview: typeof UsersRepo.User.Type = { id: 1 }
/**
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^ effecttsgo(unnecessary-typeof-type): This `typeof ... .Type` query can be replaced with `UsersRepo.User`.
*/

Language Service Configuration

See the Language Service setup guide for installation instructions.

{
  "$schema": "./node_modules/@effect/tsgo/schema.json",
  "compilerOptions": {
    "plugins": [
      {
        "name": "@effect/language-service",
        "diagnosticSeverity": {
          "unnecessaryTypeofType": "warning"
        }
      }
    ]
  }
}

Oxlint Configuration

See the Oxlint setup guide for installation and patching instructions.

{
  "$schema": "./node_modules/@effect/tsgo/oxlint-schema.json",
  "options": {
    "typeAware": true
  },
  "plugins": ["effecttsgo"],
  "rules": {
    "effecttsgo/unnecessary-typeof-type": "warn"
  }
}