// 接口export = {}// 定义一个接口interface Post {title: stringcontent: stringsubTitle?: string // 可选成员readonly summary: string // 只读成员}// 则这里就需要遵循接口的规则function printPost (post: Post) {console.log(post.title)console.log(post.content)}const hello: Post = {title: "title",content: "content",summary: "hello"}printPost(hello)// 只读成员声明后不能修改,这里会报出语法错误// hello.summary = '12'// ---------------------------------------// 动态成员interface Cache {[prop: string]: string}const cache: Cache = {123: "123"}
