TypeScript/tests/baselines/reference/contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.types
Wesley Wigham 5a1d30815b
Combine multiple overloads into a single contextual signature (#42620)
* When noImplicitAny is set, combine multiple contextual overloads into a single signature, rather than producing `any` and an error

* Amalgamate intersection composite signature return types as intersections, rather than the prior exclusively union behavior

* Add another example from an issue, albeit slightly modified

* Fix newlines, add test from DT

* Interior remodelling
2021-02-22 13:34:47 -08:00

48 lines
1.5 KiB
Plaintext

=== tests/cases/compiler/contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.ts ===
// must target esnext for `String.normalize` to exist
type Validate = (text: string, pos: number, self: Rule) => number | boolean;
>Validate : Validate
>text : string
>pos : number
>self : Rule
interface FullRule {
validate: string | RegExp | Validate;
>validate : string | RegExp | Validate
normalize?: (match: {x: string}) => void;
>normalize : ((match: { x: string;}) => void) | undefined
>match : { x: string; }
>x : string
}
type Rule = string | FullRule;
>Rule : Rule
const obj: {field: Rule} = {
>obj : { field: Rule; }
>field : Rule
>{ field: { validate: (_t, _p, _s) => false, normalize: match => match.x, }} : { field: { validate: (_t: string, _p: number, _s: Rule) => false; normalize: (match: any) => any; }; }
field: {
>field : { validate: (_t: string, _p: number, _s: Rule) => false; normalize: (match: any) => any; }
>{ validate: (_t, _p, _s) => false, normalize: match => match.x, } : { validate: (_t: string, _p: number, _s: Rule) => false; normalize: (match: any) => any; }
validate: (_t, _p, _s) => false,
>validate : (_t: string, _p: number, _s: Rule) => false
>(_t, _p, _s) => false : (_t: string, _p: number, _s: Rule) => false
>_t : string
>_p : number
>_s : Rule
>false : false
normalize: match => match.x,
>normalize : (match: any) => any
>match => match.x : (match: any) => any
>match : any
>match.x : any
>match : any
>x : any
}
};