Skip to content

Literal types don't work with generics as expected #12267

Closed
@arusakov

Description

@arusakov

TypeScript Version: master (cef9d85)

Code

function create<T, D>(type: T, data: D) {
  return { type, data };
}

const obj = create('x', 1);

Expected behavior:
obj has type { type: 'x', data: 1 }

Actual behavior:
obj has type { type: string, data: number }

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