roblox-ts / roblox-ts.com

The roblox-ts website
https://roblox-ts.com
13 stars 41 forks source link

Download packages referenced in type definitions #114

Closed Dionysusnu closed 1 year ago

Dionysusnu commented 1 year ago

For example, in @rbxts/roact-spring:

import { Binding } from '@rbxts/roact';
import { CoreHooks } from '@rbxts/roact-hooks';
import { ControllerApi, ControllerProps } from '../Controller';
import { AnimationStyle } from '../types/common';

declare interface UseSpring {
  <T extends AnimationStyle>(hooks: CoreHooks, props: ControllerProps<T>, dependencies?: Array<unknown>): {
    [key in keyof T]: Binding<T[key]>;
  };
  <T extends ControllerProps<AnimationStyle>>(
    hooks: CoreHooks,
    props: () => T,
    dependencies?: Array<unknown>
  ): LuaTuple<[{ [key in keyof T]: Binding<T[key]> }, ControllerApi]>;
}

declare const useSpring: UseSpring;
export default useSpring;

The current code would not download @rbxts/roact-hooks, leading to broken typechecks. (And, instead, throws errors failing to download https://cdn.jsdelivr.net/npm/@rbxts/roact-spring@latest/src/hooks/@rbxts/roact-hooks/index.d.ts because it interprets it as a relative reference)

Dionysusnu commented 1 year ago

Repro case: https://roblox-ts.com/playground/#code/JYWwDg9gTgLgBACQhA1gZzgMyhEcBEAAlAEYAeMaA9DgIYDGMAtABbIoCmAJvgNwCwAKCGhIsOAG84AVzQcAymCjAAdgHM4AXyw48RUhWp1GTNEtVq+QobIXn1ACiSo0AGkmaAlAMFA The useSpring call is incorrectly allowed until something else causes @rbxts/roact-hooks to get downloaded.