Typescript error TS2339: Property 'webkitURL' does not exist on type 'Window'
error TS2339: Property 'webkitURL' does not exist on type 'Window'
The lib.d.ts does not ship with stuff that is browser specific. However you can easily do (window as any).webkitURL
. This is called a type assertion.
More
The common (as any)
style type assertion is a quickfix provided by alm : https://basarat.gitbooks.io/alm/content/features/quickfix.html
The solution that works as of TypeScript 2.1.5:
interface Window { webkitURL?: any;}declare var window: Window;if (window.webkitURL !== undefined) { console.log(window.webkitURL);}
In the above code we declared an interface/shape for Window which will optionally have webkitURL defined and then we do a check to make sure it is defined.
This approach worked for me. My curren version of typescript is 2.0.3
add this out of the class
interface Window { logged_user: Object }
and when you need use this property, just use it
window.logged_user = {};//your data