microsoft / TypeScript

TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
https://www.typescriptlang.org
Apache License 2.0
101.06k stars 12.49k forks source link

Block comments inside of callback function body should not be emitted #33096

Open AnyhowStep opened 5 years ago

AnyhowStep commented 5 years ago

TypeScript Version: 3.5.1

Search Terms:

Code


export const selectClause = tsql.SelectClauseUtil.select(
    fromClause,
    undefined,
    columns => (
        /**
         * The two `SelectsT` have different `usedRef` but the first
         * is a subset of the second.
         */
        Math.random() > 0.5 ?
        [
            tsql.eq(columns.myTable.myTableId, columns.myTable.myTableId).as("eq")
        ] :
        [
            tsql.eq(columns.myTable.myTableId, columns.otherTable.otherTableId).as("eq")
        ]
    )
)

Expected behavior:

export declare const selectClause: [tsql.IExprSelectItem<{
    mapper: tm.Mapper<unknown, boolean>;
    tableAlias: "__aliased";
    alias: "eq";
    usedRef: tsql.IUsedRef<never>;
}>];

Actual behavior:

export declare const selectClause: [tsql.IExprSelectItem<{
    mapper: tm.Mapper<unknown, boolean>; /**
     * The two `SelectsT` have different `usedRef` but the first
     * is a subset of the second.
     */
    tableAlias: "__aliased";
    alias: "eq";
    usedRef: tsql.IUsedRef<never>;
}>];

Playground Link:

TODO Minimal repro

Related Issues:

TODO

AnyhowStep commented 5 years ago

The input file, https://github.com/AnyhowStep/tsql/blob/0606530ddb0be64494c984a46b74dd1b840689af/test/compile-time/input/select-clause/select/cannot-return-union-but-used-ref-merging-allowed.ts

The output file, https://github.com/AnyhowStep/tsql/blob/0606530ddb0be64494c984a46b74dd1b840689af/test/compile-time/expected-output/select-clause/select/cannot-return-union-but-used-ref-merging-allowed.d.ts


To me, the block comment inside the function body is part of an implementation detail and shouldn't be part of the exported variable selectClause.