-
-
Notifications
You must be signed in to change notification settings - Fork 794
Closed as not planned
Closed as not planned
Copy link
Description
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?
-
Enable the property
noPropertyAccessFromIndexSignaturein yourtsconfig.jsonfile. -
Write the following code:
export const getCssFromNodeData = ( data?: Readonly<Record<string, unknown>>, ): string[] => { return typeof data?.['v'] === 'number' && data['v'] % 2 === 0 ? ['even'] : [] }
-
Run biome:
pnpm biome check ./src/ -
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
antogyn, tv42, ucho, NatoBoram, betabandido and 1 more
Metadata
Metadata
Assignees
Labels
No labels