microsoft / microsoft/TypeScript

Behavior difference: (jsdoc) comment emit inconsistencies on expando functions

Đang mở
#63,836 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Possible Improvement
Ngôn ngữ chính
Go
Star
111k
Fork
14.3k
Merge trung bình
2 ngày 4 giờ
Pull request đã merge (30 ngày)
132

Mô tả

Summary as below. Note that the commit emit fix for arrows will be a breaking change from TS 6.

tsc + .js tsc + .ts tsgo + .js tsgo + .ts
ExpandoFunctionInlineNamedExport ✅ Comment ✅ Comment ✅ Comment ✅ Comment
ExpandoArrowInlineNamedExport ❌ Comment ✅ Comment ❌ Comment ❌ Comment
ExpandoFunctionNamedExport ✅ Comment ✅ Comment ✅ Comment ✅ Comment
ExpandoArrowNamedExport ✅ Comment ✅ Comment ❌ Comment ❌ Comment
ExpandoFunctionDefaultExport ✅ Comment ✅ Comment ✅ Comment ✅ Comment
ExpandoArrowDefaultExport ✅ Comment ✅ Comment ❌ Comment ❌ Comment

Steps to reproduce

  1. Start a plain new project
    • "@typescript/native-preview": "7.0.0-dev.20260612.1",
    • "typescript": "6.0.3"
  2. Run npx tsgo --init to get the default tsconfig. Turn on these flags as well.
    • "allowJs": true,
    • "checkJs": true,
    • "stableTypeOrdering": true,
    • "removeComments": false,
  3. Add the below files. Run npx tsc & npx tsgo to see the difference.
    • Emitted type output from using .js and .ts are a bit different as shown above.

src/main.js

/**
 * jsdoc description on `ExpandoFunctionInlineNamedExport`
 */
export function ExpandoFunctionInlineNamedExport() { return null; }
ExpandoFunctionInlineNamedExport.args = { num: 3 };

/**
 * jsdoc description on `ExpandoArrowInlineNamedExport`
 */
export const ExpandoArrowInlineNamedExport = () => { return null; };
ExpandoArrowInlineNamedExport.args = { num: 3 };

/**
 * jsdoc description on `ExpandoFunctionNamedExport`
 */
function ExpandoFunctionNamedExport() { return null; }
ExpandoFunctionNamedExport.args = { num: 3 };

/**
 * jsdoc description on `ExpandoArrowNamedExport`
 */
const ExpandoArrowNamedExport = () => { return null; };
ExpandoArrowNamedExport.args = { num: 3 };

export { ExpandoFunctionNamedExport, ExpandoArrowNamedExport };

src/ExpandoFunctionDefaultExport.js

/**
 * jsdoc description on `ExpandoFunctionDefaultExport`
 */
function ExpandoFunctionDefaultExport() { return null; }
ExpandoFunctionDefaultExport.args = { num: 3 };

export default ExpandoFunctionDefaultExport;

src/ExpandoArrowDefaultExport.js

/**
 * jsdoc description on `ExpandoArrowDefaultExport`
 */
const ExpandoArrowDefaultExport = () => { return null; };
ExpandoArrowDefaultExport.args = { num: 3 };

export default ExpandoArrowDefaultExport;

Behavior with typescript@6.0

Output from using .js.

/**
 * jsdoc description on `ExpandoFunctionInlineNamedExport`
 */
export function ExpandoFunctionInlineNamedExport(): null;
export namespace ExpandoFunctionInlineNamedExport {
    namespace args {
        let num: number;
    }
}
export function ExpandoArrowInlineNamedExport(): null;
export namespace ExpandoArrowInlineNamedExport {
    export namespace args_1 {
        let num_1: number;
        export { num_1 as num };
    }
    export { args_1 as args };
}
/**
 * jsdoc description on `ExpandoFunctionNamedExport`
 */
export function ExpandoFunctionNamedExport(): null;
export namespace ExpandoFunctionNamedExport {
    export namespace args_2 {
        let num_2: number;
        export { num_2 as num };
    }
    export { args_2 as args };
}
/**
 * jsdoc description on `ExpandoArrowNamedExport`
 */
export function ExpandoArrowNamedExport(): null;
export namespace ExpandoArrowNamedExport {
    export namespace args_3 {
        let num_3: number;
        export { num_3 as num };
    }
    export { args_3 as args };
}
//# sourceMappingURL=main.d.ts.map

export default ExpandoFunctionDefaultExport;
/**
 * jsdoc description on `ExpandoFunctionDefaultExport`
 */
declare function ExpandoFunctionDefaultExport(): null;
declare namespace ExpandoFunctionDefaultExport {
    namespace args {
        let num: number;
    }
}
//# sourceMappingURL=ExpandoFunctionDefaultExport.d.ts.map

export default ExpandoArrowDefaultExport;
/**
 * jsdoc description on `ExpandoArrowDefaultExport`
 */
declare function ExpandoArrowDefaultExport(): null;
declare namespace ExpandoArrowDefaultExport {
    namespace args {
        let num: number;
    }
}
//# sourceMappingURL=ExpandoArrowDefaultExport.d.ts.map

Behavior with tsgo

Output from using .js.

/**
 * jsdoc description on `ExpandoFunctionInlineNamedExport`
 */
export declare function ExpandoFunctionInlineNamedExport(): null;
export declare namespace ExpandoFunctionInlineNamedExport {
    var args: {
        num: number;
    };
}
export declare function ExpandoArrowInlineNamedExport(): null;
export declare namespace ExpandoArrowInlineNamedExport {
    var args: {
        num: number;
    };
}
/**
 * jsdoc description on `ExpandoFunctionNamedExport`
 */
declare function ExpandoFunctionNamedExport(): null;
declare namespace ExpandoFunctionNamedExport {
    var args: {
        num: number;
    };
}
declare function ExpandoArrowNamedExport(): null;
declare namespace ExpandoArrowNamedExport {
    var args: {
        num: number;
    };
}
export { ExpandoFunctionNamedExport, ExpandoArrowNamedExport };
//# sourceMappingURL=main.d.ts.map

/**
 * jsdoc description on `ExpandoFunctionDefaultExport`
 */
declare function ExpandoFunctionDefaultExport(): null;
declare namespace ExpandoFunctionDefaultExport {
    var args: {
        num: number;
    };
}
export default ExpandoFunctionDefaultExport;
//# sourceMappingURL=ExpandoFunctionDefaultExport.d.ts.map

declare function ExpandoArrowDefaultExport(): null;
declare namespace ExpandoArrowDefaultExport {
    var args: {
        num: number;
    };
}
export default ExpandoArrowDefaultExport;
//# sourceMappingURL=ExpandoArrowDefaultExport.d.ts.map

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu với bốn tệp nguồn dưới src/ và tái tạo đầu ra khai báo bằng tsc và tsgo với allowJs, checkJs, stableTypeOrdering và removeComments bị vô hiệu hóa. So sánh việc phát sinh JSDoc cho các export expando của function và arrow giữa các export có tên và default; được xem là hoàn thành khi các đầu ra tuân theo một hành vi nhất quán và đã được thống nhất.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
go, javascript, typescript
Lĩnh vực
compilers
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Ít trao đổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
45/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.