Skip to content

Instantly share code, notes, and snippets.

@myuon
Created July 3, 2016 05:19
Show Gist options
  • Select an option

  • Save myuon/cdbd59ee0da4c878def6254932c9245d to your computer and use it in GitHub Desktop.

Select an option

Save myuon/cdbd59ee0da4c878def6254932c9245d to your computer and use it in GitHub Desktop.
typescript: extending interface
import * as $ from "jquery";
function extend<T extends U, U>(itrf: T, part: U): T {
return $.extend(itrf, part);
}
// --------
interface Test {
poyo: string,
nyan: number
};
let u: Test = {poyo: "piyo", nyan: 20};
let u2: Test = extend(u, {poyo: "hey"});
// Error
// let u3: Test = extend(u, {noname: "hey"});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment