tomwanzek / d3-v4-definitelytyped

[DEPRECATED] This repo was intended as a staging area for typescript definitions supporting the latest major release of D3js (i.e. version 4.1.x) by Mike Bostock. It has been migrated to DefinitelyTyped.
MIT License
53 stars 14 forks source link

TypeScript 2.x - BaseType + null #119

Closed timruffles closed 8 years ago

timruffles commented 8 years ago

Using typescript 2.0.2, I see the following errors on compilation:

ERROR in node_modules/@types/d3-transition/index.d.ts
(100,72): error TS2344: Type 'null' does not satisfy the constraint 'BaseType'.

ERROR in node_modules/@types/d3-selection/index.d.ts
(92,108): error TS2344: Type 'null' does not satisfy the constraint 'BaseType'.

ERROR in node_modules/@types/d3-selection/index.d.ts
(94,40): error TS2344: Type 'null' does not satisfy the constraint 'BaseType'.

ERROR in node_modules/@types/d3-selection/index.d.ts
(95,54): error TS2344: Type 'null' does not satisfy the constraint 'BaseType'.

ERROR in node_modules/@types/d3-selection/index.d.ts
(97,114): error TS2344: Type 'null' does not satisfy the constraint 'BaseType'.

ERROR in node_modules/@types/d3-selection/index.d.ts
(98,123): error TS2344: Type 'null' does not satisfy the constraint 'BaseType'.

ERROR in node_modules/@types/d3-selection/index.d.ts
(107,69): error TS2344: Type 'null' does not satisfy the constraint 'BaseType'.

ERROR in node_modules/@types/d3-selection/index.d.ts
(110,28): error TS2344: Type 'null' does not satisfy the constraint 'BaseType'.

ERROR in node_modules/@types/d3-selection/index.d.ts
(111,42): error TS2344: Type 'null' does not satisfy the constraint 'BaseType'.

ERROR in node_modules/@types/d3-selection/index.d.ts
(240,37): error TS2344: Type 'null' does not satisfy the constraint 'BaseType'.

with the following compiler config:

{
    "compilerOptions": {
               // I imagine this is the important flag for the BaseType error
        "strictNullChecks": true,

        "noImplicitReturns": true,
        "forceConsistentCasingInFileNames": true,
        "noImplicitAny": true,
        "noImplicitThis": true,

        "lib": ["dom", "es2015"],

        "sourceMap": true,
        "moduleResolution": "node",
        "module": "commonjs",
        "allowJs": true,
        "target": "es6"
    },

I think BaseType needs to be made nullable

tomwanzek commented 8 years ago

@timruffles yes, the strictNullChecks should be the reason why you experience the error. As I finalize the migration from this repo to DefinitelyTypes/types-2.0 and by implication npm @types, this is a known open item to complete. I am going to transfer the effort to tackling it from here to DT, as it saves the added synchronization effort between the two repos, now that the module-level migration is essentially complete.

I did not wan to vouch for the fact that the entire set of definitions validated for use with strictNullChecks. In some cases the published API docs are not explicit enough without reviewing the actual source code of the respective D3 module.

So, I will carry this over to a new DT issue and copy you, when I open it.

I am going to leave this issue open until I have migrated it and referenced it. Thx for understanding.

tomwanzek commented 8 years ago

As discussed, the issue has been migrated to DefinitelyTyped as a work item under issue 11365