Skip to content

Regression in type inference from 2.5 -> 2.6 #19668

Closed
@phiresky

Description

@phiresky

TypeScript Version: 2.6.0-rc, 2.7.0-dev.20171101

Code Runnable Gist

import * as s from "@hediet/typed-sql";
import { Pool } from "pg";

const db = new s.DbConnection(new s.PostgreQueryService(new Pool()));

const customers = s.table(
    "customers",
    { name: s.tText, country: s.tText },
    { id: s.tInteger }
);

const orders = s.table(
    "orders",
    { customerId: customers.id.type, orderDate: s.tText },
    { id: s.tInteger }
);

async function test() {
    return await db.exec(
        s
            .from(customers)
            .where({ country: "US" })
            .leftJoin(orders)
            .on({ id: orders.id })
            .select(orders.$all)
    );
}
{
    "compilerOptions": {
        "target": "es6",
        "module": "commonjs",
        "strict": true
    }
}

Expected behavior:

Correctly inferred type of test() (Typescript 2.5.3):

function test(): Promise<{
    customerId: number;
    orderDate: string;
    id: number;
}[]>

Actual behavior:

2.6.0-rc:

function test(): Promise<void>

2.7.0-dev.20171029:

function test(): Promise<{
    [x: string]: any;
}[]>

No type errors are shown in either version.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions