Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: angular/tsickle
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.40.0
Choose a base ref
...
head repository: angular/tsickle
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.41.0
Choose a head ref

Commits on Feb 16, 2021

  1. TypeScript 4.1 upgrade

    PiperOrigin-RevId: 357773316
    brad4d authored and copybara-github committed Feb 16, 2021
    Copy the full SHA
    43f59d1 View commit details

Commits on Mar 18, 2021

  1. Create a prototype of goog.tsMigrationExportsShim which allows migrat…

    …ed TS files to alias their exports back onto their original goog.module ID.
    
    This implementation is still exploratory. It is whitelisted only to integration tests pending tests with sample migrations.
    
    PiperOrigin-RevId: 363737238
    nreid260 authored and copybara-github committed Mar 18, 2021
    Copy the full SHA
    f1c9001 View commit details

Commits on Mar 19, 2021

  1. Allow @noinline JSDoc to be output from tsickle

    This is a tag with special handling from Closure Compiler,
    so we need to preserve it in our output in order for it to have
    its desired effect.
    
    PiperOrigin-RevId: 363937937
    blickly authored and copybara-github committed Mar 19, 2021
    Copy the full SHA
    c726cf1 View commit details

Commits on Mar 31, 2021

  1. improve handling of rest arguments

    There were two similar but slightly different code paths handling
    "rest" (aka `...x`) arguments: one for when they occur as parameters
    (and show up in `@param` JSDoc) and one for when they occur within
    function types (e.g. `{function(...x: string): void}`).
    
    Bring these together into one unified code path, and fix that code path
    so that it properly returns the right type in some error conditions.
    The code is given a (possibly complex) array type like `Array<string>`
    and wants to return the `string` bit, so it should return `?` in cases
    of confusion and not `Array<?>`, like it was doing.
    
    PiperOrigin-RevId: 366084847
    evmar authored and copybara-github committed Mar 31, 2021
    Copy the full SHA
    901d11e View commit details
  2. Fix hex conversion for objectFlags

    PiperOrigin-RevId: 366123708
    tsjs-language-eng authored and copybara-github committed Mar 31, 2021
    Copy the full SHA
    40ddb47 View commit details

Commits on Apr 8, 2021

  1. Update tsmes module name generation since TS 4.2 doesn't resolve modu…

    …le names containing file extensions.
    
    PiperOrigin-RevId: 367450792
    nreid260 authored and copybara-github committed Apr 8, 2021
    Copy the full SHA
    a5dbdbb View commit details

Commits on Apr 13, 2021

  1. During prodmode goog.module transformation, delete calls to ts.migrat…

    …ionExportsShim rather than rewriting them as module map insertions.
    
    If the .closure.js file is being loaded into a browser (as part of a debug session), then the .tsmes.closure.js file probably is also. The .tsmes.closure.js file will create the necessary module map entry (because it contains a goog.module declaration). A map entry added by the .closure.js file is just a module loading error.
    
    PiperOrigin-RevId: 368311499
    nreid260 authored and copybara-github committed Apr 13, 2021
    Copy the full SHA
    1e30314 View commit details

Commits on Apr 22, 2021

  1. Propagate @pintomodule as part of goog.tsMigrationExportsShim

    There are some tools that generate chunk IDs based on the goog.module ID. Therefore the shim for a goog.module must also act as a shim for any pintomodule coming from the same file.
    
    PiperOrigin-RevId: 369955748
    nreid260 authored and copybara-github committed Apr 22, 2021
    Copy the full SHA
    3a89a86 View commit details

Commits on Apr 27, 2021

  1. use better workaround for quoted access

    This tsickle code uses a private API within TypeScript, so unless
    the access to it is quoted it gets property renamed.  But quoting
    at the usage site ties the code to an unrenamed interface to that
    API, which would then break in the other way if we ever managed to
    compile the TS API into the same compilation as this client code.
    
    Instead, the proper place to mark this distinction (whether this
    function is renamed or not) lies in the place where we decide to
    bundle TypeScript -- if it's bundled without renaming, we need an
    extern to mark this as unrenameable, and otherwise, the dotted
    access is fine.
    
    PiperOrigin-RevId: 370758824
    evmar authored and copybara-github committed Apr 27, 2021
    Copy the full SHA
    a8f5b5b View commit details

