Skip to content

Quick fix for yarn type:generate command failing#2908

Merged
piaskowyk merged 3 commits intomainfrom
@kkafar/fix-ts-types
Feb 2, 2022
Merged

Quick fix for yarn type:generate command failing#2908
piaskowyk merged 3 commits intomainfrom
@kkafar/fix-ts-types

Conversation

@kkafar
Copy link
Copy Markdown
Member

@kkafar kkafar commented Jan 31, 2022

Description

InterpolateConfig interface is declared here as follows:

export interface InterpolateConfig {
  inputRange: readonly number[];
  outputRange: readonly (string | number)[];
  colorSpace: ColorSpace;
  cache: SharedValue<InterpolateRGB | InterpolateHSV>; // <-- Shared value of non-null type!
}

few lines below it is being used:

export function useInterpolateConfig(
  inputRange: readonly number[],
  outputRange: readonly (string | number)[],
  colorSpace = ColorSpace.RGB
): SharedValue<InterpolateConfig> {
  return useSharedValue({
    inputRange,
    outputRange,
    colorSpace,
    cache: makeMutable(null), // <-- returns shared value of null type
  });
}

This caused yarn type:generate command to fail (it is launched by createNPMPackage script):

image

Changes

  • Modify InterpolateConfig interface, so cache is of type: SharedValue<InterpolateRGB | InterpolateHSV | null>
export interface InterpolateConfig {
  inputRange: readonly number[];
  outputRange: readonly (string | number)[];
  colorSpace: ColorSpace;
  cache: SharedValue<InterpolateRGB | InterpolateHSV | null>;
}

Test code and steps to reproduce

Run

yarn type:generate

and see it fails

Checklist

  • Included code example that can be used to test this change
  • Updated TS types
  • Added TS types tests
  • Added unit / integration tests
  • Updated documentation
  • Ensured that CI passes

@kkafar kkafar marked this pull request as ready for review January 31, 2022 14:41
@kkafar kkafar requested a review from piaskowyk January 31, 2022 14:41
@piaskowyk piaskowyk merged commit 986969f into main Feb 2, 2022
@piaskowyk piaskowyk deleted the @kkafar/fix-ts-types branch February 2, 2022 11:30
yiheyang pushed a commit to yiheyang/taro-reanimated that referenced this pull request Feb 3, 2022
## Description

`InterpolateConfig` interface is [declared here](https://github.com/software-mansion/react-native-reanimated/blob/7820ec095de7a719150dc5021561f0b8b0b10f38/src/reanimated2/Colors.ts#L768-L773) as follows:

```ts
export interface InterpolateConfig {
  inputRange: readonly number[];
  outputRange: readonly (string | number)[];
  colorSpace: ColorSpace;
  cache: SharedValue<InterpolateRGB | InterpolateHSV>; // <-- Shared value of non-null type!
}
```

few lines below it is being used:

```ts
export function useInterpolateConfig(
  inputRange: readonly number[],
  outputRange: readonly (string | number)[],
  colorSpace = ColorSpace.RGB
): SharedValue<InterpolateConfig> {
  return useSharedValue({
    inputRange,
    outputRange,
    colorSpace,
    cache: makeMutable(null), // <-- returns shared value of null type
  });
}
```

This caused `yarn type:generate` command to fail (it is launched by `createNPMPackage` script):

![image](https://user-images.githubusercontent.com/50801299/151813246-a55f604a-1290-464c-82a3-124b35235b14.png)

 
## Changes

* Modify `InterpolateConfig` interface, so `cache` is of type: `SharedValue<InterpolateRGB | InterpolateHSV | null>`

```ts
export interface InterpolateConfig {
  inputRange: readonly number[];
  outputRange: readonly (string | number)[];
  colorSpace: ColorSpace;
  cache: SharedValue<InterpolateRGB | InterpolateHSV | null>;
}
```



## Test code and steps to reproduce

Run

```
yarn type:generate
```
and see it fails


## Checklist

- [x] Included code example that can be used to test this change
- [x] Updated TS types
- [ ] Added TS types tests
- [ ] Added unit / integration tests
- [ ] Updated documentation
- [ ] Ensured that CI passes
aeddi pushed a commit to aeddi/react-native-reanimated that referenced this pull request Mar 22, 2022
## Description

`InterpolateConfig` interface is [declared here](https://github.com/software-mansion/react-native-reanimated/blob/7820ec095de7a719150dc5021561f0b8b0b10f38/src/reanimated2/Colors.ts#L768-L773) as follows:

```ts
export interface InterpolateConfig {
  inputRange: readonly number[];
  outputRange: readonly (string | number)[];
  colorSpace: ColorSpace;
  cache: SharedValue<InterpolateRGB | InterpolateHSV>; // <-- Shared value of non-null type!
}
```

few lines below it is being used:

```ts
export function useInterpolateConfig(
  inputRange: readonly number[],
  outputRange: readonly (string | number)[],
  colorSpace = ColorSpace.RGB
): SharedValue<InterpolateConfig> {
  return useSharedValue({
    inputRange,
    outputRange,
    colorSpace,
    cache: makeMutable(null), // <-- returns shared value of null type
  });
}
```

This caused `yarn type:generate` command to fail (it is launched by `createNPMPackage` script):

![image](https://user-images.githubusercontent.com/50801299/151813246-a55f604a-1290-464c-82a3-124b35235b14.png)

 
## Changes

* Modify `InterpolateConfig` interface, so `cache` is of type: `SharedValue<InterpolateRGB | InterpolateHSV | null>`

```ts
export interface InterpolateConfig {
  inputRange: readonly number[];
  outputRange: readonly (string | number)[];
  colorSpace: ColorSpace;
  cache: SharedValue<InterpolateRGB | InterpolateHSV | null>;
}
```



## Test code and steps to reproduce

Run

```
yarn type:generate
```
and see it fails


## Checklist

- [x] Included code example that can be used to test this change
- [x] Updated TS types
- [ ] Added TS types tests
- [ ] Added unit / integration tests
- [ ] Updated documentation
- [ ] Ensured that CI passes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants