Skip to content

duplicate emit /// <reference types="node" /> #48143

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
bluelovers opened this issue Mar 6, 2022 · 1 comment · Fixed by #57681
Closed

duplicate emit /// <reference types="node" /> #48143

bluelovers opened this issue Mar 6, 2022 · 1 comment · Fixed by #57681
Labels
Bug A bug in TypeScript Domain: Declaration Emit The issue relates to the emission of d.ts files Fix Available A PR has been opened for this issue Help Wanted You can do this
Milestone

Comments

@bluelovers
Copy link
Contributor

Bug Report

🔎 Search Terms

🕗 Version & Regression Information

Version 4.7.0-dev.20220305

  • This is a crash
  • This changed between versions ______ and _______
  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about _________
  • I was unable to test this on prior versions because _______

⏯ Playground Link

Playground link with relevant code

💻 Code

// We can quickly address your report if:
//  - The code sample is short. Nearly all TypeScript bugs can be demonstrated in 20-30 lines of code!
//  - It doesn't use external libraries. These are often issues with the type definitions rather than TypeScript bugs.
//  - The incorrectness of the behavior is readily apparent from reading the sample.
// Reports are slower to investigate if:
//  - We have to pare too much extraneous code.
//  - We have to clone a large repo and validate that the problem isn't elsewhere.
//  - The sample is confusing or doesn't clearly demonstrate what's wrong.

🙁 Actual behavior

bluelovers/ws-iconv@c039e94

https://github.com./bluelovers/ws-iconv/blob/c039e942f8562c9fdbba4e8d50c19afc20cc687f/packages/%40lazy-node/readlines/lib/types.d.ts

/// <reference types="node" />
/// <reference types="node" />
/**
 * Created by user on 2020/5/29.
 */
import { PathLike } from 'fs';
export interface IOptions {
    readChunk?: number;
    newLineCharacter?: INewLineCharacter;
}
export declare const enum EnumNewLineCharacter {
    LF = 10,
    CR = 13
}
export declare type IPathLike = PathLike | number;
export declare type INewLineCharacter = string | number | EnumNewLineCharacter | (string | number | EnumNewLineCharacter)[] | Buffer;

🙂 Expected behavior

/// <reference types="node" />
/**
 * Created by user on 2020/5/29.
 */
import { PathLike } from 'fs';
export interface IOptions {
    readChunk?: number;
    newLineCharacter?: INewLineCharacter;
}
export declare const enum EnumNewLineCharacter {
    LF = 10,
    CR = 13
}
export declare type IPathLike = PathLike | number;
export declare type INewLineCharacter = string | number | EnumNewLineCharacter | (string | number | EnumNewLineCharacter)[] | Buffer;
@RyanCavanaugh RyanCavanaugh added Bug A bug in TypeScript Domain: Declaration Emit The issue relates to the emission of d.ts files labels Mar 8, 2022
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Mar 8, 2022
@RyanCavanaugh RyanCavanaugh added the Help Wanted You can do this label Mar 8, 2022
@Silic0nS0ldier
Copy link

Same behaviour observed under 4.7.4.

Smallest repro I could muster follows.

// src/mod.ts
type ContainerOpts = {
  readonly env: NodeJS.ProcessEnv,
  readonly stderr?: readonly NodeJS.WritableStream[],
};
// dist/mod.d.ts
/// <reference types="node" />
/// <reference types="node" />
declare type ContainerOpts = {
    readonly env: NodeJS.ProcessEnv;
    readonly stderr?: readonly NodeJS.WritableStream[];
};
// tsconfig.json
{
  "compilerOptions": {
    "module": "CommonJS",
    "moduleResolution": "node",
    "target": "ES2020",
    "lib": ["ES2020"]
    "strict": true,
    "declaration": true,
    "outDir": "dist"
  },
  "include": [
    "src"
  ]
}

RomainMuller added a commit to aws/jsii-compiler that referenced this issue Jul 12, 2023
The test that assesses whether down-leveled declarations are necessary
or not accounted for the possible presence of duplicated references to
`node` types being injected by the TypeScript compiler
(microsoft/TypeScript#48143), however in some cases the reference is
present more than twice, which was not correctly accounted for;
resulting in emission of redundant down-level declarations.
RomainMuller added a commit to aws/jsii-compiler that referenced this issue Jul 12, 2023
The test that assesses whether down-leveled declarations are necessary
or not accounted for the possible presence of duplicated references to
`node` types being injected by the TypeScript compiler
(microsoft/TypeScript#48143), however in some cases the reference is
present more than twice, which was not correctly accounted for;
resulting in emission of redundant down-level declarations.
github-merge-queue bot pushed a commit to aws/jsii-compiler that referenced this issue Jul 12, 2023
The test that assesses whether down-leveled declarations are necessary
or not accounted for the possible presence of duplicated references to
`node` types being injected by the TypeScript compiler
(microsoft/TypeScript#48143), however in some cases the reference is
present more than twice, which was not correctly accounted for;
resulting in emission of redundant down-level declarations.



---

By submitting this pull request, I confirm that my contribution is made
under the terms of the [Apache 2.0 license].

[Apache 2.0 license]: https://www.apache.org/licenses/LICENSE-2.0
github-merge-queue bot pushed a commit to aws/jsii-compiler that referenced this issue Jul 12, 2023
The test that assesses whether down-leveled declarations are necessary
or not accounted for the possible presence of duplicated references to
`node` types being injected by the TypeScript compiler
(microsoft/TypeScript#48143), however in some cases the reference is
present more than twice, which was not correctly accounted for;
resulting in emission of redundant down-level declarations.

Backports #204

---

By submitting this pull request, I confirm that my contribution is made
under the terms of the [Apache 2.0 license].

[Apache 2.0 license]: https://www.apache.org/licenses/LICENSE-2.0
@typescript-bot typescript-bot added the Fix Available A PR has been opened for this issue label Mar 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: Declaration Emit The issue relates to the emission of d.ts files Fix Available A PR has been opened for this issue Help Wanted You can do this
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants