Skip to content

Error output: Don't deep compare to native objects #26986

@cevek

Description

@cevek

TypeScript Version: 3.1.0-dev.201xxxxx

Search Terms:

Currently if we assign not assignable type to a variable, ts shows a deep 'not assignable' error with mark all not compatible fields. Even for a native objects like Array, Promise, Date etc...
But I think this is too noisily. All I want to know is that my type in not assignable to Array. Don't try to compare guts of Array with my type.

Code

type A = {a: string}
var y:A = {a: ''}
var x0: string = y; // Type 'A' is not assignable to type 'string'.  -- it's ok!
var x1: A[]  = y; // Property 'length' is missing in type 'A'.
var x2: Promise<A> = y; // Property 'then' is missing in type 'A'.
var x3: Date = y; // Property 'toDateString' is missing in type 'A'.
var x4: Node = y; // Property 'baseURI' is missing in type 'A'.

Expected behavior:

Actual behavior:

Playground Link:

Related Issues:

Metadata

Metadata

Labels

CommittedThe team has roadmapped this issueDomain: Error MessagesThe issue relates to error messagingRescheduledThis issue was previously scheduled to an earlier milestoneSuggestionAn idea for TypeScript

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions