Skip to content

Strange behavior of mapped types when using with string #33196

Closed
@lorefnon

Description

@lorefnon

TypeScript Version: 3.7.0-dev.20190831

Search Terms: mapped types

Code

type M<T> = {
  [K in keyof T]: never;
}

type MStr = M<string>;

Expected behavior:

MStr is an object type where the corresponding value type for all properties of string type ("toString" | "charAt" | "charCodeAt" | "concat" | "indexOf" ...) will be never

Actual behavior:

type of MStr is string

Playground Link: Link

Related Issues:

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