Using Angular 2 on a project which is compiled with typescript.
Getting this error when trying to create a blob image:
error TS2339: Property 'webkitURL' does not exist on type 'Window'
ts code is:
public url = window.URL || window.webkitURL; this.photo = this.url.createObjectURL( res );
The "Property does not exist on type '{}'" error occurs when we try to access or set a property that is not contained in the object's type. To solve the error, type the object properties explicitly or use a type with variable key names.
The "Property does not exist on type 'Window & typeof globalThis'" error occurs when we access a property that does not exist in the Window interface. To solve the error, extend the Window interface in a . d. ts file adding the property you intend to access on the window object.
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.
The common (as any)
style type assertion is a quickfix provided by alm : https://basarat.gitbooks.io/alm/content/features/quickfix.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With