38 lines
769 B
TypeScript
38 lines
769 B
TypeScript
//// [interfaceContextualType.ts]
|
|
export interface IOptions {
|
|
italic?: boolean;
|
|
bold?: boolean;
|
|
}
|
|
export interface IMap {
|
|
[s: string]: IOptions;
|
|
}
|
|
|
|
class Bug {
|
|
public values: IMap;
|
|
ok() {
|
|
this.values = {};
|
|
this.values['comments'] = { italic: true };
|
|
}
|
|
shouldBeOK() {
|
|
this.values = {
|
|
comments: { italic: true }
|
|
};
|
|
}
|
|
}
|
|
|
|
|
|
//// [interfaceContextualType.js]
|
|
var Bug = (function () {
|
|
function Bug() {
|
|
}
|
|
Bug.prototype.ok = function () {
|
|
this.values = {};
|
|
this.values['comments'] = { italic: true };
|
|
};
|
|
Bug.prototype.shouldBeOK = function () {
|
|
this.values = {
|
|
comments: { italic: true }
|
|
};
|
|
};
|
|
return Bug;
|
|
})();
|