forked from microsoft/TypeScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Preserve the homomorphism of inlined mapped types in declaration emit (…
- Loading branch information
Showing
6 changed files
with
118 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
tests/baselines/reference/mappedTypeGenericInstantiationPreservesHomomorphism.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
//// [tests/cases/compiler/mappedTypeGenericInstantiationPreservesHomomorphism.ts] //// | ||
|
||
//// [internal.ts] | ||
export declare function usePrivateType<T extends unknown[]>(...args: T): PrivateMapped<T[any]>; | ||
|
||
type PrivateMapped<Obj> = {[K in keyof Obj]: Obj[K]}; | ||
|
||
//// [api.ts] | ||
import {usePrivateType} from './internal'; | ||
export const mappedUnionWithPrivateType = <T extends unknown[]>(...args: T) => usePrivateType(...args); | ||
|
||
|
||
//// [internal.js] | ||
"use strict"; | ||
exports.__esModule = true; | ||
//// [api.js] | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports.mappedUnionWithPrivateType = void 0; | ||
var internal_1 = require("./internal"); | ||
var mappedUnionWithPrivateType = function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
return internal_1.usePrivateType.apply(void 0, args); | ||
}; | ||
exports.mappedUnionWithPrivateType = mappedUnionWithPrivateType; | ||
|
||
|
||
//// [internal.d.ts] | ||
export declare function usePrivateType<T extends unknown[]>(...args: T): PrivateMapped<T[any]>; | ||
declare type PrivateMapped<Obj> = { | ||
[K in keyof Obj]: Obj[K]; | ||
}; | ||
export {}; | ||
//// [api.d.ts] | ||
export declare const mappedUnionWithPrivateType: <T extends unknown[]>(...args: T) => T[any] extends infer T_1 ? { [K in keyof T_1]: T[any][K]; } : never; |
29 changes: 29 additions & 0 deletions
29
tests/baselines/reference/mappedTypeGenericInstantiationPreservesHomomorphism.symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
=== tests/cases/compiler/internal.ts === | ||
export declare function usePrivateType<T extends unknown[]>(...args: T): PrivateMapped<T[any]>; | ||
>usePrivateType : Symbol(usePrivateType, Decl(internal.ts, 0, 0)) | ||
>T : Symbol(T, Decl(internal.ts, 0, 39)) | ||
>args : Symbol(args, Decl(internal.ts, 0, 60)) | ||
>T : Symbol(T, Decl(internal.ts, 0, 39)) | ||
>PrivateMapped : Symbol(PrivateMapped, Decl(internal.ts, 0, 95)) | ||
>T : Symbol(T, Decl(internal.ts, 0, 39)) | ||
|
||
type PrivateMapped<Obj> = {[K in keyof Obj]: Obj[K]}; | ||
>PrivateMapped : Symbol(PrivateMapped, Decl(internal.ts, 0, 95)) | ||
>Obj : Symbol(Obj, Decl(internal.ts, 2, 19)) | ||
>K : Symbol(K, Decl(internal.ts, 2, 28)) | ||
>Obj : Symbol(Obj, Decl(internal.ts, 2, 19)) | ||
>Obj : Symbol(Obj, Decl(internal.ts, 2, 19)) | ||
>K : Symbol(K, Decl(internal.ts, 2, 28)) | ||
|
||
=== tests/cases/compiler/api.ts === | ||
import {usePrivateType} from './internal'; | ||
>usePrivateType : Symbol(usePrivateType, Decl(api.ts, 0, 8)) | ||
|
||
export const mappedUnionWithPrivateType = <T extends unknown[]>(...args: T) => usePrivateType(...args); | ||
>mappedUnionWithPrivateType : Symbol(mappedUnionWithPrivateType, Decl(api.ts, 1, 12)) | ||
>T : Symbol(T, Decl(api.ts, 1, 43)) | ||
>args : Symbol(args, Decl(api.ts, 1, 64)) | ||
>T : Symbol(T, Decl(api.ts, 1, 43)) | ||
>usePrivateType : Symbol(usePrivateType, Decl(api.ts, 0, 8)) | ||
>args : Symbol(args, Decl(api.ts, 1, 64)) | ||
|
21 changes: 21 additions & 0 deletions
21
tests/baselines/reference/mappedTypeGenericInstantiationPreservesHomomorphism.types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
=== tests/cases/compiler/internal.ts === | ||
export declare function usePrivateType<T extends unknown[]>(...args: T): PrivateMapped<T[any]>; | ||
>usePrivateType : <T extends unknown[]>(...args: T) => PrivateMapped<T[any]> | ||
>args : T | ||
|
||
type PrivateMapped<Obj> = {[K in keyof Obj]: Obj[K]}; | ||
>PrivateMapped : PrivateMapped<Obj> | ||
|
||
=== tests/cases/compiler/api.ts === | ||
import {usePrivateType} from './internal'; | ||
>usePrivateType : <T extends unknown[]>(...args: T) => { [K in keyof T[any]]: T[any][K]; } | ||
|
||
export const mappedUnionWithPrivateType = <T extends unknown[]>(...args: T) => usePrivateType(...args); | ||
>mappedUnionWithPrivateType : <T extends unknown[]>(...args: T) => { [K in keyof T[any]]: T[any][K]; } | ||
><T extends unknown[]>(...args: T) => usePrivateType(...args) : <T extends unknown[]>(...args: T) => { [K in keyof T[any]]: T[any][K]; } | ||
>args : T | ||
>usePrivateType(...args) : { [K in keyof T[any]]: T[any][K]; } | ||
>usePrivateType : <T extends unknown[]>(...args: T) => { [K in keyof T[any]]: T[any][K]; } | ||
>...args : unknown | ||
>args : T | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
tests/cases/compiler/mappedTypeGenericInstantiationPreservesHomomorphism.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// @declaration: true | ||
// @filename: internal.ts | ||
export declare function usePrivateType<T extends unknown[]>(...args: T): PrivateMapped<T[any]>; | ||
|
||
type PrivateMapped<Obj> = {[K in keyof Obj]: Obj[K]}; | ||
|
||
// @filename: api.ts | ||
import {usePrivateType} from './internal'; | ||
export const mappedUnionWithPrivateType = <T extends unknown[]>(...args: T) => usePrivateType(...args); |