Skip to content

Excess property check misses an error with union+string indexer #20060

Closed
@sandersn

Description

@sandersn
export type Condition = And | Or | Not | Misc

export interface Misc {
	[type: string]: {
		target: string
		[key: string]: any
	}
}

export interface And {
	and: Condition[]
}

export interface Or {
	or: Condition[]
}

export interface Not {
	not: Condition
}

const c: Condition = {
        foo: "bar", // <-- should be producing an error
	not: {
		equals: {
			target: "name",
			value: "foo"
		},
	},
}

Expected behavior:

Error "foo is an excess property"

Actual behavior:

No error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScript

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions