Skip to content

Instantly share code, notes, and snippets.

@kokarn
Last active October 18, 2022 17:55
Show Gist options
  • Save kokarn/8c57bcbf043d95262926756db2553ea1 to your computer and use it in GitHub Desktop.
Save kokarn/8c57bcbf043d95262926756db2553ea1 to your computer and use it in GitHub Desktop.
FUCKING typescript
// 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();
}
}
}
// 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;
}
}
}
// 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