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

Better Type Design? #16

Open
Brooooooklyn opened this issue Dec 21, 2016 · 0 comments
Open

Better Type Design? #16

Brooooooklyn opened this issue Dec 21, 2016 · 0 comments

Comments

@Brooooooklyn
Copy link
Contributor

interface TaskSchema {
  _id: TaskId
  note: string
  created: string
  _sourceId?: TaskId
}

interface Table<T> extends lf.schema.Table {
  eq(value: T[K] | lf.schema.Column): Predicate
}

type RealTable<T> = Table<T> & {
  [K in keyof T]?: lf.schema.Column
}

let table : Table<TaskSchema>

const predicate1 = table._id.eq('1111') // pass
const predicate2 = table._id.eq(11111)  // error
const predicate3 = table._id.eq(table._souceId)  // pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant