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

TypeScript type compilation #155

Open
ryardley opened this issue Mar 29, 2020 · 1 comment
Open

TypeScript type compilation #155

ryardley opened this issue Mar 29, 2020 · 1 comment
Labels

Comments

@ryardley
Copy link
Owner

ryardley commented Mar 29, 2020

I think the next thing holding back this lib is the lack of automatic typescript support.

One way to manage this would be to change the way TypeScript support is provided and to create a compiler/watcher for auto compiling types to node_modules.

This would allow PDSL to be strongly typed by simply adding a unique typescript key identifier.

const isUser = p<"isUser">`{
  name: string[>2],
  age: > 21
}`

Behind the scenes types would be compiled to somewhere in node modules:

// node_modules/pdsl/___types.ts
export type PDSLTypes = {
  isUser: { name: string, age: number }
}

The type signature of the returned function would look something like this:

type PredicateFn = <T>(input:any) => input is PDSLTypes[T]

Not sure if it is possible to maintain backward compatibility need to look up if conditionals are possible in TypeScript - I have a feeling they might be....

@ryardley
Copy link
Owner Author

This would make sense to follow #105

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant