Skip to content

Compile error if the project imports d.ts which contains a public class that has a privare member uses destructuring assignment in arguments. #8002

@tetsuharuohzeki

Description

@tetsuharuohzeki

Sceneario

  • Project A
    • This uses typeScript@1.9.0-dev.20160409 with --noImplicitAny.
    • This import the below project B via npm.
  • Project B
    • This uses typeScript@1.9.0-dev.20160409 or before with --noImplicitAny.
    • This is published as a npm packages project-b with compiled code (*.js & *.d.ts).

Project A

import {Bar} from 'project-b';

const b = new Bar();

Project B

// index.ts

type Arg = {
    a: number;
};
export class Bar {
    private bar({ a, }: Arg): number {
        return a;
    }
}

is compiled:

// index.d.ts
export declare class Bar {
    private bar({a});
}
export class Bar {
    bar({ a, }) {
        return a;
    }
}

What happens (Actual Results)

Project A will be a compile error. The error log is here:

2     private bar({a});
                   ~

project-b/index.d.ts(2,18): error TS7031: Binding element 'a' implicitly has an 'any' type.

Expected behavior

  • TypeScript should emit a type signature of private members arguments of a exported object which uses destructuring assignment.
    • I think this is most clear way.
    • But this might have a compatibility risk with libraries compiled wirh ~TypeScript 1.8.
  • ...or ignore a type signature of private members...
    • As my personal opinion, I dont like it.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScript

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions