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 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #113
- Loading branch information
Showing
7 changed files
with
76 additions
and
0 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
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/** @provideGoog */ | ||
/** @const */ var goog = goog || {}; | ||
goog.provide = function (arg) {}; | ||
goog.require = function (arg) {}; |
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
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
28 changes: 28 additions & 0 deletions
28
src/test/java/com/google/javascript/clutz/goog_require.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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
declare namespace ಠ_ಠ.clutz_internal.foo { | ||
class SimpleClass { | ||
} | ||
} | ||
declare namespace ಠ_ಠ.clutz_internal.goog { | ||
function require(name: 'foo.SimpleClass'): typeof ಠ_ಠ.clutz_internal.foo.SimpleClass; | ||
} | ||
declare module 'goog:foo.SimpleClass' { | ||
import alias = ಠ_ಠ.clutz_internal.foo.SimpleClass; | ||
export default alias; | ||
} | ||
declare namespace ಠ_ಠ.clutz_internal.foo.simpleNamespace { | ||
var a : number ; | ||
} | ||
declare namespace ಠ_ಠ.clutz_internal.goog { | ||
function require(name: 'foo.simpleNamespace'): typeof ಠ_ಠ.clutz_internal.foo.simpleNamespace; | ||
} | ||
declare module 'goog:foo.simpleNamespace' { | ||
import alias = ಠ_ಠ.clutz_internal.foo.simpleNamespace; | ||
export = alias; | ||
} | ||
declare namespace ಠ_ಠ.clutz_internal.goog { | ||
function require (name : string ) : void ; | ||
} | ||
declare module 'goog:goog.require' { | ||
import alias = ಠ_ಠ.clutz_internal.goog.require; | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
goog.provide('foo.SimpleClass'); | ||
goog.provide('foo.simpleNamespace'); | ||
|
||
/** | ||
* @constructor | ||
*/ | ||
foo.SimpleClass = function() {}; | ||
|
||
/** | ||
* @const {number} | ||
*/ | ||
foo.simpleNamespace.a = 0; |
10 changes: 10 additions & 0 deletions
10
src/test/java/com/google/javascript/clutz/goog_require_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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const SimpleClass = goog.require('foo.SimpleClass'); | ||
const {a} = goog.require('foo.simpleNamespace'); | ||
|
||
// Asserting that types carry through. | ||
var b: number = a; | ||
// TODO(rado): this should be c: SimpleClass, but without ES6 module | ||
// imports we cannot bring the type symbol in. | ||
// Note that does not mean that the type won't flow through the assignment | ||
// but simply it does not have accessible symbol in the client code. | ||
var c = new SimpleClass(); |