mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
[ts-nameof] Add nameof.interpolate (#38706)
* ts-nameof: Add nameof.interpolate * Fix old ts vs new ts difference with string literal types.
This commit is contained in:
parent
c3042f83c5
commit
56f0f57acf
3
types/ts-nameof/index.d.ts
vendored
3
types/ts-nameof/index.d.ts
vendored
@ -1,4 +1,4 @@
|
||||
// Type definitions for ts-nameof 3.2
|
||||
// Type definitions for ts-nameof 4.0
|
||||
// Project: https://github.com/dsherret/ts-nameof#readme
|
||||
// Definitions by: David Sherret <https://github.com/dsherret>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
@ -15,4 +15,5 @@ declare namespace nameof {
|
||||
// tslint:disable-next-line no-unnecessary-generics
|
||||
function toArray<T>(func: (obj: T) => any[]): string[];
|
||||
function toArray(...args: any[]): string[];
|
||||
function interpolate<T>(value: T): T;
|
||||
}
|
||||
|
||||
@ -29,6 +29,9 @@ nameof.toArray(testInstance.prop1); // $ExpectType string[]
|
||||
nameof.toArray(testInstance.prop1, testInstance.prop2); // $ExpectType string[]
|
||||
nameof.toArray<TestClass>(t => [t.prop1]); // $ExpectType string[]
|
||||
|
||||
// nameof.interpolate tests
|
||||
nameof.interpolate("" as string); // $ExpectType string
|
||||
|
||||
// reference type test
|
||||
const myObj = { test: "" };
|
||||
nameof(myObj); // $ExpectType string
|
||||
|
||||
Loading…
Reference in New Issue
Block a user