You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// tag types: https://github.com/Microsoft/TypeScript/issues/4895constenumTag{}// <-- tag (hopefully nominal) type to indicate some assertion taken place over a string valuefunctionfoo(values: (string&Tag)[],callback: (one: string&Tag)=>number// <-- only strings that have satisfied the assertion are welcome here){returnundefined;}functionbar(one: string): number{// <-- function that doesn't require its parameter to be markedreturnundefined}foo([],bar);// <-- no problem... why is bar an ok argument? didn't we ask for a function that requires a string & enum?// are enums not nominal? why is it ok to ignore it here?
The text was updated successfully, but these errors were encountered:
When comparing the types of function parameters, assignment succeeds if either the source parameter is assignable to the target parameter, or vice versa. This is unsound because a caller might end up being given a function that takes a more specialized type, but invokes the function with a less specialized type. In practice, this sort of error is rare, and allowing this enables many common JavaScript patterns.
string & Marker is assignable to string, so (one: string) => number is assignable to (one: string & Marker) => number
The text was updated successfully, but these errors were encountered: