From cee3c4af3296dd1f7db3cd519b56b1a0ffc4c4db Mon Sep 17 00:00:00 2001 From: teppeis Date: Mon, 10 Dec 2018 09:06:26 +0900 Subject: [PATCH] Improve Promise and remove `--noStrictGenericChecks` from DeclarationSyntaxTest --- .../com/google/javascript/clutz/DeclarationGenerator.java | 4 +--- .../com/google/javascript/clutz/DeclarationSyntaxTest.java | 5 +---- .../google/javascript/clutz/goog_promise_with_platform.d.ts | 4 ++-- .../google/javascript/clutz/partial/tte_promise_partial.d.ts | 2 +- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/google/javascript/clutz/DeclarationGenerator.java b/src/main/java/com/google/javascript/clutz/DeclarationGenerator.java index dd4f0310..09934319 100644 --- a/src/main/java/com/google/javascript/clutz/DeclarationGenerator.java +++ b/src/main/java/com/google/javascript/clutz/DeclarationGenerator.java @@ -2968,9 +2968,7 @@ private String getSignatureForInstanceTTEFn( } else { return "then < RESULT > (opt_onFulfilled ? : ( (a : " + templateVarName - + " ) => " - + classTemplatizedType - + " | RESULT ) | null , " + + " ) => PromiseLike < RESULT > | RESULT ) | null , " + "opt_onRejected ? : ( (a : any ) => any ) | null) : " + classTemplatizedType + " ;"; diff --git a/src/test/java/com/google/javascript/clutz/DeclarationSyntaxTest.java b/src/test/java/com/google/javascript/clutz/DeclarationSyntaxTest.java index f71f43b6..ab246c78 100644 --- a/src/test/java/com/google/javascript/clutz/DeclarationSyntaxTest.java +++ b/src/test/java/com/google/javascript/clutz/DeclarationSyntaxTest.java @@ -49,10 +49,7 @@ public class DeclarationSyntaxTest { "--lib", "es5,dom,es2015.iterable", "--noImplicitAny", - "--strictNullChecks", - // TODO(lucassloan): Necessary to allow promise like things that extend other promise like - // things. Turn off when turned off in g3 - "--noStrictGenericChecks"); + "--strictNullChecks"); @Test public void testDeclarationSyntax() throws Exception { diff --git a/src/test/java/com/google/javascript/clutz/goog_promise_with_platform.d.ts b/src/test/java/com/google/javascript/clutz/goog_promise_with_platform.d.ts index d7df00c3..389f5927 100644 --- a/src/test/java/com/google/javascript/clutz/goog_promise_with_platform.d.ts +++ b/src/test/java/com/google/javascript/clutz/goog_promise_with_platform.d.ts @@ -2,7 +2,7 @@ declare namespace ಠ_ಠ.clutz.goog { class Promise < TYPE , RESOLVER_CONTEXT > implements ಠ_ಠ.clutz.goog.Thenable < TYPE > { private noStructuralTyping_goog_Promise : any; constructor (resolver : (this : RESOLVER_CONTEXT , a : (a ? : TYPE | PromiseLike < TYPE > | null | { then : any } ) => any , b : (a ? : any ) => any ) => void , opt_context ? : RESOLVER_CONTEXT ) ; - then < RESULT > (opt_onFulfilled ? : ( (a : TYPE ) => any | RESULT ) | null , opt_onRejected ? : ( (a : any ) => any ) | null) : any ; + then < RESULT > (opt_onFulfilled ? : ( (a : TYPE ) => PromiseLike < RESULT > | RESULT ) | null , opt_onRejected ? : ( (a : any ) => any ) | null) : any ; static all < TYPE > (promises : any [] ) : ಠ_ಠ.clutz.goog.Promise < TYPE [] , any > ; static race < TYPE > (promises : any [] ) : ಠ_ಠ.clutz.goog.Promise < TYPE , any > ; static resolve < T >(value: ಠ_ಠ.clutz.goog.Promise < T , any > | T): any; @@ -19,7 +19,7 @@ declare namespace ಠ_ಠ.clutz.goog { function isImplementedBy (object : any ) : boolean ; } interface Thenable < TYPE > extends PromiseLike < TYPE > { - then < RESULT > (opt_onFulfilled ? : ( (a : TYPE ) => ಠ_ಠ.clutz.goog.Thenable < RESULT > | RESULT ) | null , opt_onRejected ? : ( (a : any ) => any ) | null) : ಠ_ಠ.clutz.goog.Thenable < RESULT > ; + then < RESULT > (opt_onFulfilled ? : ( (a : TYPE ) => PromiseLike < RESULT > | RESULT ) | null , opt_onRejected ? : ( (a : any ) => any ) | null) : ಠ_ಠ.clutz.goog.Thenable < RESULT > ; } } declare module 'goog:goog.Thenable' { diff --git a/src/test/java/com/google/javascript/clutz/partial/tte_promise_partial.d.ts b/src/test/java/com/google/javascript/clutz/partial/tte_promise_partial.d.ts index 35d53a7f..787120f9 100644 --- a/src/test/java/com/google/javascript/clutz/partial/tte_promise_partial.d.ts +++ b/src/test/java/com/google/javascript/clutz/partial/tte_promise_partial.d.ts @@ -2,7 +2,7 @@ declare namespace ಠ_ಠ.clutz.module$exports$tte$Promise$Partial { class PartialDeferred < VALUE = any > extends ಠ_ಠ.clutz.Base < VALUE > { private noStructuralTyping_module$exports$tte$Promise$Partial_PartialDeferred : any; constructor ( ) ; - then < RESULT > (opt_onFulfilled ? : ( (a : VALUE ) => ಠ_ಠ.clutz.module$exports$tte$Promise$Partial.PartialDeferred < RESULT > | RESULT ) | null , opt_onRejected ? : ( (a : any ) => any ) | null) : ಠ_ಠ.clutz.module$exports$tte$Promise$Partial.PartialDeferred < RESULT > ; + then < RESULT > (opt_onFulfilled ? : ( (a : VALUE ) => PromiseLike < RESULT > | RESULT ) | null , opt_onRejected ? : ( (a : any ) => any ) | null) : ಠ_ಠ.clutz.module$exports$tte$Promise$Partial.PartialDeferred < RESULT > ; } } declare module 'goog:tte.Promise.Partial' {