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

Private members have implicit any type in generated declaration files #37621

Open
olee opened this issue Mar 26, 2020 · 3 comments
Open

Private members have implicit any type in generated declaration files #37621

olee opened this issue Mar 26, 2020 · 3 comments
Assignees
Labels
Needs Investigation This issue needs a team member to investigate its status.
Milestone

Comments

@olee
Copy link

olee commented Mar 26, 2020

It seems the bug that was fixed in #36216 is happening again:
When generating delcarations for private class members, no type information is appended which causes the declaration file to generate errors when imported into a project with noImplicitAny enabled.

TypeScript Version: 3.8.3

Code

// Test.ts
export default class Test {
    private _number: number = 0;
    public str: string = '';
    private get num() { return this._number; }
}

Expected behavior:

// Test.d.ts
export default class Test {
    private num: any;
    str: string;
    private get num(): any;
}

Actual behavior:

// Test.d.ts
export default class Test {
    private _number;
    str: string;
    private get num();
}

Related Issues: #36216, #36639

@RyanCavanaugh RyanCavanaugh added the Needs Investigation This issue needs a team member to investigate its status. label Mar 27, 2020
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 3.9.1 milestone Mar 27, 2020
@sandersn sandersn added this to Not started in Rolling Work Tracking via automation Apr 1, 2020
@sandersn sandersn moved this from Not started to In Progress in Rolling Work Tracking Apr 2, 2020
@sandersn
Copy link
Member

sandersn commented Apr 2, 2020

The version without any is the intended emit: private _number. But you're not supposed to get an implicit any error with that file.

When I manually write and compile that .d.ts file, I do not get an error. Are you using a version older than 3.8.3? Can you give more details about your setup? A standalone repo would be most helpful.

@olee
Copy link
Author

olee commented Apr 3, 2020

Yes, the project consuming the .d.ts file is still running on older typescript version.
From what I read in the referenced issues, I thought it was changed to append the any type to the declarations, but after checking again I see that the resolution was actually to just ignore implicit any errors in .d.ts files. Is that correct?

If so, I guess this issue is invalid and there's no other way but to try upgrading the other typescript project.

@sandersn
Copy link
Member

sandersn commented Apr 9, 2020

Re-reading #35216, it looks like 3.6 and 3.7 got patch versions. I take it you are working with a version older than that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Investigation This issue needs a team member to investigate its status.
Projects
None yet
Development

No branches or pull requests

3 participants