TypeScript/tests/baselines/reference/complicatedIndexesOfIntersectionsAreInferencable.types
Anders Hejlsberg 6f0c91c4cb
Template literal types and mapped type 'as' clauses (#40336)
* Initial implementation of string template types

* Accept new API baselines

* Accept new baselines

* Unified checking for large cross product union types

* Accept new baselines

* Ensure errors from union type resolution are reported

* Accept new baselines

* Compute constraints for string template types

* Support `as T` clause in mapped types

* Accept new API baselines

* Add missing semicolon

* Add checking of `as T` clauses

* Support casing modifiers in string template types

* Accept new baselines

* Bump keyword maximum length

* fix anders

* Revert "fix anders"

This reverts commit b3178d4618.

* Properly handle 'as T' clause with keyof for mapped type

* Fix lint error

* Single character inferences and anchored end span matching

* Fewer array copy operations in template literal type resolution

* Handle cases where 'as T' maps multiple properties onto one

* Fix lint error

* Store key type instead of type mapper in MappedSymbol

* No constraint on `in T` type when `as N` clause present

* Rename from TemplateType to TemplateLiteralType

* Accept new API baselines

* Add tests

* Accept new baselines

* Address CR feedback

* Accept new API baselines

Co-authored-by: Erich Gamma <egamma@microsoft.com>
2020-09-09 17:23:22 -10:00

50 lines
2.7 KiB
Plaintext

=== tests/cases/compiler/complicatedIndexesOfIntersectionsAreInferencable.ts ===
interface FormikConfig<Values> {
initialValues: Values;
>initialValues : Values
validate?: (props: Values) => void;
>validate : ((props: Values) => void) | undefined
>props : Values
validateOnChange?: boolean;
>validateOnChange : boolean | undefined
}
declare function Func<Values = object, ExtraProps = {}>(
>Func : <Values = object, ExtraProps = {}>(x: (string extends "validate" | "initialValues" | keyof ExtraProps ? Readonly<FormikConfig<Values> & ExtraProps> : Pick<Readonly<FormikConfig<Values> & ExtraProps>, "validate" | "initialValues" | Exclude<keyof ExtraProps, "validateOnChange">> & Partial<Pick<Readonly<FormikConfig<Values> & ExtraProps>, "validateOnChange" | Extract<keyof ExtraProps, "validateOnChange">>>)) => void
x: (string extends "validate" | "initialValues" | keyof ExtraProps
>x : string extends "validate" | "initialValues" | keyof ExtraProps ? Readonly<FormikConfig<Values> & ExtraProps> : Pick<Readonly<FormikConfig<Values> & ExtraProps>, "validate" | "initialValues" | Exclude<keyof ExtraProps, "validateOnChange">> & Partial<Pick<Readonly<FormikConfig<Values> & ExtraProps>, "validateOnChange" | Extract<keyof ExtraProps, "validateOnChange">>>
? Readonly<FormikConfig<Values> & ExtraProps>
: Pick<Readonly<FormikConfig<Values> & ExtraProps>, "validate" | "initialValues" | Exclude<keyof ExtraProps, "validateOnChange">>
& Partial<Pick<Readonly<FormikConfig<Values> & ExtraProps>, "validateOnChange" | Extract<keyof ExtraProps, "validateOnChange">>>)
): void;
Func({
>Func({ initialValues: { foo: "" }, validate: props => { props.foo; }}) : void
>Func : <Values = object, ExtraProps = {}>(x: string extends "validate" | "initialValues" | keyof ExtraProps ? Readonly<FormikConfig<Values> & ExtraProps> : Pick<Readonly<FormikConfig<Values> & ExtraProps>, "validate" | "initialValues" | Exclude<keyof ExtraProps, "validateOnChange">> & Partial<Pick<Readonly<FormikConfig<Values> & ExtraProps>, "validateOnChange" | Extract<keyof ExtraProps, "validateOnChange">>>) => void
>{ initialValues: { foo: "" }, validate: props => { props.foo; }} : { initialValues: { foo: string; }; validate: (props: { foo: string; }) => void; }
initialValues: {
>initialValues : { foo: string; }
>{ foo: "" } : { foo: string; }
foo: ""
>foo : string
>"" : ""
},
validate: props => {
>validate : (props: { foo: string; }) => void
>props => { props.foo; } : (props: { foo: string; }) => void
>props : { foo: string; }
props.foo;
>props.foo : string
>props : { foo: string; }
>foo : string
}
});