Typescript error with type Colors
See original GitHub issueFailed to compile.
.../node_modules/grommet/themes/base.d.ts
TypeScript error in .../node_modules/grommet/themes/base.d.ts(34,3):
Property ''accent-1'' of type 'string | { dark?: string | undefined; light?: string | undefined; } | undefined' is not assignable to string index type 'ColorType'. TS2411
32 |
33 | type Colors = typeof colors & {
> 34 | 'accent-1'?: ColorType;
| ^
35 | 'accent-2'?: ColorType;
36 | 'accent-3'?: ColorType;
37 | 'accent-4'?: ColorType;
Expected Behavior
Compile Successfully
Actual Behavior
Failed to compile.
Steps to Reproduce
yarn start
Your Environment
- Grommet version: 2.8.1
- Typescript version: 3.7.2
- React Version: 16.8.6
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Type error: Type 'string' is not assignable to type 'Colors'
I have a status component button that receives props of color and title, the color has different colors defined in typescript.
Read more >Handbook - Interfaces - TypeScript
Did you mean 'color'?. // Error: Property 'clor' does not exist on type 'SquareConfig'. newSquare . color = config . clor ;. Property...
Read more >TypeScript - Theme UI
export type ExactTheme = typeof theme. // No error. const lightBlue = theme.colors.blue.light. You can then reexport useThemeUI hook with narrowed type.
Read more >TypeScript | WebStorm Documentation - JetBrains
Compilation errors are reported in the TypeScript tool window. ... When you type your code or paste a fragment with a symbol that...
Read more >Typescript errors when setting color of PointGraphics
to: color: Color | Property | undefined; A similar issue occurs with BillBoardGraphics. Wrong type in typescript.
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
Issue has been fixed after upgrading the project to the latest create-react-app. Cheers
was running into the same issue here:
TypeScript error in /app/src/App.tsx(17,20): Type '{ global: { colors: { brand: string; focus: string; placeholder: string; control: string; }; font: { family: string; size: number; }; input: { weight: number; padding: string; }; edgeSize: { small: string; }; }; ... 6 more ...; textArea: { ...; }; }' is not assignable to type 'ThemeType'.
turns out, we hadn’t added a typescript loader to our app. app now runs after following the instructions here: https://ricostacruz.com/til/babel-typescript