mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-04 21:53:42 -06:00
Ensure generated property names for methods named "new" are quoted (#55750)
Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
This commit is contained in:
parent
b3770e7852
commit
9cbcf010ce
@ -8213,16 +8213,17 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
function getPropertyNameNodeForSymbol(symbol: Symbol, context: NodeBuilderContext) {
|
||||
const stringNamed = !!length(symbol.declarations) && every(symbol.declarations, isStringNamed);
|
||||
const singleQuote = !!length(symbol.declarations) && every(symbol.declarations, isSingleQuotedStringNamed);
|
||||
const fromNameType = getPropertyNameNodeForSymbolFromNameType(symbol, context, singleQuote, stringNamed);
|
||||
const isMethod = !!(symbol.flags & SymbolFlags.Method);
|
||||
const fromNameType = getPropertyNameNodeForSymbolFromNameType(symbol, context, singleQuote, stringNamed, isMethod);
|
||||
if (fromNameType) {
|
||||
return fromNameType;
|
||||
}
|
||||
const rawName = unescapeLeadingUnderscores(symbol.escapedName);
|
||||
return createPropertyNameNodeForIdentifierOrLiteral(rawName, getEmitScriptTarget(compilerOptions), singleQuote, stringNamed);
|
||||
return createPropertyNameNodeForIdentifierOrLiteral(rawName, getEmitScriptTarget(compilerOptions), singleQuote, stringNamed, isMethod);
|
||||
}
|
||||
|
||||
// See getNameForSymbolFromNameType for a stringy equivalent
|
||||
function getPropertyNameNodeForSymbolFromNameType(symbol: Symbol, context: NodeBuilderContext, singleQuote?: boolean, stringNamed?: boolean) {
|
||||
function getPropertyNameNodeForSymbolFromNameType(symbol: Symbol, context: NodeBuilderContext, singleQuote: boolean, stringNamed: boolean, isMethod: boolean) {
|
||||
const nameType = getSymbolLinks(symbol).nameType;
|
||||
if (nameType) {
|
||||
if (nameType.flags & TypeFlags.StringOrNumberLiteral) {
|
||||
@ -8233,7 +8234,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
if (isNumericLiteralName(name) && startsWith(name, "-")) {
|
||||
return factory.createComputedPropertyName(factory.createPrefixUnaryExpression(SyntaxKind.MinusToken, factory.createNumericLiteral(Math.abs(+name))));
|
||||
}
|
||||
return createPropertyNameNodeForIdentifierOrLiteral(name, getEmitScriptTarget(compilerOptions));
|
||||
return createPropertyNameNodeForIdentifierOrLiteral(name, getEmitScriptTarget(compilerOptions), singleQuote, stringNamed, isMethod);
|
||||
}
|
||||
if (nameType.flags & TypeFlags.UniqueESSymbol) {
|
||||
return factory.createComputedPropertyName(symbolToExpression((nameType as UniqueESSymbolType).symbol, context, SymbolFlags.Value));
|
||||
|
||||
@ -10216,9 +10216,10 @@ export function isNumericLiteralName(name: string | __String) {
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function createPropertyNameNodeForIdentifierOrLiteral(name: string, target: ScriptTarget, singleQuote?: boolean, stringNamed?: boolean) {
|
||||
return isIdentifierText(name, target) ? factory.createIdentifier(name) :
|
||||
!stringNamed && isNumericLiteralName(name) && +name >= 0 ? factory.createNumericLiteral(+name) :
|
||||
export function createPropertyNameNodeForIdentifierOrLiteral(name: string, target: ScriptTarget, singleQuote: boolean, stringNamed: boolean, isMethod: boolean) {
|
||||
const isMethodNamedNew = isMethod && name === "new";
|
||||
return !isMethodNamedNew && isIdentifierText(name, target) ? factory.createIdentifier(name) :
|
||||
!stringNamed && !isMethodNamedNew && isNumericLiteralName(name) && +name >= 0 ? factory.createNumericLiteral(+name) :
|
||||
factory.createStringLiteral(name, !!singleQuote);
|
||||
}
|
||||
|
||||
|
||||
@ -772,7 +772,8 @@ function createPropertyNameFromSymbol(symbol: Symbol, target: ScriptTarget, quot
|
||||
const prop = checker.symbolToNode(symbol, SymbolFlags.Value, /*enclosingDeclaration*/ undefined, NodeBuilderFlags.WriteComputedProps);
|
||||
if (prop && isComputedPropertyName(prop)) return prop;
|
||||
}
|
||||
return createPropertyNameNodeForIdentifierOrLiteral(symbol.name, target, quotePreference === QuotePreference.Single);
|
||||
// We're using these nodes as property names in an object literal; no need to quote names when not needed.
|
||||
return createPropertyNameNodeForIdentifierOrLiteral(symbol.name, target, quotePreference === QuotePreference.Single, /*stringNamed*/ false, /*isMethod*/ false);
|
||||
}
|
||||
|
||||
function findScope(node: Node) {
|
||||
|
||||
43
tests/baselines/reference/emitMethodCalledNew.js
Normal file
43
tests/baselines/reference/emitMethodCalledNew.js
Normal file
@ -0,0 +1,43 @@
|
||||
//// [tests/cases/compiler/emitMethodCalledNew.ts] ////
|
||||
|
||||
//// [emitMethodCalledNew.ts]
|
||||
// https://github.com/microsoft/TypeScript/issues/55075
|
||||
|
||||
export const a = {
|
||||
new(x: number) { return x + 1 }
|
||||
}
|
||||
export const b = {
|
||||
"new"(x: number) { return x + 1 }
|
||||
}
|
||||
export const c = {
|
||||
["new"](x: number) { return x + 1 }
|
||||
}
|
||||
|
||||
|
||||
//// [emitMethodCalledNew.js]
|
||||
"use strict";
|
||||
// https://github.com/microsoft/TypeScript/issues/55075
|
||||
var _a;
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.c = exports.b = exports.a = void 0;
|
||||
exports.a = {
|
||||
new: function (x) { return x + 1; }
|
||||
};
|
||||
exports.b = {
|
||||
"new": function (x) { return x + 1; }
|
||||
};
|
||||
exports.c = (_a = {},
|
||||
_a["new"] = function (x) { return x + 1; },
|
||||
_a);
|
||||
|
||||
|
||||
//// [emitMethodCalledNew.d.ts]
|
||||
export declare const a: {
|
||||
"new"(x: number): number;
|
||||
};
|
||||
export declare const b: {
|
||||
"new"(x: number): number;
|
||||
};
|
||||
export declare const c: {
|
||||
"new"(x: number): number;
|
||||
};
|
||||
31
tests/baselines/reference/emitMethodCalledNew.symbols
Normal file
31
tests/baselines/reference/emitMethodCalledNew.symbols
Normal file
@ -0,0 +1,31 @@
|
||||
//// [tests/cases/compiler/emitMethodCalledNew.ts] ////
|
||||
|
||||
=== emitMethodCalledNew.ts ===
|
||||
// https://github.com/microsoft/TypeScript/issues/55075
|
||||
|
||||
export const a = {
|
||||
>a : Symbol(a, Decl(emitMethodCalledNew.ts, 2, 12))
|
||||
|
||||
new(x: number) { return x + 1 }
|
||||
>new : Symbol(new, Decl(emitMethodCalledNew.ts, 2, 18))
|
||||
>x : Symbol(x, Decl(emitMethodCalledNew.ts, 3, 6))
|
||||
>x : Symbol(x, Decl(emitMethodCalledNew.ts, 3, 6))
|
||||
}
|
||||
export const b = {
|
||||
>b : Symbol(b, Decl(emitMethodCalledNew.ts, 5, 12))
|
||||
|
||||
"new"(x: number) { return x + 1 }
|
||||
>"new" : Symbol("new", Decl(emitMethodCalledNew.ts, 5, 18))
|
||||
>x : Symbol(x, Decl(emitMethodCalledNew.ts, 6, 8))
|
||||
>x : Symbol(x, Decl(emitMethodCalledNew.ts, 6, 8))
|
||||
}
|
||||
export const c = {
|
||||
>c : Symbol(c, Decl(emitMethodCalledNew.ts, 8, 12))
|
||||
|
||||
["new"](x: number) { return x + 1 }
|
||||
>["new"] : Symbol(["new"], Decl(emitMethodCalledNew.ts, 8, 18))
|
||||
>"new" : Symbol(["new"], Decl(emitMethodCalledNew.ts, 8, 18))
|
||||
>x : Symbol(x, Decl(emitMethodCalledNew.ts, 9, 10))
|
||||
>x : Symbol(x, Decl(emitMethodCalledNew.ts, 9, 10))
|
||||
}
|
||||
|
||||
40
tests/baselines/reference/emitMethodCalledNew.types
Normal file
40
tests/baselines/reference/emitMethodCalledNew.types
Normal file
@ -0,0 +1,40 @@
|
||||
//// [tests/cases/compiler/emitMethodCalledNew.ts] ////
|
||||
|
||||
=== emitMethodCalledNew.ts ===
|
||||
// https://github.com/microsoft/TypeScript/issues/55075
|
||||
|
||||
export const a = {
|
||||
>a : { "new"(x: number): number; }
|
||||
>{ new(x: number) { return x + 1 }} : { "new"(x: number): number; }
|
||||
|
||||
new(x: number) { return x + 1 }
|
||||
>new : (x: number) => number
|
||||
>x : number
|
||||
>x + 1 : number
|
||||
>x : number
|
||||
>1 : 1
|
||||
}
|
||||
export const b = {
|
||||
>b : { "new"(x: number): number; }
|
||||
>{ "new"(x: number) { return x + 1 }} : { "new"(x: number): number; }
|
||||
|
||||
"new"(x: number) { return x + 1 }
|
||||
>"new" : (x: number) => number
|
||||
>x : number
|
||||
>x + 1 : number
|
||||
>x : number
|
||||
>1 : 1
|
||||
}
|
||||
export const c = {
|
||||
>c : { "new"(x: number): number; }
|
||||
>{ ["new"](x: number) { return x + 1 }} : { "new"(x: number): number; }
|
||||
|
||||
["new"](x: number) { return x + 1 }
|
||||
>["new"] : (x: number) => number
|
||||
>"new" : "new"
|
||||
>x : number
|
||||
>x + 1 : number
|
||||
>x : number
|
||||
>1 : 1
|
||||
}
|
||||
|
||||
@ -32,8 +32,8 @@ var a: { new(x: Date): string }
|
||||
>x : Date
|
||||
|
||||
var b = { new(x: RegExp) { return ''; } }; // not a construct signature, function called new
|
||||
>b : { new(x: RegExp): string; }
|
||||
>{ new(x: RegExp) { return ''; } } : { new(x: RegExp): string; }
|
||||
>b : { "new"(x: RegExp): string; }
|
||||
>{ new(x: RegExp) { return ''; } } : { "new"(x: RegExp): string; }
|
||||
>new : (x: RegExp) => string
|
||||
>x : RegExp
|
||||
>'' : ""
|
||||
@ -89,17 +89,17 @@ function foo3(x: any) { }
|
||||
>x : any
|
||||
|
||||
function foo4(x: typeof b);
|
||||
>foo4 : { (x: typeof b): any; (x: { new(x: RegExp): string; }): any; }
|
||||
>x : { new(x: RegExp): string; }
|
||||
>b : { new(x: RegExp): string; }
|
||||
>foo4 : { (x: typeof b): any; (x: { "new"(x: RegExp): string; }): any; }
|
||||
>x : { "new"(x: RegExp): string; }
|
||||
>b : { "new"(x: RegExp): string; }
|
||||
|
||||
function foo4(x: typeof b); // error
|
||||
>foo4 : { (x: { new(x: RegExp): string; }): any; (x: typeof b): any; }
|
||||
>x : { new(x: RegExp): string; }
|
||||
>b : { new(x: RegExp): string; }
|
||||
>foo4 : { (x: { "new"(x: RegExp): string; }): any; (x: typeof b): any; }
|
||||
>x : { "new"(x: RegExp): string; }
|
||||
>b : { "new"(x: RegExp): string; }
|
||||
|
||||
function foo4(x: any) { }
|
||||
>foo4 : { (x: { new(x: RegExp): string; }): any; (x: { new(x: RegExp): string; }): any; }
|
||||
>foo4 : { (x: { "new"(x: RegExp): string; }): any; (x: { "new"(x: RegExp): string; }): any; }
|
||||
>x : any
|
||||
|
||||
function foo8(x: B);
|
||||
@ -140,16 +140,16 @@ function foo10(x: any) { }
|
||||
>x : any
|
||||
|
||||
function foo11(x: B);
|
||||
>foo11 : { (x: B): any; (x: { new(x: RegExp): string; }): any; }
|
||||
>foo11 : { (x: B): any; (x: { "new"(x: RegExp): string; }): any; }
|
||||
>x : B
|
||||
|
||||
function foo11(x: typeof b); // ok
|
||||
>foo11 : { (x: B): any; (x: typeof b): any; }
|
||||
>x : { new(x: RegExp): string; }
|
||||
>b : { new(x: RegExp): string; }
|
||||
>x : { "new"(x: RegExp): string; }
|
||||
>b : { "new"(x: RegExp): string; }
|
||||
|
||||
function foo11(x: any) { }
|
||||
>foo11 : { (x: B): any; (x: { new(x: RegExp): string; }): any; }
|
||||
>foo11 : { (x: B): any; (x: { "new"(x: RegExp): string; }): any; }
|
||||
>x : any
|
||||
|
||||
function foo12(x: I);
|
||||
@ -190,16 +190,16 @@ function foo13(x: any) { }
|
||||
>x : any
|
||||
|
||||
function foo14(x: I);
|
||||
>foo14 : { (x: I): any; (x: { new(x: RegExp): string; }): any; }
|
||||
>foo14 : { (x: I): any; (x: { "new"(x: RegExp): string; }): any; }
|
||||
>x : I
|
||||
|
||||
function foo14(x: typeof b); // ok
|
||||
>foo14 : { (x: I): any; (x: typeof b): any; }
|
||||
>x : { new(x: RegExp): string; }
|
||||
>b : { new(x: RegExp): string; }
|
||||
>x : { "new"(x: RegExp): string; }
|
||||
>b : { "new"(x: RegExp): string; }
|
||||
|
||||
function foo14(x: any) { }
|
||||
>foo14 : { (x: I): any; (x: { new(x: RegExp): string; }): any; }
|
||||
>foo14 : { (x: I): any; (x: { "new"(x: RegExp): string; }): any; }
|
||||
>x : any
|
||||
|
||||
function foo15(x: I2<string>);
|
||||
|
||||
@ -35,8 +35,8 @@ var a: { new(x: string, y: string): string }
|
||||
>y : string
|
||||
|
||||
var b = { new(x: string) { return ''; } }; // not a construct signature, function called new
|
||||
>b : { new(x: string): string; }
|
||||
>{ new(x: string) { return ''; } } : { new(x: string): string; }
|
||||
>b : { "new"(x: string): string; }
|
||||
>{ new(x: string) { return ''; } } : { "new"(x: string): string; }
|
||||
>new : (x: string) => string
|
||||
>x : string
|
||||
>'' : ""
|
||||
@ -92,17 +92,17 @@ function foo3(x: any) { }
|
||||
>x : any
|
||||
|
||||
function foo4(x: typeof b);
|
||||
>foo4 : { (x: typeof b): any; (x: { new(x: string): string; }): any; }
|
||||
>x : { new(x: string): string; }
|
||||
>b : { new(x: string): string; }
|
||||
>foo4 : { (x: typeof b): any; (x: { "new"(x: string): string; }): any; }
|
||||
>x : { "new"(x: string): string; }
|
||||
>b : { "new"(x: string): string; }
|
||||
|
||||
function foo4(x: typeof b); // error
|
||||
>foo4 : { (x: { new(x: string): string; }): any; (x: typeof b): any; }
|
||||
>x : { new(x: string): string; }
|
||||
>b : { new(x: string): string; }
|
||||
>foo4 : { (x: { "new"(x: string): string; }): any; (x: typeof b): any; }
|
||||
>x : { "new"(x: string): string; }
|
||||
>b : { "new"(x: string): string; }
|
||||
|
||||
function foo4(x: any) { }
|
||||
>foo4 : { (x: { new(x: string): string; }): any; (x: { new(x: string): string; }): any; }
|
||||
>foo4 : { (x: { "new"(x: string): string; }): any; (x: { "new"(x: string): string; }): any; }
|
||||
>x : any
|
||||
|
||||
function foo8(x: B);
|
||||
@ -143,16 +143,16 @@ function foo10(x: any) { }
|
||||
>x : any
|
||||
|
||||
function foo11(x: B);
|
||||
>foo11 : { (x: B): any; (x: { new(x: string): string; }): any; }
|
||||
>foo11 : { (x: B): any; (x: { "new"(x: string): string; }): any; }
|
||||
>x : B
|
||||
|
||||
function foo11(x: typeof b); // ok
|
||||
>foo11 : { (x: B): any; (x: typeof b): any; }
|
||||
>x : { new(x: string): string; }
|
||||
>b : { new(x: string): string; }
|
||||
>x : { "new"(x: string): string; }
|
||||
>b : { "new"(x: string): string; }
|
||||
|
||||
function foo11(x: any) { }
|
||||
>foo11 : { (x: B): any; (x: { new(x: string): string; }): any; }
|
||||
>foo11 : { (x: B): any; (x: { "new"(x: string): string; }): any; }
|
||||
>x : any
|
||||
|
||||
function foo12(x: I);
|
||||
@ -193,16 +193,16 @@ function foo13(x: any) { }
|
||||
>x : any
|
||||
|
||||
function foo14(x: I);
|
||||
>foo14 : { (x: I): any; (x: { new(x: string): string; }): any; }
|
||||
>foo14 : { (x: I): any; (x: { "new"(x: string): string; }): any; }
|
||||
>x : I
|
||||
|
||||
function foo14(x: typeof b); // ok
|
||||
>foo14 : { (x: I): any; (x: typeof b): any; }
|
||||
>x : { new(x: string): string; }
|
||||
>b : { new(x: string): string; }
|
||||
>x : { "new"(x: string): string; }
|
||||
>b : { "new"(x: string): string; }
|
||||
|
||||
function foo14(x: any) { }
|
||||
>foo14 : { (x: I): any; (x: { new(x: string): string; }): any; }
|
||||
>foo14 : { (x: I): any; (x: { "new"(x: string): string; }): any; }
|
||||
>x : any
|
||||
|
||||
function foo15(x: I2<string>);
|
||||
|
||||
@ -34,8 +34,8 @@ var a: { new<T extends Array<string>>(x: T): string }
|
||||
>x : T
|
||||
|
||||
var b = { new<T extends RegExp>(x: T) { return ''; } }; // not a construct signature, function called new
|
||||
>b : { new<T extends RegExp>(x: T): string; }
|
||||
>{ new<T extends RegExp>(x: T) { return ''; } } : { new<T extends RegExp>(x: T): string; }
|
||||
>b : { "new"<T extends RegExp>(x: T): string; }
|
||||
>{ new<T extends RegExp>(x: T) { return ''; } } : { "new"<T extends RegExp>(x: T): string; }
|
||||
>new : <T extends RegExp>(x: T) => string
|
||||
>x : T
|
||||
>'' : ""
|
||||
@ -91,17 +91,17 @@ function foo3(x: any) { }
|
||||
>x : any
|
||||
|
||||
function foo4(x: typeof b);
|
||||
>foo4 : { (x: typeof b): any; (x: { new<T extends RegExp>(x: T): string; }): any; }
|
||||
>x : { new<T extends RegExp>(x: T): string; }
|
||||
>b : { new<T extends RegExp>(x: T): string; }
|
||||
>foo4 : { (x: typeof b): any; (x: { "new"<T extends RegExp>(x: T): string; }): any; }
|
||||
>x : { "new"<T extends RegExp>(x: T): string; }
|
||||
>b : { "new"<T extends RegExp>(x: T): string; }
|
||||
|
||||
function foo4(x: typeof b); // error
|
||||
>foo4 : { (x: { new<T extends RegExp>(x: T): string; }): any; (x: typeof b): any; }
|
||||
>x : { new<T extends RegExp>(x: T): string; }
|
||||
>b : { new<T extends RegExp>(x: T): string; }
|
||||
>foo4 : { (x: { "new"<T extends RegExp>(x: T): string; }): any; (x: typeof b): any; }
|
||||
>x : { "new"<T extends RegExp>(x: T): string; }
|
||||
>b : { "new"<T extends RegExp>(x: T): string; }
|
||||
|
||||
function foo4(x: any) { }
|
||||
>foo4 : { (x: { new<T extends RegExp>(x: T): string; }): any; (x: { new<T extends RegExp>(x: T): string; }): any; }
|
||||
>foo4 : { (x: { "new"<T extends RegExp>(x: T): string; }): any; (x: { "new"<T extends RegExp>(x: T): string; }): any; }
|
||||
>x : any
|
||||
|
||||
function foo8(x: B<Array<number>>);
|
||||
@ -142,16 +142,16 @@ function foo10(x: any) { }
|
||||
>x : any
|
||||
|
||||
function foo11(x: B<Array<number>>);
|
||||
>foo11 : { (x: B<Array<number>>): any; (x: { new<T extends RegExp>(x: T): string; }): any; }
|
||||
>foo11 : { (x: B<Array<number>>): any; (x: { "new"<T extends RegExp>(x: T): string; }): any; }
|
||||
>x : B<number[]>
|
||||
|
||||
function foo11(x: typeof b); // ok
|
||||
>foo11 : { (x: B<number[]>): any; (x: typeof b): any; }
|
||||
>x : { new<T extends RegExp>(x: T): string; }
|
||||
>b : { new<T extends RegExp>(x: T): string; }
|
||||
>x : { "new"<T extends RegExp>(x: T): string; }
|
||||
>b : { "new"<T extends RegExp>(x: T): string; }
|
||||
|
||||
function foo11(x: any) { }
|
||||
>foo11 : { (x: B<number[]>): any; (x: { new<T extends RegExp>(x: T): string; }): any; }
|
||||
>foo11 : { (x: B<number[]>): any; (x: { "new"<T extends RegExp>(x: T): string; }): any; }
|
||||
>x : any
|
||||
|
||||
function foo12(x: I<Number>);
|
||||
@ -192,15 +192,15 @@ function foo13(x: any) { }
|
||||
>x : any
|
||||
|
||||
function foo14(x: I<Number>);
|
||||
>foo14 : { (x: I<Number>): any; (x: { new<T extends RegExp>(x: T): string; }): any; }
|
||||
>foo14 : { (x: I<Number>): any; (x: { "new"<T extends RegExp>(x: T): string; }): any; }
|
||||
>x : I<Number>
|
||||
|
||||
function foo14(x: typeof b); // ok
|
||||
>foo14 : { (x: I<Number>): any; (x: typeof b): any; }
|
||||
>x : { new<T extends RegExp>(x: T): string; }
|
||||
>b : { new<T extends RegExp>(x: T): string; }
|
||||
>x : { "new"<T extends RegExp>(x: T): string; }
|
||||
>b : { "new"<T extends RegExp>(x: T): string; }
|
||||
|
||||
function foo14(x: any) { }
|
||||
>foo14 : { (x: I<Number>): any; (x: { new<T extends RegExp>(x: T): string; }): any; }
|
||||
>foo14 : { (x: I<Number>): any; (x: { "new"<T extends RegExp>(x: T): string; }): any; }
|
||||
>x : any
|
||||
|
||||
|
||||
@ -47,8 +47,8 @@ var a: { new<T extends U, U extends Array<string>>(x: T, y: U): string }
|
||||
>y : U
|
||||
|
||||
var b = { new<T extends U, U extends RegExp>(x: T, y: U) { return ''; } }; // not a construct signature, function called new
|
||||
>b : { new<T extends U, U extends RegExp>(x: T, y: U): string; }
|
||||
>{ new<T extends U, U extends RegExp>(x: T, y: U) { return ''; } } : { new<T extends U, U extends RegExp>(x: T, y: U): string; }
|
||||
>b : { "new"<T extends U, U extends RegExp>(x: T, y: U): string; }
|
||||
>{ new<T extends U, U extends RegExp>(x: T, y: U) { return ''; } } : { "new"<T extends U, U extends RegExp>(x: T, y: U): string; }
|
||||
>new : <T extends U, U extends RegExp>(x: T, y: U) => string
|
||||
>x : T
|
||||
>y : U
|
||||
@ -105,17 +105,17 @@ function foo3(x: any) { }
|
||||
>x : any
|
||||
|
||||
function foo4(x: typeof b);
|
||||
>foo4 : { (x: typeof b): any; (x: { new<T extends U, U extends RegExp>(x: T, y: U): string; }): any; }
|
||||
>x : { new<T extends U, U extends RegExp>(x: T, y: U): string; }
|
||||
>b : { new<T extends U, U extends RegExp>(x: T, y: U): string; }
|
||||
>foo4 : { (x: typeof b): any; (x: { "new"<T extends U, U extends RegExp>(x: T, y: U): string; }): any; }
|
||||
>x : { "new"<T extends U, U extends RegExp>(x: T, y: U): string; }
|
||||
>b : { "new"<T extends U, U extends RegExp>(x: T, y: U): string; }
|
||||
|
||||
function foo4(x: typeof b); // error
|
||||
>foo4 : { (x: { new<T extends U, U extends RegExp>(x: T, y: U): string; }): any; (x: typeof b): any; }
|
||||
>x : { new<T extends U, U extends RegExp>(x: T, y: U): string; }
|
||||
>b : { new<T extends U, U extends RegExp>(x: T, y: U): string; }
|
||||
>foo4 : { (x: { "new"<T extends U, U extends RegExp>(x: T, y: U): string; }): any; (x: typeof b): any; }
|
||||
>x : { "new"<T extends U, U extends RegExp>(x: T, y: U): string; }
|
||||
>b : { "new"<T extends U, U extends RegExp>(x: T, y: U): string; }
|
||||
|
||||
function foo4(x: any) { }
|
||||
>foo4 : { (x: { new<T extends U, U extends RegExp>(x: T, y: U): string; }): any; (x: { new<T extends U, U extends RegExp>(x: T, y: U): string; }): any; }
|
||||
>foo4 : { (x: { "new"<T extends U, U extends RegExp>(x: T, y: U): string; }): any; (x: { "new"<T extends U, U extends RegExp>(x: T, y: U): string; }): any; }
|
||||
>x : any
|
||||
|
||||
function foo5c(x: C<String, String>);
|
||||
@ -180,16 +180,16 @@ function foo10(x: any) { }
|
||||
>x : any
|
||||
|
||||
function foo11(x: B<Array<number>, Array<number>>);
|
||||
>foo11 : { (x: B<Array<number>, Array<number>>): any; (x: { new<T extends U, U extends RegExp>(x: T, y: U): string; }): any; }
|
||||
>foo11 : { (x: B<Array<number>, Array<number>>): any; (x: { "new"<T extends U, U extends RegExp>(x: T, y: U): string; }): any; }
|
||||
>x : B<number[], number[]>
|
||||
|
||||
function foo11(x: typeof b); // ok
|
||||
>foo11 : { (x: B<number[], number[]>): any; (x: typeof b): any; }
|
||||
>x : { new<T extends U, U extends RegExp>(x: T, y: U): string; }
|
||||
>b : { new<T extends U, U extends RegExp>(x: T, y: U): string; }
|
||||
>x : { "new"<T extends U, U extends RegExp>(x: T, y: U): string; }
|
||||
>b : { "new"<T extends U, U extends RegExp>(x: T, y: U): string; }
|
||||
|
||||
function foo11(x: any) { }
|
||||
>foo11 : { (x: B<number[], number[]>): any; (x: { new<T extends U, U extends RegExp>(x: T, y: U): string; }): any; }
|
||||
>foo11 : { (x: B<number[], number[]>): any; (x: { "new"<T extends U, U extends RegExp>(x: T, y: U): string; }): any; }
|
||||
>x : any
|
||||
|
||||
function foo12(x: I<Number, Number>);
|
||||
@ -230,15 +230,15 @@ function foo13(x: any) { }
|
||||
>x : any
|
||||
|
||||
function foo14(x: I<Number, Number>);
|
||||
>foo14 : { (x: I<Number, Number>): any; (x: { new<T extends U, U extends RegExp>(x: T, y: U): string; }): any; }
|
||||
>foo14 : { (x: I<Number, Number>): any; (x: { "new"<T extends U, U extends RegExp>(x: T, y: U): string; }): any; }
|
||||
>x : I<Number, Number>
|
||||
|
||||
function foo14(x: typeof b); // ok
|
||||
>foo14 : { (x: I<Number, Number>): any; (x: typeof b): any; }
|
||||
>x : { new<T extends U, U extends RegExp>(x: T, y: U): string; }
|
||||
>b : { new<T extends U, U extends RegExp>(x: T, y: U): string; }
|
||||
>x : { "new"<T extends U, U extends RegExp>(x: T, y: U): string; }
|
||||
>b : { "new"<T extends U, U extends RegExp>(x: T, y: U): string; }
|
||||
|
||||
function foo14(x: any) { }
|
||||
>foo14 : { (x: I<Number, Number>): any; (x: { new<T extends U, U extends RegExp>(x: T, y: U): string; }): any; }
|
||||
>foo14 : { (x: I<Number, Number>): any; (x: { "new"<T extends U, U extends RegExp>(x: T, y: U): string; }): any; }
|
||||
>x : any
|
||||
|
||||
|
||||
@ -67,8 +67,8 @@ var a: { new<T extends U, U extends One>(x: T, y: U): string }
|
||||
>y : U
|
||||
|
||||
var b = { new<T extends U, U extends Two>(x: T, y: U) { return ''; } }; // not a construct signature, function called new
|
||||
>b : { new<T extends U, U extends Two>(x: T, y: U): string; }
|
||||
>{ new<T extends U, U extends Two>(x: T, y: U) { return ''; } } : { new<T extends U, U extends Two>(x: T, y: U): string; }
|
||||
>b : { "new"<T extends U, U extends Two>(x: T, y: U): string; }
|
||||
>{ new<T extends U, U extends Two>(x: T, y: U) { return ''; } } : { "new"<T extends U, U extends Two>(x: T, y: U): string; }
|
||||
>new : <T extends U, U extends Two>(x: T, y: U) => string
|
||||
>x : T
|
||||
>y : U
|
||||
@ -125,17 +125,17 @@ function foo3(x: any) { }
|
||||
>x : any
|
||||
|
||||
function foo4(x: typeof b);
|
||||
>foo4 : { (x: typeof b): any; (x: { new<T extends U, U extends Two>(x: T, y: U): string; }): any; }
|
||||
>x : { new<T extends U, U extends Two>(x: T, y: U): string; }
|
||||
>b : { new<T extends U, U extends Two>(x: T, y: U): string; }
|
||||
>foo4 : { (x: typeof b): any; (x: { "new"<T extends U, U extends Two>(x: T, y: U): string; }): any; }
|
||||
>x : { "new"<T extends U, U extends Two>(x: T, y: U): string; }
|
||||
>b : { "new"<T extends U, U extends Two>(x: T, y: U): string; }
|
||||
|
||||
function foo4(x: typeof b); // error
|
||||
>foo4 : { (x: { new<T extends U, U extends Two>(x: T, y: U): string; }): any; (x: typeof b): any; }
|
||||
>x : { new<T extends U, U extends Two>(x: T, y: U): string; }
|
||||
>b : { new<T extends U, U extends Two>(x: T, y: U): string; }
|
||||
>foo4 : { (x: { "new"<T extends U, U extends Two>(x: T, y: U): string; }): any; (x: typeof b): any; }
|
||||
>x : { "new"<T extends U, U extends Two>(x: T, y: U): string; }
|
||||
>b : { "new"<T extends U, U extends Two>(x: T, y: U): string; }
|
||||
|
||||
function foo4(x: any) { }
|
||||
>foo4 : { (x: { new<T extends U, U extends Two>(x: T, y: U): string; }): any; (x: { new<T extends U, U extends Two>(x: T, y: U): string; }): any; }
|
||||
>foo4 : { (x: { "new"<T extends U, U extends Two>(x: T, y: U): string; }): any; (x: { "new"<T extends U, U extends Two>(x: T, y: U): string; }): any; }
|
||||
>x : any
|
||||
|
||||
function foo5c(x: C<Three, Three>);
|
||||
@ -200,16 +200,16 @@ function foo10(x: any) { }
|
||||
>x : any
|
||||
|
||||
function foo11(x: B<Two, Two>);
|
||||
>foo11 : { (x: B<Two, Two>): any; (x: { new<T extends U, U extends Two>(x: T, y: U): string; }): any; }
|
||||
>foo11 : { (x: B<Two, Two>): any; (x: { "new"<T extends U, U extends Two>(x: T, y: U): string; }): any; }
|
||||
>x : B<Two, Two>
|
||||
|
||||
function foo11(x: typeof b); // ok
|
||||
>foo11 : { (x: B<Two, Two>): any; (x: typeof b): any; }
|
||||
>x : { new<T extends U, U extends Two>(x: T, y: U): string; }
|
||||
>b : { new<T extends U, U extends Two>(x: T, y: U): string; }
|
||||
>x : { "new"<T extends U, U extends Two>(x: T, y: U): string; }
|
||||
>b : { "new"<T extends U, U extends Two>(x: T, y: U): string; }
|
||||
|
||||
function foo11(x: any) { }
|
||||
>foo11 : { (x: B<Two, Two>): any; (x: { new<T extends U, U extends Two>(x: T, y: U): string; }): any; }
|
||||
>foo11 : { (x: B<Two, Two>): any; (x: { "new"<T extends U, U extends Two>(x: T, y: U): string; }): any; }
|
||||
>x : any
|
||||
|
||||
function foo12(x: I<Five<string>, Five<string>>);
|
||||
@ -250,15 +250,15 @@ function foo13(x: any) { }
|
||||
>x : any
|
||||
|
||||
function foo14(x: I<Five<string>, Five<string>>);
|
||||
>foo14 : { (x: I<Five<string>, Five<string>>): any; (x: { new<T extends U, U extends Two>(x: T, y: U): string; }): any; }
|
||||
>foo14 : { (x: I<Five<string>, Five<string>>): any; (x: { "new"<T extends U, U extends Two>(x: T, y: U): string; }): any; }
|
||||
>x : I<Five<string>, Five<string>>
|
||||
|
||||
function foo14(x: typeof b); // ok
|
||||
>foo14 : { (x: I<Five<string>, Five<string>>): any; (x: typeof b): any; }
|
||||
>x : { new<T extends U, U extends Two>(x: T, y: U): string; }
|
||||
>b : { new<T extends U, U extends Two>(x: T, y: U): string; }
|
||||
>x : { "new"<T extends U, U extends Two>(x: T, y: U): string; }
|
||||
>b : { "new"<T extends U, U extends Two>(x: T, y: U): string; }
|
||||
|
||||
function foo14(x: any) { }
|
||||
>foo14 : { (x: I<Five<string>, Five<string>>): any; (x: { new<T extends U, U extends Two>(x: T, y: U): string; }): any; }
|
||||
>foo14 : { (x: I<Five<string>, Five<string>>): any; (x: { "new"<T extends U, U extends Two>(x: T, y: U): string; }): any; }
|
||||
>x : any
|
||||
|
||||
|
||||
@ -34,8 +34,8 @@ var a: { new<T>(x: T): T }
|
||||
>x : T
|
||||
|
||||
var b = { new<T>(x: T): T { return null; } }; // not a construct signature, function called new
|
||||
>b : { new<T>(x: T): T; }
|
||||
>{ new<T>(x: T): T { return null; } } : { new<T>(x: T): T; }
|
||||
>b : { "new"<T>(x: T): T; }
|
||||
>{ new<T>(x: T): T { return null; } } : { "new"<T>(x: T): T; }
|
||||
>new : <T>(x: T) => T
|
||||
>x : T
|
||||
|
||||
@ -90,31 +90,31 @@ function foo3(x: any) { }
|
||||
>x : any
|
||||
|
||||
function foo4(x: typeof b);
|
||||
>foo4 : { (x: typeof b): any; (x: { new<T>(x: T): T; }): any; }
|
||||
>x : { new<T>(x: T): T; }
|
||||
>b : { new<T>(x: T): T; }
|
||||
>foo4 : { (x: typeof b): any; (x: { "new"<T>(x: T): T; }): any; }
|
||||
>x : { "new"<T>(x: T): T; }
|
||||
>b : { "new"<T>(x: T): T; }
|
||||
|
||||
function foo4(x: typeof b); // error
|
||||
>foo4 : { (x: { new<T>(x: T): T; }): any; (x: typeof b): any; }
|
||||
>x : { new<T>(x: T): T; }
|
||||
>b : { new<T>(x: T): T; }
|
||||
>foo4 : { (x: { "new"<T>(x: T): T; }): any; (x: typeof b): any; }
|
||||
>x : { "new"<T>(x: T): T; }
|
||||
>b : { "new"<T>(x: T): T; }
|
||||
|
||||
function foo4(x: any) { }
|
||||
>foo4 : { (x: { new<T>(x: T): T; }): any; (x: { new<T>(x: T): T; }): any; }
|
||||
>foo4 : { (x: { "new"<T>(x: T): T; }): any; (x: { "new"<T>(x: T): T; }): any; }
|
||||
>x : any
|
||||
|
||||
function foo5(x: typeof a): number;
|
||||
>foo5 : { (x: typeof a): number; (x: { new<T>(x: T): T; }): string; }
|
||||
>foo5 : { (x: typeof a): number; (x: { "new"<T>(x: T): T; }): string; }
|
||||
>x : new <T>(x: T) => T
|
||||
>a : new <T>(x: T) => T
|
||||
|
||||
function foo5(x: typeof b): string; // ok
|
||||
>foo5 : { (x: new <T>(x: T) => T): number; (x: typeof b): string; }
|
||||
>x : { new<T>(x: T): T; }
|
||||
>b : { new<T>(x: T): T; }
|
||||
>x : { "new"<T>(x: T): T; }
|
||||
>b : { "new"<T>(x: T): T; }
|
||||
|
||||
function foo5(x: any): any { }
|
||||
>foo5 : { (x: new <T>(x: T) => T): number; (x: { new<T>(x: T): T; }): string; }
|
||||
>foo5 : { (x: new <T>(x: T) => T): number; (x: { "new"<T>(x: T): T; }): string; }
|
||||
>x : any
|
||||
|
||||
function foo8(x: B<string>);
|
||||
@ -155,16 +155,16 @@ function foo10(x: any) { }
|
||||
>x : any
|
||||
|
||||
function foo11(x: B<string>);
|
||||
>foo11 : { (x: B<string>): any; (x: { new<T>(x: T): T; }): any; }
|
||||
>foo11 : { (x: B<string>): any; (x: { "new"<T>(x: T): T; }): any; }
|
||||
>x : B<string>
|
||||
|
||||
function foo11(x: typeof b); // ok
|
||||
>foo11 : { (x: B<string>): any; (x: typeof b): any; }
|
||||
>x : { new<T>(x: T): T; }
|
||||
>b : { new<T>(x: T): T; }
|
||||
>x : { "new"<T>(x: T): T; }
|
||||
>b : { "new"<T>(x: T): T; }
|
||||
|
||||
function foo11(x: any) { }
|
||||
>foo11 : { (x: B<string>): any; (x: { new<T>(x: T): T; }): any; }
|
||||
>foo11 : { (x: B<string>): any; (x: { "new"<T>(x: T): T; }): any; }
|
||||
>x : any
|
||||
|
||||
function foo12(x: I<string>);
|
||||
@ -205,16 +205,16 @@ function foo13(x: any) { }
|
||||
>x : any
|
||||
|
||||
function foo14(x: I<string>);
|
||||
>foo14 : { (x: I<string>): any; (x: { new<T>(x: T): T; }): any; }
|
||||
>foo14 : { (x: I<string>): any; (x: { "new"<T>(x: T): T; }): any; }
|
||||
>x : I<string>
|
||||
|
||||
function foo14(x: typeof b); // ok
|
||||
>foo14 : { (x: I<string>): any; (x: typeof b): any; }
|
||||
>x : { new<T>(x: T): T; }
|
||||
>b : { new<T>(x: T): T; }
|
||||
>x : { "new"<T>(x: T): T; }
|
||||
>b : { "new"<T>(x: T): T; }
|
||||
|
||||
function foo14(x: any) { }
|
||||
>foo14 : { (x: I<string>): any; (x: { new<T>(x: T): T; }): any; }
|
||||
>foo14 : { (x: I<string>): any; (x: { "new"<T>(x: T): T; }): any; }
|
||||
>x : any
|
||||
|
||||
function foo15(x: I2);
|
||||
|
||||
@ -34,8 +34,8 @@ var a: { new<T extends Date>(x: T): T }
|
||||
>x : T
|
||||
|
||||
var b = { new<T extends Date>(x: T) { return null; } }; // not a construct signature, function called new
|
||||
>b : { new<T extends Date>(x: T): any; }
|
||||
>{ new<T extends Date>(x: T) { return null; } } : { new<T extends Date>(x: T): any; }
|
||||
>b : { "new"<T extends Date>(x: T): any; }
|
||||
>{ new<T extends Date>(x: T) { return null; } } : { "new"<T extends Date>(x: T): any; }
|
||||
>new : <T extends Date>(x: T) => any
|
||||
>x : T
|
||||
|
||||
@ -90,17 +90,17 @@ function foo3(x: any) { }
|
||||
>x : any
|
||||
|
||||
function foo4(x: typeof b);
|
||||
>foo4 : { (x: typeof b): any; (x: { new<T extends Date>(x: T): any; }): any; }
|
||||
>x : { new<T extends Date>(x: T): any; }
|
||||
>b : { new<T extends Date>(x: T): any; }
|
||||
>foo4 : { (x: typeof b): any; (x: { "new"<T extends Date>(x: T): any; }): any; }
|
||||
>x : { "new"<T extends Date>(x: T): any; }
|
||||
>b : { "new"<T extends Date>(x: T): any; }
|
||||
|
||||
function foo4(x: typeof b); // error
|
||||
>foo4 : { (x: { new<T extends Date>(x: T): any; }): any; (x: typeof b): any; }
|
||||
>x : { new<T extends Date>(x: T): any; }
|
||||
>b : { new<T extends Date>(x: T): any; }
|
||||
>foo4 : { (x: { "new"<T extends Date>(x: T): any; }): any; (x: typeof b): any; }
|
||||
>x : { "new"<T extends Date>(x: T): any; }
|
||||
>b : { "new"<T extends Date>(x: T): any; }
|
||||
|
||||
function foo4(x: any) { }
|
||||
>foo4 : { (x: { new<T extends Date>(x: T): any; }): any; (x: { new<T extends Date>(x: T): any; }): any; }
|
||||
>foo4 : { (x: { "new"<T extends Date>(x: T): any; }): any; (x: { "new"<T extends Date>(x: T): any; }): any; }
|
||||
>x : any
|
||||
|
||||
function foo8(x: B<Date>);
|
||||
@ -141,16 +141,16 @@ function foo10(x: any) { }
|
||||
>x : any
|
||||
|
||||
function foo11(x: B<Date>);
|
||||
>foo11 : { (x: B<Date>): any; (x: { new<T extends Date>(x: T): any; }): any; }
|
||||
>foo11 : { (x: B<Date>): any; (x: { "new"<T extends Date>(x: T): any; }): any; }
|
||||
>x : B<Date>
|
||||
|
||||
function foo11(x: typeof b); // ok
|
||||
>foo11 : { (x: B<Date>): any; (x: typeof b): any; }
|
||||
>x : { new<T extends Date>(x: T): any; }
|
||||
>b : { new<T extends Date>(x: T): any; }
|
||||
>x : { "new"<T extends Date>(x: T): any; }
|
||||
>b : { "new"<T extends Date>(x: T): any; }
|
||||
|
||||
function foo11(x: any) { }
|
||||
>foo11 : { (x: B<Date>): any; (x: { new<T extends Date>(x: T): any; }): any; }
|
||||
>foo11 : { (x: B<Date>): any; (x: { "new"<T extends Date>(x: T): any; }): any; }
|
||||
>x : any
|
||||
|
||||
function foo12(x: I<Date>);
|
||||
@ -191,16 +191,16 @@ function foo13(x: any) { }
|
||||
>x : any
|
||||
|
||||
function foo14(x: I<Date>);
|
||||
>foo14 : { (x: I<Date>): any; (x: { new<T extends Date>(x: T): any; }): any; }
|
||||
>foo14 : { (x: I<Date>): any; (x: { "new"<T extends Date>(x: T): any; }): any; }
|
||||
>x : I<Date>
|
||||
|
||||
function foo14(x: typeof b); // ok
|
||||
>foo14 : { (x: I<Date>): any; (x: typeof b): any; }
|
||||
>x : { new<T extends Date>(x: T): any; }
|
||||
>b : { new<T extends Date>(x: T): any; }
|
||||
>x : { "new"<T extends Date>(x: T): any; }
|
||||
>b : { "new"<T extends Date>(x: T): any; }
|
||||
|
||||
function foo14(x: any) { }
|
||||
>foo14 : { (x: I<Date>): any; (x: { new<T extends Date>(x: T): any; }): any; }
|
||||
>foo14 : { (x: I<Date>): any; (x: { "new"<T extends Date>(x: T): any; }): any; }
|
||||
>x : any
|
||||
|
||||
function foo15(x: I2);
|
||||
|
||||
@ -32,8 +32,8 @@ var a: { new <Z, A, B, CC, D>(x: Z): C<Z, A, B>; }
|
||||
>x : Z
|
||||
|
||||
var b = { new<A, B, C, D, E, F>(x: A) { return x; } };
|
||||
>b : { new<A, B, C, D, E, F>(x: A): A; }
|
||||
>{ new<A, B, C, D, E, F>(x: A) { return x; } } : { new<A, B, C, D, E, F>(x: A): A; }
|
||||
>b : { "new"<A, B, C, D, E, F>(x: A): A; }
|
||||
>{ new<A, B, C, D, E, F>(x: A) { return x; } } : { "new"<A, B, C, D, E, F>(x: A): A; }
|
||||
>new : <A, B, C, D, E, F>(x: A) => A
|
||||
>x : A
|
||||
>x : A
|
||||
@ -89,17 +89,17 @@ function foo3(x: any) { }
|
||||
>x : any
|
||||
|
||||
function foo4(x: typeof b);
|
||||
>foo4 : { (x: typeof b): any; (x: { new<A, B, C, D, E, F>(x: A): A; }): any; }
|
||||
>x : { new<A, B, C, D, E, F>(x: A): A; }
|
||||
>b : { new<A, B, C, D, E, F>(x: A): A; }
|
||||
>foo4 : { (x: typeof b): any; (x: { "new"<A, B, C, D, E, F>(x: A): A; }): any; }
|
||||
>x : { "new"<A, B, C, D, E, F>(x: A): A; }
|
||||
>b : { "new"<A, B, C, D, E, F>(x: A): A; }
|
||||
|
||||
function foo4(x: typeof b); // error
|
||||
>foo4 : { (x: { new<A, B, C, D, E, F>(x: A): A; }): any; (x: typeof b): any; }
|
||||
>x : { new<A, B, C, D, E, F>(x: A): A; }
|
||||
>b : { new<A, B, C, D, E, F>(x: A): A; }
|
||||
>foo4 : { (x: { "new"<A, B, C, D, E, F>(x: A): A; }): any; (x: typeof b): any; }
|
||||
>x : { "new"<A, B, C, D, E, F>(x: A): A; }
|
||||
>b : { "new"<A, B, C, D, E, F>(x: A): A; }
|
||||
|
||||
function foo4(x: any) { }
|
||||
>foo4 : { (x: { new<A, B, C, D, E, F>(x: A): A; }): any; (x: { new<A, B, C, D, E, F>(x: A): A; }): any; }
|
||||
>foo4 : { (x: { "new"<A, B, C, D, E, F>(x: A): A; }): any; (x: { "new"<A, B, C, D, E, F>(x: A): A; }): any; }
|
||||
>x : any
|
||||
|
||||
function foo8(x: B<string, string>);
|
||||
@ -140,16 +140,16 @@ function foo10(x: any) { }
|
||||
>x : any
|
||||
|
||||
function foo11(x: B<string, boolean>);
|
||||
>foo11 : { (x: B<string, boolean>): any; (x: { new<A, B, C, D, E, F>(x: A): A; }): any; }
|
||||
>foo11 : { (x: B<string, boolean>): any; (x: { "new"<A, B, C, D, E, F>(x: A): A; }): any; }
|
||||
>x : B<string, boolean>
|
||||
|
||||
function foo11(x: typeof b); // ok
|
||||
>foo11 : { (x: B<string, boolean>): any; (x: typeof b): any; }
|
||||
>x : { new<A, B, C, D, E, F>(x: A): A; }
|
||||
>b : { new<A, B, C, D, E, F>(x: A): A; }
|
||||
>x : { "new"<A, B, C, D, E, F>(x: A): A; }
|
||||
>b : { "new"<A, B, C, D, E, F>(x: A): A; }
|
||||
|
||||
function foo11(x: any) { }
|
||||
>foo11 : { (x: B<string, boolean>): any; (x: { new<A, B, C, D, E, F>(x: A): A; }): any; }
|
||||
>foo11 : { (x: B<string, boolean>): any; (x: { "new"<A, B, C, D, E, F>(x: A): A; }): any; }
|
||||
>x : any
|
||||
|
||||
function foo12(x: I<B<string, number>, number, Date, string>);
|
||||
@ -190,15 +190,15 @@ function foo13(x: any) { }
|
||||
>x : any
|
||||
|
||||
function foo14(x: I<string, Date, RegExp, boolean>);
|
||||
>foo14 : { (x: I<string, Date, RegExp, boolean>): any; (x: { new<A, B, C, D, E, F>(x: A): A; }): any; }
|
||||
>foo14 : { (x: I<string, Date, RegExp, boolean>): any; (x: { "new"<A, B, C, D, E, F>(x: A): A; }): any; }
|
||||
>x : I<string, Date, RegExp, boolean>
|
||||
|
||||
function foo14(x: typeof b); // ok
|
||||
>foo14 : { (x: I<string, Date, RegExp, boolean>): any; (x: typeof b): any; }
|
||||
>x : { new<A, B, C, D, E, F>(x: A): A; }
|
||||
>b : { new<A, B, C, D, E, F>(x: A): A; }
|
||||
>x : { "new"<A, B, C, D, E, F>(x: A): A; }
|
||||
>b : { "new"<A, B, C, D, E, F>(x: A): A; }
|
||||
|
||||
function foo14(x: any) { }
|
||||
>foo14 : { (x: I<string, Date, RegExp, boolean>): any; (x: { new<A, B, C, D, E, F>(x: A): A; }): any; }
|
||||
>foo14 : { (x: I<string, Date, RegExp, boolean>): any; (x: { "new"<A, B, C, D, E, F>(x: A): A; }): any; }
|
||||
>x : any
|
||||
|
||||
|
||||
@ -32,8 +32,8 @@ var a: { new<Z>(x: Z): B<Z> }
|
||||
>x : Z
|
||||
|
||||
var b = { new<A>(x: A) { return new C<A>(x); } };
|
||||
>b : { new<A>(x: A): C<A>; }
|
||||
>{ new<A>(x: A) { return new C<A>(x); } } : { new<A>(x: A): C<A>; }
|
||||
>b : { "new"<A>(x: A): C<A>; }
|
||||
>{ new<A>(x: A) { return new C<A>(x); } } : { "new"<A>(x: A): C<A>; }
|
||||
>new : <A>(x: A) => C<A>
|
||||
>x : A
|
||||
>new C<A>(x) : C<A>
|
||||
@ -91,17 +91,17 @@ function foo3(x: any) { }
|
||||
>x : any
|
||||
|
||||
function foo4(x: typeof b);
|
||||
>foo4 : { (x: typeof b): any; (x: { new<A>(x: A): C<A>; }): any; }
|
||||
>x : { new<A>(x: A): C<A>; }
|
||||
>b : { new<A>(x: A): C<A>; }
|
||||
>foo4 : { (x: typeof b): any; (x: { "new"<A>(x: A): C<A>; }): any; }
|
||||
>x : { "new"<A>(x: A): C<A>; }
|
||||
>b : { "new"<A>(x: A): C<A>; }
|
||||
|
||||
function foo4(x: typeof b); // error
|
||||
>foo4 : { (x: { new<A>(x: A): C<A>; }): any; (x: typeof b): any; }
|
||||
>x : { new<A>(x: A): C<A>; }
|
||||
>b : { new<A>(x: A): C<A>; }
|
||||
>foo4 : { (x: { "new"<A>(x: A): C<A>; }): any; (x: typeof b): any; }
|
||||
>x : { "new"<A>(x: A): C<A>; }
|
||||
>b : { "new"<A>(x: A): C<A>; }
|
||||
|
||||
function foo4(x: any) { }
|
||||
>foo4 : { (x: { new<A>(x: A): C<A>; }): any; (x: { new<A>(x: A): C<A>; }): any; }
|
||||
>foo4 : { (x: { "new"<A>(x: A): C<A>; }): any; (x: { "new"<A>(x: A): C<A>; }): any; }
|
||||
>x : any
|
||||
|
||||
function foo8(x: B<string>);
|
||||
@ -142,16 +142,16 @@ function foo10(x: any) { }
|
||||
>x : any
|
||||
|
||||
function foo11(x: B<string>);
|
||||
>foo11 : { (x: B<string>): any; (x: { new<A>(x: A): C<A>; }): any; }
|
||||
>foo11 : { (x: B<string>): any; (x: { "new"<A>(x: A): C<A>; }): any; }
|
||||
>x : B<string>
|
||||
|
||||
function foo11(x: typeof b); // ok
|
||||
>foo11 : { (x: B<string>): any; (x: typeof b): any; }
|
||||
>x : { new<A>(x: A): C<A>; }
|
||||
>b : { new<A>(x: A): C<A>; }
|
||||
>x : { "new"<A>(x: A): C<A>; }
|
||||
>b : { "new"<A>(x: A): C<A>; }
|
||||
|
||||
function foo11(x: any) { }
|
||||
>foo11 : { (x: B<string>): any; (x: { new<A>(x: A): C<A>; }): any; }
|
||||
>foo11 : { (x: B<string>): any; (x: { "new"<A>(x: A): C<A>; }): any; }
|
||||
>x : any
|
||||
|
||||
function foo12(x: I<string>);
|
||||
@ -192,15 +192,15 @@ function foo13(x: any) { }
|
||||
>x : any
|
||||
|
||||
function foo14(x: I<string>);
|
||||
>foo14 : { (x: I<string>): any; (x: { new<A>(x: A): C<A>; }): any; }
|
||||
>foo14 : { (x: I<string>): any; (x: { "new"<A>(x: A): C<A>; }): any; }
|
||||
>x : I<string>
|
||||
|
||||
function foo14(x: typeof b); // ok
|
||||
>foo14 : { (x: I<string>): any; (x: typeof b): any; }
|
||||
>x : { new<A>(x: A): C<A>; }
|
||||
>b : { new<A>(x: A): C<A>; }
|
||||
>x : { "new"<A>(x: A): C<A>; }
|
||||
>b : { "new"<A>(x: A): C<A>; }
|
||||
|
||||
function foo14(x: any) { }
|
||||
>foo14 : { (x: I<string>): any; (x: { new<A>(x: A): C<A>; }): any; }
|
||||
>foo14 : { (x: I<string>): any; (x: { "new"<A>(x: A): C<A>; }): any; }
|
||||
>x : any
|
||||
|
||||
|
||||
@ -39,8 +39,8 @@ var a: { new<T>(x: T, y?: T): B<T> }
|
||||
>y : T
|
||||
|
||||
var b = { new<T>(x: T, y?: T) { return new C<T>(x, y); } }; // not a construct signature, function called new
|
||||
>b : { new<T>(x: T, y?: T): C<T>; }
|
||||
>{ new<T>(x: T, y?: T) { return new C<T>(x, y); } } : { new<T>(x: T, y?: T): C<T>; }
|
||||
>b : { "new"<T>(x: T, y?: T): C<T>; }
|
||||
>{ new<T>(x: T, y?: T) { return new C<T>(x, y); } } : { "new"<T>(x: T, y?: T): C<T>; }
|
||||
>new : <T>(x: T, y?: T) => C<T>
|
||||
>x : T
|
||||
>y : T
|
||||
@ -100,17 +100,17 @@ function foo3(x: any) { }
|
||||
>x : any
|
||||
|
||||
function foo4(x: typeof b);
|
||||
>foo4 : { (x: typeof b): any; (x: { new<T>(x: T, y?: T): C<T>; }): any; }
|
||||
>x : { new<T>(x: T, y?: T): C<T>; }
|
||||
>b : { new<T>(x: T, y?: T): C<T>; }
|
||||
>foo4 : { (x: typeof b): any; (x: { "new"<T>(x: T, y?: T): C<T>; }): any; }
|
||||
>x : { "new"<T>(x: T, y?: T): C<T>; }
|
||||
>b : { "new"<T>(x: T, y?: T): C<T>; }
|
||||
|
||||
function foo4(x: typeof b); // error
|
||||
>foo4 : { (x: { new<T>(x: T, y?: T): C<T>; }): any; (x: typeof b): any; }
|
||||
>x : { new<T>(x: T, y?: T): C<T>; }
|
||||
>b : { new<T>(x: T, y?: T): C<T>; }
|
||||
>foo4 : { (x: { "new"<T>(x: T, y?: T): C<T>; }): any; (x: typeof b): any; }
|
||||
>x : { "new"<T>(x: T, y?: T): C<T>; }
|
||||
>b : { "new"<T>(x: T, y?: T): C<T>; }
|
||||
|
||||
function foo4(x: any) { }
|
||||
>foo4 : { (x: { new<T>(x: T, y?: T): C<T>; }): any; (x: { new<T>(x: T, y?: T): C<T>; }): any; }
|
||||
>foo4 : { (x: { "new"<T>(x: T, y?: T): C<T>; }): any; (x: { "new"<T>(x: T, y?: T): C<T>; }): any; }
|
||||
>x : any
|
||||
|
||||
function foo8(x: B<string>): string;
|
||||
@ -151,16 +151,16 @@ function foo10(x: any) { }
|
||||
>x : any
|
||||
|
||||
function foo11(x: B<string>);
|
||||
>foo11 : { (x: B<string>): any; (x: { new<T>(x: T, y?: T): C<T>; }): any; }
|
||||
>foo11 : { (x: B<string>): any; (x: { "new"<T>(x: T, y?: T): C<T>; }): any; }
|
||||
>x : B<string>
|
||||
|
||||
function foo11(x: typeof b); // ok
|
||||
>foo11 : { (x: B<string>): any; (x: typeof b): any; }
|
||||
>x : { new<T>(x: T, y?: T): C<T>; }
|
||||
>b : { new<T>(x: T, y?: T): C<T>; }
|
||||
>x : { "new"<T>(x: T, y?: T): C<T>; }
|
||||
>b : { "new"<T>(x: T, y?: T): C<T>; }
|
||||
|
||||
function foo11(x: any) { }
|
||||
>foo11 : { (x: B<string>): any; (x: { new<T>(x: T, y?: T): C<T>; }): any; }
|
||||
>foo11 : { (x: B<string>): any; (x: { "new"<T>(x: T, y?: T): C<T>; }): any; }
|
||||
>x : any
|
||||
|
||||
function foo12(x: I<string>);
|
||||
@ -201,15 +201,15 @@ function foo13(x: any) { }
|
||||
>x : any
|
||||
|
||||
function foo14(x: I<string>);
|
||||
>foo14 : { (x: I<string>): any; (x: { new<T>(x: T, y?: T): C<T>; }): any; }
|
||||
>foo14 : { (x: I<string>): any; (x: { "new"<T>(x: T, y?: T): C<T>; }): any; }
|
||||
>x : I<string>
|
||||
|
||||
function foo14(x: typeof b); // ok
|
||||
>foo14 : { (x: I<string>): any; (x: typeof b): any; }
|
||||
>x : { new<T>(x: T, y?: T): C<T>; }
|
||||
>b : { new<T>(x: T, y?: T): C<T>; }
|
||||
>x : { "new"<T>(x: T, y?: T): C<T>; }
|
||||
>b : { "new"<T>(x: T, y?: T): C<T>; }
|
||||
|
||||
function foo14(x: any) { }
|
||||
>foo14 : { (x: I<string>): any; (x: { new<T>(x: T, y?: T): C<T>; }): any; }
|
||||
>foo14 : { (x: I<string>): any; (x: { "new"<T>(x: T, y?: T): C<T>; }): any; }
|
||||
>x : any
|
||||
|
||||
|
||||
@ -39,8 +39,8 @@ var a: { new<T, U>(x: T, y?: U): B<T,U> }
|
||||
>y : U
|
||||
|
||||
var b = { new<T, U>(x: T, y?: U) { return new C<T, U>(x, y); } }; // not a construct signature, function called new
|
||||
>b : { new<T, U>(x: T, y?: U): C<T, U>; }
|
||||
>{ new<T, U>(x: T, y?: U) { return new C<T, U>(x, y); } } : { new<T, U>(x: T, y?: U): C<T, U>; }
|
||||
>b : { "new"<T, U>(x: T, y?: U): C<T, U>; }
|
||||
>{ new<T, U>(x: T, y?: U) { return new C<T, U>(x, y); } } : { "new"<T, U>(x: T, y?: U): C<T, U>; }
|
||||
>new : <T, U>(x: T, y?: U) => C<T, U>
|
||||
>x : T
|
||||
>y : U
|
||||
@ -100,17 +100,17 @@ function foo3(x: any) { }
|
||||
>x : any
|
||||
|
||||
function foo4(x: typeof b);
|
||||
>foo4 : { (x: typeof b): any; (x: { new<T, U>(x: T, y?: U): C<T, U>; }): any; }
|
||||
>x : { new<T, U>(x: T, y?: U): C<T, U>; }
|
||||
>b : { new<T, U>(x: T, y?: U): C<T, U>; }
|
||||
>foo4 : { (x: typeof b): any; (x: { "new"<T, U>(x: T, y?: U): C<T, U>; }): any; }
|
||||
>x : { "new"<T, U>(x: T, y?: U): C<T, U>; }
|
||||
>b : { "new"<T, U>(x: T, y?: U): C<T, U>; }
|
||||
|
||||
function foo4(x: typeof b); // error
|
||||
>foo4 : { (x: { new<T, U>(x: T, y?: U): C<T, U>; }): any; (x: typeof b): any; }
|
||||
>x : { new<T, U>(x: T, y?: U): C<T, U>; }
|
||||
>b : { new<T, U>(x: T, y?: U): C<T, U>; }
|
||||
>foo4 : { (x: { "new"<T, U>(x: T, y?: U): C<T, U>; }): any; (x: typeof b): any; }
|
||||
>x : { "new"<T, U>(x: T, y?: U): C<T, U>; }
|
||||
>b : { "new"<T, U>(x: T, y?: U): C<T, U>; }
|
||||
|
||||
function foo4(x: any) { }
|
||||
>foo4 : { (x: { new<T, U>(x: T, y?: U): C<T, U>; }): any; (x: { new<T, U>(x: T, y?: U): C<T, U>; }): any; }
|
||||
>foo4 : { (x: { "new"<T, U>(x: T, y?: U): C<T, U>; }): any; (x: { "new"<T, U>(x: T, y?: U): C<T, U>; }): any; }
|
||||
>x : any
|
||||
|
||||
function foo8(x: B<string, number>);
|
||||
@ -151,16 +151,16 @@ function foo10(x: any) { }
|
||||
>x : any
|
||||
|
||||
function foo11(x: B<string, number>);
|
||||
>foo11 : { (x: B<string, number>): any; (x: { new<T, U>(x: T, y?: U): C<T, U>; }): any; }
|
||||
>foo11 : { (x: B<string, number>): any; (x: { "new"<T, U>(x: T, y?: U): C<T, U>; }): any; }
|
||||
>x : B<string, number>
|
||||
|
||||
function foo11(x: typeof b); // ok
|
||||
>foo11 : { (x: B<string, number>): any; (x: typeof b): any; }
|
||||
>x : { new<T, U>(x: T, y?: U): C<T, U>; }
|
||||
>b : { new<T, U>(x: T, y?: U): C<T, U>; }
|
||||
>x : { "new"<T, U>(x: T, y?: U): C<T, U>; }
|
||||
>b : { "new"<T, U>(x: T, y?: U): C<T, U>; }
|
||||
|
||||
function foo11(x: any) { }
|
||||
>foo11 : { (x: B<string, number>): any; (x: { new<T, U>(x: T, y?: U): C<T, U>; }): any; }
|
||||
>foo11 : { (x: B<string, number>): any; (x: { "new"<T, U>(x: T, y?: U): C<T, U>; }): any; }
|
||||
>x : any
|
||||
|
||||
function foo12(x: I<string, number>);
|
||||
@ -201,15 +201,15 @@ function foo13(x: any) { }
|
||||
>x : any
|
||||
|
||||
function foo14(x: I<string, number>);
|
||||
>foo14 : { (x: I<string, number>): any; (x: { new<T, U>(x: T, y?: U): C<T, U>; }): any; }
|
||||
>foo14 : { (x: I<string, number>): any; (x: { "new"<T, U>(x: T, y?: U): C<T, U>; }): any; }
|
||||
>x : I<string, number>
|
||||
|
||||
function foo14(x: typeof b); // ok
|
||||
>foo14 : { (x: I<string, number>): any; (x: typeof b): any; }
|
||||
>x : { new<T, U>(x: T, y?: U): C<T, U>; }
|
||||
>b : { new<T, U>(x: T, y?: U): C<T, U>; }
|
||||
>x : { "new"<T, U>(x: T, y?: U): C<T, U>; }
|
||||
>b : { "new"<T, U>(x: T, y?: U): C<T, U>; }
|
||||
|
||||
function foo14(x: any) { }
|
||||
>foo14 : { (x: I<string, number>): any; (x: { new<T, U>(x: T, y?: U): C<T, U>; }): any; }
|
||||
>foo14 : { (x: I<string, number>): any; (x: { "new"<T, U>(x: T, y?: U): C<T, U>; }): any; }
|
||||
>x : any
|
||||
|
||||
|
||||
@ -39,8 +39,8 @@ var a: { new <T, U>(x: T, y?: U): B<T, U> };
|
||||
>y : U
|
||||
|
||||
var b = { new<T, U>(x: T, y: U) { return new C<T, U>(x, y); } }; // not a construct signature, function called new
|
||||
>b : { new<T, U>(x: T, y: U): C<T, U>; }
|
||||
>{ new<T, U>(x: T, y: U) { return new C<T, U>(x, y); } } : { new<T, U>(x: T, y: U): C<T, U>; }
|
||||
>b : { "new"<T, U>(x: T, y: U): C<T, U>; }
|
||||
>{ new<T, U>(x: T, y: U) { return new C<T, U>(x, y); } } : { "new"<T, U>(x: T, y: U): C<T, U>; }
|
||||
>new : <T, U>(x: T, y: U) => C<T, U>
|
||||
>x : T
|
||||
>y : U
|
||||
@ -100,17 +100,17 @@ function foo3(x: any) { }
|
||||
>x : any
|
||||
|
||||
function foo4(x: typeof b);
|
||||
>foo4 : { (x: typeof b): any; (x: { new<T, U>(x: T, y: U): C<T, U>; }): any; }
|
||||
>x : { new<T, U>(x: T, y: U): C<T, U>; }
|
||||
>b : { new<T, U>(x: T, y: U): C<T, U>; }
|
||||
>foo4 : { (x: typeof b): any; (x: { "new"<T, U>(x: T, y: U): C<T, U>; }): any; }
|
||||
>x : { "new"<T, U>(x: T, y: U): C<T, U>; }
|
||||
>b : { "new"<T, U>(x: T, y: U): C<T, U>; }
|
||||
|
||||
function foo4(x: typeof b); // error
|
||||
>foo4 : { (x: { new<T, U>(x: T, y: U): C<T, U>; }): any; (x: typeof b): any; }
|
||||
>x : { new<T, U>(x: T, y: U): C<T, U>; }
|
||||
>b : { new<T, U>(x: T, y: U): C<T, U>; }
|
||||
>foo4 : { (x: { "new"<T, U>(x: T, y: U): C<T, U>; }): any; (x: typeof b): any; }
|
||||
>x : { "new"<T, U>(x: T, y: U): C<T, U>; }
|
||||
>b : { "new"<T, U>(x: T, y: U): C<T, U>; }
|
||||
|
||||
function foo4(x: any) { }
|
||||
>foo4 : { (x: { new<T, U>(x: T, y: U): C<T, U>; }): any; (x: { new<T, U>(x: T, y: U): C<T, U>; }): any; }
|
||||
>foo4 : { (x: { "new"<T, U>(x: T, y: U): C<T, U>; }): any; (x: { "new"<T, U>(x: T, y: U): C<T, U>; }): any; }
|
||||
>x : any
|
||||
|
||||
function foo8(x: B<string, number>);
|
||||
@ -151,16 +151,16 @@ function foo10(x: any) { }
|
||||
>x : any
|
||||
|
||||
function foo11(x: B<string, number>);
|
||||
>foo11 : { (x: B<string, number>): any; (x: { new<T, U>(x: T, y: U): C<T, U>; }): any; }
|
||||
>foo11 : { (x: B<string, number>): any; (x: { "new"<T, U>(x: T, y: U): C<T, U>; }): any; }
|
||||
>x : B<string, number>
|
||||
|
||||
function foo11(x: typeof b); // ok
|
||||
>foo11 : { (x: B<string, number>): any; (x: typeof b): any; }
|
||||
>x : { new<T, U>(x: T, y: U): C<T, U>; }
|
||||
>b : { new<T, U>(x: T, y: U): C<T, U>; }
|
||||
>x : { "new"<T, U>(x: T, y: U): C<T, U>; }
|
||||
>b : { "new"<T, U>(x: T, y: U): C<T, U>; }
|
||||
|
||||
function foo11(x: any) { }
|
||||
>foo11 : { (x: B<string, number>): any; (x: { new<T, U>(x: T, y: U): C<T, U>; }): any; }
|
||||
>foo11 : { (x: B<string, number>): any; (x: { "new"<T, U>(x: T, y: U): C<T, U>; }): any; }
|
||||
>x : any
|
||||
|
||||
function foo12(x: I<string, number>);
|
||||
@ -201,15 +201,15 @@ function foo13(x: any) { }
|
||||
>x : any
|
||||
|
||||
function foo14(x: I<string, number>);
|
||||
>foo14 : { (x: I<string, number>): any; (x: { new<T, U>(x: T, y: U): C<T, U>; }): any; }
|
||||
>foo14 : { (x: I<string, number>): any; (x: { "new"<T, U>(x: T, y: U): C<T, U>; }): any; }
|
||||
>x : I<string, number>
|
||||
|
||||
function foo14(x: typeof b); // ok
|
||||
>foo14 : { (x: I<string, number>): any; (x: typeof b): any; }
|
||||
>x : { new<T, U>(x: T, y: U): C<T, U>; }
|
||||
>b : { new<T, U>(x: T, y: U): C<T, U>; }
|
||||
>x : { "new"<T, U>(x: T, y: U): C<T, U>; }
|
||||
>b : { "new"<T, U>(x: T, y: U): C<T, U>; }
|
||||
|
||||
function foo14(x: any) { }
|
||||
>foo14 : { (x: I<string, number>): any; (x: { new<T, U>(x: T, y: U): C<T, U>; }): any; }
|
||||
>foo14 : { (x: I<string, number>): any; (x: { "new"<T, U>(x: T, y: U): C<T, U>; }): any; }
|
||||
>x : any
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
=== parser645484.ts ===
|
||||
var c : {
|
||||
>c : { new?(): any; }
|
||||
>c : { "new"?(): any; }
|
||||
|
||||
new?(): any;
|
||||
>new : () => any
|
||||
|
||||
@ -66,7 +66,7 @@ var n1: { [s: string]: number; };
|
||||
>s : string
|
||||
|
||||
var c : {
|
||||
>c : { new?(): any; }
|
||||
>c : { "new"?(): any; }
|
||||
|
||||
new? (): any;
|
||||
>new : () => any
|
||||
|
||||
13
tests/cases/compiler/emitMethodCalledNew.ts
Normal file
13
tests/cases/compiler/emitMethodCalledNew.ts
Normal file
@ -0,0 +1,13 @@
|
||||
// @declaration: true
|
||||
|
||||
// https://github.com/microsoft/TypeScript/issues/55075
|
||||
|
||||
export const a = {
|
||||
new(x: number) { return x + 1 }
|
||||
}
|
||||
export const b = {
|
||||
"new"(x: number) { return x + 1 }
|
||||
}
|
||||
export const c = {
|
||||
["new"](x: number) { return x + 1 }
|
||||
}
|
||||
17
tests/cases/fourslash/codeFixAddMissingMember31.ts
Normal file
17
tests/cases/fourslash/codeFixAddMissingMember31.ts
Normal file
@ -0,0 +1,17 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
////class C {
|
||||
//// "new"(x: number) {}
|
||||
////}
|
||||
////[|const foo: C = {}|];
|
||||
|
||||
verify.codeFix({
|
||||
index: 0,
|
||||
description: ts.Diagnostics.Add_missing_properties.message,
|
||||
newRangeContent:
|
||||
`const foo: C = {
|
||||
new: function(x: number): void {
|
||||
throw new Error("Function not implemented.");
|
||||
}
|
||||
}`
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user