TypeScript/tests/cases/fourslash/codeFixConvertToMappedObjectType9.ts
Wenlu Wang 4606709672 add code fix convert to mapped object type (#24286)
* add code fix convert to mapped object type

* add support for type literal and improve test

* fix typo

* add support for heritageClauses

* only determine declaration is not class
2018-05-23 14:09:49 -07:00

22 lines
487 B
TypeScript

/// <reference path='fourslash.ts' />
//// type K = "foo" | "bar";
//// interface Foo { }
//// interface Bar<T> { bar: T; }
//// interface SomeType extends Foo, Bar<number> {
//// a: number;
//// [prop: K]: any;
//// }
verify.codeFix({
description: `Convert 'SomeType' to mapped object type`,
newFileContent: `type K = "foo" | "bar";
interface Foo { }
interface Bar<T> { bar: T; }
type SomeType = Foo & Bar<number> & {
[prop in K]: any;
} & {
a: number;
};`
})