This repository has been archived by the owner on Feb 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(bug): handle nested classes and enums.
- Loading branch information
Showing
4 changed files
with
58 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/test/java/com/google/javascript/cl2dts/provide_single_class.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,32 @@ | ||
declare namespace ಠ_ಠ.cl2dts_internal.foo.bar.Baz { | ||
type NestedEnum = number ; | ||
var NestedEnum : { | ||
A : NestedEnum , | ||
B : NestedEnum , | ||
}; | ||
} | ||
declare module 'goog:foo.bar.Baz.NestedEnum' { | ||
import alias = ಠ_ಠ.cl2dts_internal.foo.bar.Baz.NestedEnum; | ||
export default alias; | ||
} | ||
declare namespace ಠ_ಠ.cl2dts_internal.foo.bar { | ||
class Baz { | ||
field : string ; | ||
equals (b : Baz.NestedClass ) : boolean ; | ||
method (a : string ) : number ; | ||
static staticMethod (a : string ) : number ; | ||
/* not emitting AnotherNestedEnum because it is an enum and it is not provided */ | ||
} | ||
} | ||
declare module 'goog:foo.bar.Baz' { | ||
import alias = ಠ_ಠ.cl2dts_internal.foo.bar.Baz; | ||
export default alias; | ||
} | ||
declare namespace ಠ_ಠ.cl2dts_internal.foo.bar.Baz { | ||
class NestedClass { | ||
} | ||
} | ||
declare module 'goog:foo.bar.Baz.NestedClass' { | ||
import alias = ಠ_ಠ.cl2dts_internal.foo.bar.Baz.NestedClass; | ||
export default alias; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
src/test/java/com/google/javascript/cl2dts/provide_single_class_usage.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
/// <reference path="./provide_single_class"/> | ||
import C from 'goog:foo.bar.Baz'; | ||
import NE from 'goog:foo.bar.Baz.NestedEnum'; | ||
|
||
var n: number = C.staticMethod("some"); | ||
let x = new C(); | ||
let s: string = x.field; | ||
n = x.method("some"); | ||
let e: C.NestedEnum = C.NestedEnum.A; | ||
e = NE.B; |