TypeScript
在Window下添加属性
declare global {
interface Window {
key: any
}
}
1
2
3
4
5
2
3
4
5
忽视警告
注释会忽略下一行中产生的所有错误
// @ts-ignore
// eslint-disable-next-line to ignore the next line.
/* eslint-disable */ to ignore all warnings in a file.
1
2
3
4
5
6
2
3
4
5
6
[]
避开检测
使用往一个第三方实例的prototype
属性上添加自定义的属性和方法
这样用会报错:
Object.prototype.attribute = 'value' // Property 'attribute' does not exist on type 'Object'.
1
这样用可以通过:
Object.prototype['attribute'] = 'value'
1