Jump to content

Navigator in D.TS


JCPalmer
 Share

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...