Created
May 10, 2018 04:35
-
-
Save beall49/cc9211ca353561300a7ba9e0ba7f5385 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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