Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Commit bca1863

Browse files
teppeisrkirov
authored andcommitted
Improve Promise and remove --noStrictGenericChecks from DeclarationSyntaxTest
1 parent 0d4ff75 commit bca1863

File tree

4 files changed

+7
-13
lines changed

4 files changed

+7
-13
lines changed

src/main/java/com/google/javascript/clutz/DeclarationGenerator.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2979,9 +2979,8 @@ private String getSignatureForInstanceTTEFn(
29792979
String templateVarName = templateTypeNames.next();
29802980

29812981
// TODO(lucassloan): goog.Promise has bad types (caused by an inconsistent number of generic
2982-
// type
2983-
// params) that are coerced to any, so explicitly emit any and fix when the callers have been
2984-
// fixed.
2982+
// type params) that are coerced to any, so explicitly emit any for the return type and
2983+
// fix when the callers have been fixed.
29852984
String classTemplatizedType =
29862985
className.equals("ಠ_ಠ.clutz.goog.Promise") ? " any" : className + " < RESULT >";
29872986
// The AngularJS promise type should match the TypeScript type declaration since they describe
@@ -3001,9 +3000,7 @@ private String getSignatureForInstanceTTEFn(
30013000
} else {
30023001
return "then < RESULT > (opt_onFulfilled ? : ( (a : "
30033002
+ templateVarName
3004-
+ " ) => "
3005-
+ classTemplatizedType
3006-
+ " | RESULT ) | null , "
3003+
+ " ) => PromiseLike < RESULT > | RESULT ) | null , "
30073004
+ "opt_onRejected ? : ( (a : any ) => any ) | null) : "
30083005
+ classTemplatizedType
30093006
+ " ;";

src/test/java/com/google/javascript/clutz/DeclarationSyntaxTest.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,7 @@ public class DeclarationSyntaxTest {
4949
"--lib",
5050
"es5,dom,es2015.iterable",
5151
"--noImplicitAny",
52-
"--strictNullChecks",
53-
// TODO(lucassloan): Necessary to allow promise like things that extend other promise like
54-
// things. Turn off when turned off in g3
55-
"--noStrictGenericChecks");
52+
"--strictNullChecks");
5653

5754
@Test
5855
public void testDeclarationSyntax() throws Exception {

src/test/java/com/google/javascript/clutz/goog_promise_with_platform.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ declare namespace ಠ_ಠ.clutz.goog {
22
class Promise < TYPE , RESOLVER_CONTEXT > implements ಠ_ಠ.clutz.goog.Thenable < TYPE > {
33
private noStructuralTyping_goog_Promise : any;
44
constructor (resolver : (this : RESOLVER_CONTEXT , a : (a ? : TYPE | PromiseLike < TYPE > | null | { then : any } ) => any , b : (a ? : any ) => any ) => void , opt_context ? : RESOLVER_CONTEXT ) ;
5-
then < RESULT > (opt_onFulfilled ? : ( (a : TYPE ) => any | RESULT ) | null , opt_onRejected ? : ( (a : any ) => any ) | null) : any ;
5+
then < RESULT > (opt_onFulfilled ? : ( (a : TYPE ) => PromiseLike < RESULT > | RESULT ) | null , opt_onRejected ? : ( (a : any ) => any ) | null) : any ;
66
static all < TYPE > (promises : any [] ) : ಠ_ಠ.clutz.goog.Promise < TYPE [] , any > ;
77
static race < TYPE > (promises : any [] ) : ಠ_ಠ.clutz.goog.Promise < TYPE , any > ;
88
static resolve < T >(value: ಠ_ಠ.clutz.goog.Promise < T , any > | T): any;
@@ -19,7 +19,7 @@ declare namespace ಠ_ಠ.clutz.goog {
1919
function isImplementedBy (object : any ) : boolean ;
2020
}
2121
interface Thenable < TYPE > extends PromiseLike < TYPE > {
22-
then < RESULT > (opt_onFulfilled ? : ( (a : TYPE ) => ಠ_ಠ.clutz.goog.Thenable < RESULT > | RESULT ) | null , opt_onRejected ? : ( (a : any ) => any ) | null) : ಠ_ಠ.clutz.goog.Thenable < RESULT > ;
22+
then < RESULT > (opt_onFulfilled ? : ( (a : TYPE ) => PromiseLike < RESULT > | RESULT ) | null , opt_onRejected ? : ( (a : any ) => any ) | null) : ಠ_ಠ.clutz.goog.Thenable < RESULT > ;
2323
}
2424
}
2525
declare module 'goog:goog.Thenable' {

src/test/java/com/google/javascript/clutz/partial/tte_promise_partial.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ declare namespace ಠ_ಠ.clutz.module$exports$tte$Promise$Partial {
22
class PartialDeferred < VALUE = any > extends ಠ_ಠ.clutz.Base < VALUE > {
33
private noStructuralTyping_module$exports$tte$Promise$Partial_PartialDeferred : any;
44
constructor ( ) ;
5-
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 > ;
5+
then < RESULT > (opt_onFulfilled ? : ( (a : VALUE ) => PromiseLike < RESULT > | RESULT ) | null , opt_onRejected ? : ( (a : any ) => any ) | null) : ಠ_ಠ.clutz.module$exports$tte$Promise$Partial.PartialDeferred < RESULT > ;
66
}
77
}
88
declare module 'goog:tte.Promise.Partial' {

0 commit comments

Comments
 (0)