@chakra-ui/descendant fails TypeScript strict type-checking, breaking CI
See original GitHub issueDescription
When using chakra-ui in a project with noPropertyAccessFromIndexSignature
enabled (a strict type-checking option in tsconfig.json), @chakra-ui/descendant causes tsc to fail and complain due to two easily fixable errors
Link to Reproduction
https://www.npmjs.com/package/@chakra-ui/cra-template-typescript
Steps to reproduce
- Clone any chakra-ui project/template (
npx create-react-app issue-chakra-types --template @chakra-ui/typescript
) - Add
"noPropertyAccessFromIndexSignature": true
totsconfig.json
->compilerOptions
- Have tsc check types, f.e. with a
package.json
script ("check": "tsc"
) - Watch tsc cry about two minor mistakes:
node_modules/@chakra-ui/descendant/src/descendant.ts:64:31 - error TS4111: Property 'index' comes from an index signature, so it must be accessed with ['index'].
64 descendant.node.dataset.index = descendant.index.toString()
~~~~~
node_modules/@chakra-ui/descendant/src/use-descendant.ts:60:50 - error TS4111: Property 'index' comes from an index signature, so it must be accessed with ['index'].
60 const dataIndex = Number(ref.current.dataset.index)
~~~~~
Chakra UI Version
1.7.3
Browser
Node 17.3.0 / TS 4.5.4
Operating System
- macOS
- Windows
- Linux
Additional Information
Perhaps do some CI checks with a strict tsconfig.json
: 😉
"strict": true /* Enable all strict type-checking options. */,
"noImplicitAny": true /* Enable error reporting for expressions and declarations with an implied `any` type.. */,
"strictNullChecks": true /* When type checking, take into account `null` and `undefined`. */,
"strictFunctionTypes": true /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */,
"strictBindCallApply": true /* Check that the arguments for `bind`, `call`, and `apply` methods match the original function. */,
"strictPropertyInitialization": true /* Check for class properties that are declared but not set in the constructor. */,
"noImplicitThis": true /* Enable error reporting when `this` is given the type `any`. */,
"useUnknownInCatchVariables": true /* Type catch clause variables as 'unknown' instead of 'any'. */,
"alwaysStrict": true /* Ensure 'use strict' is always emitted. */,
"noUnusedLocals": true /* Enable error reporting when a local variables aren't read. */,
"noUnusedParameters": true /* Raise an error when a function parameter isn't read */,
"noImplicitReturns": true /* Enable error reporting for codepaths that do not explicitly return in a function. */,
"noFallthroughCasesInSwitch": true /* Enable error reporting for fallthrough cases in switch statements. */,
"noUncheckedIndexedAccess": true /* Include 'undefined' in index signature results */,
"noImplicitOverride": true /* Ensure overriding members in derived classes are marked with an override modifier. */,
"noPropertyAccessFromIndexSignature": true /* Enforces using indexed accessors for keys declared using an indexed type */,
Issue Analytics
- State:
- Created 2 years ago
- Reactions:6
- Comments:8 (1 by maintainers)
Top Results From Across the Web
Changelog - Chakra UI
When the Chakra CLI fails to generate theme typings, it now exits with a status code of 1 . This resolves an issue...
Read more >typescript Code Example - Code Grepper
TypeScript is a programming language developed and maintained by Microsoft.
Read more >@material-ui/types | Yarn - Package Manager
Fast, reliable, and secure dependency management.
Read more >target/npmlist.json · 1-local-storage · IT2810 H21 / Team 06 ...
{"name":"react-prosjekt","version":"0.1.0","dependencies":{"@chakra-ui/icons":{"version":"1.0.15" ...
Read more >Release Notes — Airflow Documentation
In order to make airflow dags test more useful as a testing and debugging tool, we no longer run a backfill job and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
DOM
andDOM.Iterable
were missing from mycompilerOptions.lib
, adding them resolved the compilation issueThis issue still persists in
1.8.1
,skipLibCheck
only skips declaration filesMy error is with
descendant.ts
: