mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 08:11:30 -06:00
Co-authored-by: Titian Cernicova-Dragomir <tcernicovad1@bloomberg.net>
This commit is contained in:
parent
fca87f2721
commit
021dba5c83
@ -1123,15 +1123,16 @@ export function createSyntacticTypeNodeBuilder(
|
||||
);
|
||||
}
|
||||
function reuseTypeParameters(typeParameters: NodeArray<TypeParameterDeclaration> | undefined, context: SyntacticTypeNodeBuilderContext) {
|
||||
return typeParameters?.map(tp =>
|
||||
factory.updateTypeParameterDeclaration(
|
||||
return typeParameters?.map(tp => {
|
||||
const { node: tpName } = resolver.trackExistingEntityName(context, tp.name);
|
||||
return factory.updateTypeParameterDeclaration(
|
||||
tp,
|
||||
tp.modifiers?.map(m => reuseNode(context, m)),
|
||||
reuseNode(context, tp.name),
|
||||
tpName,
|
||||
serializeExistingTypeNodeWithFallback(tp.constraint, context),
|
||||
serializeExistingTypeNodeWithFallback(tp.default, context),
|
||||
)
|
||||
);
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
function typeFromObjectLiteralMethod(method: MethodDeclaration, name: PropertyName, context: SyntacticTypeNodeBuilderContext, isConstContext: boolean) {
|
||||
|
||||
41
tests/baselines/reference/declarationEmitShadowing.js
Normal file
41
tests/baselines/reference/declarationEmitShadowing.js
Normal file
@ -0,0 +1,41 @@
|
||||
//// [tests/cases/compiler/declarationEmitShadowing.ts] ////
|
||||
|
||||
//// [declarationEmitShadowing.ts]
|
||||
export class A<T = any> {
|
||||
public readonly ShadowedButDoesNotRequireRenaming = <T>(): T => {
|
||||
return null as any
|
||||
}
|
||||
}
|
||||
|
||||
export function needsRenameForShadowing<T>() {
|
||||
type A = T
|
||||
return function O<T>(t: A, t2: T) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// [declarationEmitShadowing.js]
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.A = void 0;
|
||||
exports.needsRenameForShadowing = needsRenameForShadowing;
|
||||
var A = /** @class */ (function () {
|
||||
function A() {
|
||||
this.ShadowedButDoesNotRequireRenaming = function () {
|
||||
return null;
|
||||
};
|
||||
}
|
||||
return A;
|
||||
}());
|
||||
exports.A = A;
|
||||
function needsRenameForShadowing() {
|
||||
return function O(t, t2) {
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
//// [declarationEmitShadowing.d.ts]
|
||||
export declare class A<T = any> {
|
||||
readonly ShadowedButDoesNotRequireRenaming: <T_1>() => T_1;
|
||||
}
|
||||
export declare function needsRenameForShadowing<T>(): <T_1>(t: T, t2: T_1) => void;
|
||||
34
tests/baselines/reference/declarationEmitShadowing.symbols
Normal file
34
tests/baselines/reference/declarationEmitShadowing.symbols
Normal file
@ -0,0 +1,34 @@
|
||||
//// [tests/cases/compiler/declarationEmitShadowing.ts] ////
|
||||
|
||||
=== declarationEmitShadowing.ts ===
|
||||
export class A<T = any> {
|
||||
>A : Symbol(A, Decl(declarationEmitShadowing.ts, 0, 0))
|
||||
>T : Symbol(T, Decl(declarationEmitShadowing.ts, 0, 15))
|
||||
|
||||
public readonly ShadowedButDoesNotRequireRenaming = <T>(): T => {
|
||||
>ShadowedButDoesNotRequireRenaming : Symbol(A.ShadowedButDoesNotRequireRenaming, Decl(declarationEmitShadowing.ts, 0, 25))
|
||||
>T : Symbol(T, Decl(declarationEmitShadowing.ts, 1, 55))
|
||||
>T : Symbol(T, Decl(declarationEmitShadowing.ts, 1, 55))
|
||||
|
||||
return null as any
|
||||
}
|
||||
}
|
||||
|
||||
export function needsRenameForShadowing<T>() {
|
||||
>needsRenameForShadowing : Symbol(needsRenameForShadowing, Decl(declarationEmitShadowing.ts, 4, 1))
|
||||
>T : Symbol(T, Decl(declarationEmitShadowing.ts, 6, 40))
|
||||
|
||||
type A = T
|
||||
>A : Symbol(A, Decl(declarationEmitShadowing.ts, 6, 46))
|
||||
>T : Symbol(T, Decl(declarationEmitShadowing.ts, 6, 40))
|
||||
|
||||
return function O<T>(t: A, t2: T) {
|
||||
>O : Symbol(O, Decl(declarationEmitShadowing.ts, 8, 8))
|
||||
>T : Symbol(T, Decl(declarationEmitShadowing.ts, 8, 20))
|
||||
>t : Symbol(t, Decl(declarationEmitShadowing.ts, 8, 23))
|
||||
>A : Symbol(A, Decl(declarationEmitShadowing.ts, 6, 46))
|
||||
>t2 : Symbol(t2, Decl(declarationEmitShadowing.ts, 8, 28))
|
||||
>T : Symbol(T, Decl(declarationEmitShadowing.ts, 8, 20))
|
||||
}
|
||||
}
|
||||
|
||||
38
tests/baselines/reference/declarationEmitShadowing.types
Normal file
38
tests/baselines/reference/declarationEmitShadowing.types
Normal file
@ -0,0 +1,38 @@
|
||||
//// [tests/cases/compiler/declarationEmitShadowing.ts] ////
|
||||
|
||||
=== declarationEmitShadowing.ts ===
|
||||
export class A<T = any> {
|
||||
>A : A<T>
|
||||
> : ^^^^
|
||||
|
||||
public readonly ShadowedButDoesNotRequireRenaming = <T>(): T => {
|
||||
>ShadowedButDoesNotRequireRenaming : <T_1>() => T_1
|
||||
> : ^^^^^^^^^^^
|
||||
><T>(): T => { return null as any } : <T_1>() => T_1
|
||||
> : ^^^^^^^^^^^
|
||||
|
||||
return null as any
|
||||
>null as any : any
|
||||
}
|
||||
}
|
||||
|
||||
export function needsRenameForShadowing<T>() {
|
||||
>needsRenameForShadowing : <T>() => <T_1>(t: T, t2: T_1) => void
|
||||
> : ^ ^^^^^^^^ ^^ ^^^ ^^^^^^^^^
|
||||
|
||||
type A = T
|
||||
>A : T
|
||||
> : ^
|
||||
|
||||
return function O<T>(t: A, t2: T) {
|
||||
>function O<T>(t: A, t2: T) { } : <T_1>(t: T, t2: T_1) => void
|
||||
> : ^^^^^^ ^^^^^ ^^ ^^^^^^^^^
|
||||
>O : <T>(t: T_1, t2: T) => void
|
||||
> : ^ ^^ ^^^^^^^ ^^ ^^^^^^^^^
|
||||
>t : T_1
|
||||
> : ^^^
|
||||
>t2 : T
|
||||
> : ^
|
||||
}
|
||||
}
|
||||
|
||||
13
tests/cases/compiler/declarationEmitShadowing.ts
Normal file
13
tests/cases/compiler/declarationEmitShadowing.ts
Normal file
@ -0,0 +1,13 @@
|
||||
// @declaration: true
|
||||
|
||||
export class A<T = any> {
|
||||
public readonly ShadowedButDoesNotRequireRenaming = <T>(): T => {
|
||||
return null as any
|
||||
}
|
||||
}
|
||||
|
||||
export function needsRenameForShadowing<T>() {
|
||||
type A = T
|
||||
return function O<T>(t: A, t2: T) {
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user