TypeScript/tests/baselines/reference/doubleUnderscoreMappedTypes.types
Anders Hejlsberg 6aeb8c12cc
Preserve type aliases for union and intersection types (#42149)
* Create separate types for equivalent aliased unions

* Accept new baselines

* Preserve original types for union types

* Accept new baselines

* Preserve intersection origin for union types

* Accept new baselines

* Accept new baselines

* Preserve aliases during relationship checks

* Accept new baselines

* Preserve aliases for intersection and indexed access types

* Accept new baselines

* Compute intersection-of-unions cross product without recursion

* Accept new baselines

* Use denormalized type objects for origin / support 'keyof' origins

* Accept new baselines

* Fix fourslash test

* Recursively extract named union types

* Accept new baselines

* Map on union origin in mapType to better preserve aliases and origins

* Remove redundant call

* Accept new baselines

* Revert back to declared type when branches produce equivalent union

* Accept new baselines

* Don't include denormal origin types in regular type statistics

* Fix issue with unions not being marked primitive-only

* Allow new alias to be associated with type alias instantiation

* Accept new baselines

* Revert "Accept new baselines"

This reverts commit 4507270cc1.

* Revert "Allow new alias to be associated with type alias instantiation"

This reverts commit 2c2d06dfe1.
2021-01-08 15:19:58 -10:00

52 lines
1.1 KiB
Plaintext

=== tests/cases/compiler/doubleUnderscoreMappedTypes.ts ===
interface Properties {
property1: string;
>property1 : string
__property2: string;
>__property2 : string
}
// As expected, I can make an object satisfying this interface
const ok: Properties = {
>ok : Properties
>{ property1: "", __property2: ""} : { property1: string; __property2: string; }
property1: "",
>property1 : string
>"" : ""
__property2: ""
>__property2 : string
>"" : ""
};
// As expected, "__property2" is indeed a key of the type
type Keys = keyof Properties;
>Keys : keyof Properties
const k: Keys = "__property2"; // ok
>k : keyof Properties
>"__property2" : "__property2"
// This should be valid
type Property2Type = Properties["__property2"];
>Property2Type : string
// And should work with partial
const partial: Partial<Properties> = {
>partial : Partial<Properties>
>{ property1: "", __property2: ""} : { property1: string; __property2: string; }
property1: "",
>property1 : string
>"" : ""
__property2: ""
>__property2 : string
>"" : ""
};