Commits on May 5, 2021

  1. Suppress const warnings in tsickle generated externs.

    tsickle generates assignments to `@const` namespace properties:
    
        /** @const */
        chrome.runtime = {};
    
    This can cause clashes with hand-written Closure externs that also define these
    properties. The expedient workaround is to ignore these warnings by suppressing
    the `const` error class.
    
    PiperOrigin-RevId: 372145305
    mprobst authored and copybara-github committed May 5, 2021
    Copy the full SHA
    11ae37d View commit details

Commits on May 10, 2021

  1. Bump handlebars from 4.7.6 to 4.7.7

    Bumps [handlebars](https://github.com/wycats/handlebars.js) from 4.7.6 to 4.7.7.
    - [Release notes](https://github.com/wycats/handlebars.js/releases)
    - [Changelog](https://github.com/handlebars-lang/handlebars.js/blob/master/release-notes.md)
    - [Commits](handlebars-lang/handlebars.js@v4.7.6...v4.7.7)
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored and mprobst committed May 10, 2021
    Copy the full SHA
    c033d95 View commit details
  2. Bump hosted-git-info from 2.8.4 to 2.8.9

    Bumps [hosted-git-info](https://github.com/npm/hosted-git-info) from 2.8.4 to 2.8.9.
    - [Release notes](https://github.com/npm/hosted-git-info/releases)
    - [Changelog](https://github.com/npm/hosted-git-info/blob/v2.8.9/CHANGELOG.md)
    - [Commits](npm/hosted-git-info@v2.8.4...v2.8.9)
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored and mprobst committed May 10, 2021
    Copy the full SHA
    68d14f9 View commit details

Commits on May 13, 2021

  1. Update tsmes to allow shimming type-only symbols. (vis. interface, ty…

    …pe aliases, etc.)
    
    PiperOrigin-RevId: 373671534
    tsjs-language-eng authored and copybara-github committed May 13, 2021
    Copy the full SHA
    4495891 View commit details

Commits on May 20, 2021

  1. Introduce types for the various EventMaps.

    This will allow users using unquoted property names to declare new event types. See the test case for example code.
    
    PiperOrigin-RevId: 374894086
    mprobst authored and copybara-github committed May 20, 2021
    Copy the full SHA
    fc811b8 View commit details

Commits on May 21, 2021

  1. Add two new tsmes functions to the goog object

    One that shims all exports using default exports syntax; one that shims all exports using named exports syntax.
    
    Make it so that the following TypeScript in `some/path/to/a/file.ts`
    
    ```
    export interface I {}
    goog.tsMigrationDefaultExportsShim('a.javascript.flavored.module.id');
    ```
    
    generates this shim:
    
    ```
    goog.module('a.javascript.flavored.module.id');
    const { I } = goog.require('some.path.to.a.file');
    exports = I;
    ```
    
    And this TypeScript in `some/other/path/to/a/file.ts`
    
    ```
    export interface I {}
    export class C {}
    goog.tsMigrationNamedExportsShim('a.javascript.flavored.module.id');
    ```
    
    generates this shim:
    
    ```
    goog.module('a.javascript.flavored.module.id');
    const { I, C } = goog.require('some.other.path.to.a.file');
    exports.I = I;
    exports.C = C;
    ```
    
    PiperOrigin-RevId: 375110881
    tsjs-language-eng authored and copybara-github committed May 21, 2021
    Copy the full SHA
    e920a79 View commit details

Commits on May 24, 2021

  1. Emit NonNullable<T> as T instead of ? to avoid disambiguation f…

    …ailures.
    
    PiperOrigin-RevId: 375528277
    12wrigja authored and copybara-github committed May 24, 2021
    Copy the full SHA
    8ffda97 View commit details

Commits on May 25, 2021

  1. Add DocumentEventMap and WindowEventMap to the EventMap list in closu…

    …re_externs.js
    
    PiperOrigin-RevId: 375740336
    tsjs-language-eng authored and copybara-github committed May 25, 2021
    Copy the full SHA
    f64f042 View commit details

Commits on May 27, 2021

  1. Set up Node.js CI

    Based on the github standard action for NodeJS.
    mprobst authored May 27, 2021
    Copy the full SHA
    b5b6c0d View commit details
  2. Fix compilation issues with TypeScript 4.3.

    PiperOrigin-RevId: 375895241
    tsjs-language-eng authored and mprobst committed May 27, 2021
    Copy the full SHA
    c631a54 View commit details
  3. Copy the full SHA
    09e8eee View commit details
  4. build & test using npm scripts.

    This change migrates the open source build from bazel back to plain npm
    scripts. bazel worked well for a while, but the internal and external
    build definitions are diverging, and we no longer have the expertise to
    maintain either of them.
    
    While simplistic, plain npm scripts work well for our use case, both
    from a performance and a maintainability perspective.
    mprobst committed May 27, 2021
    Copy the full SHA
    3f6f23b View commit details

Commits on Jun 7, 2021

  1. Merge pull request #1267 from angular:unbazel

    PiperOrigin-RevId: 377874934
    copybara-github committed Jun 7, 2021
    Copy the full SHA
    869e760 View commit details
  2. Flip the version of the TS Compiler from 4.2.4 to 4.3.2.

    PiperOrigin-RevId: 377876230
    tsjs-language-eng authored and copybara-github committed Jun 7, 2021
    Copy the full SHA
    5f679a0 View commit details
  3. Remove bazel BUILD files.

    mprobst committed Jun 7, 2021
    Copy the full SHA
    7237873 View commit details
  4. Copy the full SHA
    3f3fefd View commit details
  5. Depend on TypeScript 4.3.

    mprobst committed Jun 7, 2021
    Copy the full SHA
    85cafb1 View commit details
  6. Clean up dependencies.

    Remove some no longer used deps.
    Upgrade remaining deps.
    mprobst committed Jun 7, 2021
    Copy the full SHA
    666bb37 View commit details
  7. Copy the full SHA
    0498000 View commit details
  8. Copy the full SHA
    5d79c3f View commit details
  9. Simplify CI setup

    - just use one NodeJS version
    - name the build "CI" for easier reference
    mprobst authored Jun 7, 2021
    Copy the full SHA
    228fadf View commit details
  10. Internal change.

    PiperOrigin-RevId: 377922236
    mprobst authored and copybara-github committed Jun 7, 2021
    Copy the full SHA
    ac813e6 View commit details
  11. Merge pull request #1269 from angular:unbazel

    PiperOrigin-RevId: 378026079
    copybara-github committed Jun 7, 2021
    Copy the full SHA
    4e636bc View commit details

Commits on Jun 9, 2021

  1. Update development instructions

    Remove some more references to npm and bazel.
    mprobst authored Jun 9, 2021
    Copy the full SHA
    1e36d3d View commit details

Commits on Jun 14, 2021

  1. rel: 0.41.0

    mprobst committed Jun 14, 2021
    Copy the full SHA
    d9f6f89 View commit details
Showing with 2,776 additions and 1,486 deletions.
  1. +0 −27 .bazelrc
  2. +23 −0 .github/workflows/node.js.yml
  3. +2 −5 .gitignore
  4. +0 −40 BUILD
  5. +19 −31 README.md
  6. +0 −29 WORKSPACE
  7. +2 −0 demo/demo.ts
  8. +20 −18 package.json
  9. +0 −32 src/BUILD
  10. +19 −0 src/closure_externs.js
  11. +2 −2 src/clutz.ts
  12. +4 −2 src/externs.ts
  13. +93 −44 src/googmodule.ts
  14. +1 −0 src/jsdoc.ts
  15. +10 −19 src/module_type_translator.ts
  16. +59 −0 src/transformer_util.ts
  17. +528 −0 src/ts_migration_exports_shim.ts
  18. +40 −2 src/tsickle.ts
  19. +92 −32 src/type_translator.ts
  20. +0 −144 test/BUILD
  21. +1 −0 test/decorator_downlevel_transformer_test.ts
  22. +3 −0 test/e2e_closure_test.ts
  23. +0 −1 test/e2e_clutz_dts_test.ts
  24. +74 −21 test/golden_tsickle_test.ts
  25. +57 −16 test/test_support.ts
  26. +45 −0 test/ts_migration_exports_shim/BUILD
  27. +9 −0 test/ts_migration_exports_shim/README.md
  28. +141 −0 test/ts_migration_exports_shim/goog_colon_and_clutz_ref.ts
  29. +56 −0 test/ts_migration_exports_shim/goog_module_ref.js
  30. +16 −0 test/ts_migration_exports_shim/migrated_default_shorthand.ts
  31. +27 −0 test/ts_migration_exports_shim/migrated_default_type.ts
  32. +30 −0 test/ts_migration_exports_shim/migrated_default_value.ts
  33. +33 −0 test/ts_migration_exports_shim/migrated_named.ts
  34. +16 −0 test/ts_migration_exports_shim/migrated_named_shorthand.ts
  35. +4 −1 test/tsickle_test.ts
  36. +23 −5 test/type_translator_test.ts
  37. +1 −1 test_files/augment/externs.js
  38. +8 −5 test_files/conditional_rest_tuple_type/conditional_rest_tuple_type.js
  39. +5 −0 test_files/conditional_rest_tuple_type/conditional_rest_tuple_type.ts
  40. +1 −1 test_files/debugger/externs.js
  41. +1 −1 test_files/declare/externs.js
  42. +1 −1 test_files/declare_anonymous_type/externs.js
  43. +1 −1 test_files/declare_class_ns/externs.js
  44. +1 −1 test_files/declare_class_overloads/externs.js
  45. +1 −1 test_files/declare_computed/externs.js
  46. +1 −1 test_files/declare_enum/externs.js
  47. +1 −1 test_files/declare_export.untyped/externs.js
  48. +1 −1 test_files/declare_export/externs.js
  49. +1 −1 test_files/declare_export_dts/externs.js
  50. +1 −1 test_files/declare_export_global/externs.js
  51. +1 −1 test_files/declare_extends/externs.js
  52. +1 −1 test_files/declare_function_repeated_tags/externs.js
  53. +1 −1 test_files/declare_generic/externs.js
  54. +1 −1 test_files/declare_import/externs.js
  55. +1 −1 test_files/declare_var_and_ns/externs.js
  56. +1 −1 test_files/decorator_nested_scope/externs.js
  57. +15 −0 test_files/eventmap/eventmap.js
  58. +12 −0 test_files/eventmap/eventmap.ts
  59. +16 −0 test_files/eventmap/externs.js
  60. +1 −1 test_files/export/externs.js
  61. +1 −1 test_files/export_as_namespace/externs.js
  62. +1 −1 test_files/export_as_namespace_exporteq/externs.js
  63. +1 −1 test_files/export_declare_namespace/externs.js
  64. +1 −1 test_files/export_equals.shim/externs.js
  65. +1 −1 test_files/export_star_dts/externs.js
  66. +38 −6 test_files/functions/functions.js
  67. +14 −6 test_files/functions/functions.ts
  68. +1 −1 test_files/ignored_ambient_external_module/externs.js
  69. +1 −1 test_files/import_equals/externs.js
  70. +1 −1 test_files/invalid_closure_properties/externs.js
  71. +0 −1 test_files/invalid_closure_properties/invalid_closure_properties.js
  72. +1 −1 test_files/mixin/externs.js
  73. +1 −1 test_files/namespaced/externs.js
  74. +34 −0 test_files/nonnullable/nonnullable.js
  75. +20 −0 test_files/nonnullable/nonnullable.ts
  76. +1 −1 test_files/overload_with_this_parameter/externs.js
  77. +6 −6 test_files/private_field/private_field.js
  78. +1 −1 test_files/promiseconstructor/promiseconstructor.js
  79. +2 −2 test_files/promisectorlike/promisectorlike.js
  80. +7 −8 test_files/rest_parameters_any/rest_parameters_any.js
  81. +5 −5 test_files/rest_parameters_any/rest_parameters_any.ts
  82. +8 −6 test_files/rest_parameters_generic_empty/rest_parameters_generic_empty.js
  83. +5 −0 test_files/rest_parameters_generic_empty/rest_parameters_generic_empty.ts
  84. +21 −0 test_files/ts_migration_exports_shim.no_externs.puretransform.declaration/bad.d.ts
  85. +35 −0 test_files/ts_migration_exports_shim.no_externs.puretransform.declaration/bad.js
  86. +38 −0 test_files/ts_migration_exports_shim.no_externs.puretransform.declaration/bad.ts
  87. +15 −0 test_files/ts_migration_exports_shim.no_externs.puretransform.declaration/correct_default_type.d.ts
  88. +11 −0 test_files/ts_migration_exports_shim.no_externs.puretransform.declaration/correct_default_type.js
  89. +10 −0 test_files/ts_migration_exports_shim.no_externs.puretransform.declaration/correct_default_type.ts
  90. +16 −0 ...es/ts_migration_exports_shim.no_externs.puretransform.declaration/correct_default_type.tsmes.d.ts
  91. +15 −0 test_files/ts_migration_exports_shim.no_externs.puretransform.declaration/correct_default_value.d.ts
  92. +14 −0 test_files/ts_migration_exports_shim.no_externs.puretransform.declaration/correct_default_value.js
  93. +10 −0 test_files/ts_migration_exports_shim.no_externs.puretransform.declaration/correct_default_value.ts
  94. +16 −0 ...s/ts_migration_exports_shim.no_externs.puretransform.declaration/correct_default_value.tsmes.d.ts
  95. +15 −0 test_files/ts_migration_exports_shim.no_externs.puretransform.declaration/correct_named.d.ts
  96. +14 −0 test_files/ts_migration_exports_shim.no_externs.puretransform.declaration/correct_named.js
  97. +10 −0 test_files/ts_migration_exports_shim.no_externs.puretransform.declaration/correct_named.ts
  98. +15 −0 test_files/ts_migration_exports_shim.no_externs.puretransform.declaration/correct_named.tsmes.d.ts
  99. +77 −0 test_files/ts_migration_exports_shim.no_externs.puretransform.declaration/google3_strict.d.ts
  100. +64 −0 test_files/ts_migration_exports_shim.no_externs/bad.js
  101. +63 −0 test_files/ts_migration_exports_shim.no_externs/bad.ts
  102. +24 −0 test_files/ts_migration_exports_shim.no_externs/bad_default_shorthand_with_more_than_one_export.js
  103. +14 −0 test_files/ts_migration_exports_shim.no_externs/bad_default_shorthand_with_more_than_one_export.ts
  104. +17 −0 test_files/ts_migration_exports_shim.no_externs/bad_default_shorthand_with_no_exports.js
  105. +11 −0 test_files/ts_migration_exports_shim.no_externs/bad_default_shorthand_with_no_exports.ts
  106. +20 −0 test_files/ts_migration_exports_shim.no_externs/correct_default_shorthand.js
  107. +6 −0 test_files/ts_migration_exports_shim.no_externs/correct_default_shorthand.ts
  108. +8 −0 test_files/ts_migration_exports_shim.no_externs/correct_default_shorthand.tsmes.closure.js
  109. +19 −0 test_files/ts_migration_exports_shim.no_externs/correct_default_type.js
  110. +6 −0 test_files/ts_migration_exports_shim.no_externs/correct_default_type.ts
  111. +8 −0 test_files/ts_migration_exports_shim.no_externs/correct_default_type.tsmes.closure.js
  112. +13 −0 test_files/ts_migration_exports_shim.no_externs/correct_default_type_literal.js
  113. +5 −0 test_files/ts_migration_exports_shim.no_externs/correct_default_type_literal.ts
  114. +8 −0 test_files/ts_migration_exports_shim.no_externs/correct_default_type_literal.tsmes.closure.js
  115. +22 −0 test_files/ts_migration_exports_shim.no_externs/correct_default_value.js
  116. +6 −0 test_files/ts_migration_exports_shim.no_externs/correct_default_value.ts
  117. +8 −0 test_files/ts_migration_exports_shim.no_externs/correct_default_value.tsmes.closure.js
  118. +32 −0 test_files/ts_migration_exports_shim.no_externs/correct_named.js
  119. +13 −0 test_files/ts_migration_exports_shim.no_externs/correct_named.ts
  120. +11 −0 test_files/ts_migration_exports_shim.no_externs/correct_named.tsmes.closure.js
  121. +31 −0 test_files/ts_migration_exports_shim.no_externs/correct_named_shorthand.js
  122. +12 −0 test_files/ts_migration_exports_shim.no_externs/correct_named_shorthand.ts
  123. +11 −0 test_files/ts_migration_exports_shim.no_externs/correct_named_shorthand.tsmes.closure.js
  124. +77 −0 test_files/ts_migration_exports_shim.no_externs/google3_strict.d.ts
  125. +14 −0 test_files/ts_migration_exports_shim.no_externs/pintomodule.js
  126. +9 −0 test_files/ts_migration_exports_shim.no_externs/pintomodule.ts
  127. +8 −0 test_files/ts_migration_exports_shim.no_externs/pintomodule.tsmes.closure.js
  128. +1 −1 test_files/type/externs.js
  129. +1 −1 test_files/type_and_value/externs.js
  130. +1 −1 test_files/underscore/externs.js
  131. +1 −1 test_files/use_closure_externs/externs.js
  132. +10 −9 tsconfig.json
  133. +215 −926 yarn.lock
27 changes: 0 additions & 27 deletions .bazelrc

This file was deleted.

23 changes: 23 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
- name: Use Node.js 15.x
uses: actions/setup-node@v2
with:
node-version: 15.x
- run: yarn
- run: yarn run build
- run: yarn test
7 changes: 2 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -7,8 +7,5 @@
# VSCode directory
.vscode

# Bazel working directories
/bazel-*

# Created by bazel run :npm_package.pack
tsickle-*.tgz
# Build output
/out
40 changes: 0 additions & 40 deletions BUILD

This file was deleted.

50 changes: 19 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Tsickle - TypeScript to Closure Translator [![Build Status](https://circleci.com/gh/angular/tsickle.svg?style=svg)](https://circleci.com/gh/angular/tsickle) [![Windows build](https://ci.appveyor.com/api/projects/status/puxdblmlqbofqqt1/branch/master?svg=true)](https://ci.appveyor.com/project/alexeagle/tsickle/branch/master)
# Tsickle - TypeScript to Closure Translator [![Build Status](https://github.com/angular/tsickle/actions/workflows/node.js.yml/badge.svg)](https://github.com/angular/tsickle/actions/workflows/node.js.yml)

Tsickle converts TypeScript code into a form acceptable to the [Closure
Compiler]. This allows using TypeScript to transpile your sources, and then
@@ -120,29 +120,19 @@ Example:
[NVM](https://github.com/nvm-sh/nvm)
- yarn. Install from your operating system's package manager or by following
[instructions on yarnpkg.com](https://yarnpkg.com/en/docs/install).
- bazel. Install from your operating system's package manager or by [following
instructions here](https://docs.bazel.build/versions/master/install.html).

### One-time setup

Run `bazel run @nodejs//:yarn` to install dependencies.
Run `yarn` to install dependencies.

### Bazel install
### Build & Test commands

We use [bazel](https://bazel.build/) to build, and are pinned to a specific
version of it in `package.json` for reproducible builds. The build rules check
for a compatible version of bazel, so it is generally safe to use your local
installed version. If in doubt, you can run `yarn bazel` instead of `bazel` in
any of the below commands to make sure you are using the right version.

### Test commands

- `ibazel test test:unit_test` executes the unit tests in watch mode (use `bazel test test:unit_test` for a single run),
- `bazel test test:e2e_test` executes the e2e tests,
- `bazel test test:golden_test` executes the golden tests,
- `node check_format.js` checks the source code formatting using
`clang-format`,
- `yarn test` runs unit tests, e2e tests and checks the source code formatting.
- `yarn build` builds the code base.
- Run `tsc --watch` for an interactive, incremental, and continuous build.
- `yarn lint` checks for lint.
- `yarn test` runs unit tests, e2e tests and checks for lint (but make sure to
`yarn build` first or run tsc!). Set the `TEST_FILTER` environment variable
to filter what golden tests to run.

### TypeScript AST help

@@ -151,13 +141,13 @@ visualize and inspect a TypeScript AST.

### Debugging

You can debug tests by using `bazel run` and passing `--node_options=--inspect`
or `--node_options=--inspect-brk` (to suspend execution directly after startup).
You can debug tests by passing `--node_options=--inspect` or
`--node_options=--inspect-brk` (to suspend execution directly after startup).

For example, to debug a specific golden test:

```shell
TEST_FILTER=my_golden_test ibazel run //test:golden_test -- --node_options=--inspect-brk
TEST_FILTER=my_golden_test node --inspect-brk=4332 ./node_modules/.bin/jasmine out/test/*.js
```

Then open [about:inspect] in Chrome and choose "about:inspect". Chrome will
@@ -168,19 +158,15 @@ to `localhost:9229`, so things should work out of the box.
The break in specific code locations you can add `debugger;` statements in the
source code.

Note: IDEs such as VS Code have support for the inspect protocol, but the
integration does not work due to bazel's complex directory layout.

### Updating Goldens

Run `UPDATE_GOLDENS=y bazel run test:golden_test` to have the test suite update
the goldens in `test_files/...`.
Run `UPDATE_GOLDENS=y yarn test` to have the test suite update the goldens in
`test_files/...`.

### Environment variables

Pass the flag `--action_env=TEST_FILTER=<REGEX>` to bazel test to limit the
end-to-end test (found in `test_files/...`) run tests with a name matching the
regex.
Set the environment variable `TEST_FILTER=<REGEX>` to limit the golden tests
(found in `test_files/...`) to only run tests with a name matching the regex.

### Releasing

@@ -220,5 +206,7 @@ https://github.com/angular/tsickle/releases) will be implicitly created.
From the master branch run:

```
bazel run :npm_package.publish -- --registry https://wombat-dressing-room.appspot.com
npm config set registry https://wombat-dressing-room.appspot.com
npm login
npm publish -- --registry https://wombat-dressing-room.appspot.com
```
29 changes: 0 additions & 29 deletions WORKSPACE

This file was deleted.

2 changes: 2 additions & 0 deletions demo/demo.ts
Original file line number Diff line number Diff line change
@@ -156,6 +156,7 @@ export function toClosureJS(
const filesToProcess = new Set(absoluteFileNames);
const rootModulePath = options.rootDir || getCommonParentDirectory(absoluteFileNames);
const transformerHost: tsickle.TsickleHost = {
rootDirsRelative: (f: string) => f,
shouldSkipTsickleProcessing: (fileName: string) => {
return !filesToProcess.has(path.resolve(fileName));
},
@@ -176,6 +177,7 @@ export function toClosureJS(
const diagnostics = ts.getPreEmitDiagnostics(program);
if (diagnostics.length > 0) {
return {
tsMigrationExportsShimFiles: new Map(),
diagnostics,
modulesManifest: new tsickle.ModulesManifest(),
externs: {},
38 changes: 20 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
{
"name": "tsickle",
"version": "0.40.0",
"version": "0.41.0",
"description": "Transpile TypeScript code to JavaScript with Closure annotations.",
"main": "src/tsickle.js",
"typings": "src/tsickle.d.ts",
"main": "out/src/tsickle.js",
"typings": "out/src/tsickle.d.ts",
"directories": {
"test": "test"
},
"files": [
"src/*"
"out/src/*"
],
"peerDependencies": {
"typescript": "~4.0.5"
"typescript": "~4.3"
},
"devDependencies": {
"@bazel/bazel": "^0.29.0",
"@bazel/jasmine": "^0.38.0",
"@bazel/typescript": "^0.38.0",
"@types/diff-match-patch": "^1.0.32",
"@types/glob": "5.0.35",
"@types/jasmine": "2.8.8",
"@types/jasmine": "^3.7.7",
"@types/node": "^10.5.6",
"diff-match-patch": "^1.0.1",
"@types/source-map-support": "^0.5.3",
"diff-match-patch": "^1.0.5",
"glob": "7.1.2",
"google-closure-compiler": "^20190929.0.0",
"jasmine": "3.1.0",
"jasmine": "^3.7.0",
"jasmine-node": "^3.0.0",
"source-map": "^0.7.3",
"source-map-support": "^0.5.6",
"tslib": "1.11",
"tslint": "5.11.0",
"typescript": "4.0"
"source-map-support": "^0.5.19",
"tslib": "^2.2.0",
"tslint": "^6.1.3",
"typescript": "~4.3"
},
"scripts": {
"build": "bazel build //:npm_package",
"build": "tsc ",
"clean": "rm -r out",
"lint": "tslint -c tslint.json -p tsconfig.json",
"test": "yarn lint && bazel test ..."
"test": "jasmine out/test/*.js && npm run lint"
},
"repository": {
"type": "git",
@@ -56,5 +56,7 @@
"url": "https://github.com/angular/tsickle/issues"
},
"homepage": "https://github.com/angular/tsickle",
"private": true
"dependencies": {
"@types/minimist": "^1.2.1"
}
}
32 changes: 0 additions & 32 deletions src/BUILD

This file was deleted.

19 changes: 19 additions & 0 deletions src/closure_externs.js
Original file line number Diff line number Diff line change
@@ -112,3 +112,22 @@ var EventListenerObject;

/** @record */
function ImportMeta() {};

// Representations for TS' EventMap objects.
// These are types that contain a mapping from event names to event object
// types. User code can augment them, which produces externs.js files that then
// reference the EventMap types - even though they are not defined in Closure.
// Defining them here works around the problem.

/** @interface */
class HTMLElementEventMap {}
/** @interface */
class ElementEventMap {}
/** @interface */
class DocumentEventMap {}
/** @interface */
class WindowEventMap {}
/** @interface */
class GlobalEventHandlersEventMap {}
/** @interface */
class DocumentAndElementEventHandlersEventMap {}
4 changes: 2 additions & 2 deletions src/clutz.ts
Original file line number Diff line number Diff line change
@@ -202,7 +202,7 @@ function generateClutzAliases(
for (const symbol of localExports) {
let localName = symbol.name;
const declaration =
symbol.declarations.find(d => d.getSourceFile() === origSourceFile);
symbol.declarations?.find(d => d.getSourceFile() === origSourceFile);
if (declaration && ts.isExportSpecifier(declaration) &&
declaration.propertyName) {
// If declared in an "export {X as Y};" export specifier, then X (stored
@@ -350,7 +350,7 @@ function clutzSymbolFromNode(
* file extension.
*/
function importPathForSymbol(sym: ts.Symbol): string|undefined {
if (sym.declarations.length === 0) {
if (!sym.declarations || sym.declarations.length === 0) {
// This can happen if an import or symbol somehow references a nonexistent
// type, for example in a case where type checking failed or via 'any'.
return undefined;
Loading