JCPalmer Posted May 18, 2018 Share Posted May 18, 2018 I just updated the D.TS for 3.2, and found that the Navigator interface is causing errors in multiple projects. I am streaming microphones & cameras in a number of places. interface Navigator { mozGetVRDevices: (any: any) => any; webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void; mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void; msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void; webkitGetGamepads(): Gamepad[]; msGetGamepads(): Gamepad[]; webkitGamepads(): Gamepad[]; } I am using typescript 2.7.2, and I did not need to put anything in anymore. As more gets put into the "Official" listings for Navigator, could not this get axed? Could this interface somehow also "subclass" the official one with only the new stuff not there yet? I also recently re-did how I initiate stuff. Not sure if I went back or forward, but it is MUCH cleaner. It looks like how you are describing in here. No more Promise SHIT! Will be nuking this section in my projects. Quote Link to comment Share on other sites More sharing options...
RaananW Posted May 18, 2018 Share Posted May 18, 2018 Is the navigator class defined in TS's lib containing those functions? What are the errors? Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted May 18, 2018 Author Share Posted May 18, 2018 They must be in TS's lib. The problems seems now to be in what a NavigatorUserMediaErrorCallback is. Transpiler says: > tsc src/SensorCamera.ts(66,21): error TS2345: Argument of type '(reportError: string) => void' is not assignable to parameter of type 'NavigatorUserMediaErrorCallback'. Types of parameters 'reportError' and 'error' are incompatible. Type 'MediaStreamError' is not assignable to type 'string'. I has just put a function with a string argument, not a MediaStreamError. function (reportError : string) { window.alert(name + ': Error initializing video capture:\n\t' + reportError); } I changed to this & it now worked. function (reportError : MediaStreamError) { window.alert(name + ': Error initializing video capture:\n\t' + reportError.message); } BJS did not even include a MediaStreamError in D.TS, but I changed type, and intellisense knew there was a message property. Changing source rather than editing Babylon.D.TS is preferable. I guess the definitions in 2.7.2 are a little behind what's here. This is an evolving syntax area. One thing I did, which i quickly un-did, was specify typescript with a '^' in package.json, but for next version of BJS looking at the highest version of typescript that will transpile might mean you can nuke this. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.