You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 16, 2023. It is now read-only.
The issue is that the interface augmentation is not localized in the following sense.
A module with the following imports works as intended:
// Module 'A'
import * as d3Selection from 'd3-selection';
import * as d3Transition from 'd3-transition';
The d3-transition module import extends the Selection object from the d3-selection module as per D3 and the relevant Selection interface is augmented correspondingly.
However, the following module, may exhibit interface bleed.
// Module 'B'
import * as d3Selection from 'd3-selection';
In module 'B', the Selection interface should not show properties related to transitions. This is true and a non-issue, if the d3-transition definitions file is not part of the project.
However, if the d3-transition module is part of the project, even when it is not locally imported into the module 'B' file, the Selection interface has been augmented with transition properties.
import * as d3Selection from '../../src/d3-selection';
At the end of the file, the following test segment indicates lines that are unexpectedly compiling
successfully:
// ---------------------------------------------------------------------------------------
// TEST OF GITHUB ISSUE #4 (https://github.com/tomwanzek/d3-v4-definitelytyped/issues/4)
// ---------------------------------------------------------------------------------------
// fails as expected, as transition(...) method and Transition<...> interface are not defined on d3-selection
// let transition : d3Selection.Transition<any,any,any,any> = d3Selection.transition('test');
// UNEXPECTEDLY does NOT FAIL as module augmentation of Selection<...> interface in d3-transition bleeds into this test module,
// although d3-transition has not been imported
let ghostTransition = body.transition('test'); // SHOULD FAIL, method transition(...) SHOULD NOT BE AVAILABLE on body Selection<...> without d3-transition import
ghostTransition.duration(500); // SHOULD FAIL, ghostTransition has properties of Transition<...>
body.interrupt('test'); // SHOULD FAIL, method interrupt(...) SHOULD NOT BE AVAILABLE on body Selection<...> without d3-transition import
The
Selection
interface defined ind3-selection
is augmented in relation to transitions ind3-transition
.In the definitions this is handled using the standard module augmentation pattern in the
d3-transition
definition file:The issue is that the interface augmentation is not localized in the following sense.
A module with the following imports works as intended:
The
d3-transition
module import extends theSelection
object from thed3-selection
module as per D3 and the relevantSelection
interface is augmented correspondingly.However, the following module, may exhibit interface bleed.
In module 'B', the Selection interface should not show properties related to transitions. This is true and a non-issue, if the
d3-transition
definitions file is not part of the project.However, if the
d3-transition
module is part of the project, even when it is not locally imported into the module 'B' file, theSelection
interface has been augmented with transition properties.This issue seems to be related to the type script issue: Proposal: Localized typings for definition files.
Need to file issue/investigate on Typescript.
The text was updated successfully, but these errors were encountered: