8d715ff53e
* Error on mapped types with properties 1. Error on properties of type literals with computed properties whose name is a binary expression with `in`, because that's a good sign of a mapped type. 2. Parse following properties on mapped types, and error on them. 3. Stop checking computed property names in (1) to avoid producing errors based on misinterpreting mapped type syntax as an expression. * add comment in types.ts * Update API again * Check interfaces and classes too * Add missed check in updateMappedTypeNode
96 lines
1.8 KiB
Plaintext
96 lines
1.8 KiB
Plaintext
=== tests/cases/conformance/types/mapped/mappedTypeProperties.ts ===
|
|
export type PlaceType = 'openSky' | 'roofed' | 'garage'
|
|
>PlaceType : PlaceType
|
|
|
|
type Before = {
|
|
>Before : Before
|
|
|
|
model: 'hour' | 'day';
|
|
>model : "hour" | "day"
|
|
|
|
[placeType in PlaceType]: void;
|
|
>[placeType in PlaceType] : void
|
|
>placeType in PlaceType : boolean
|
|
>placeType : any
|
|
>PlaceType : any
|
|
}
|
|
|
|
type After = {
|
|
>After : After
|
|
|
|
[placeType in PlaceType]: void;
|
|
model: 'hour' | 'day'
|
|
>model : "hour" | "day"
|
|
}
|
|
|
|
type AfterQuestion = {
|
|
>AfterQuestion : AfterQuestion
|
|
|
|
[placeType in PlaceType]?: void;
|
|
model: 'hour' | 'day';
|
|
>model : "hour" | "day"
|
|
}
|
|
type AfterMethod = {
|
|
>AfterMethod : AfterMethod
|
|
|
|
[placeType in PlaceType]?: void;
|
|
model(duration: number): 'hour' | 'day';
|
|
>model : (duration: number) => 'hour' | 'day'
|
|
>duration : number
|
|
}
|
|
|
|
type AfterImplicit = {
|
|
>AfterImplicit : AfterImplicit
|
|
|
|
[placeType in PlaceType]
|
|
model: 'hour' | 'day';
|
|
>model : "hour" | "day"
|
|
}
|
|
type AfterImplicitQ = {
|
|
>AfterImplicitQ : AfterImplicitQ
|
|
|
|
[placeType in PlaceType]?
|
|
model: 'hour' | 'day'
|
|
>model : "hour" | "day"
|
|
}
|
|
|
|
interface I {
|
|
[P in PlaceType]: any
|
|
>[P in PlaceType] : any
|
|
>P in PlaceType : boolean
|
|
>P : any
|
|
>PlaceType : any
|
|
}
|
|
class C {
|
|
>C : C
|
|
|
|
[P in PlaceType]: any
|
|
>[P in PlaceType] : any
|
|
>P in PlaceType : boolean
|
|
>P : any
|
|
>PlaceType : any
|
|
}
|
|
const D = class {
|
|
>D : typeof D
|
|
>class { [P in PlaceType]: any} : typeof D
|
|
|
|
[P in PlaceType]: any
|
|
>[P in PlaceType] : any
|
|
>P in PlaceType : boolean
|
|
>P : any
|
|
>PlaceType : any
|
|
}
|
|
const E = class {
|
|
>E : typeof E
|
|
>class { [P in 'a' | 'b']: any} : typeof E
|
|
|
|
[P in 'a' | 'b']: any
|
|
>[P in 'a' | 'b'] : any
|
|
>P in 'a' | 'b' : number
|
|
>P in 'a' : boolean
|
|
>P : any
|
|
>'a' : "a"
|
|
>'b' : "b"
|
|
}
|
|
|