Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hard to represent extensions/augmentations to other libraries using ts2fable #424

Open
baronfel opened this issue Aug 4, 2021 · 0 comments

Comments

@baronfel
Copy link

baronfel commented Aug 4, 2021

I'm attempting to generate bindings for the VsCode proposed API, which is shipped as a .d.ts file that contains API additions to the base vscode d.ts file.

In this PR I'm documenting the steps taken so far.

Specifically, for this vscode.proposed.d.ts code (which is in the 'vscode' module per the declaration at the top of the d.ts file):

	export namespace authentication {
		/**
		 * Get an authentication session matching the desired scopes. Rejects if a provider with providerId is not
		 * registered, or if the user does not consent to sharing authentication information with
		 * the extension. If there are multiple sessions with the same scopes, the user will be shown a
		 * quickpick to select which account they would like to use.
		 *
		 * Currently, there are only two authentication providers that are contributed from built in extensions
		 * to the editor that implement GitHub and Microsoft authentication: their providerId's are 'github' and 'microsoft'.
		 * @param providerId The id of the provider to use
		 * @param scopes A list of scopes representing the permissions requested. These are dependent on the authentication provider
		 * @param options The {@link AuthenticationGetSessionOptions} to use
		 * @returns A thenable that resolves to an authentication session
		 */
		export function getSession(providerId: string, scopes: readonly string[], options: AuthenticationGetSessionOptions & { forceNewSession: true }): Thenable<AuthenticationSession>;
		export function getSession(providerId: string, scopes: readonly string[], options: AuthenticationGetSessionOptions & { forceNewSession: { detail: string } }): Thenable<AuthenticationSession>;
	}

ts2fable 0.8.0-build.616 generates bindings of the form

module Vscode =
    let [<Import("authentication","vscode.proposed/vscode")>] authentication: Authentication.IExports = jsNative

This appears to be an incorrect module name that would fail at runtime.

One other thing I noticed was that the current mechanisms (interfaces) are hard to extend with these kinds of proposed members. The user cannot convert between the Authentication.IExports defined here and the same ones defined in the 'base' vscode bindings. It's almost like ideally we'd be able to define a new Authentication.IExports that extended the interface from the base package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant