typescript error
Type: Bug
VS code is displaying a typescript error despite no compilation problems. The Typescript in question:
export type LocalIcon = 'big_tick_icon'
| 'deposit_icon'
| 'events_icon'
| 'fruit_icon_1'
| 'fruit_icon_2'
| 'fruit_icon_3'
| 'fruit_icon_4'
| 'fruit_icon_5'
// ...MaterialIconsIcon, OcticonsIcon, SimpleLineIconsIcon & ZocialIcon the same but omitted for brevity.
export enum IconLibrary {
MaterialIcons = 'MaterialIcons',
Octicons = 'Octicons',
SimpleLineIcons = 'SimpleLineIcons',
Zocial = 'Zocial',
Local = 'Local',
}
type ExpoIcon =
| { iconLibraryName: IconLibrary.MaterialIcons; iconName: MaterialIconsIcon }
| { iconLibraryName: IconLibrary.Octicons; iconName: OcticonsIcon }
| { iconLibraryName: IconLibrary.SimpleLineIcons; iconName: SimpleLineIconsIcon }
| { iconLibraryName: IconLibrary.Zocial; iconName: ZocialIcon }
| { iconLibraryName: IconLibrary.Local; iconName: LocalIcon }
type DashboardButtonProps = UniqueDashboardButtonProps & ExpoIcon;
export default function DashboardButton({
iconName,
iconLibraryName,
route,
params = {}
}: DashboardButtonProps) {
return (
<>
<View>
<Pressable>
<CustomIcon
iconLibraryName={iconLibraryName}
iconName={iconName}
/>
</Pressable>
</View>
</>
);
}
export type CustomIconProps = ExpoIcon & {
color?: string;
size?: number;
disabled?: boolean;
};
export function CustomIcon(props: CustomIconProps): JSX.Element {
return <DynamicIconComponent {...props} />;
}
error on CustomIcon component:
Types of property 'iconLibraryName' are incompatible.
Type 'IconLibrary.MaterialIcons | IconLibrary.Octicons | IconLibrary.SimpleLineIcons | IconLibrary.Zocial | IconLibrary.Local' is not assignable to type 'IconLibrary.Local'.
Type 'IconLibrary.MaterialIcons' is not assignable to type 'IconLibrary.Local'.ts(2322)
VS Code version: Code 1.86.1 (31c37ee8f63491495ac49e43b8544550fbae4533, 2024-02-07T09:08:20.941Z) OS version: Windows_NT x64 10.0.19045 Modes:
System Info
| Item | Value |
|---|---|
| CPUs | 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz (8 x 2803) |
| GPU Status | 2d_canvas: enabled canvas_oop_rasterization: enabled_on direct_rendering_display_compositor: disabled_off_ok gpu_compositing: enabled multiple_raster_threads: enabled_on opengl: enabled_on rasterization: enabled raw_draw: disabled_off_ok skia_graphite: disabled_off video_decode: enabled video_encode: enabled vulkan: disabled_off webgl: enabled webgl2: enabled webgpu: enabled |
| Load (avg) | undefined |
| Memory (System) | 31.73GB (18.68GB free) |
| Process Argv | C:/Users/Gil.Reich/Documents/liraShapiraApp/ --crash-reporter-id b07f73c2-26d7-4f33-ab9e-0e6b3bca3204 |
| Screen Reader | no |
| VM | 0% |
Extensions (11)
| Extension | Author (truncated) | Version |
|---|---|---|
| increment-selection | alb | 0.2.0 |
| gitlens | eam | 14.8.2 |
| prettier-vscode | esb | 10.1.0 |
| figma-vscode-extension | fig | 0.3.3 |
| todo-tree | Gru | 0.0.226 |
| paste-from-screenshot | jam | 0.0.1 |
| git-graph | mhu | 1.30.0 |
| vsliveshare | ms- | 1.0.5905 |
| prisma | Pri | 5.9.1 |
| open-in-browser | tec | 2.0.0 |
| vscode-icons | vsc | 12.7.0 |
A/B Experiments
vsliv368cf:30146710
vspor879:30202332
vspor708:30202333
vspor363:30204092
vscoreces:30445986
vscod805cf:30301675
binariesv615:30325510
vsaa593cf:30376535
py29gd2263:30899288
c4g48928:30535728
azure-dev_surveyone:30548225
a9j8j154:30646983
962ge761:30959799
pythongtdpath:30769146
welcomedialog:30910333
pythonidxpt:30866567
pythonnoceb:30805159
asynctok:30898717
pythontestfixt:30902429
pythonregdiag2:30936856
pyreplss1:30897532
pythonmypyd1:30879173
pythoncet0:30885854
pythontbext0:30879054
dsvsc016:30899300
dsvsc017:30899301
dsvsc018:30899302
fegfb526:30961430
3ef8e399:30964150
bg6jg535:30958357
Thanks for creating this issue! It looks like you may be using an old version of VS Code, the latest stable release is 1.86.2. Please try upgrading to the latest version and checking whether this issue remains.
Happy Coding!
We closed this issue because it is a question about using VS Code rather than an issue or feature request. Please search for help on StackOverflow, where the community has already answered thousands of similar questions. You may find their guide on asking a new question helpful if your question has not already been asked. See also our issue reporting guidelines.
Happy Coding!