Skip to content

Instantly share code, notes, and snippets.

@beall49
Created May 10, 2018 04:35
Show Gist options
  • Save beall49/cc9211ca353561300a7ba9e0ba7f5385 to your computer and use it in GitHub Desktop.
Save beall49/cc9211ca353561300a7ba9e0ba7f5385 to your computer and use it in GitHub Desktop.
interface CommonData {
data: any;
meta: any,
[propName: string]: any;
}
function getCommonData(common: CommonData) {
return common;
}
class CD implements CommonData{
constructor(data: any, meta: any) {
this.data = data;
this.meta = meta;
}
data: any;
meta: any;
}
// const common = getCommonData({data:"data", meta:"meta", meta1:"meta", meta2:"meta"});
const common = new CD({ data: "data" },
{
meta: "meta",
meta1: "meta",
meta2: "meta"
});
alert(JSON.stringify(common))
https://www.typescriptlang.org/docs/handbook/interfaces.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment