-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for TypeScript 3.8 (#1134)
Add support for TypeScript 3.8 This upgrades the version of TypeScript Tsickle uses as a `devDependency` and a `peerDependency`. Support for Private Fields -------------------------- Tsickle mostly ignores private fields, however it no longer warns when not generating externs for them. Externs are not generated because the fields no not exist on the class when downleveled. Support for `export * as ns` Syntax ----------------------------------- Tsickle compiles: ```ts export * as ns from './namespace'; ``` to ```ts var tsickle_module_1_ = goog.require('project.namespace'); exports.ns = tsickle_module_1_; ``` New `tslib` Functions --------------------- Private fields require two new functions in `tslib`: `__classPrivateFieldGet` and `__classPrivateFieldSet`. Both of these were added to Tsickle's version of `tslib.js` along with Closure type annotations. Other Changes ------------- * The `import_export_typedef_conflict` test was removed because that code is no longer valid in TypeScript 3.8, and produces a compile error. * `tslib@1.11.0` was added as a `devDependency`. Before it was being pulled in as a transitive dependency, but the packages pulling it in depend on `1.10`. To upgrade to TypeScript 3.8 Tsickle needs the latest version of `tslib`.
- Loading branch information
Showing
20 changed files
with
227 additions
and
58 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
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
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
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,40 @@ | ||
goog.module('test_files.class.private_field'); | ||
var module = module || { id: 'test_files/class/private_field.ts' }; | ||
module = module; | ||
var _someField; | ||
const tslib_1 = goog.require('tslib'); | ||
/** | ||
* | ||
* @fileoverview Tests the generation of private field accessors from Tsickle. They do not generate | ||
* any externs, as they do not exist on the class themselves when downleveled by TypeScript. | ||
* | ||
* Generated from: test_files/class/private_field.ts | ||
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc | ||
*/ | ||
class ContainsPrivateField { | ||
/** | ||
* @param {string} arg | ||
*/ | ||
constructor(arg) { | ||
_someField.set(this, void 0); | ||
tslib_1.__classPrivateFieldSet(this, _someField, arg); | ||
} | ||
/** | ||
* @param {string} value | ||
* @return {void} | ||
*/ | ||
setSomeField(value) { | ||
tslib_1.__classPrivateFieldSet(this, _someField, value); | ||
} | ||
/** | ||
* @return {string} | ||
*/ | ||
getSomeField() { | ||
return tslib_1.__classPrivateFieldGet(this, _someField); | ||
} | ||
} | ||
_someField = new WeakMap(); | ||
if (false) { | ||
/* Skipping private member: | ||
#someField: string;*/ | ||
} |
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,22 @@ | ||
/** | ||
* @fileoverview Tests the generation of private field accessors from Tsickle. They do not generate | ||
* any externs, as they do not exist on the class themselves when downleveled by TypeScript. | ||
*/ | ||
|
||
export {}; | ||
|
||
class ContainsPrivateField { | ||
#someField: string; | ||
|
||
constructor(arg: string) { | ||
this.#someField = arg; | ||
} | ||
|
||
setSomeField(value: string) { | ||
this.#someField = value; | ||
} | ||
|
||
getSomeField() { | ||
return this.#someField; | ||
} | ||
} |
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
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,13 @@ | ||
/** | ||
* @fileoverview added by tsickle | ||
* Generated from: test_files/export_star_as_ns/ns.ts | ||
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc | ||
*/ | ||
goog.module('test_files.export_star_as_ns.ns'); | ||
var module = module || { id: 'test_files/export_star_as_ns/ns.ts' }; | ||
module = module; | ||
goog.require('tslib'); | ||
/** @type {number} */ | ||
exports.x = 10; | ||
/** @type {string} */ | ||
exports.y = 'y!'; |
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,2 @@ | ||
export const x = 10; | ||
export const y = 'y!'; |
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,16 @@ | ||
/** | ||
* | ||
* @fileoverview Tests exporting a namespace with a given name from Closure. This doesn't expand | ||
* each export like the `export * from '...'` syntax, so it's output just an assignment of the | ||
* imported module to a property on `exports`. | ||
* | ||
* Generated from: test_files/export_star_as_ns/star_as_ns.ts | ||
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc | ||
*/ | ||
goog.module('test_files.export_star_as_ns.star_as_ns'); | ||
var module = module || { id: 'test_files/export_star_as_ns/star_as_ns.ts' }; | ||
module = module; | ||
goog.require('tslib'); | ||
const tsickle_ns_1 = goog.requireType("test_files.export_star_as_ns.ns"); | ||
const tsickle_module_1_ = goog.require('test_files.export_star_as_ns.ns'); | ||
exports.ns = tsickle_module_1_; |
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,7 @@ | ||
/** | ||
* @fileoverview Tests exporting a namespace with a given name from Closure. This doesn't expand | ||
* each export like the `export * from '...'` syntax, so it's output just an assignment of the | ||
* imported module to a property on `exports`. | ||
*/ | ||
|
||
export * as ns from './ns'; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
19 changes: 0 additions & 19 deletions
19
test_files/import_export_typedef_conflict/import_export_typedef_conflict.js
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
test_files/import_export_typedef_conflict/import_export_typedef_conflict.ts
This file was deleted.
Oops, something went wrong.
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