Created
November 13, 2022 00:04
-
-
Save zakuroishikuro/de84483374b3dbc08614441079776573 to your computer and use it in GitHub Desktop.
console.logするだけのgetter生やしたい
This file contains 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
Object.defineProperty(Object.prototype, "out", { | |
get() { | |
console.log(this.toString()); | |
return this; | |
}, | |
}); | |
interface Object { | |
get out(): any; // ここをanyじゃなくoutを呼んでいるインスタンスの型にしたい | |
} | |
"abc".out.slice(1).out; // .out以降がanyになってしまうのでslice等がサジェストされない |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment