mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-22 12:03:44 -05:00
Add test for issue 54655 (#57275)
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
//// [tests/cases/compiler/declarationEmitArrowFunctionNoRenaming.ts] ////
|
||||
|
||||
//// [declarationEmitArrowFunctionNoRenaming.ts]
|
||||
export type Brand<
|
||||
Base,
|
||||
Branding,
|
||||
ReservedName extends string = "__type__"
|
||||
> = Base & { [K in ReservedName]: Branding } & { __witness__: Base };
|
||||
|
||||
export type BoundedInteger<
|
||||
LowerBound extends number,
|
||||
UpperBound extends number
|
||||
> = Brand<number, "BoundedInteger">;
|
||||
|
||||
export const toBoundedInteger =
|
||||
<LowerBound extends number, UpperBound extends number>(bounds: {
|
||||
lowerBound: LowerBound;
|
||||
upperBound: UpperBound;
|
||||
}) =>
|
||||
(
|
||||
n: number
|
||||
): BoundedInteger<LowerBound, UpperBound> =>
|
||||
// Implementation doesn't matter here
|
||||
({} as any)
|
||||
|
||||
|
||||
//// [declarationEmitArrowFunctionNoRenaming.js]
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.toBoundedInteger = void 0;
|
||||
var toBoundedInteger = function (bounds) {
|
||||
return function (n) {
|
||||
// Implementation doesn't matter here
|
||||
return ({});
|
||||
};
|
||||
};
|
||||
exports.toBoundedInteger = toBoundedInteger;
|
||||
|
||||
|
||||
//// [declarationEmitArrowFunctionNoRenaming.d.ts]
|
||||
export type Brand<Base, Branding, ReservedName extends string = "__type__"> = Base & {
|
||||
[K in ReservedName]: Branding;
|
||||
} & {
|
||||
__witness__: Base;
|
||||
};
|
||||
export type BoundedInteger<LowerBound extends number, UpperBound extends number> = Brand<number, "BoundedInteger">;
|
||||
export declare const toBoundedInteger: <LowerBound extends number, UpperBound extends number>(bounds: {
|
||||
lowerBound: LowerBound;
|
||||
upperBound: UpperBound;
|
||||
}) => (n: number) => BoundedInteger<LowerBound, UpperBound>;
|
||||
@@ -0,0 +1,64 @@
|
||||
//// [tests/cases/compiler/declarationEmitArrowFunctionNoRenaming.ts] ////
|
||||
|
||||
=== declarationEmitArrowFunctionNoRenaming.ts ===
|
||||
export type Brand<
|
||||
>Brand : Symbol(Brand, Decl(declarationEmitArrowFunctionNoRenaming.ts, 0, 0))
|
||||
|
||||
Base,
|
||||
>Base : Symbol(Base, Decl(declarationEmitArrowFunctionNoRenaming.ts, 0, 18))
|
||||
|
||||
Branding,
|
||||
>Branding : Symbol(Branding, Decl(declarationEmitArrowFunctionNoRenaming.ts, 1, 7))
|
||||
|
||||
ReservedName extends string = "__type__"
|
||||
>ReservedName : Symbol(ReservedName, Decl(declarationEmitArrowFunctionNoRenaming.ts, 2, 11))
|
||||
|
||||
> = Base & { [K in ReservedName]: Branding } & { __witness__: Base };
|
||||
>Base : Symbol(Base, Decl(declarationEmitArrowFunctionNoRenaming.ts, 0, 18))
|
||||
>K : Symbol(K, Decl(declarationEmitArrowFunctionNoRenaming.ts, 4, 14))
|
||||
>ReservedName : Symbol(ReservedName, Decl(declarationEmitArrowFunctionNoRenaming.ts, 2, 11))
|
||||
>Branding : Symbol(Branding, Decl(declarationEmitArrowFunctionNoRenaming.ts, 1, 7))
|
||||
>__witness__ : Symbol(__witness__, Decl(declarationEmitArrowFunctionNoRenaming.ts, 4, 48))
|
||||
>Base : Symbol(Base, Decl(declarationEmitArrowFunctionNoRenaming.ts, 0, 18))
|
||||
|
||||
export type BoundedInteger<
|
||||
>BoundedInteger : Symbol(BoundedInteger, Decl(declarationEmitArrowFunctionNoRenaming.ts, 4, 69))
|
||||
|
||||
LowerBound extends number,
|
||||
>LowerBound : Symbol(LowerBound, Decl(declarationEmitArrowFunctionNoRenaming.ts, 6, 27))
|
||||
|
||||
UpperBound extends number
|
||||
>UpperBound : Symbol(UpperBound, Decl(declarationEmitArrowFunctionNoRenaming.ts, 7, 28))
|
||||
|
||||
> = Brand<number, "BoundedInteger">;
|
||||
>Brand : Symbol(Brand, Decl(declarationEmitArrowFunctionNoRenaming.ts, 0, 0))
|
||||
|
||||
export const toBoundedInteger =
|
||||
>toBoundedInteger : Symbol(toBoundedInteger, Decl(declarationEmitArrowFunctionNoRenaming.ts, 11, 12))
|
||||
|
||||
<LowerBound extends number, UpperBound extends number>(bounds: {
|
||||
>LowerBound : Symbol(LowerBound, Decl(declarationEmitArrowFunctionNoRenaming.ts, 12, 3))
|
||||
>UpperBound : Symbol(UpperBound, Decl(declarationEmitArrowFunctionNoRenaming.ts, 12, 29))
|
||||
>bounds : Symbol(bounds, Decl(declarationEmitArrowFunctionNoRenaming.ts, 12, 57))
|
||||
|
||||
lowerBound: LowerBound;
|
||||
>lowerBound : Symbol(lowerBound, Decl(declarationEmitArrowFunctionNoRenaming.ts, 12, 66))
|
||||
>LowerBound : Symbol(LowerBound, Decl(declarationEmitArrowFunctionNoRenaming.ts, 12, 3))
|
||||
|
||||
upperBound: UpperBound;
|
||||
>upperBound : Symbol(upperBound, Decl(declarationEmitArrowFunctionNoRenaming.ts, 13, 27))
|
||||
>UpperBound : Symbol(UpperBound, Decl(declarationEmitArrowFunctionNoRenaming.ts, 12, 29))
|
||||
|
||||
}) =>
|
||||
(
|
||||
n: number
|
||||
>n : Symbol(n, Decl(declarationEmitArrowFunctionNoRenaming.ts, 16, 3))
|
||||
|
||||
): BoundedInteger<LowerBound, UpperBound> =>
|
||||
>BoundedInteger : Symbol(BoundedInteger, Decl(declarationEmitArrowFunctionNoRenaming.ts, 4, 69))
|
||||
>LowerBound : Symbol(LowerBound, Decl(declarationEmitArrowFunctionNoRenaming.ts, 12, 3))
|
||||
>UpperBound : Symbol(UpperBound, Decl(declarationEmitArrowFunctionNoRenaming.ts, 12, 29))
|
||||
|
||||
// Implementation doesn't matter here
|
||||
({} as any)
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
//// [tests/cases/compiler/declarationEmitArrowFunctionNoRenaming.ts] ////
|
||||
|
||||
=== declarationEmitArrowFunctionNoRenaming.ts ===
|
||||
export type Brand<
|
||||
>Brand : Brand<Base, Branding, ReservedName>
|
||||
|
||||
Base,
|
||||
Branding,
|
||||
ReservedName extends string = "__type__"
|
||||
> = Base & { [K in ReservedName]: Branding } & { __witness__: Base };
|
||||
>__witness__ : Base
|
||||
|
||||
export type BoundedInteger<
|
||||
>BoundedInteger : BoundedInteger<LowerBound, UpperBound>
|
||||
|
||||
LowerBound extends number,
|
||||
UpperBound extends number
|
||||
> = Brand<number, "BoundedInteger">;
|
||||
|
||||
export const toBoundedInteger =
|
||||
>toBoundedInteger : <LowerBound extends number, UpperBound extends number>(bounds: { lowerBound: LowerBound; upperBound: UpperBound;}) => (n: number) => BoundedInteger<LowerBound, UpperBound>
|
||||
|
||||
<LowerBound extends number, UpperBound extends number>(bounds: {
|
||||
><LowerBound extends number, UpperBound extends number>(bounds: { lowerBound: LowerBound; upperBound: UpperBound; }) => ( n: number ): BoundedInteger<LowerBound, UpperBound> => // Implementation doesn't matter here ({} as any) : <LowerBound extends number, UpperBound extends number>(bounds: { lowerBound: LowerBound; upperBound: UpperBound;}) => (n: number) => BoundedInteger<LowerBound, UpperBound>
|
||||
>bounds : { lowerBound: LowerBound; upperBound: UpperBound; }
|
||||
|
||||
lowerBound: LowerBound;
|
||||
>lowerBound : LowerBound
|
||||
|
||||
upperBound: UpperBound;
|
||||
>upperBound : UpperBound
|
||||
|
||||
}) =>
|
||||
(
|
||||
>( n: number ): BoundedInteger<LowerBound, UpperBound> => // Implementation doesn't matter here ({} as any) : (n: number) => BoundedInteger<LowerBound, UpperBound>
|
||||
|
||||
n: number
|
||||
>n : number
|
||||
|
||||
): BoundedInteger<LowerBound, UpperBound> =>
|
||||
// Implementation doesn't matter here
|
||||
({} as any)
|
||||
>({} as any) : any
|
||||
>{} as any : any
|
||||
>{} : {}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
// @strict: true
|
||||
// @declaration: true
|
||||
|
||||
export type Brand<
|
||||
Base,
|
||||
Branding,
|
||||
ReservedName extends string = "__type__"
|
||||
> = Base & { [K in ReservedName]: Branding } & { __witness__: Base };
|
||||
|
||||
export type BoundedInteger<
|
||||
LowerBound extends number,
|
||||
UpperBound extends number
|
||||
> = Brand<number, "BoundedInteger">;
|
||||
|
||||
export const toBoundedInteger =
|
||||
<LowerBound extends number, UpperBound extends number>(bounds: {
|
||||
lowerBound: LowerBound;
|
||||
upperBound: UpperBound;
|
||||
}) =>
|
||||
(
|
||||
n: number
|
||||
): BoundedInteger<LowerBound, UpperBound> =>
|
||||
// Implementation doesn't matter here
|
||||
({} as any)
|
||||
Reference in New Issue
Block a user