From 5cabe0e5deec25c3240d2cfe189f2d210d0cd244 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Thu, 13 Jul 2017 14:32:42 -0700 Subject: [PATCH 1/2] Reuse stored types for any[] and Promise instead of creating new ones --- src/compiler/checker.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 6c5fcc36e4df1..cb5d5ad2d2c2d 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -298,6 +298,7 @@ namespace ts { let globalBooleanType: ObjectType; let globalRegExpType: ObjectType; let globalThisType: GenericType; + let anyPromiseType: Type; let anyArrayType: Type; let autoArrayType: Type; let anyReadonlyArrayType: Type; @@ -6890,10 +6891,10 @@ namespace ts { return globalFunctionType; case "Array": case "array": - return !node.typeArguments || !node.typeArguments.length ? createArrayType(anyType) : undefined; + return !node.typeArguments || !node.typeArguments.length ? anyArrayType : undefined; case "Promise": case "promise": - return !node.typeArguments || !node.typeArguments.length ? createPromiseType(anyType) : undefined; + return !node.typeArguments || !node.typeArguments.length ? anyPromiseType : undefined; } } } @@ -23486,6 +23487,7 @@ namespace ts { globalNumberType = getGlobalType("Number" as __String, /*arity*/ 0, /*reportErrors*/ true); globalBooleanType = getGlobalType("Boolean" as __String, /*arity*/ 0, /*reportErrors*/ true); globalRegExpType = getGlobalType("RegExp" as __String, /*arity*/ 0, /*reportErrors*/ true); + anyPromiseType = createPromiseType(anyType); anyArrayType = createArrayType(anyType); autoArrayType = createArrayType(autoType); From 82758590b34601080a8be71a6abf7cc664adcf09 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Fri, 14 Jul 2017 11:06:36 -0700 Subject: [PATCH 2/2] Don't store anyPromiseType --- src/compiler/checker.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index cb5d5ad2d2c2d..b0c79d16e46e8 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -298,7 +298,6 @@ namespace ts { let globalBooleanType: ObjectType; let globalRegExpType: ObjectType; let globalThisType: GenericType; - let anyPromiseType: Type; let anyArrayType: Type; let autoArrayType: Type; let anyReadonlyArrayType: Type; @@ -6894,7 +6893,7 @@ namespace ts { return !node.typeArguments || !node.typeArguments.length ? anyArrayType : undefined; case "Promise": case "promise": - return !node.typeArguments || !node.typeArguments.length ? anyPromiseType : undefined; + return !node.typeArguments || !node.typeArguments.length ? createPromiseType(anyType) : undefined; } } } @@ -23487,7 +23486,6 @@ namespace ts { globalNumberType = getGlobalType("Number" as __String, /*arity*/ 0, /*reportErrors*/ true); globalBooleanType = getGlobalType("Boolean" as __String, /*arity*/ 0, /*reportErrors*/ true); globalRegExpType = getGlobalType("RegExp" as __String, /*arity*/ 0, /*reportErrors*/ true); - anyPromiseType = createPromiseType(anyType); anyArrayType = createArrayType(anyType); autoArrayType = createArrayType(autoType);