Skip to content

Instantly share code, notes, and snippets.

@TitasGailius
Last active March 27, 2018 17:46
Show Gist options
  • Save TitasGailius/34056b8ae17502c465f4688f606507f3 to your computer and use it in GitHub Desktop.
Save TitasGailius/34056b8ae17502c465f4688f606507f3 to your computer and use it in GitHub Desktop.
export interface Module<State> {
state(): State
}
export interface FooState {
foo: String,
}
// No error
const correct: Module<FooState> = {
state() {
return {
foo: 'bar',
baz: 'qux'
}
}
}
// Error
const wrong: Module<FooState> = {
state(): FooState {
return {
foo: 'bar',
baz: 'qux' // <-- 'baz' does not exist in type 'FooState'
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment