Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use template literal types to at least allow validating that non-nested-path dependencies arguments are valid #73

Open
helixbass opened this issue May 16, 2021 · 3 comments

Comments

@helixbass
Copy link
Owner

Per helixbass/eslint-plugin-ad-hok#60, I'm not seeing a successful way to leverage template literal types to check whether path-style dependencies arguments are valid or not

But so can at least take an approach like:

type StringWithDot = `${string}.${string}`

type AddEffectOnPropFalsy = <
  TProps,
  TPropPath extends StringWithDot | (keyof TProps & string)
>(
  propPath: TPropPath,
  effectCallback: (props: TProps) => () => void | (() => void | undefined)
) => CurriedUnchangedProps<TProps>

to validate non-dotted dependencies arguments (perhaps in combination with an ESLint rule checking dotted dependencies arguments per that issue)?

@helixbass
Copy link
Owner Author

Playing around with Path types here

@helixbass
Copy link
Owner Author

Using the "hose to dirty string" technique here

@helixbass
Copy link
Owner Author

Neither Path types nor the "hose" technique seems to be working when applied to unresolved TProps generics (eg in ad-hok helpers)

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

No branches or pull requests

1 participant