Skip to content

🐛 Incompatibility with tsconfig.json's noPropertyAccessFromIndexSignature #463

@castarco

Description

@castarco

Environment information

CLI:
  Version:                      1.2.2
  Color support:                true

Platform:
  CPU Architecture:             aarch64
  OS:                           macos

Environment:
  BIOME_LOG_DIR:                unset
  NO_COLOR:                     unset
  TERM:                         "xterm-256color"
  JS_RUNTIME_VERSION:           "v20.1.0"
  JS_RUNTIME_NAME:              "node"
  NODE_PACKAGE_MANAGER:         "pnpm/8.8.0"

Biome Configuration:
  Status:                       Loaded successfully
  Formatter disabled:           false
  Linter disabled:              false
  Organize imports disabled:    false
  VCS disabled:                 true

Workspace:
  Open Documents:               0

Discovering running Biome servers...

Running Biome Server: ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

ℹ The client isn't connected to any server but rage discovered this running Biome server.

Server:
  Version:                      1.2.2
  Name:                         biome_lsp
  CPU Architecture:             aarch64
  OS:                           macos

Workspace:
  Open Documents:               0

Other Active Server Workspaces:

Workspace:
  Open Documents:               11
  Client Name:                  Visual Studio Code
  Client Version:               1.82.2

What happened?

  1. Enable the property noPropertyAccessFromIndexSignature in your tsconfig.json file.

  2. Write the following code:

    export const getCssFromNodeData = (
    	data?: Readonly<Record<string, unknown>>,
    ): string[] => {
    	return typeof data?.['v'] === 'number' && data['v'] % 2 === 0 ? ['even'] : []
    }
  3. Run biome: pnpm biome check ./src/

  4. See how it complains about the indexed access being too complex:

    ✖ The computed expression can be simplified without the use of a string literal.
    

Expected result

Biome should accept that code, given that the TSC type checker will fail if we use .v instead of ['v'] (in the particular case where v is not a known property of the object that we are accessing).

tsc would fail with the following message if we used .v:

src/stories/treeFixtures.ts:17:22 - error TS4111: Property 'v' comes from an index signature, so it must be accessed with ['v'].

Code of Conduct

  • I agree to follow Biome's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions