TypeScript
TypeScript copied to clipboard
duplicate emit `/// <reference types="node" />`
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
https://github.com/bluelovers/ws-iconv/commit/c039e942f8562c9fdbba4e8d50c19afc20cc687f
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;
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"
]
}