Skip to content

Missing expected errors when type alias is used recursively in generic type parameter #8789

Open
@jedwards1211

Description

@jedwards1211
// @flow
type Stuff<T> = {[string]: T | Stuff<T>}
const stuff: Stuff<number> = { a: { b: 'not a number' } } // errors as expected

type Record<K, V> = {[K]: V}
type RecordStuff<T> = Record<string, T | RecordStuff<T>>
const recordStuff: RecordStuff<number> = { a: { b: 'not a number' } } // should error, but doesn't

TypeScript reports a circular reference error in the recordStuff case but not the stuff case. Seems like there's something hard about supporting types like this, but I don't understand why it would be impossible?

Flow version: 0.164.0

Expected behavior

stuff and recordStuff have the same error

Actual behavior

No error on recordStuff

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Typing: soundnessNo false negatives (type checker claims that there is no error in the incorrect program)bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions