Skip to content

Add Support for Getter and Setter in Ambient Context #9907

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

Closed
dneimke opened this issue Jul 23, 2016 · 2 comments
Closed

Add Support for Getter and Setter in Ambient Context #9907

dneimke opened this issue Jul 23, 2016 · 2 comments
Labels
External Relates to another program, environment, or user action which we cannot control.

Comments

@dneimke
Copy link

dneimke commented Jul 23, 2016

As a library developer, I want to provide accurate typing definition files for my components.

The scenario that I cannot achieve this in is where I have a getter and setter on a class declared within an Ambient context.

**foo.d.ts**
// The following gives an error message: 'an accessor cannot be declared in an ambient context'

declare namespace Foo {
    class Widget {
        get name(): string;  // gets the name
        set name(name: string): void;    // sets the name
    }
} 
@dneimke dneimke closed this as completed Jul 23, 2016
@dneimke
Copy link
Author

dneimke commented Jul 23, 2016

My reason for suggesting this change is to support libraries such as kendo.ui:

https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/kendo-ui/kendo-ui.d.ts#L3373

In that code file, the value property of the DropDownList needs to be set and get'ted using the following syntax:

let foo = dd.value();
dd.value('new value');

@dneimke dneimke reopened this Jul 23, 2016
@dneimke dneimke closed this as completed Jul 23, 2016
@dneimke
Copy link
Author

dneimke commented Jul 23, 2016

Closing: Adding getter and setter here wouldn't resolve the underlying issue which is described fully here: http://stackoverflow.com/questions/38536989/how-to-create-typescript-type-definition-for-same-named-methods

@RyanCavanaugh RyanCavanaugh added the External Relates to another program, environment, or user action which we cannot control. label Jul 25, 2016
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
External Relates to another program, environment, or user action which we cannot control.
Projects
None yet
Development

No branches or pull requests

2 participants