Last active
October 18, 2022 17:55
-
-
Save kokarn/8c57bcbf043d95262926756db2553ea1 to your computer and use it in GitHub Desktop.
FUCKING typescript
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
// Errors on line 12 | |
// Operator '!==' cannot be applied to types 'boolean' and 'View'. | |
class Server { | |
currentView: View; | |
manualView: ManualView; | |
private showViewCommand(view: View, data?: string) { | |
let oldView = this.currentView; | |
this.currentView = view; | |
if( !this.currentView !== oldView ){ | |
this.manualView.onLoad(); | |
} | |
} | |
} |
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
// Errors on line 12 | |
// Property 'data' does not exist on type '{}'. | |
class MyClass { | |
constructor(data?: MyInterface) { | |
this.model = { | |
data: { | |
someProp: true | |
} | |
}; | |
if( data ){ | |
this.model.data = data; | |
} | |
} | |
} |
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
// Property 'contentWindow' does not exist on type 'Element'. | |
document.querySelector( 'iframe' ).contentWindow.postMessage(command, '*'); | |
// "Proper" way to do it | |
(<HTMLIFrameElement>document.querySelector( 'iframe' )).contentWindow.postMessage(command, '*'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment