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
73 lines
1.4 KiB
TypeScript
73 lines
1.4 KiB
TypeScript
//// [mappedTypeProperties.ts]
|
|
export type PlaceType = 'openSky' | 'roofed' | 'garage'
|
|
type Before = {
|
|
model: 'hour' | 'day';
|
|
[placeType in PlaceType]: void;
|
|
}
|
|
|
|
type After = {
|
|
[placeType in PlaceType]: void;
|
|
model: 'hour' | 'day'
|
|
}
|
|
|
|
type AfterQuestion = {
|
|
[placeType in PlaceType]?: void;
|
|
model: 'hour' | 'day';
|
|
}
|
|
type AfterMethod = {
|
|
[placeType in PlaceType]?: void;
|
|
model(duration: number): 'hour' | 'day';
|
|
}
|
|
|
|
type AfterImplicit = {
|
|
[placeType in PlaceType]
|
|
model: 'hour' | 'day';
|
|
}
|
|
type AfterImplicitQ = {
|
|
[placeType in PlaceType]?
|
|
model: 'hour' | 'day'
|
|
}
|
|
|
|
interface I {
|
|
[P in PlaceType]: any
|
|
}
|
|
class C {
|
|
[P in PlaceType]: any
|
|
}
|
|
const D = class {
|
|
[P in PlaceType]: any
|
|
}
|
|
const E = class {
|
|
[P in 'a' | 'b']: any
|
|
}
|
|
|
|
|
|
//// [mappedTypeProperties.js]
|
|
"use strict";
|
|
var _a, _b;
|
|
exports.__esModule = true;
|
|
var C = /** @class */ (function () {
|
|
function C() {
|
|
}
|
|
return C;
|
|
}());
|
|
P in PlaceType;
|
|
var D = (_a = /** @class */ (function () {
|
|
function class_1() {
|
|
}
|
|
return class_1;
|
|
}()),
|
|
P in PlaceType,
|
|
_a);
|
|
var E = (_b = /** @class */ (function () {
|
|
function class_2() {
|
|
}
|
|
return class_2;
|
|
}()),
|
|
P in 'a' | 'b',
|
|
_b);
|
|
|
|
|
|
//// [mappedTypeProperties.d.ts]
|
|
export declare type PlaceType = 'openSky' | 'roofed' | 'garage';
|