├── .circleci └── config.yml ├── .clang-format ├── .github └── workflows │ └── node.js.yml ├── .gitignore ├── .npmrc ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── demo ├── .gitignore ├── README.md ├── demo.ts ├── package.json └── tsconfig.json ├── package.json ├── src ├── annotator_host.ts ├── cli_support.ts ├── closure_externs.js ├── clutz.ts ├── decorator_downlevel_transformer.ts ├── decorators.ts ├── enum_transformer.ts ├── externs.ts ├── fileoverview_comment_transformer.ts ├── googmodule.ts ├── jsdoc.ts ├── jsdoc_transformer.ts ├── module_type_translator.ts ├── modules_manifest.ts ├── ns_transformer.ts ├── path.ts ├── summary.ts ├── transformer_util.ts ├── ts_migration_exports_shim.ts ├── tsickle.ts ├── tsickle_declaration_marker.ts └── type_translator.ts ├── test ├── ast_printing_transform.ts ├── closure.ts ├── decorator_downlevel_transformer_test.ts ├── e2e_closure_test.ts ├── e2e_clutz_dts_test.ts ├── golden_tsickle_test.ts ├── googbase_fake.js ├── googmodule_test.ts ├── jsdoc_test.ts ├── test_support.ts ├── ts_migration_exports_shim │ ├── BUILD │ ├── README.md │ ├── goog_colon_and_clutz_ref.ts │ ├── goog_module_ref.js │ ├── migrated_default_shorthand.ts │ ├── migrated_default_type.ts │ ├── migrated_default_value.ts │ ├── migrated_named.ts │ └── migrated_named_shorthand.ts ├── tsickle_test.ts └── type_translator_test.ts ├── test_files ├── METADATA ├── abstract │ ├── abstract.js │ └── abstract.ts ├── accessor │ ├── accessor.js │ ├── accessor.ts │ └── externs.js ├── anon_class.no_nstransform │ ├── anon_class.js │ └── anon_class.ts ├── arrow_fn.es5 │ ├── arrow_fn_es5.js │ └── arrow_fn_es5.ts ├── arrow_fn.untyped │ ├── arrow_fn.untyped.js │ └── arrow_fn.untyped.ts ├── arrow_fn │ ├── arrow_fn.js │ └── arrow_fn.ts ├── async_functions │ ├── async_functions.js │ └── async_functions.ts ├── augment │ ├── angular │ │ └── index.d.ts │ ├── externs.js │ ├── shim.js │ ├── user.js │ ├── user.ts │ └── zz_angular-augment.d.ts ├── automatic_semicolon_insertion │ ├── asi.js │ └── asi.ts ├── basic.declaration │ ├── basic.d.ts │ └── basic.ts ├── basic.untyped │ ├── basic.untyped.js │ └── basic.untyped.ts ├── cast_extends │ ├── cast_extends.js │ └── cast_extends.ts ├── class.declaration │ ├── class.d.ts │ └── class.ts ├── class.untyped │ ├── class.js │ └── class.ts ├── class │ ├── class.js │ └── class.ts ├── clutz.no_externs │ ├── clutz_typings.d.ts │ ├── default_export.js │ ├── import_default.js │ ├── import_default.ts │ ├── some_name_space.js │ ├── some_other.js │ ├── strip_clutz_type.js │ └── strip_clutz_type.ts ├── clutz_imports.declaration.no_externs │ ├── clutz2_output_demo8.d.ts │ ├── clutz_output_demo1.d.ts │ ├── clutz_output_demo2.d.ts │ ├── clutz_output_demo3.d.ts │ ├── clutz_output_demo4.d.ts │ ├── clutz_output_demo5.d.ts │ ├── clutz_output_demo6.d.ts │ ├── clutz_output_demo7.d.ts │ ├── user_code.d.ts │ └── user_code.ts ├── clutz_type_value.no_externs │ ├── clutz.d.ts │ ├── type_value.js │ ├── user.js │ └── user.ts ├── clutz_user.d.ts ├── coerce │ ├── coerce.js │ └── coerce.ts ├── comments │ ├── comments.js │ └── comments.ts ├── conditional_rest_tuple_type │ ├── conditional_rest_tuple_type.js │ └── conditional_rest_tuple_type.ts ├── conditional_type │ ├── conditional_type.js │ └── conditional_type.ts ├── conformance.proto ├── ctors │ ├── ctors.js │ └── ctors.ts ├── debugger │ ├── dbg.d.ts │ ├── externs.js │ ├── user.js │ └── user.ts ├── decl_merge │ ├── imported_inner_decl.js │ ├── imported_inner_decl.ts │ ├── inner_class.js │ ├── inner_class.ts │ ├── inner_enum.js │ ├── inner_enum.ts │ ├── inner_interface.js │ ├── inner_interface.ts │ ├── inner_typedef.js │ ├── inner_typedef.ts │ ├── rejected_ns.js │ └── rejected_ns.ts ├── declare │ ├── declare.d.ts │ ├── declare_module.d.ts │ ├── declare_nondts.js │ ├── declare_nondts.ts │ ├── dtsdiagnostics.txt │ ├── externs.js │ ├── shim.js │ ├── user.js │ └── user.ts ├── declare_anonymous_type │ ├── declare_anonymous_type.d.ts │ └── externs.js ├── declare_class_ns │ ├── declare_class_ns.d.ts │ └── externs.js ├── declare_class_overloads │ ├── declare_class_overloads.d.ts │ └── externs.js ├── declare_computed │ ├── declare_computed_prop.d.ts │ └── externs.js ├── declare_enum │ ├── declare_enum.d.ts │ ├── externs.js │ └── user.js ├── declare_export.untyped │ ├── declare_export.js │ ├── declare_export.ts │ └── externs.js ├── declare_export │ ├── declare_export.js │ ├── declare_export.ts │ └── externs.js ├── declare_export_dts │ ├── declare_export_dts.d.ts │ ├── declare_export_var.d.ts │ ├── externs.js │ ├── shim.js │ ├── user.js │ └── user.ts ├── declare_export_global │ ├── declare_export_global.d.ts │ ├── declare_export_global_nested.d.ts │ ├── dtsdiagnostics.txt │ └── externs.js ├── declare_extends │ ├── declare_extends.d.ts │ └── externs.js ├── declare_function_repeated_tags │ ├── declare_function_repeated_tags.d.ts │ └── externs.js ├── declare_generic │ ├── declare_generic.d.ts │ └── externs.js ├── declare_implements │ ├── declare_implements.d.ts │ └── externs.js ├── declare_import │ ├── closure_default_export.js │ ├── closure_named_export.js │ ├── clutz.d.ts │ ├── declare_import_in_dts.d.ts │ ├── declare_import_in_ts.js │ ├── declare_import_in_ts.ts │ ├── dtsdiagnostics.txt │ ├── export_default.js │ ├── export_default.ts │ ├── exporter.js │ ├── exporter.ts │ ├── exporting.d.ts │ ├── exporting.js │ └── externs.js ├── declare_var_and_ns │ ├── declare_var_and_ns.d.ts │ └── externs.js ├── declared_class │ ├── declared_class.d.ts │ └── externs.js ├── decorator │ ├── decorator.decorated.ts │ ├── decorator.js │ ├── decorator.ts │ ├── default_export.js │ ├── default_export.ts │ ├── export_const.js │ ├── export_const.ts │ ├── external.js │ ├── external.ts │ ├── external2.js │ ├── external2.ts │ ├── only_types.js │ └── only_types.ts ├── decorator_nested_scope │ ├── decorator_nested_scope.decorated.ts │ ├── decorator_nested_scope.js │ ├── decorator_nested_scope.ts │ └── externs.js ├── default │ ├── default.js │ └── default.ts ├── direct_externs_type_reference │ ├── clutz2_generated_dee_dot_tee_ess.d.ts │ ├── clutz_generated_dee_dot_tee_ess.d.ts │ ├── externs.js │ ├── lib.js │ ├── lib.ts │ ├── literal_dee_dot_tee_ess.d.ts │ ├── main.js │ ├── main.ts │ ├── shim.js │ └── tsickle_generated_dee_dot_tee_ess.d.ts ├── doc_params │ ├── doc_params.js │ └── doc_params.ts ├── docs_on_ctor_param_properties │ ├── docs_on_ctor_param_properties.js │ └── docs_on_ctor_param_properties.ts ├── enum.untyped │ ├── enum.untyped.js │ └── enum.untyped.ts ├── enum │ ├── enum.js │ ├── enum.ts │ ├── enum_user.js │ └── enum_user.ts ├── enum_ref_import │ ├── enum_ref_import.js │ ├── enum_ref_import.ts │ ├── exporter.js │ └── exporter.ts ├── enum_value_literal_type │ ├── enum_value_literal_type.js │ └── enum_value_literal_type.ts ├── es5_exports.declaration │ ├── es5_exports.d.ts │ └── es5_exports.ts ├── eventmap │ ├── eventmap.js │ ├── eventmap.ts │ └── externs.js ├── export │ ├── export.js │ ├── export.ts │ ├── export_helper.js │ ├── export_helper.ts │ ├── export_helper_2.js │ ├── export_helper_2.ts │ ├── export_helper_3.js │ ├── export_helper_3.ts │ ├── export_star_imported.js │ ├── export_star_imported.ts │ ├── externs.js │ ├── type_and_value.js │ └── type_and_value.ts ├── export_as_namespace │ ├── export_as_namespace.d.ts │ └── externs.js ├── export_as_namespace_exporteq │ ├── export_as_namespace_exporteq.d.ts │ └── externs.js ├── export_declare_namespace │ ├── export_declare_namespace.js │ ├── export_declare_namespace.ts │ ├── externs.js │ ├── user.js │ └── user.ts ├── export_default.declaration │ ├── default.d.ts │ └── default.ts ├── export_equals.shim │ ├── export_equals.js │ ├── export_equals.ts │ ├── externs.js │ ├── namespace.d.ts │ ├── shim.js │ ├── user.js │ └── user.ts ├── export_local_type │ ├── export_local_type.js │ └── export_local_type.ts ├── export_merged │ ├── main.js │ └── main.ts ├── export_multi │ ├── export_multi.js │ └── export_multi.ts ├── export_star_as_ns │ ├── ns.js │ ├── ns.ts │ ├── star_as_ns.js │ └── star_as_ns.ts ├── export_star_dts │ ├── export_star.d.ts │ ├── exported.d.ts │ └── externs.js ├── export_types_values.untyped │ ├── importer.js │ ├── importer.ts │ ├── type_exporter.js │ ├── type_exporter.ts │ ├── value_exporter.js │ └── value_exporter.ts ├── exporting_decorator │ ├── exporting.js │ └── exporting.ts ├── extend_and_implement │ ├── extend_and_implement.js │ └── extend_and_implement.ts ├── extends_ctor │ ├── extends_ctor.d.ts │ └── externs.js ├── fake_goog_reflect.js ├── fields │ ├── fields.js │ └── fields.ts ├── fields_no_ctor │ ├── fields_no_ctor.js │ └── fields_no_ctor.ts ├── file_comment.puretransform │ ├── before_import.js │ ├── before_import.ts │ ├── comment_before_class.js │ ├── comment_before_class.ts │ ├── comment_before_elided_import.js │ ├── comment_before_elided_import.ts │ ├── comment_before_var.js │ ├── comment_before_var.ts │ ├── comment_no_tag.js │ ├── comment_no_tag.ts │ ├── comment_with_text.js │ ├── comment_with_text.ts │ ├── file_comment.js │ ├── file_comment.ts │ ├── fileoverview_and_jsdoc.js │ ├── fileoverview_and_jsdoc.ts │ ├── fileoverview_comment_add_suppress.js │ ├── fileoverview_comment_add_suppress.ts │ ├── fileoverview_comment_add_suppress_before_license.js │ ├── fileoverview_comment_add_suppress_before_license.ts │ ├── fileoverview_comment_merge_suppress.js │ ├── fileoverview_comment_merge_suppress.ts │ ├── jsdoc_comment.js │ ├── jsdoc_comment.ts │ ├── multiple_comments.js │ ├── multiple_comments.ts │ ├── other_fileoverview_comments.js │ ├── other_fileoverview_comments.ts │ ├── side_effect_import.js │ └── side_effect_import.ts ├── file_comment │ ├── before_import.js │ ├── before_import.ts │ ├── comment_before_class.js │ ├── comment_before_class.ts │ ├── comment_before_elided_import.js │ ├── comment_before_elided_import.ts │ ├── comment_before_var.js │ ├── comment_before_var.ts │ ├── comment_no_tag.js │ ├── comment_no_tag.ts │ ├── comment_with_text.js │ ├── comment_with_text.ts │ ├── export_star.js │ ├── export_star.ts │ ├── file_comment.js │ ├── file_comment.ts │ ├── fileoverview_and_jsdoc.js │ ├── fileoverview_and_jsdoc.ts │ ├── fileoverview_comment_add_suppress.js │ ├── fileoverview_comment_add_suppress.ts │ ├── fileoverview_comment_add_suppress_before_license.js │ ├── fileoverview_comment_add_suppress_before_license.ts │ ├── fileoverview_comment_merge_suppress.js │ ├── fileoverview_comment_merge_suppress.ts │ ├── fileoverview_in_comment_text.js │ ├── fileoverview_in_comment_text.ts │ ├── jsdoc_comment.js │ ├── jsdoc_comment.ts │ ├── latecomment.js │ ├── latecomment.ts │ ├── latecomment_front.js │ ├── latecomment_front.ts │ ├── multiple_comments.js │ ├── multiple_comments.ts │ ├── other_fileoverview_comments.js │ ├── other_fileoverview_comments.ts │ ├── run_in_comment.js │ ├── run_in_comment.ts │ ├── side_effect_import.js │ └── side_effect_import.ts ├── functions.untyped │ ├── functions.js │ └── functions.ts ├── functions │ ├── functions.js │ ├── functions.ts │ ├── two_jsdoc_blocks.js │ └── two_jsdoc_blocks.ts ├── generic_extends │ ├── user.js │ └── user.ts ├── generic_fn_type │ ├── generic_fn_type.js │ └── generic_fn_type.ts ├── generic_in_prop_access │ ├── user.js │ └── user.ts ├── generic_local_var │ ├── generic_local_var.js │ └── generic_local_var.ts ├── generic_nested_classes │ ├── user.js │ └── user.ts ├── generic_type_alias │ ├── generic_type_alias.js │ └── generic_type_alias.ts ├── generics.declaration │ ├── generics.d.ts │ └── generics.ts ├── googmodule_esmodule.declaration.no_externs │ ├── some_module.d.ts │ ├── some_module.js │ ├── user.d.ts │ └── user.ts ├── googmodule_esmodule.no_externs │ ├── some_module.d.ts │ ├── some_module.js │ ├── user.js │ └── user.ts ├── ignored_ambient_external_module │ ├── externs.js │ ├── ignored.d.ts │ ├── user.js │ └── user.ts ├── implement_reexported_interface │ ├── exporter.js │ ├── exporter.ts │ ├── interface.js │ ├── interface.ts │ ├── user.js │ └── user.ts ├── implements │ ├── implements.js │ └── implements.ts ├── import_alias │ ├── exporter.js │ ├── exporter.ts │ ├── importer.js │ └── importer.ts ├── import_by_path.declaration.no_externs │ ├── clutz_input.d.ts │ ├── decluser.d.ts │ ├── decluser.ts │ └── jsprovides.js ├── import_by_path.no_externs │ ├── clutz_input.d.ts │ ├── conflicting_multiple.js │ ├── conflicting_multiple.ts │ ├── conflicting_multiple_bystar.js │ ├── conflicting_multiple_bystar.ts │ ├── conflicting_multiple_empty.js │ ├── conflicting_multiple_empty.ts │ ├── conflicting_multiple_type.js │ ├── conflicting_multiple_type.ts │ ├── jsprovides.js │ ├── multiple_side_effect.js │ ├── multiple_side_effect.ts │ ├── user.js │ ├── user.ts │ ├── user_default.js │ ├── user_default.ts │ ├── using_multiple.js │ └── using_multiple.ts ├── import_default │ ├── exporter.js │ ├── exporter.ts │ ├── import_default.js │ └── import_default.ts ├── import_empty │ ├── import_empty.js │ ├── import_empty.ts │ ├── imported.js │ └── imported.ts ├── import_equals │ ├── exporter.d.ts │ ├── exporter.js │ ├── externs.js │ ├── import_equals_global.d.ts │ ├── import_equals_module.d.ts │ ├── import_equals_type_usage.js │ └── import_equals_type_usage.ts ├── import_from_goog.no_externs │ ├── closure_LegacyModule.js │ ├── closure_Module.js │ ├── closure_OtherModule.js │ ├── decls.d.ts │ ├── import_from_goog.js │ ├── import_from_goog.ts │ └── transitive_type.js ├── import_only_types │ ├── import_only_types.js │ ├── import_only_types.ts │ ├── types_and_constenum.js │ ├── types_and_constenum.ts │ ├── types_only.js │ └── types_only.ts ├── import_prefixed │ ├── exporter.js │ ├── exporter.ts │ ├── import_prefixed_mixed.js │ ├── import_prefixed_mixed.ts │ ├── import_prefixed_types.js │ └── import_prefixed_types.ts ├── index_import │ ├── has_index │ │ ├── index.js │ │ ├── index.ts │ │ ├── relative.js │ │ └── relative.ts │ ├── lib.js │ ├── lib.ts │ ├── node_modules │ │ └── foo │ │ │ ├── package.json │ │ │ └── subdir │ │ │ └── index.js │ ├── user.js │ └── user.ts ├── interface │ ├── implement_import.js │ ├── implement_import.ts │ ├── interface.js │ ├── interface.ts │ ├── interface_extends.js │ ├── interface_extends.ts │ ├── interface_merge.js │ ├── interface_merge.ts │ ├── interface_type_params.js │ └── interface_type_params.ts ├── interface_and_type.declaration │ ├── interface_and_type.d.ts │ └── interface_and_type.ts ├── internal.declaration │ ├── internal.d.ts │ ├── internal.js │ └── internal.ts ├── invalid_closure_properties │ ├── externs.js │ ├── invalid_closure_properties.js │ └── invalid_closure_properties.ts ├── iterator │ ├── iterator.js │ └── iterator.ts ├── jsdoc │ ├── enum_tag.js │ ├── enum_tag.ts │ ├── jsdoc.js │ └── jsdoc.ts ├── jsdoc_types.untyped │ ├── default.js │ ├── default.ts │ ├── jsdoc_types.js │ ├── jsdoc_types.ts │ ├── module1.js │ ├── module1.ts │ ├── module2.js │ ├── module2.ts │ ├── nevertyped.js │ └── nevertyped.ts ├── jsdoc_types │ ├── default.js │ ├── default.ts │ ├── initialized_unknown.js │ ├── initialized_unknown.ts │ ├── jsdoc_types.js │ ├── jsdoc_types.ts │ ├── module1.js │ ├── module1.ts │ ├── module2.js │ ├── module2.ts │ ├── nevertyped.js │ └── nevertyped.ts ├── jsx.no_externs │ ├── jsx.js │ ├── jsx.tsx │ └── react.d.ts ├── methods │ ├── methods.js │ └── methods.ts ├── mixin │ ├── dtsdiagnostics.txt │ ├── externs.js │ └── mixin.d.ts ├── module.no_nstransform │ ├── module.js │ └── module.ts ├── module_symbol │ ├── generates_symbol.js │ ├── generates_symbol.ts │ ├── module.d.ts │ ├── preexisting_module_export.js │ ├── preexisting_module_export.ts │ ├── preexisting_module_func.js │ ├── preexisting_module_func.ts │ ├── preexisting_module_import.js │ ├── preexisting_module_import.ts │ ├── preexisting_module_type.js │ ├── preexisting_module_type.ts │ ├── preexisting_module_var.js │ └── preexisting_module_var.ts ├── namespaced.no_nstransform │ ├── ambient_namespaced.js │ ├── ambient_namespaced.ts │ ├── export_enum_in_namespace.js │ ├── export_enum_in_namespace.ts │ ├── export_namespace.js │ ├── export_namespace.ts │ ├── externs.js │ ├── local_namespace.js │ ├── local_namespace.ts │ ├── merged_namespace.js │ ├── merged_namespace.ts │ ├── reopen_ns.js │ ├── reopen_ns.ts │ ├── user.js │ └── user.ts ├── nested_folder.declaration │ └── inner_folder │ │ ├── nested.d.ts │ │ └── nested.ts ├── no_dollar_type_reference.no_externs │ ├── closure_x.js │ ├── closure_y.js │ ├── decl.d.ts │ ├── import.js │ └── import.ts ├── no_exports.declaration │ ├── no_exports.d.ts │ └── no_exports.ts ├── nonnull_generics │ ├── nonnull_generics.js │ └── nonnull_generics.ts ├── nonnullable │ ├── nonnullable.js │ └── nonnullable.ts ├── nullable │ ├── nullable.js │ └── nullable.ts ├── optional │ ├── optional.js │ └── optional.ts ├── optional_chaining │ ├── keyed_access.js │ ├── keyed_access.ts │ ├── optional_chaining.js │ └── optional_chaining.ts ├── optional_method │ ├── optional_method.js │ └── optional_method.ts ├── overload_with_this_parameter │ ├── externs.js │ └── overload_with_this_parameter.d.ts ├── parameter_properties │ ├── parameter_properties.js │ └── parameter_properties.ts ├── partial │ ├── partial.js │ └── partial.ts ├── private_field │ ├── private_field.js │ └── private_field.ts ├── promiseconstructor │ ├── promiseconstructor.js │ └── promiseconstructor.ts ├── promisectorlike │ ├── promisectorlike.js │ └── promisectorlike.ts ├── promiselike │ ├── promiselike.js │ └── promiselike.ts ├── protected │ ├── protected.js │ └── protected.ts ├── readonly │ ├── externs.js │ ├── readonly.js │ └── readonly.ts ├── recursive_alias │ ├── recursive_alias.js │ └── recursive_alias.ts ├── recursive_union │ ├── recursive_union.js │ └── recursive_union.ts ├── reexport.declaration │ ├── export.d.ts │ ├── export.ts │ ├── import_reexport.d.ts │ ├── import_reexport.ts │ ├── reexport.d.ts │ ├── reexport.ts │ ├── reexport_named.d.ts │ ├── reexport_named.ts │ ├── renamed_export.d.ts │ └── renamed_export.ts ├── rest_parameters_any │ ├── rest_parameters_any.js │ └── rest_parameters_any.ts ├── rest_parameters_generic_empty │ ├── rest_parameters_generic_empty.js │ └── rest_parameters_generic_empty.ts ├── rest_parameters_tuple │ ├── rest_parameters_tuple.js │ └── rest_parameters_tuple.ts ├── return_this │ ├── return_this.js │ └── return_this.ts ├── scope_collision │ ├── collision.js │ └── collision.ts ├── side_effect_import │ ├── module1.js │ ├── module1.ts │ ├── module2.js │ ├── module2.ts │ ├── side_effect_import.js │ └── side_effect_import.ts ├── single_value_enum │ ├── single_value_enum.js │ └── single_value_enum.ts ├── static │ ├── static.js │ └── static.ts ├── string_manipulations │ ├── uncapitalize_lowercase.js │ └── uncapitalize_lowercase.ts ├── structural.untyped │ ├── structural.untyped.js │ └── structural.untyped.ts ├── super │ ├── super.js │ └── super.ts ├── symbol │ ├── symbol.js │ └── symbol.ts ├── this_type │ ├── this_type.js │ └── this_type.ts ├── transitive_symbol_type_only │ ├── exporter.js │ ├── exporter.ts │ ├── reexporter.js │ ├── reexporter.ts │ ├── transitive_symbol_type_only.js │ └── transitive_symbol_type_only.ts ├── ts_migration_exports_shim.no_externs.puretransform.declaration │ ├── bad.d.ts │ ├── bad.js │ ├── bad.ts │ ├── correct_default_type.d.ts │ ├── correct_default_type.js │ ├── correct_default_type.ts │ ├── correct_default_type.tsmes.d.ts │ ├── correct_default_type_shorthand.d.ts │ ├── correct_default_type_shorthand.js │ ├── correct_default_type_shorthand.ts │ ├── correct_default_type_shorthand.tsmes.d.ts │ ├── correct_default_value.d.ts │ ├── correct_default_value.js │ ├── correct_default_value.ts │ ├── correct_default_value.tsmes.d.ts │ ├── correct_default_value_shorthand.d.ts │ ├── correct_default_value_shorthand.js │ ├── correct_default_value_shorthand.ts │ ├── correct_default_value_shorthand.tsmes.d.ts │ ├── correct_named.d.ts │ ├── correct_named.js │ ├── correct_named.ts │ ├── correct_named.tsmes.d.ts │ ├── correct_named_shorthand.d.ts │ ├── correct_named_shorthand.js │ ├── correct_named_shorthand.ts │ ├── correct_named_shorthand.tsmes.d.ts │ └── google3_strict.d.ts ├── ts_migration_exports_shim.no_externs │ ├── bad.js │ ├── bad.ts │ ├── bad_default_shorthand_with_more_than_one_export.js │ ├── bad_default_shorthand_with_more_than_one_export.ts │ ├── bad_default_shorthand_with_no_exports.js │ ├── bad_default_shorthand_with_no_exports.ts │ ├── bad_dln_only.js │ ├── bad_dln_only.ts │ ├── correct_default_shorthand.js │ ├── correct_default_shorthand.ts │ ├── correct_default_shorthand.tsmes.js │ ├── correct_default_type.js │ ├── correct_default_type.ts │ ├── correct_default_type.tsmes.js │ ├── correct_default_type_literal.js │ ├── correct_default_type_literal.ts │ ├── correct_default_type_literal.tsmes.js │ ├── correct_default_value.js │ ├── correct_default_value.ts │ ├── correct_default_value.tsmes.js │ ├── correct_default_with_re_export.js │ ├── correct_default_with_re_export.ts │ ├── correct_default_with_re_export.tsmes.js │ ├── correct_named.js │ ├── correct_named.ts │ ├── correct_named.tsmes.js │ ├── correct_named_shorthand.js │ ├── correct_named_shorthand.ts │ ├── correct_named_shorthand.tsmes.js │ ├── google3_strict.d.ts │ ├── pintomodule.js │ ├── pintomodule.ts │ └── pintomodule.tsmes.js ├── ts_migration_exports_shim.tsmes_disabled.no_externs │ ├── emits_other_errors.js │ ├── emits_other_errors.ts │ └── google3_strict.d.ts ├── tsconfig.json ├── tuple_types │ ├── tuple_functions.js │ ├── tuple_functions.ts │ ├── tuple_types.js │ └── tuple_types.ts ├── type │ ├── externs.js │ ├── type.js │ └── type.ts ├── type_alias_imported │ ├── elided_comment.js │ ├── elided_comment.ts │ ├── export_constant.js │ ├── export_constant.ts │ ├── type_alias_declare.js │ ├── type_alias_declare.ts │ ├── type_alias_default_exporter.js │ ├── type_alias_default_exporter.ts │ ├── type_alias_exporter.js │ ├── type_alias_exporter.ts │ ├── type_alias_imported.js │ └── type_alias_imported.ts ├── type_and_value │ ├── externs.js │ ├── module.js │ ├── module.ts │ ├── type_and_value.js │ ├── type_and_value.ts │ └── typing.d.ts ├── type_args_repeated │ ├── type_args_repeated.js │ └── type_args_repeated.ts ├── type_guard_fn │ ├── type_guard_fn.js │ └── type_guard_fn.ts ├── type_intersection │ ├── externs.js │ ├── intersection.js │ └── intersection.ts ├── type_narrowing │ ├── emit_extra_casts.js │ └── emit_extra_casts.ts ├── type_propaccess.no_externs │ ├── clutzed_namespace.d.ts │ ├── nested_clazz.js │ ├── type_propaccess.js │ └── type_propaccess.ts ├── typedef.untyped │ ├── typedef.js │ └── typedef.ts ├── typedef │ ├── typedef.js │ └── typedef.ts ├── typeof_namespace │ ├── dtsdiagnostics.txt │ ├── exported_namespace.d.ts │ └── externs.js ├── underscore │ ├── export_underscore.js │ ├── export_underscore.ts │ ├── externs.js │ ├── underscore.js │ └── underscore.ts ├── use_closure_externs │ ├── externs.js │ ├── use_closure_externs.js │ ├── use_closure_externs.ts │ └── use_closure_externs_decl.d.ts ├── variables │ ├── variables.js │ └── variables.ts └── visibility │ ├── public_override.js │ └── public_override.ts ├── third_party └── tslib │ ├── LICENSE.txt │ ├── README.google │ ├── externs.js │ └── tslib.js ├── tsconfig.json └── tslint.json /.clang-format: -------------------------------------------------------------------------------- 1 | Language: JavaScript 2 | BasedOnStyle: Google 3 | -------------------------------------------------------------------------------- /.github/workflows/node.js.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | jobs: 10 | build: 11 | 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - uses: actions/checkout@v2 16 | # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ 17 | - name: Use Node.js 15.x 18 | uses: actions/setup-node@v2 19 | with: 20 | node-version: 15.x 21 | - run: yarn 22 | - run: yarn run build 23 | - run: yarn test 24 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | .vscode/ 3 | out/ 4 | package-lock.json 5 | yarn.lock 6 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | message="rel: %s" 2 | -------------------------------------------------------------------------------- /demo/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | /tsickle-out 3 | /node_modules 4 | -------------------------------------------------------------------------------- /demo/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "tsickle-demo", 3 | "version": "0.0.0", 4 | "description": "sample app demonstrating tsickle", 5 | "main": "demo.js", 6 | "license": "Apache-2.0", 7 | "private": true, 8 | "dependencies": { 9 | "minimist": "^1.2.3", 10 | "tsickle": "file:../", 11 | "typescript": "5.2.2" 12 | }, 13 | "devDependencies": { 14 | "@types/minimist": "1.2.0", 15 | "@types/node": "^10.5.6" 16 | }, 17 | "scripts": { 18 | "build": "(cd ../ && yarn build) && tsc", 19 | "demo": "node --preserve-symlinks build/demo.js -- --outDir `pwd`/tsickle-out" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /demo/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2017", 4 | "module": "commonjs", 5 | "outDir": "build/", 6 | "strict": true 7 | }, 8 | "exclude": [ 9 | "test.ts" 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /test/googbase_fake.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @license 3 | * Copyright Google Inc. All Rights Reserved. 4 | * 5 | * Use of this source code is governed by an MIT-style license that can be 6 | * found in the LICENSE file at https://angular.io/license 7 | */ 8 | 9 | /** 10 | * @fileoverview Mocks missing goog functions for e2e_closure_test.ts. Closure 11 | * Compiler complains about a missing goog.provide without these definitions. 12 | */ 13 | 14 | /** @const */ 15 | var goog = goog || {}; 16 | goog.provide = function(ns) {}; 17 | goog.require = function(ns) {}; 18 | goog.requireType = function(ns) {}; 19 | -------------------------------------------------------------------------------- /test/ts_migration_exports_shim/README.md: -------------------------------------------------------------------------------- 1 | # goog.tsMigrationExportsShim Functional Test 2 | 3 | This package is intended to verify that goog.tsMigrationExportsShim functions 4 | correctly as part of an actual build. It wires together libraries in the way 5 | users are expected to and then verifies that the build success and that types 6 | are propagated. 7 | 8 | The actual content for the generated files is not relevant here. There are 9 | separate golden tests for that. 10 | -------------------------------------------------------------------------------- /test/ts_migration_exports_shim/migrated_default_shorthand.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @license 3 | * Copyright Google Inc. All Rights Reserved. 4 | * 5 | * Use of this source code is governed by an MIT-style license that can be 6 | * found in the LICENSE file at https://angular.io/license 7 | */ 8 | 9 | /** 10 | * See what happens when we use the shorthand syntax for shimming named 11 | * exports. 12 | */ 13 | 14 | export const SomeConstant = 42; 15 | 16 | goog.tsMigrationDefaultExportsShim('migrated.module.default_shorthand'); 17 | -------------------------------------------------------------------------------- /test/ts_migration_exports_shim/migrated_named_shorthand.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @license 3 | * Copyright Google Inc. All Rights Reserved. 4 | * 5 | * Use of this source code is governed by an MIT-style license that can be 6 | * found in the LICENSE file at https://angular.io/license 7 | */ 8 | 9 | /** 10 | * See what happens when we use the shorthand syntax for shimming named 11 | * exports. 12 | */ 13 | 14 | export const SomeConstant = 42; 15 | 16 | goog.tsMigrationNamedExportsShim('migrated.module.named_shorthand'); 17 | -------------------------------------------------------------------------------- /test_files/METADATA: -------------------------------------------------------------------------------- 1 | # go/google3metadata 2 | # proto-file: devtools/metadata/metadata.proto 3 | # proto-message: MetaData 4 | tricorder { 5 | # Disable lint on tsickle test data. 6 | disable: ThirdPartyAndExperimentalLint 7 | } 8 | -------------------------------------------------------------------------------- /test_files/accessor/accessor.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview added by tsickle 3 | * Generated from: test_files/accessor/accessor.ts 4 | */ 5 | goog.module('test_files.accessor.accessor'); 6 | var module = module || { id: 'test_files/accessor/accessor.ts' }; 7 | goog.require('tslib'); 8 | -------------------------------------------------------------------------------- /test_files/arrow_fn.es5/arrow_fn_es5.ts: -------------------------------------------------------------------------------- 1 | /** @fileoverview Reproduces an error that caused incorrect Automatic Semicolon Insertion. */ 2 | 3 | const foo = () => 4 | // this comment must not get inserted between the return and expression in ES5 (ASI). 5 | console.log('foo'); 6 | 7 | const bar = () => 8 | // Print "bar" 9 | { 10 | console.log('bar'); 11 | }; 12 | -------------------------------------------------------------------------------- /test_files/arrow_fn.untyped/arrow_fn.untyped.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview added by tsickle 3 | * Generated from: test_files/arrow_fn.untyped/arrow_fn.untyped.ts 4 | */ 5 | goog.module('test_files.arrow_fn.untyped.arrow_fn.untyped'); 6 | var module = module || { id: 'test_files/arrow_fn.untyped/arrow_fn.untyped.ts' }; 7 | goog.require('tslib'); 8 | /** @type {?} */ 9 | var fn3 = (/** 10 | * @param {?} a 11 | * @return {?} 12 | */ 13 | (a) => 12); 14 | -------------------------------------------------------------------------------- /test_files/arrow_fn.untyped/arrow_fn.untyped.ts: -------------------------------------------------------------------------------- 1 | var fn3 = (a: number): number => 12; 2 | -------------------------------------------------------------------------------- /test_files/arrow_fn/arrow_fn.ts: -------------------------------------------------------------------------------- 1 | var fn3 = (a: number): number => 12; 2 | var fn4 = (a) => a + 12; 3 | export var fn5 = (a = 10) => a; 4 | 5 | /** @param a this must be escaped, as Closure bails on it. */ 6 | const fn6 = (a = 10) => a; 7 | -------------------------------------------------------------------------------- /test_files/augment/angular/index.d.ts: -------------------------------------------------------------------------------- 1 | export = angular; 2 | export as namespace angular; 3 | 4 | declare var angular: angular.IAngularStatic; 5 | 6 | declare namespace angular { 7 | interface Scope { 8 | name: string; 9 | } 10 | namespace sub { 11 | type SubType = string; 12 | } 13 | interface IAngularStatic { 14 | copy(a: string): string; 15 | version: string; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /test_files/augment/shim.js: -------------------------------------------------------------------------------- 1 | goog.module('test_files.augment.angular.index'); 2 | 3 | exports = window.angular; 4 | -------------------------------------------------------------------------------- /test_files/augment/user.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @fileoverview 4 | * Generated from: test_files/augment/user.ts 5 | * @suppress {checkTypes} 6 | * 7 | */ 8 | goog.module('test_files.augment.user'); 9 | var module = module || { id: 'test_files/augment/user.ts' }; 10 | goog.require('tslib'); 11 | const tsickle_index_1 = goog.requireType("test_files.augment.angular.index"); 12 | const ng = goog.require('test_files.augment.angular.index'); 13 | /** @type {!tsickle_index_1.Scope} */ 14 | const fakeScope = { 15 | name: ng.version 16 | }; 17 | /** @type {!tsickle_index_1.sub.AugmentSubType} */ 18 | const usingAugment = { 19 | prop: fakeScope.name 20 | }; 21 | -------------------------------------------------------------------------------- /test_files/augment/user.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview 3 | * @suppress {checkTypes} 4 | */ 5 | 6 | import * as ng from './angular/index'; 7 | 8 | const fakeScope: ng.Scope = { 9 | name: ng.version 10 | }; 11 | const usingAugment: ng.sub.AugmentSubType = { 12 | prop: fakeScope.name 13 | }; 14 | -------------------------------------------------------------------------------- /test_files/automatic_semicolon_insertion/asi.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview added by tsickle 3 | * Generated from: test_files/automatic_semicolon_insertion/asi.ts 4 | */ 5 | goog.module('test_files.automatic_semicolon_insertion.asi'); 6 | var module = module || { id: 'test_files/automatic_semicolon_insertion/asi.ts' }; 7 | goog.require('tslib'); 8 | /** 9 | * @return {function(number): number} 10 | */ 11 | function mustParenthesizeCommentedReturnFn() { 12 | return (/** 13 | * @param {number} x 14 | * @return {number} 15 | */ 16 | (x) => x + 1); 17 | } 18 | exports.mustParenthesizeCommentedReturnFn = mustParenthesizeCommentedReturnFn; 19 | -------------------------------------------------------------------------------- /test_files/automatic_semicolon_insertion/asi.ts: -------------------------------------------------------------------------------- 1 | export function mustParenthesizeCommentedReturnFn() { 2 | return (x: number) => x + 1; 3 | } 4 | -------------------------------------------------------------------------------- /test_files/basic.declaration/basic.d.ts: -------------------------------------------------------------------------------- 1 | //!! generated by tsickle from test_files/basic.declaration/basic.ts 2 | export declare const x = 1; 3 | export declare function incr(n: any): number; 4 | export declare const y = 1; 5 | declare global { 6 | namespace ಠ_ಠ.clutz { 7 | export { incr as module$contents$test_files$basic$declaration$basic_incr, x as module$contents$test_files$basic$declaration$basic_x, y as module$contents$test_files$basic$declaration$basic_y }; 8 | export namespace module$exports$test_files$basic$declaration$basic { 9 | export { incr, x, y }; 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test_files/basic.declaration/basic.ts: -------------------------------------------------------------------------------- 1 | export const x = 1; 2 | export function incr(n) { 3 | return x + 1; 4 | } 5 | export const y = 1; 6 | -------------------------------------------------------------------------------- /test_files/class.declaration/class.d.ts: -------------------------------------------------------------------------------- 1 | //!! generated by tsickle from test_files/class.declaration/class.ts 2 | export declare class Foo { 3 | } 4 | declare global { 5 | namespace ಠ_ಠ.clutz { 6 | export { Foo as module$contents$test_files$class$declaration$class_Foo }; 7 | export namespace module$exports$test_files$class$declaration$class { 8 | export { Foo }; 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test_files/class.declaration/class.ts: -------------------------------------------------------------------------------- 1 | export class Foo {} -------------------------------------------------------------------------------- /test_files/clutz.no_externs/default_export.js: -------------------------------------------------------------------------------- 1 | goog.module('default_export'); 2 | 3 | exports = class {}; 4 | -------------------------------------------------------------------------------- /test_files/clutz.no_externs/some_name_space.js: -------------------------------------------------------------------------------- 1 | goog.module('some.name.space'); 2 | 3 | const other = goog.require('some.other'); 4 | 5 | exports.ClutzedClass = class { 6 | constructor() { /** @type {!other.TypeAlias} */ this.field; } 7 | }; 8 | /** @param {!other.TypeAlias} param a param. */ 9 | exports.clutzedFn = function(param) {}; 10 | -------------------------------------------------------------------------------- /test_files/clutz.no_externs/some_other.js: -------------------------------------------------------------------------------- 1 | goog.module('some.other'); 2 | 3 | /** @record */ 4 | const ClutzedInterface = function() {}; 5 | /** @type {string} */ 6 | ClutzedInterface.prototype.field; 7 | 8 | exports.ClutzedInterface = ClutzedInterface; 9 | 10 | /** @typedef {ClutzedInterface} */ 11 | exports.TypeAlias; 12 | -------------------------------------------------------------------------------- /test_files/clutz.no_externs/strip_clutz_type.ts: -------------------------------------------------------------------------------- 1 | import {ClutzedClass, clutzedFn} from 'goog:some.name.space'; 2 | import {TypeAlias} from 'goog:some.other'; 3 | 4 | let clutzedClass: ClutzedClass = new ClutzedClass(); 5 | console.log(clutzedClass); 6 | let typeAliased: TypeAlias = clutzedClass.field; 7 | clutzedFn(typeAliased); 8 | -------------------------------------------------------------------------------- /test_files/clutz_imports.declaration.no_externs/clutz2_output_demo8.d.ts: -------------------------------------------------------------------------------- 1 | //!! generated by clutz2 2 | /** 3 | * @fileoverview This file contains the Clutz2 output for a simple goog.provide. 4 | * It was manually created and is a support file for the actual test. 5 | */ 6 | 7 | declare namespace ಠ_ಠ.clutz { 8 | namespace demo8 { 9 | export class C { 10 | private noStructuralTyping_demo8$C: any; 11 | } 12 | } // namespace demo8 13 | } // ಠ_ಠ.clutz 14 | 15 | declare module 'goog:demo8' { 16 | import demo8 = ಠ_ಠ.clutz.demo8; 17 | export default demo8; 18 | } 19 | -------------------------------------------------------------------------------- /test_files/clutz_imports.declaration.no_externs/clutz_output_demo1.d.ts: -------------------------------------------------------------------------------- 1 | //!! generated by clutz. 2 | /** 3 | * @fileoverview This file contains the Clutz output for a simple goog.module. 4 | * It was manually created and is a support file for the actual test. 5 | */ 6 | 7 | declare namespace ಠ_ಠ.clutz.module$exports$demo1 { 8 | class C { 9 | private noStructuralTyping_module$exports$demo1_C: any; 10 | foo(): void; 11 | } 12 | } 13 | declare module 'goog:demo1' { 14 | import demo1 = ಠ_ಠ.clutz.module$exports$demo1; 15 | export = demo1; 16 | } 17 | -------------------------------------------------------------------------------- /test_files/clutz_imports.declaration.no_externs/clutz_output_demo2.d.ts: -------------------------------------------------------------------------------- 1 | //!! generated by clutz. 2 | /** 3 | * @fileoverview This file contains the Clutz output for a simple goog.provide. 4 | * It was manually created and is a support file for the actual test. 5 | */ 6 | 7 | declare namespace ಠ_ಠ.clutz.demo2 { 8 | class C { 9 | private noStructuralTyping_demo2_C: any; 10 | bar(): void; 11 | } 12 | } 13 | declare module 'goog:demo2' { 14 | import demo2 = ಠ_ಠ.clutz.demo2; 15 | export = demo2; 16 | } 17 | -------------------------------------------------------------------------------- /test_files/clutz_imports.declaration.no_externs/clutz_output_demo3.d.ts: -------------------------------------------------------------------------------- 1 | //!! generated by clutz. 2 | /** 3 | * @fileoverview This file contains the Clutz output for a simple goog.module. 4 | * It was manually created and is a support file for the actual test. 5 | */ 6 | 7 | declare namespace ಠ_ಠ.clutz { 8 | class module$exports$demo3 { 9 | private noStructuralTyping_module$exports$demo3: any; 10 | bar(): void; 11 | } 12 | } 13 | declare module 'goog:demo3' { 14 | import demo3 = ಠ_ಠ.clutz.module$exports$demo3; 15 | export default demo3; 16 | } 17 | -------------------------------------------------------------------------------- /test_files/clutz_imports.declaration.no_externs/clutz_output_demo4.d.ts: -------------------------------------------------------------------------------- 1 | //!! generated by clutz. 2 | /** 3 | * @fileoverview This file contains the Clutz output for a simple goog.provide. 4 | * It was manually created and is a support file for the actual test. 5 | */ 6 | 7 | declare namespace ಠ_ಠ.clutz.demo4 { 8 | function f(): void; 9 | } 10 | declare module 'goog:demo4' { 11 | import demo4 = ಠ_ಠ.clutz.demo4; 12 | export = demo4; 13 | } 14 | -------------------------------------------------------------------------------- /test_files/clutz_imports.declaration.no_externs/clutz_output_demo5.d.ts: -------------------------------------------------------------------------------- 1 | //!! generated by clutz. 2 | /** 3 | * @fileoverview This file contains the Clutz output for a simple goog.module. 4 | * It was manually created and is a support file for the actual test. 5 | */ 6 | 7 | declare namespace ಠ_ಠ.clutz.module$exports$demo5 { 8 | class C { 9 | private noStructuralTyping_module$exports$demo5_C : any; 10 | f ( ) : void ; 11 | } 12 | } 13 | declare module 'goog:demo5' { 14 | import demo5 = ಠ_ಠ.clutz.module$exports$demo5; 15 | export = demo5; 16 | } 17 | 18 | -------------------------------------------------------------------------------- /test_files/clutz_imports.declaration.no_externs/clutz_output_demo6.d.ts: -------------------------------------------------------------------------------- 1 | //!! generated by clutz. 2 | /** 3 | * @fileoverview This file contains the Clutz output for a simple goog.module, 4 | * with a generic class. 5 | * It was manually created and is a support file for the actual test. 6 | */ 7 | 8 | declare namespace ಠ_ಠ.clutz.module$exports$demo6 { 9 | class C < T = any > { 10 | private noStructuralTyping_module$exports$demo6_C : [ T ]; 11 | foo ( ) : void ; 12 | } 13 | } 14 | declare module 'goog:demo6' { 15 | import demo6 = ಠ_ಠ.clutz.module$exports$demo6; 16 | export = demo6; 17 | } 18 | 19 | -------------------------------------------------------------------------------- /test_files/clutz_imports.declaration.no_externs/clutz_output_demo7.d.ts: -------------------------------------------------------------------------------- 1 | //!! generated by clutz. 2 | /** 3 | * @fileoverview This file contains the Clutz output for an externs file. 4 | * It was manually created and is a support file for the actual test. 5 | */ 6 | 7 | declare namespace demo7 { 8 | class C { 9 | foo(): void; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test_files/clutz_type_value.no_externs/clutz.d.ts: -------------------------------------------------------------------------------- 1 | //!! generated by clutz. 2 | 3 | // This file recreates the clutz output that has a type/value conflict. 4 | 5 | declare namespace ಠ_ಠ.clutz { 6 | interface module$contents$type_value$IFace { 7 | field: string; 8 | } 9 | } 10 | declare namespace ಠ_ಠ.clutz.module$contents$type_value$IFace { 11 | class Class { 12 | otherField: string; 13 | } 14 | } 15 | 16 | declare namespace ಠ_ಠ.clutz.type_value { 17 | export import IFace = ಠ_ಠ.clutz.module$contents$type_value$IFace; 18 | } 19 | 20 | declare module 'goog:type_value' { 21 | import IFace = ಠ_ಠ.clutz.type_value.IFace; 22 | export default IFace; 23 | } 24 | -------------------------------------------------------------------------------- /test_files/clutz_type_value.no_externs/type_value.js: -------------------------------------------------------------------------------- 1 | goog.module('type_value'); 2 | 3 | /** @record */ 4 | class IFace { 5 | constructor() { 6 | /** @type {string} */ 7 | this.field; 8 | } 9 | } 10 | 11 | class Class { 12 | constructor() { 13 | /** @type {string} */ 14 | this.otherField; 15 | } 16 | } 17 | 18 | IFace.Class = Class; 19 | 20 | exports = IFace; 21 | -------------------------------------------------------------------------------- /test_files/clutz_type_value.no_externs/user.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview This test verifies that a type/value-conflict symbol that 3 | * occurs in a clutz file still can be used in a heritage clause. 4 | * @suppress {uselessCode} 5 | */ 6 | 7 | import IFace from 'goog:type_value'; 8 | 9 | // We expect IFace to show up in the @implements tag. 10 | class C implements IFace { 11 | field = 'abc'; 12 | } 13 | 14 | // We expect IFace to show up in the @type of usingTypeValueConflictType below. 15 | const usingTypeValueConflictType: IFace|null = null; 16 | -------------------------------------------------------------------------------- /test_files/clutz_user.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview Tests that renamed exports get emitted with the correct Clutz 3 | * alias names. This is simulating the kinds of references Clutz wants to 4 | * generate to refer to types in tsickle. 5 | * 6 | * This file is tested by the e2e_clutz_dts test and passes as long as it 7 | * type-checks. 8 | */ 9 | 10 | export {}; 11 | 12 | declare const moduleInternalName: typeof ಠ_ಠ.clutz 13 | .module$contents$test_files$reexport$declaration$renamed_export_MOTHER; 14 | 15 | declare const exportedName: typeof ಠ_ಠ.clutz 16 | .module$exports$test_files$reexport$declaration$renamed_export.MOTHER; 17 | -------------------------------------------------------------------------------- /test_files/coerce/coerce.ts: -------------------------------------------------------------------------------- 1 | function acceptString(arg: string): string { return arg; } 2 | acceptString(3); 3 | acceptString(3 as any); 4 | acceptString(`${3 as any}`); 5 | 6 | const nullableVariable: string|null = 'asd'; 7 | const nonNullVariable: string = nullableVariable!; 8 | -------------------------------------------------------------------------------- /test_files/conditional_rest_tuple_type/conditional_rest_tuple_type.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview Tests an interaction between conditional types and rest (...) 3 | * types. 4 | */ 5 | 6 | function conditionalRestTupleType(...args: T extends string ? [] : ['a']) {} 7 | 8 | export const x = { 9 | conditionalRestTupleType(...args: T extends string ? [] : ['a']) { 10 | conditionalRestTupleType(...args); 11 | } 12 | }; 13 | -------------------------------------------------------------------------------- /test_files/conditional_type/conditional_type.js: -------------------------------------------------------------------------------- 1 | // test_files/conditional_type/conditional_type.ts(1,1): warning TS0: emitting ? for conditional/substitution type 2 | /** 3 | * @fileoverview added by tsickle 4 | * Generated from: test_files/conditional_type/conditional_type.ts 5 | */ 6 | goog.module('test_files.conditional_type.conditional_type'); 7 | var module = module || { id: 'test_files/conditional_type/conditional_type.ts' }; 8 | goog.require('tslib'); 9 | /** @typedef {?} */ 10 | exports.Filter; 11 | -------------------------------------------------------------------------------- /test_files/conditional_type/conditional_type.ts: -------------------------------------------------------------------------------- 1 | export type Filter = T extends U ? T : never; 2 | -------------------------------------------------------------------------------- /test_files/conformance.proto: -------------------------------------------------------------------------------- 1 | # Conformance configuration for tsickle tests. 2 | # 3 | # This attempts to reproduce failures we've seen in the Google-internal 4 | # JS compilations. 5 | # 6 | # See 7 | # https://github.com/google/closure-compiler/wiki/JS-Conformance-Framework 8 | # for more about conformance. 9 | 10 | requirement: { 11 | rule_id: 'closure:unknownThis' 12 | type: CUSTOM 13 | java_class: 'com.google.javascript.jscomp.ConformanceRules$BanUnknownThis' 14 | error_message: 'References to "this" that are typed as "unknown" are not allowed. See https://google.github.io/closure-library/develop/conformance_rules.html#unknownThis' 15 | } 16 | -------------------------------------------------------------------------------- /test_files/ctors/ctors.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview 3 | * @suppress {uselessCode} 4 | */ 5 | 6 | let x = Document; 7 | class X { 8 | constructor(private a: number) {} 9 | } 10 | let y: {new (a: number): X} = X; 11 | 12 | 13 | class OverloadedCtor { 14 | constructor(a: number); 15 | constructor(a: string); 16 | constructor(private a: number|string) {} 17 | } 18 | -------------------------------------------------------------------------------- /test_files/debugger/dbg.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview Reproduces .d.ts files that use export {} declarations to work around namespaces 3 | * being reserved identifiers (such as debugger below). 4 | */ 5 | 6 | declare module outer { 7 | namespace _debugger { 8 | export class Foo {} 9 | } 10 | export {_debugger as debugger}; 11 | 12 | namespace unrenamed { 13 | export const x: number; 14 | } 15 | export {unrenamed}; 16 | } 17 | -------------------------------------------------------------------------------- /test_files/debugger/externs.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @externs 3 | * @suppress {checkTypes,const,duplicate,missingOverride} 4 | */ 5 | // NOTE: generated by tsickle, do not edit. 6 | // Generated from: test_files/debugger/dbg.d.ts 7 | /** @const */ 8 | var outer = {}; 9 | /** @const */ 10 | outer._debugger = {}; 11 | /** 12 | * @constructor 13 | * @struct 14 | */ 15 | outer._debugger.Foo = function() {}; 16 | /** @const */ 17 | outer.debugger = outer._debugger; 18 | /** @const */ 19 | outer.unrenamed = {}; 20 | /** @type {number} */ 21 | outer.unrenamed.x; 22 | -------------------------------------------------------------------------------- /test_files/debugger/user.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @fileoverview 4 | * Generated from: test_files/debugger/user.ts 5 | * @suppress {checkTypes} 6 | * 7 | */ 8 | // TODO: the type below should be emitted as `outer.debugger.Foo`. However 9 | // TypeScript does not take the re-export in the outer namespace into account, 10 | // and thus produces not quite the right result. 11 | // See https://github.com/Microsoft/TypeScript/issues/29459 12 | goog.module('test_files.debugger.user'); 13 | var module = module || { id: 'test_files/debugger/user.ts' }; 14 | goog.require('tslib'); 15 | /** @type {(null|!_debugger.Foo)} */ 16 | const x = null; 17 | -------------------------------------------------------------------------------- /test_files/debugger/user.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview 3 | * @suppress {checkTypes} 4 | */ 5 | 6 | // TODO: the type below should be emitted as `outer.debugger.Foo`. However 7 | // TypeScript does not take the re-export in the outer namespace into account, 8 | // and thus produces not quite the right result. 9 | // See https://github.com/Microsoft/TypeScript/issues/29459 10 | 11 | const x: outer.debugger.Foo|null = null; 12 | 13 | export {}; 14 | -------------------------------------------------------------------------------- /test_files/decl_merge/imported_inner_decl.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview Ensure transformed inner classes and enums can be 3 | * imported and used, and the types are properly annotated in the 4 | * JS output. 5 | */ 6 | 7 | import {SomeClass} from './inner_class'; 8 | import {e0, Outer} from './inner_enum'; 9 | 10 | const foo0 = e0(); 11 | function bar(e: Outer.Event) { 12 | return Outer.Event.E_1; 13 | } 14 | 15 | let inner: SomeClass.Inner; 16 | -------------------------------------------------------------------------------- /test_files/decl_merge/inner_enum.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview Ensure enums nested in a class, defined with declaration 3 | * merging are properly transformed and hoisted out of the namespace, and no 4 | * iife is created for the namespace. 5 | * 6 | * @suppress {uselessCode} 7 | */ 8 | 9 | export class Outer { 10 | e = Outer.Event.E_1; 11 | foo(): Outer.Event { 12 | return Outer.Event.E_0; 13 | } 14 | } 15 | 16 | // tslint:disable-next-line:no-namespace 17 | export namespace Outer { 18 | export enum Event {E_0, E_1} 19 | } 20 | 21 | export function e0() { 22 | return Outer.Event.E_0; 23 | } -------------------------------------------------------------------------------- /test_files/decl_merge/inner_typedef.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview Ensure that a type alias declared in a declaration 3 | * merging namespace is generated as a property of the merged outer class. 4 | * 5 | * @suppress {uselessCode,checkTypes} 6 | */ 7 | 8 | export class A { 9 | foo(f: A.F): A.X { return f(''); } 10 | } 11 | 12 | // tslint:disable-next-line:no-namespace 13 | export namespace A { 14 | export type F = (a: string) => X; 15 | export class X { } 16 | } 17 | 18 | let cb: A.F; 19 | -------------------------------------------------------------------------------- /test_files/declare/declare_nondts.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview added by tsickle 3 | * Generated from: test_files/declare/declare_nondts.ts 4 | */ 5 | goog.module('test_files.declare.declare_nondts'); 6 | var module = module || { id: 'test_files/declare/declare_nondts.ts' }; 7 | goog.require('tslib'); 8 | -------------------------------------------------------------------------------- /test_files/declare/declare_nondts.ts: -------------------------------------------------------------------------------- 1 | export {}; 2 | 3 | /** 4 | * Despite being declared in a module, the module is a .ts file, so it 5 | * should appear as a global in the externs. 6 | */ 7 | declare var declaredInPlainTS: number; 8 | -------------------------------------------------------------------------------- /test_files/declare/dtsdiagnostics.txt: -------------------------------------------------------------------------------- 1 | test_files/declare/declare.d.ts(109,1): warning TS0: anonymous type has no symbol 2 | -------------------------------------------------------------------------------- /test_files/declare/shim.js: -------------------------------------------------------------------------------- 1 | goog.module('test_files.declare.declare_module'); 2 | 3 | exports = /** @type {?} */ ({}); 4 | -------------------------------------------------------------------------------- /test_files/declare/user.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview added by tsickle 3 | * Generated from: test_files/declare/user.ts 4 | */ 5 | goog.module('test_files.declare.user'); 6 | var module = module || { id: 'test_files/declare/user.ts' }; 7 | goog.require('tslib'); 8 | const tsickle_declare_module_1 = goog.requireType("test_files.declare.declare_module"); 9 | const declare_module_1 = goog.require('test_files.declare.declare_module'); 10 | /** @type {!ModuleGlobalClass} */ 11 | let x; 12 | /** @type {!moduleGlobalNamespace.GlobalNamespaced} */ 13 | let y; 14 | /** @type {string} */ 15 | let z = declare_module_1.moduleExported; 16 | -------------------------------------------------------------------------------- /test_files/declare/user.ts: -------------------------------------------------------------------------------- 1 | import {moduleExported} from './declare_module'; 2 | 3 | let x: ModuleGlobalClass; 4 | let y: moduleGlobalNamespace.GlobalNamespaced; 5 | let z = moduleExported; 6 | -------------------------------------------------------------------------------- /test_files/declare_anonymous_type/declare_anonymous_type.d.ts: -------------------------------------------------------------------------------- 1 | // `ambientFn` is ambient because it is in a `.d.ts` file. It has no `declare` keyword though (which 2 | // is legal TS in modules). 3 | // This test makes sure that even if so, types declared within its signature (such as the anonymous 4 | // type of `param`) do get considered ambient for the purpose of emitting externs. 5 | export function ambientFn(param: {key: string}): {value: string}; 6 | -------------------------------------------------------------------------------- /test_files/declare_anonymous_type/externs.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @externs 3 | * @suppress {checkTypes,const,duplicate,missingOverride} 4 | */ 5 | // NOTE: generated by tsickle, do not edit. 6 | // Generated from: test_files/declare_anonymous_type/declare_anonymous_type.d.ts 7 | /** @const */ 8 | var test_files$declare_anonymous_type$declare_anonymous_type = {}; 9 | 10 | /** 11 | * @param {{key: string}} param 12 | * @return {{value: string}} 13 | */ 14 | test_files$declare_anonymous_type$declare_anonymous_type.ambientFn = function(param) {}; 15 | -------------------------------------------------------------------------------- /test_files/declare_class_ns/declare_class_ns.d.ts: -------------------------------------------------------------------------------- 1 | declare class ClassAndNamespace { 2 | classFunction(x: string): void; 3 | } 4 | declare namespace ClassAndNamespace { 5 | var bar: number; 6 | } 7 | declare namespace ClassAndNamespace { 8 | var baz: number; 9 | function namespaceFunction(x: number): string; 10 | } 11 | -------------------------------------------------------------------------------- /test_files/declare_computed/declare_computed_prop.d.ts: -------------------------------------------------------------------------------- 1 | declare interface Type { 2 | // Supported by JSCompiler. 3 | [Symbol.iterator](): Iterator; 4 | // Not really supported by JSCompiler, mostly making sure this does not cause 5 | // a syntax error. 6 | ['computedMethod'](): number; 7 | // Not supported, only emitted as a TODO. 8 | ['computedProp']: number; 9 | } 10 | -------------------------------------------------------------------------------- /test_files/declare_computed/externs.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @externs 3 | * @suppress {checkTypes,const,duplicate,missingOverride} 4 | */ 5 | // NOTE: generated by tsickle, do not edit. 6 | // Generated from: test_files/declare_computed/declare_computed_prop.d.ts 7 | /** 8 | * @record 9 | * @struct 10 | */ 11 | function Type() {} 12 | 13 | /* TODO: PropertySignature: ['computedProp'] */ 14 | 15 | /** 16 | * @public 17 | * @return {!Iterator} 18 | */ 19 | Type.prototype[Symbol.iterator] = function() {}; 20 | 21 | /** 22 | * @public 23 | * @return {number} 24 | */ 25 | Type.prototype['computedMethod'] = function() {}; 26 | -------------------------------------------------------------------------------- /test_files/declare_enum/declare_enum.d.ts: -------------------------------------------------------------------------------- 1 | /** @fileoverview Tests generating externs for ambient enum declarations. */ 2 | 3 | declare enum AmbientEnum { 4 | ENUM_MEMBER_1 = 1, 5 | ENUM_MEMBER_2 = 5, 6 | } 7 | 8 | declare enum AmbientStringEnum { 9 | ENUM_MEMBER_1 = 'a', 10 | ENUM_MEMBER_2 = 'b', 11 | } 12 | 13 | declare enum MixedAmbientEnum { 14 | ENUM_MEMBER_1 = 'a', 15 | ENUM_MEMBER_2 = 1, 16 | } 17 | 18 | declare enum StringKeyEnum { 19 | 'foo', 20 | '.tricky.invalid name', 21 | } 22 | 23 | declare namespace namespaceWithEnums { 24 | enum EnumInNamespace { 25 | V = 1, 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /test_files/declare_enum/user.js: -------------------------------------------------------------------------------- 1 | 2 | /** @type {!AmbientEnum} */ 3 | let ambientEnumValue = AmbientEnum.ENUM_MEMBER_1; 4 | 5 | /** @type {!AmbientStringEnum} */ 6 | let ambientStringEnumValue = AmbientStringEnum.ENUM_MEMBER_1; 7 | 8 | /** @type {!MixedAmbientEnum} */ 9 | let mixedAmbientEnumValue = MixedAmbientEnum.ENUM_MEMBER_1; 10 | -------------------------------------------------------------------------------- /test_files/declare_export.untyped/declare_export.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview added by tsickle 3 | * Generated from: test_files/declare_export.untyped/declare_export.ts 4 | */ 5 | goog.module('test_files.declare_export.untyped.declare_export'); 6 | var module = module || { id: 'test_files/declare_export.untyped/declare_export.ts' }; 7 | goog.require('tslib'); 8 | ; 9 | ; 10 | -------------------------------------------------------------------------------- /test_files/declare_export.untyped/declare_export.ts: -------------------------------------------------------------------------------- 1 | export declare interface ExportDeclaredIf { x: number; } 2 | export declare const exportedDeclaredVar: number; 3 | export declare class ExportDeclaredClass { x: number; }; 4 | export declare function exportedDeclaredFn(): string; 5 | export declare const multiExportedDeclaredVar1, multiExportedDeclaredVar2: number; 6 | export declare type X = string; 7 | export declare enum ExportDeclaredEnum { VALUE = 1 }; 8 | -------------------------------------------------------------------------------- /test_files/declare_export_dts/shim.js: -------------------------------------------------------------------------------- 1 | goog.module("test_files.declare_export_dts.declare_export_dts"); 2 | 3 | exports = /** @type {?} */ ({}); 4 | -------------------------------------------------------------------------------- /test_files/declare_export_dts/user.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @fileoverview 4 | * Generated from: test_files/declare_export_dts/user.ts 5 | * @suppress {checkTypes} 6 | * 7 | */ 8 | goog.module('test_files.declare_export_dts.user'); 9 | var module = module || { id: 'test_files/declare_export_dts/user.ts' }; 10 | goog.require('tslib'); 11 | const tsickle_declare_export_dts_1 = goog.requireType("test_files.declare_export_dts.declare_export_dts"); 12 | /** @type {!tsickle_declare_export_dts_1.InterfaceExportedInDts} */ 13 | const useExportDeclaredInterface = { 14 | nestedInterface: { property: 'x' }, 15 | namespaceNestedInterface: {}, 16 | globalInterface: {}, 17 | }; 18 | -------------------------------------------------------------------------------- /test_files/declare_export_dts/user.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview 3 | * @suppress {checkTypes} 4 | */ 5 | 6 | import {InterfaceExportedInDts} from './declare_export_dts'; 7 | 8 | const useExportDeclaredInterface: InterfaceExportedInDts = { 9 | nestedInterface: {property: 'x'}, 10 | namespaceNestedInterface: {}, 11 | globalInterface: {}, 12 | }; 13 | -------------------------------------------------------------------------------- /test_files/declare_export_global/declare_export_global.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview Tests declaring a namespace in a module .d.ts file, as a globally available symbol 3 | * using a `declare global` block. 4 | */ 5 | 6 | declare global { 7 | namespace globalNamespace { 8 | export const x: number; 9 | } 10 | } 11 | 12 | // tsickle must emit the `globalNamespace` reference below as a global name, not the mangled module 13 | // scoped name. 14 | export = globalNamespace; 15 | -------------------------------------------------------------------------------- /test_files/declare_export_global/dtsdiagnostics.txt: -------------------------------------------------------------------------------- 1 | test_files/declare_export_global/declare_export_global_nested.d.ts(17,10): error TS0: export = expression must be a qualified name, got PropertyAccessExpression. 2 | -------------------------------------------------------------------------------- /test_files/declare_extends/declare_extends.d.ts: -------------------------------------------------------------------------------- 1 | 2 | declare class Parent { x: number; } 3 | declare class Child extends Parent { y: number; } 4 | 5 | declare interface ParentInterface { foo(): void; } 6 | declare interface ChildInterface extends ParentInterface { bar(): void; } 7 | 8 | declare class ImplementingClass implements ParentInterface { foo(): void; } 9 | 10 | declare namespace foo { 11 | class NamespacedParent { x: number; } 12 | class NamespacedChildSameNamespace extends NamespacedParent { y: number; } 13 | } 14 | 15 | declare namespace bar { 16 | class NamespacedChild extends foo.NamespacedParent { y: number; } 17 | } 18 | -------------------------------------------------------------------------------- /test_files/declare_function_repeated_tags/declare_function_repeated_tags.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This overload has docs and a tag. 3 | * @param x is a string here 4 | * @export 5 | */ 6 | declare function foo(x: number); 7 | /** 8 | * This overload has the same. 9 | * @param x is a number here. 10 | * @export 11 | */ 12 | declare function foo(x: number); 13 | /** 14 | * And here is the actual implementation. 15 | * @export 16 | */ 17 | declare function foo(x: string|number); 18 | -------------------------------------------------------------------------------- /test_files/declare_function_repeated_tags/externs.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @externs 3 | * @suppress {checkTypes,const,duplicate,missingOverride} 4 | */ 5 | // NOTE: generated by tsickle, do not edit. 6 | // Generated from: test_files/declare_function_repeated_tags/declare_function_repeated_tags.d.ts 7 | 8 | /** 9 | * This overload has docs and a tag. / This overload has the same. / And here is the actual implementation. 10 | * @export 11 | * @param {number|(string|number)} x is a string here / is a number here. 12 | * @return {?} 13 | */ 14 | function foo(x) {} 15 | -------------------------------------------------------------------------------- /test_files/declare_generic/declare_generic.d.ts: -------------------------------------------------------------------------------- 1 | /** @fileoverview Tests use of generic types in .d.ts files. */ 2 | 3 | declare class WithGeneric { 4 | useGenericType(t: T): U; 5 | } 6 | 7 | declare function genericFn(): T; 8 | -------------------------------------------------------------------------------- /test_files/declare_generic/externs.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @externs 3 | * @suppress {checkTypes,const,duplicate,missingOverride} 4 | */ 5 | // NOTE: generated by tsickle, do not edit. 6 | // Generated from: test_files/declare_generic/declare_generic.d.ts 7 | /** 8 | * @template T, U 9 | * @constructor 10 | * @struct 11 | */ 12 | function WithGeneric() {} 13 | 14 | /** 15 | * @public 16 | * @param {T} t 17 | * @return {U} 18 | */ 19 | WithGeneric.prototype.useGenericType = function(t) {}; 20 | 21 | /** 22 | * @template T 23 | * @return {T} 24 | */ 25 | function genericFn() {} 26 | -------------------------------------------------------------------------------- /test_files/declare_implements/declare_implements.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview Tests that multiple implemented interfaces in a .d.ts file do 3 | * not get merged, but produce multiple implements tags. 4 | */ 5 | 6 | export declare interface MyInterface { 7 | a: string; 8 | } 9 | 10 | export declare interface MyOtherInterface { 11 | b: string; 12 | } 13 | 14 | export declare class InterfaceMultipleImpl implements MyInterface, 15 | MyOtherInterface { 16 | a: string; 17 | b: string; 18 | constructor(); 19 | } 20 | -------------------------------------------------------------------------------- /test_files/declare_import/closure_default_export.js: -------------------------------------------------------------------------------- 1 | goog.module('imported.closure.default.Class'); 2 | exports = class {}; 3 | -------------------------------------------------------------------------------- /test_files/declare_import/closure_named_export.js: -------------------------------------------------------------------------------- 1 | goog.module('imported.closure.named'); 2 | class Class {} 3 | exports = {Class}; 4 | -------------------------------------------------------------------------------- /test_files/declare_import/dtsdiagnostics.txt: -------------------------------------------------------------------------------- 1 | test_files/declare_import/declare_import_in_dts.d.ts(19,1): warning TS0: dropped extends: {?} type 2 | test_files/declare_import/declare_import_in_dts.d.ts(20,1): warning TS0: dropped extends: {?} type 3 | test_files/declare_import/declare_import_in_dts.d.ts(21,1): warning TS0: dropped extends: {?} type 4 | test_files/declare_import/declare_import_in_dts.d.ts(22,1): warning TS0: dropped extends: {?} type 5 | test_files/declare_import/declare_import_in_dts.d.ts(25,1): warning TS0: dropped extends: {?} type 6 | -------------------------------------------------------------------------------- /test_files/declare_import/export_default.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview added by tsickle 3 | * Generated from: test_files/declare_import/export_default.ts 4 | */ 5 | goog.module('test_files.declare_import.export_default'); 6 | var module = module || { id: 'test_files/declare_import/export_default.ts' }; 7 | goog.require('tslib'); 8 | // tslint:disable-next-line:no-default-export 9 | class ExportDefaultClass { 10 | } 11 | exports.default = ExportDefaultClass; 12 | -------------------------------------------------------------------------------- /test_files/declare_import/export_default.ts: -------------------------------------------------------------------------------- 1 | // tslint:disable-next-line:no-default-export 2 | export default class ExportDefaultClass {} 3 | -------------------------------------------------------------------------------- /test_files/declare_import/exporter.ts: -------------------------------------------------------------------------------- 1 | export class ExportedClass {} 2 | export class PrefixedExportedClass {} 3 | export class RenamedExportedClass {} 4 | export class ImportEqualsExportedClass {} 5 | -------------------------------------------------------------------------------- /test_files/declare_import/exporting.d.ts: -------------------------------------------------------------------------------- 1 | export declare class ExportedFromDts {} 2 | -------------------------------------------------------------------------------- /test_files/declare_import/exporting.js: -------------------------------------------------------------------------------- 1 | goog.module('test_files.declare_import.exporting'); 2 | exports.ExportedFromDts = class {}; 3 | -------------------------------------------------------------------------------- /test_files/declare_var_and_ns/declare_var_and_ns.d.ts: -------------------------------------------------------------------------------- 1 | /** @fileoverview Tests declaring a global variable and a matching (conflicting) namespace. */ 2 | 3 | declare var globalVariable: globalVariable.SomeInterface; 4 | 5 | // tsickle avoids emitting another initializer (`= {}`) if the symbol has been declared earlier. 6 | // However variables specifically are not initialized to a value, so this must still emit an 7 | // initializer for the namespace. 8 | declare namespace globalVariable { 9 | interface SomeInterface {} 10 | } 11 | -------------------------------------------------------------------------------- /test_files/declare_var_and_ns/externs.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @externs 3 | * @suppress {checkTypes,const,duplicate,missingOverride} 4 | */ 5 | // NOTE: generated by tsickle, do not edit. 6 | // Generated from: test_files/declare_var_and_ns/declare_var_and_ns.d.ts 7 | /** @type {!globalVariable.SomeInterface} */ 8 | var globalVariable; 9 | /** @const */ 10 | var globalVariable = {}; 11 | /** 12 | * @record 13 | * @struct 14 | */ 15 | globalVariable.SomeInterface = function() {}; 16 | -------------------------------------------------------------------------------- /test_files/declared_class/declared_class.d.ts: -------------------------------------------------------------------------------- 1 | declare class Something { 2 | constructor(value: number); 3 | 4 | static AnotherConstructor: typeof Something; 5 | } 6 | -------------------------------------------------------------------------------- /test_files/declared_class/externs.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @externs 3 | * @suppress {checkTypes,const,duplicate,missingOverride} 4 | */ 5 | // NOTE: generated by tsickle, do not edit. 6 | // Generated from: test_files/declared_class/declared_class.d.ts 7 | 8 | /** 9 | * @constructor 10 | * @struct 11 | * @public 12 | * @param {number} value 13 | */ 14 | function Something(value) {} 15 | /** @type {function(new:Something, number)} */ 16 | Something.AnotherConstructor; 17 | -------------------------------------------------------------------------------- /test_files/decorator/default_export.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview Tests using a default imported class for in a decorated ctor. 3 | * @suppress {uselessCode} 4 | */ 5 | 6 | // tslint:disable-next-line:no-default-export 7 | export default class DefaultExport { 8 | field: string; 9 | } 10 | -------------------------------------------------------------------------------- /test_files/decorator/export_const.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview Decorated class, whose type and value are exported separately. 3 | * The value used afterwards. 4 | */ 5 | 6 | function classDecorator(t: any) { 7 | return t; 8 | } 9 | 10 | @classDecorator 11 | class FooImpl { 12 | } 13 | 14 | export type Foo = FooImpl; 15 | export const Foo = FooImpl; 16 | 17 | console.log(Foo); 18 | -------------------------------------------------------------------------------- /test_files/decorator/external.ts: -------------------------------------------------------------------------------- 1 | export {OtherClass as ReexportedOtherClass} from './external2'; 2 | 3 | export class AClass {} 4 | 5 | export class AClassWithGenerics {} 6 | 7 | export interface AType {} -------------------------------------------------------------------------------- /test_files/decorator/external2.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview added by tsickle 3 | * Generated from: test_files/decorator/external2.ts 4 | */ 5 | goog.module('test_files.decorator.external2'); 6 | var module = module || { id: 'test_files/decorator/external2.ts' }; 7 | goog.require('tslib'); 8 | class OtherClass { 9 | } 10 | exports.OtherClass = OtherClass; 11 | -------------------------------------------------------------------------------- /test_files/decorator/external2.ts: -------------------------------------------------------------------------------- 1 | export class OtherClass {} 2 | -------------------------------------------------------------------------------- /test_files/decorator/only_types.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview only_types only exports types, so TypeScript will elide the 3 | * import entirely. 4 | * @suppress {uselessCode} 5 | */ 6 | 7 | export interface AnotherType { 8 | field: string; 9 | } 10 | -------------------------------------------------------------------------------- /test_files/decorator_nested_scope/decorator_nested_scope.decorated.ts: -------------------------------------------------------------------------------- 1 | 2 | /** @Annotation */ 3 | declare const Component: any; 4 | 5 | class SomeService {} 6 | 7 | export function main() { 8 | 9 | class TestComp3 { 10 | constructor(service: SomeService) {} 11 | static decorators: {type: Function, args?: any[]}[] = [ 12 | { type: Component }, 13 | ]; 14 | /** @nocollapse */ 15 | static ctorParameters: () => ({type: any, decorators?: {type: Function, args?: any[]}[]}|null)[] = () => [ 16 | {type: SomeService, }, 17 | ]; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /test_files/decorator_nested_scope/decorator_nested_scope.ts: -------------------------------------------------------------------------------- 1 | 2 | /** @Annotation */ 3 | declare const Component: any; 4 | 5 | class SomeService {} 6 | 7 | export function main() { 8 | @Component() 9 | class TestComp3 { 10 | constructor(service: SomeService) {} 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test_files/decorator_nested_scope/externs.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @externs 3 | * @suppress {checkTypes,const,duplicate,missingOverride} 4 | */ 5 | // NOTE: generated by tsickle, do not edit. 6 | // Generated from: test_files/decorator_nested_scope/decorator_nested_scope.ts 7 | /** @const */ 8 | var test_files$decorator_nested_scope$decorator_nested_scope = {}; 9 | /** @type {?} */ 10 | var Component; 11 | -------------------------------------------------------------------------------- /test_files/default/default.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview added by tsickle 3 | * Generated from: test_files/default/default.ts 4 | */ 5 | goog.module('test_files.default.default'); 6 | var module = module || { id: 'test_files/default/default.ts' }; 7 | goog.require('tslib'); 8 | /** 9 | * @param {number} x 10 | * @param {string=} y 11 | * @return {void} 12 | */ 13 | function DefaultArgument(x, y = 'hi') { 14 | } 15 | -------------------------------------------------------------------------------- /test_files/default/default.ts: -------------------------------------------------------------------------------- 1 | function DefaultArgument(x: number, y: string = 'hi') { 2 | } 3 | -------------------------------------------------------------------------------- /test_files/direct_externs_type_reference/clutz2_generated_dee_dot_tee_ess.d.ts: -------------------------------------------------------------------------------- 1 | //!! generated by clutz2 2 | export interface hasBoolAndNum { 3 | bool: boolean; 4 | num: number; 5 | } -------------------------------------------------------------------------------- /test_files/direct_externs_type_reference/clutz_generated_dee_dot_tee_ess.d.ts: -------------------------------------------------------------------------------- 1 | //!! generated by clutz 2 | export interface hasBool { 3 | bool: boolean; 4 | } -------------------------------------------------------------------------------- /test_files/direct_externs_type_reference/literal_dee_dot_tee_ess.d.ts: -------------------------------------------------------------------------------- 1 | export interface hasString { 2 | string: string; 3 | } -------------------------------------------------------------------------------- /test_files/direct_externs_type_reference/main.ts: -------------------------------------------------------------------------------- 1 | import {returnsClutz2DtsImportedType, returnsClutzDtsImportedType, returnsLiteralDtsImportedType, returnsString, returnsTsickleDtsImportedType} from './lib'; 2 | 3 | const inferredAsLiteralType = returnsString('some string'); 4 | 5 | const inferredAsExternType = returnsLiteralDtsImportedType('some string'); 6 | 7 | const inferredAsImportedClutzType = returnsClutzDtsImportedType('some string'); 8 | 9 | const inferredAsImportedClutz2Type = 10 | returnsClutz2DtsImportedType('some string'); 11 | 12 | const inferredAsImportedTsickleType = 13 | returnsTsickleDtsImportedType('some string'); 14 | -------------------------------------------------------------------------------- /test_files/direct_externs_type_reference/tsickle_generated_dee_dot_tee_ess.d.ts: -------------------------------------------------------------------------------- 1 | //!! generated by tsickle 2 | export interface hasNumber { 3 | num: number; 4 | } -------------------------------------------------------------------------------- /test_files/doc_params/doc_params.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview 3 | * @suppress {uselessCode} 4 | */ 5 | 6 | class Foo { 7 | /** @ngInject */ 8 | // Some comment 9 | constructor(private a: string) {} 10 | } 11 | -------------------------------------------------------------------------------- /test_files/docs_on_ctor_param_properties/docs_on_ctor_param_properties.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview 3 | * @suppress {uselessCode} 4 | */ 5 | 6 | export class Clazz { 7 | constructor( 8 | readonly id: string[], 9 | /** 10 | * Here is a docstring for the parameter property. 11 | */ 12 | readonly parameterProperty: string[] = [], 13 | ) {} 14 | } 15 | -------------------------------------------------------------------------------- /test_files/enum.untyped/enum.untyped.ts: -------------------------------------------------------------------------------- 1 | enum EnumUntypedTest1 {XYZ, PI = 3.14159} 2 | 3 | // This additional exported enum is here to exercise the fix for issue #51. 4 | export enum EnumUntypedTest2 {XYZ, PI = 3.14159} 5 | -------------------------------------------------------------------------------- /test_files/enum/enum_user.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview 3 | * @suppress {checkTypes,uselessCode} 4 | */ 5 | 6 | import {ConstEnum} from './enum'; 7 | 8 | export interface EnumUsingIf { 9 | field: ConstEnum; 10 | } 11 | 12 | const fieldUsingConstEnum = ConstEnum.EMITTED_ENUM_VALUE; 13 | -------------------------------------------------------------------------------- /test_files/enum_ref_import/exporter.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview See enum_ref_import.ts. 3 | * Generated from: test_files/enum_ref_import/exporter.ts 4 | */ 5 | goog.module('test_files.enum_ref_import.exporter'); 6 | var module = module || { id: 'test_files/enum_ref_import/exporter.ts' }; 7 | goog.require('tslib'); 8 | /** @enum {string} */ 9 | const Enum = { 10 | X: "x", 11 | }; 12 | exports.Enum = Enum; 13 | -------------------------------------------------------------------------------- /test_files/enum_ref_import/exporter.ts: -------------------------------------------------------------------------------- 1 | /** @fileoverview See enum_ref_import.ts. */ 2 | 3 | export enum Enum { 4 | X = 'x', 5 | } 6 | -------------------------------------------------------------------------------- /test_files/enum_value_literal_type/enum_value_literal_type.ts: -------------------------------------------------------------------------------- 1 | // Note: if you only have one value in the enum, then the type of "x" below 2 | // is just ExportedEnum, regardless of the annotation. This might be a bug 3 | // in TypeScript but this test is just trying to verify the behavior of 4 | // exporting an enum's value, not that. 5 | 6 | export enum ExportedEnum { 7 | VALUE = 0, 8 | OTHERVALUE, 9 | } 10 | export const x: ExportedEnum.VALUE = ExportedEnum.VALUE; 11 | -------------------------------------------------------------------------------- /test_files/es5_exports.declaration/es5_exports.d.ts: -------------------------------------------------------------------------------- 1 | //!! generated by tsickle from test_files/es5_exports.declaration/es5_exports.ts 2 | declare let x: number; 3 | export = x; 4 | -------------------------------------------------------------------------------- /test_files/es5_exports.declaration/es5_exports.ts: -------------------------------------------------------------------------------- 1 | let x = 0; 2 | export = x; -------------------------------------------------------------------------------- /test_files/eventmap/eventmap.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @fileoverview 4 | * Generated from: test_files/eventmap/eventmap.ts 5 | * @suppress {checkTypes} 6 | * 7 | */ 8 | goog.module('test_files.eventmap.eventmap'); 9 | var module = module || { id: 'test_files/eventmap/eventmap.ts' }; 10 | goog.require('tslib'); 11 | document.body.addEventListener('wobble', (/** 12 | * @param {!WobbleEvent} we 13 | * @return {void} 14 | */ 15 | (we) => { 16 | console.log('wobble!'); 17 | })); 18 | -------------------------------------------------------------------------------- /test_files/eventmap/eventmap.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview 3 | * @suppress {checkTypes} 4 | */ 5 | 6 | export {}; 7 | 8 | declare global { 9 | class WobbleEvent extends Event {} 10 | interface HTMLElementEventMap { 11 | wobble: WobbleEvent; 12 | } 13 | } 14 | 15 | document.body.addEventListener('wobble', (we: WobbleEvent) => { 16 | console.log('wobble!'); 17 | }); 18 | -------------------------------------------------------------------------------- /test_files/eventmap/externs.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @externs 3 | * @suppress {checkTypes,const,duplicate,missingOverride} 4 | */ 5 | // NOTE: generated by tsickle, do not edit. 6 | // Generated from: test_files/eventmap/eventmap.ts 7 | /** @const */ 8 | var test_files$eventmap$eventmap = {}; 9 | /** 10 | * @extends {Event} 11 | * @constructor 12 | * @struct 13 | */ 14 | function WobbleEvent() {} 15 | /** @type {!WobbleEvent} */ 16 | HTMLElementEventMap.prototype.wobble; 17 | -------------------------------------------------------------------------------- /test_files/export/export_helper.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview This file isn't itself a test case, but it is imported by the 3 | * export.in.ts test case. 4 | * @suppress {uselessCode} 5 | */ 6 | 7 | export * from './export_helper_2'; 8 | export let export1 = 3; 9 | export let export2 = 3; 10 | 11 | export interface Bar { 12 | barField: number; 13 | } 14 | export var export3: Bar; 15 | 16 | export let export5 = 3; 17 | 18 | export {TypeDef as RenamedTypeDef} from './export_helper_2'; 19 | -------------------------------------------------------------------------------- /test_files/export/export_helper_2.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview This file isn't itself a test case, but it is imported by the 3 | * export.in.ts test case. 4 | * @suppress {uselessCode} 5 | */ 6 | 7 | export let export2 = 3; 8 | export let export3 = 3; 9 | export let export4 = 3; 10 | 11 | export type TypeDef = string|number; 12 | export interface Interface { 13 | x: string; 14 | } 15 | 16 | export const enum ConstEnum { 17 | AValue = 1 18 | } 19 | 20 | export declare type DeclaredType = { 21 | a: number 22 | }; 23 | 24 | export declare interface DeclaredInterface { 25 | a: number; 26 | } 27 | -------------------------------------------------------------------------------- /test_files/export/export_helper_3.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @fileoverview This file isn't itself a test case, but it is imported by the 4 | * export.in.ts test case. 5 | * Generated from: test_files/export/export_helper_3.ts 6 | * @suppress {uselessCode} 7 | * 8 | */ 9 | goog.module('test_files.export.export_helper_3'); 10 | var module = module || { id: 'test_files/export/export_helper_3.ts' }; 11 | goog.require('tslib'); 12 | /** 13 | * @record 14 | */ 15 | function Foo() { } 16 | exports.Foo = Foo; 17 | /* istanbul ignore if */ 18 | if (false) { 19 | /** 20 | * @type {string} 21 | * @public 22 | */ 23 | Foo.prototype.fooStr; 24 | } 25 | -------------------------------------------------------------------------------- /test_files/export/export_helper_3.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview This file isn't itself a test case, but it is imported by the 3 | * export.in.ts test case. 4 | * @suppress {uselessCode} 5 | */ 6 | 7 | export interface Foo { 8 | fooStr: string; 9 | } 10 | -------------------------------------------------------------------------------- /test_files/export/export_star_imported.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview 3 | * @suppress {checkTypes} 4 | */ 5 | 6 | import {export2} from './export_helper'; 7 | export * from './export_helper'; 8 | const something = 1; 9 | export {something as export2}; 10 | -------------------------------------------------------------------------------- /test_files/export/externs.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @externs 3 | * @suppress {checkTypes,const,duplicate,missingOverride} 4 | */ 5 | // NOTE: generated by tsickle, do not edit. 6 | // Generated from: test_files/export/export_helper_2.ts 7 | /** @const */ 8 | var test_files$export$export_helper_2 = {}; 9 | 10 | /** @typedef {{a: number}} */ 11 | test_files$export$export_helper_2.DeclaredType; 12 | /** 13 | * @record 14 | * @struct 15 | */ 16 | test_files$export$export_helper_2.DeclaredInterface = function() {}; 17 | /** @type {number} */ 18 | test_files$export$export_helper_2.DeclaredInterface.prototype.a; 19 | -------------------------------------------------------------------------------- /test_files/export/type_and_value.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview added by tsickle 3 | * Generated from: test_files/export/type_and_value.ts 4 | */ 5 | goog.module('test_files.export.type_and_value'); 6 | var module = module || { id: 'test_files/export/type_and_value.ts' }; 7 | goog.require('tslib'); 8 | /** @type {number} */ 9 | exports.TypeAndValue = 1; 10 | -------------------------------------------------------------------------------- /test_files/export/type_and_value.ts: -------------------------------------------------------------------------------- 1 | export const TypeAndValue = 1; 2 | export type TypeAndValue = number; 3 | -------------------------------------------------------------------------------- /test_files/export_as_namespace/export_as_namespace.d.ts: -------------------------------------------------------------------------------- 1 | /** @fileoverview tests "export as namespace" in a global (non-module) .d.ts file. */ 2 | 3 | export declare namespace foo { 4 | export class Bar { 5 | baz(): void; 6 | } 7 | } 8 | 9 | // On the Closure side, this must generate a global `exportNamespace` symbol. 10 | // exportNamespace.foo must resolve to the namespace above. 11 | export as namespace exportNamespace; 12 | -------------------------------------------------------------------------------- /test_files/export_as_namespace_exporteq/export_as_namespace_exporteq.d.ts: -------------------------------------------------------------------------------- 1 | /** @fileoverview tests "export as namespace" with an exported subnamespace. */ 2 | 3 | declare namespace anamespace { 4 | export class NamespacedClass { method(): string; } 5 | } 6 | 7 | // On the Closure side, this must generate a global `exportedNamespaceIncludingImportEq` symbol. 8 | // exportedNamespaceIncludingImportEq.NamespacedClass must resolve to the class above, i.e. the 9 | // export = statement below dereferences the global exported namespace. 10 | export = anamespace; 11 | export as namespace exportedNamespaceIncludingImportEq; 12 | -------------------------------------------------------------------------------- /test_files/export_declare_namespace/export_declare_namespace.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview added by tsickle 3 | * Generated from: test_files/export_declare_namespace/export_declare_namespace.ts 4 | */ 5 | goog.module('test_files.export_declare_namespace.export_declare_namespace'); 6 | var module = module || { id: 'test_files/export_declare_namespace/export_declare_namespace.ts' }; 7 | goog.require('tslib'); 8 | class ModuleType { 9 | } 10 | exports.ModuleType = ModuleType; 11 | -------------------------------------------------------------------------------- /test_files/export_declare_namespace/user.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview 3 | * @suppress {checkTypes} 4 | */ 5 | 6 | import {exportedDeclaredNamespace, nested} from './export_declare_namespace'; 7 | 8 | let x: exportedDeclaredNamespace.Used; 9 | let y: nested.exportedNamespace.User; 10 | -------------------------------------------------------------------------------- /test_files/export_default.declaration/default.d.ts: -------------------------------------------------------------------------------- 1 | //!! generated by tsickle from test_files/export_default.declaration/default.ts 2 | export default class foo { 3 | } 4 | -------------------------------------------------------------------------------- /test_files/export_default.declaration/default.ts: -------------------------------------------------------------------------------- 1 | export default class foo { 2 | 3 | } -------------------------------------------------------------------------------- /test_files/export_equals.shim/export_equals.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview added by tsickle 3 | * Generated from: test_files/export_equals.shim/export_equals.ts 4 | */ 5 | goog.module('test_files.export_equals.shim.export_equals'); 6 | var module = module || { id: 'test_files/export_equals.shim/export_equals.ts' }; 7 | goog.require('tslib'); 8 | const tsickle_namespace_1 = goog.requireType("test_files.export_equals.shim.namespace"); 9 | const someNamespace = goog.require('test_files.export_equals.shim.namespace'); 10 | exports = someNamespace; 11 | -------------------------------------------------------------------------------- /test_files/export_equals.shim/export_equals.ts: -------------------------------------------------------------------------------- 1 | import * as someNamespace from './namespace'; 2 | 3 | // Important: this must not assign into module.exports, but rather directly into 4 | // exports, as expected by goog.module. 5 | export = someNamespace; 6 | -------------------------------------------------------------------------------- /test_files/export_equals.shim/namespace.d.ts: -------------------------------------------------------------------------------- 1 | /** @fileoverview namespace.d.ts declares a namespace SomeNamespace, which is then re-exported by export_equals.ts. */ 2 | 3 | export = SomeNamespace; 4 | // Because this library has a shim, tsickle does not generate a global symbol for the `export as 5 | // namespace` below. 6 | export as namespace SomeNamespace; 7 | declare namespace SomeNamespace { 8 | export class Clazz {} 9 | } 10 | -------------------------------------------------------------------------------- /test_files/export_equals.shim/shim.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview An example of how to shim an external namespace declared in a .d.ts that's an ES6 3 | * module. 4 | */ 5 | 6 | goog.module('test_files.export_equals.shim.namespace'); 7 | 8 | // Assign the external namespace. "SomeNamespace" is assumed to be loaded separately, e.g. through a 9 | // script tag or so. 10 | exports = window['SomeNamespace']; 11 | -------------------------------------------------------------------------------- /test_files/export_equals.shim/user.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview added by tsickle 3 | * Generated from: test_files/export_equals.shim/user.ts 4 | */ 5 | goog.module('test_files.export_equals.shim.user'); 6 | var module = module || { id: 'test_files/export_equals.shim/user.ts' }; 7 | goog.require('tslib'); 8 | const tsickle_export_equals_1 = goog.requireType("test_files.export_equals.shim.export_equals"); 9 | const modPrefix = goog.require('test_files.export_equals.shim.export_equals'); 10 | console.log(new modPrefix.Clazz()); 11 | -------------------------------------------------------------------------------- /test_files/export_equals.shim/user.ts: -------------------------------------------------------------------------------- 1 | import * as modPrefix from './export_equals'; 2 | 3 | console.log(new modPrefix.Clazz()); 4 | -------------------------------------------------------------------------------- /test_files/export_local_type/export_local_type.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview Regression test to ensure local type symbols can be exported. 3 | * @suppress {uselessCode} 4 | */ 5 | 6 | interface LocalInterface { 7 | field: string; 8 | } 9 | 10 | export {LocalInterface, LocalInterface as AliasedName}; 11 | -------------------------------------------------------------------------------- /test_files/export_merged/main.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview Test to ensure that only one assignment to 3 | * `exports.A` is emitted when A is a namespace with merged declarations. 4 | * Tsickle eliminates the second assignment. 5 | * @suppress {checkTypes} 6 | */ 7 | 8 | // Ensure that the merged namespace is only assigned to exports.A once 9 | // in the JS output. 10 | class A {} 11 | namespace A { 12 | export class B {}; 13 | } 14 | export {A}; 15 | -------------------------------------------------------------------------------- /test_files/export_star_as_ns/ns.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview added by tsickle 3 | * Generated from: test_files/export_star_as_ns/ns.ts 4 | */ 5 | goog.module('test_files.export_star_as_ns.ns'); 6 | var module = module || { id: 'test_files/export_star_as_ns/ns.ts' }; 7 | goog.require('tslib'); 8 | /** @type {number} */ 9 | exports.x = 10; 10 | /** @type {string} */ 11 | exports.y = 'y!'; 12 | -------------------------------------------------------------------------------- /test_files/export_star_as_ns/ns.ts: -------------------------------------------------------------------------------- 1 | export const x = 10; 2 | export const y = 'y!'; 3 | -------------------------------------------------------------------------------- /test_files/export_star_as_ns/star_as_ns.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview Tests exporting a namespace with a given name from Closure. This doesn't expand 3 | * each export like the `export * from '...'` syntax, so it's output just an assignment of the 4 | * imported module to a property on `exports`. 5 | */ 6 | 7 | export * as ns from './ns'; 8 | -------------------------------------------------------------------------------- /test_files/export_star_dts/export_star.d.ts: -------------------------------------------------------------------------------- 1 | export * from './exported'; 2 | -------------------------------------------------------------------------------- /test_files/export_star_dts/exported.d.ts: -------------------------------------------------------------------------------- 1 | export declare class ExportedClass {} 2 | -------------------------------------------------------------------------------- /test_files/export_star_dts/externs.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @externs 3 | * @suppress {checkTypes,const,duplicate,missingOverride} 4 | */ 5 | // NOTE: generated by tsickle, do not edit. 6 | // Generated from: test_files/export_star_dts/export_star.d.ts 7 | /** @const */ 8 | var test_files$export_star_dts$export_star = {}; 9 | 10 | // TODO(tsickle): export * declaration in test_files$export_star_dts$export_star 11 | // Generated from: test_files/export_star_dts/exported.d.ts 12 | /** @const */ 13 | var test_files$export_star_dts$exported = {}; 14 | /** 15 | * @constructor 16 | * @struct 17 | */ 18 | test_files$export_star_dts$exported.ExportedClass = function() {}; 19 | -------------------------------------------------------------------------------- /test_files/export_types_values.untyped/importer.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview added by tsickle 3 | * Generated from: test_files/export_types_values.untyped/importer.ts 4 | */ 5 | goog.module('test_files.export_types_values.untyped.importer'); 6 | var module = module || { id: 'test_files/export_types_values.untyped/importer.ts' }; 7 | goog.require('tslib'); 8 | const type_exporter_1 = goog.require('test_files.export_types_values.untyped.type_exporter'); 9 | const value_exporter_1 = goog.require('test_files.export_types_values.untyped.value_exporter'); 10 | exports.Clazz = value_exporter_1.Clazz; 11 | -------------------------------------------------------------------------------- /test_files/export_types_values.untyped/importer.ts: -------------------------------------------------------------------------------- 1 | export * from './type_exporter'; 2 | import {Clazz} from './value_exporter'; 3 | 4 | export {Clazz}; 5 | -------------------------------------------------------------------------------- /test_files/export_types_values.untyped/type_exporter.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview added by tsickle 3 | * Generated from: test_files/export_types_values.untyped/type_exporter.ts 4 | */ 5 | goog.module('test_files.export_types_values.untyped.type_exporter'); 6 | var module = module || { id: 'test_files/export_types_values.untyped/type_exporter.ts' }; 7 | goog.require('tslib'); 8 | /** @typedef {?} */ 9 | exports.TypeDef; 10 | -------------------------------------------------------------------------------- /test_files/export_types_values.untyped/type_exporter.ts: -------------------------------------------------------------------------------- 1 | export type TypeDef = number; 2 | -------------------------------------------------------------------------------- /test_files/export_types_values.untyped/value_exporter.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview added by tsickle 3 | * Generated from: test_files/export_types_values.untyped/value_exporter.ts 4 | */ 5 | goog.module('test_files.export_types_values.untyped.value_exporter'); 6 | var module = module || { id: 'test_files/export_types_values.untyped/value_exporter.ts' }; 7 | goog.require('tslib'); 8 | class Clazz { 9 | } 10 | exports.Clazz = Clazz; 11 | -------------------------------------------------------------------------------- /test_files/export_types_values.untyped/value_exporter.ts: -------------------------------------------------------------------------------- 1 | export class Clazz {} -------------------------------------------------------------------------------- /test_files/extend_and_implement/extend_and_implement.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview Reproduces a problem where tsickle would emit "\@extends 3 | * {ClassInImplements}", conflicting the ES6 extends syntax, leading to 4 | * incorrect optimization results. 5 | * @suppress {uselessCode} 6 | */ 7 | 8 | class ClassInImplements { 9 | foo: string|undefined; 10 | } 11 | class ClassInExtends { 12 | bar() { 13 | return 'a'; 14 | } 15 | } 16 | class ExtendsAndImplementsClass extends ClassInExtends implements 17 | ClassInImplements { 18 | foo: string; 19 | } 20 | -------------------------------------------------------------------------------- /test_files/extends_ctor/extends_ctor.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview A class indirectly extending a class with constructor. 3 | */ 4 | 5 | declare namespace foo { 6 | abstract class Base { 7 | constructor(s: string); 8 | } 9 | abstract class BaseChild extends Base {} 10 | 11 | class Child extends Base {} 12 | } 13 | -------------------------------------------------------------------------------- /test_files/fields_no_ctor/fields_no_ctor.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @fileoverview 4 | * Generated from: test_files/fields_no_ctor/fields_no_ctor.ts 5 | * @suppress {uselessCode} 6 | * 7 | */ 8 | goog.module('test_files.fields_no_ctor.fields_no_ctor'); 9 | var module = module || { id: 'test_files/fields_no_ctor/fields_no_ctor.ts' }; 10 | goog.require('tslib'); 11 | class NoCtor { 12 | } 13 | /* istanbul ignore if */ 14 | if (false) { 15 | /** 16 | * @type {number} 17 | * @public 18 | */ 19 | NoCtor.prototype.field1; 20 | } 21 | -------------------------------------------------------------------------------- /test_files/fields_no_ctor/fields_no_ctor.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview 3 | * @suppress {uselessCode} 4 | */ 5 | 6 | class NoCtor { 7 | field1: number; 8 | } 9 | -------------------------------------------------------------------------------- /test_files/file_comment.puretransform/before_import.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview fileoverview comment before import. transformer_util.ts has 3 | * special logic to handle comments before import/require() calls. This file 4 | * tests the regular import case. 5 | */ 6 | goog.module('test_files.file_comment.puretransform.before_import'); 7 | var module = module || { id: 'test_files/file_comment.puretransform/before_import.ts' }; 8 | goog.require('tslib'); 9 | const comment_before_var_1 = goog.require('test_files.file_comment.puretransform.comment_before_var'); 10 | console.log(comment_before_var_1.y); 11 | -------------------------------------------------------------------------------- /test_files/file_comment.puretransform/before_import.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview fileoverview comment before import. transformer_util.ts has 3 | * special logic to handle comments before import/require() calls. This file 4 | * tests the regular import case. 5 | */ 6 | 7 | import {y} from './comment_before_var'; 8 | 9 | console.log(y); 10 | -------------------------------------------------------------------------------- /test_files/file_comment.puretransform/comment_before_class.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview Class handling code does not special cases comments preceding 3 | * it before its JSDoc block. This comment would not get emitted if detached 4 | * source file comments were not emitted separately. 5 | */ 6 | goog.module('test_files.file_comment.puretransform.comment_before_class'); 7 | var module = module || { id: 'test_files/file_comment.puretransform/comment_before_class.ts' }; 8 | goog.require('tslib'); 9 | class Clazz { 10 | } 11 | exports.Clazz = Clazz; 12 | -------------------------------------------------------------------------------- /test_files/file_comment.puretransform/comment_before_class.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview Class handling code does not special cases comments preceding 3 | * it before its JSDoc block. This comment would not get emitted if detached 4 | * source file comments were not emitted separately. 5 | */ 6 | 7 | export class Clazz {} 8 | -------------------------------------------------------------------------------- /test_files/file_comment.puretransform/comment_before_elided_import.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview This is a comment before an import, where the import will be elided but the comment 3 | * must be kept. 4 | */ 5 | goog.module('test_files.file_comment.puretransform.comment_before_elided_import'); 6 | var module = module || { id: 'test_files/file_comment.puretransform/comment_before_elided_import.ts' }; 7 | goog.require('tslib'); 8 | const x = null; 9 | console.log(x); 10 | -------------------------------------------------------------------------------- /test_files/file_comment.puretransform/comment_before_elided_import.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview This is a comment before an import, where the import will be elided but the comment 3 | * must be kept. 4 | */ 5 | 6 | import * as otherMod from './comment_before_class'; 7 | 8 | const x: otherMod.Clazz|null = null; 9 | console.log(x); 10 | -------------------------------------------------------------------------------- /test_files/file_comment.puretransform/comment_before_var.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview This comment must not be emitted twice. 3 | * @mods {google3.java.com.google.javascript.typescript.examples.boqui.boqui} 4 | * @modName {foobar} 5 | */ 6 | goog.module('test_files.file_comment.puretransform.comment_before_var'); 7 | var module = module || { id: 'test_files/file_comment.puretransform/comment_before_var.ts' }; 8 | goog.require('tslib'); 9 | exports.y = 3; 10 | -------------------------------------------------------------------------------- /test_files/file_comment.puretransform/comment_before_var.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview This comment must not be emitted twice. 3 | * @mods {google3.java.com.google.javascript.typescript.examples.boqui.boqui} 4 | * @modName {foobar} 5 | */ 6 | 7 | export const y = 3; 8 | -------------------------------------------------------------------------------- /test_files/file_comment.puretransform/comment_no_tag.js: -------------------------------------------------------------------------------- 1 | /** A comment without any tags. */ 2 | goog.module('test_files.file_comment.puretransform.comment_no_tag'); 3 | var module = module || { id: 'test_files/file_comment.puretransform/comment_no_tag.ts' }; 4 | goog.require('tslib'); 5 | // here comes code. 6 | exports.x = 1; 7 | -------------------------------------------------------------------------------- /test_files/file_comment.puretransform/comment_no_tag.ts: -------------------------------------------------------------------------------- 1 | /** A comment without any tags. */ 2 | 3 | // here comes code. 4 | export let x = 1; 5 | -------------------------------------------------------------------------------- /test_files/file_comment.puretransform/comment_with_text.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview 3 | * @suppress {undefinedVars} because we don't like them errors 4 | */ 5 | goog.module('test_files.file_comment.puretransform.comment_with_text'); 6 | var module = module || { id: 'test_files/file_comment.puretransform/comment_with_text.ts' }; 7 | goog.require('tslib'); 8 | console.log('hello'); 9 | -------------------------------------------------------------------------------- /test_files/file_comment.puretransform/comment_with_text.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview 3 | * @suppress {undefinedVars} because we don't like them errors 4 | */ 5 | 6 | console.log('hello'); 7 | -------------------------------------------------------------------------------- /test_files/file_comment.puretransform/file_comment.js: -------------------------------------------------------------------------------- 1 | goog.module('test_files.file_comment.puretransform.file_comment'); 2 | var module = module || { id: 'test_files/file_comment.puretransform/file_comment.ts' }; 3 | goog.require('tslib'); 4 | // This test verifies that initial comments don't confuse offsets. 5 | function foo() { 6 | return 'foo'; 7 | } 8 | // More text here to exhibit the problem. 9 | -------------------------------------------------------------------------------- /test_files/file_comment.puretransform/file_comment.ts: -------------------------------------------------------------------------------- 1 | // This test verifies that initial comments don't confuse offsets. 2 | function foo(): string { 3 | return 'foo'; 4 | } 5 | // More text here to exhibit the problem. 6 | -------------------------------------------------------------------------------- /test_files/file_comment.puretransform/fileoverview_and_jsdoc.js: -------------------------------------------------------------------------------- 1 | goog.module('test_files.file_comment.puretransform.fileoverview_and_jsdoc'); 2 | var module = module || { id: 'test_files/file_comment.puretransform/fileoverview_and_jsdoc.ts' }; 3 | goog.require('tslib'); 4 | /** @fileoverview A file. */ 5 | /** 6 | * @deprecated Some Text 7 | */ 8 | const aVariable = 1; 9 | -------------------------------------------------------------------------------- /test_files/file_comment.puretransform/fileoverview_and_jsdoc.ts: -------------------------------------------------------------------------------- 1 | /** @fileoverview A file. */ 2 | /** 3 | * @deprecated Some Text 4 | */ 5 | const aVariable = 1; 6 | -------------------------------------------------------------------------------- /test_files/file_comment.puretransform/fileoverview_comment_add_suppress.js: -------------------------------------------------------------------------------- 1 | /** @fileoverview a comment without a suppress tag. */ 2 | goog.module('test_files.file_comment.puretransform.fileoverview_comment_add_suppress'); 3 | var module = module || { id: 'test_files/file_comment.puretransform/fileoverview_comment_add_suppress.ts' }; 4 | goog.require('tslib'); 5 | // here comes code. 6 | exports.x = 1; 7 | -------------------------------------------------------------------------------- /test_files/file_comment.puretransform/fileoverview_comment_add_suppress.ts: -------------------------------------------------------------------------------- 1 | /** @fileoverview a comment without a suppress tag. */ 2 | 3 | // here comes code. 4 | export let x = 1; 5 | -------------------------------------------------------------------------------- /test_files/file_comment.puretransform/fileoverview_comment_add_suppress_before_license.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview a comment with a license tag. 3 | * 4 | * @license 5 | * Some license 6 | */ 7 | goog.module('test_files.file_comment.puretransform.fileoverview_comment_add_suppress_before_license'); 8 | var module = module || { id: 'test_files/file_comment.puretransform/fileoverview_comment_add_suppress_before_license.ts' }; 9 | goog.require('tslib'); 10 | // here comes code. 11 | exports.x = 1; 12 | -------------------------------------------------------------------------------- /test_files/file_comment.puretransform/fileoverview_comment_add_suppress_before_license.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview a comment with a license tag. 3 | * 4 | * @license 5 | * Some license 6 | */ 7 | 8 | // here comes code. 9 | export let x = 1; 10 | -------------------------------------------------------------------------------- /test_files/file_comment.puretransform/fileoverview_comment_merge_suppress.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview Tests merging JSDoc tags in fileoverview comments. 3 | * @suppress {extraRequire} 4 | */ 5 | goog.module('test_files.file_comment.puretransform.fileoverview_comment_merge_suppress'); 6 | var module = module || { id: 'test_files/file_comment.puretransform/fileoverview_comment_merge_suppress.ts' }; 7 | goog.require('tslib'); 8 | /** second comment here */ 9 | console.log('code'); 10 | -------------------------------------------------------------------------------- /test_files/file_comment.puretransform/fileoverview_comment_merge_suppress.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview Tests merging JSDoc tags in fileoverview comments. 3 | * @suppress {extraRequire} 4 | */ 5 | 6 | /** second comment here */ 7 | 8 | console.log('code'); 9 | -------------------------------------------------------------------------------- /test_files/file_comment.puretransform/jsdoc_comment.js: -------------------------------------------------------------------------------- 1 | goog.module('test_files.file_comment.puretransform.jsdoc_comment'); 2 | var module = module || { id: 'test_files/file_comment.puretransform/jsdoc_comment.ts' }; 3 | goog.require('tslib'); 4 | /** 5 | * This comment belongs to the class below. 6 | */ 7 | class ClassWithComment { 8 | } 9 | -------------------------------------------------------------------------------- /test_files/file_comment.puretransform/jsdoc_comment.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This comment belongs to the class below. 3 | */ 4 | class ClassWithComment {} 5 | -------------------------------------------------------------------------------- /test_files/file_comment.puretransform/other_fileoverview_comments.js: -------------------------------------------------------------------------------- 1 | /** @modName {some_mod} */ 2 | goog.module('test_files.file_comment.puretransform.other_fileoverview_comments'); 3 | var module = module || { id: 'test_files/file_comment.puretransform/other_fileoverview_comments.ts' }; 4 | goog.require('tslib'); 5 | // @modName also belongs in a fileoverview comment, so must be merged. 6 | console.log('hello'); 7 | -------------------------------------------------------------------------------- /test_files/file_comment.puretransform/other_fileoverview_comments.ts: -------------------------------------------------------------------------------- 1 | /** @modName {some_mod} */ 2 | 3 | // @modName also belongs in a fileoverview comment, so must be merged. 4 | console.log('hello'); 5 | -------------------------------------------------------------------------------- /test_files/file_comment.puretransform/side_effect_import.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview This is a fileoverview comment preceding a side-effect import. 3 | * transformer_util.ts has special logic to handle comments before 4 | * import/require() calls. This file tests the side-effect import case. 5 | */ 6 | goog.module('test_files.file_comment.puretransform.side_effect_import'); 7 | var module = module || { id: 'test_files/file_comment.puretransform/side_effect_import.ts' }; 8 | goog.require('tslib'); 9 | goog.require('test_files.file_comment.puretransform.file_comment'); 10 | -------------------------------------------------------------------------------- /test_files/file_comment.puretransform/side_effect_import.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview This is a fileoverview comment preceding a side-effect import. 3 | * transformer_util.ts has special logic to handle comments before 4 | * import/require() calls. This file tests the side-effect import case. 5 | */ 6 | 7 | import './file_comment'; 8 | -------------------------------------------------------------------------------- /test_files/file_comment/before_import.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview fileoverview comment before import. transformer_util.ts has 3 | * special logic to handle comments before import/require() calls. This file 4 | * tests the regular import case. 5 | */ 6 | 7 | import {y} from './comment_before_var'; 8 | 9 | console.log(y); 10 | -------------------------------------------------------------------------------- /test_files/file_comment/comment_before_class.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @fileoverview Class handling code does not special cases comments preceding 4 | * it before its JSDoc block. This comment would not get emitted if detached 5 | * source file comments were not emitted separately. 6 | * 7 | * Generated from: test_files/file_comment/comment_before_class.ts 8 | */ 9 | goog.module('test_files.file_comment.comment_before_class'); 10 | var module = module || { id: 'test_files/file_comment/comment_before_class.ts' }; 11 | goog.require('tslib'); 12 | class Clazz { 13 | } 14 | exports.Clazz = Clazz; 15 | -------------------------------------------------------------------------------- /test_files/file_comment/comment_before_class.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview Class handling code does not special cases comments preceding 3 | * it before its JSDoc block. This comment would not get emitted if detached 4 | * source file comments were not emitted separately. 5 | */ 6 | 7 | export class Clazz {} 8 | -------------------------------------------------------------------------------- /test_files/file_comment/comment_before_elided_import.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview This is a comment before an import, where the import will be elided but the comment 3 | * must be kept. 4 | */ 5 | 6 | import * as otherMod from './comment_before_class'; 7 | 8 | const x: otherMod.Clazz|null = null; 9 | console.log(x); 10 | -------------------------------------------------------------------------------- /test_files/file_comment/comment_before_var.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @fileoverview This comment must not be emitted twice. 4 | * Generated from: test_files/file_comment/comment_before_var.ts 5 | * @mods {google3.java.com.google.javascript.typescript.examples.boqui.boqui} 6 | * @modName {foobar} 7 | * 8 | */ 9 | goog.module('test_files.file_comment.comment_before_var'); 10 | var module = module || { id: 'test_files/file_comment/comment_before_var.ts' }; 11 | goog.require('tslib'); 12 | /** @type {number} */ 13 | exports.y = 3; 14 | -------------------------------------------------------------------------------- /test_files/file_comment/comment_before_var.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview This comment must not be emitted twice. 3 | * @mods {google3.java.com.google.javascript.typescript.examples.boqui.boqui} 4 | * @modName {foobar} 5 | */ 6 | 7 | export const y = 3; 8 | -------------------------------------------------------------------------------- /test_files/file_comment/comment_no_tag.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview added by tsickle 3 | * Generated from: test_files/file_comment/comment_no_tag.ts 4 | */ 5 | /** A comment without any tags. */ 6 | // here comes code. 7 | goog.module('test_files.file_comment.comment_no_tag'); 8 | var module = module || { id: 'test_files/file_comment/comment_no_tag.ts' }; 9 | goog.require('tslib'); 10 | /** @type {number} */ 11 | exports.x = 1; 12 | -------------------------------------------------------------------------------- /test_files/file_comment/comment_no_tag.ts: -------------------------------------------------------------------------------- 1 | /** A comment without any tags. */ 2 | 3 | // here comes code. 4 | export let x = 1; 5 | -------------------------------------------------------------------------------- /test_files/file_comment/comment_with_text.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @fileoverview 4 | * Generated from: test_files/file_comment/comment_with_text.ts 5 | * @suppress {undefinedVars} because we don't like them errors 6 | * 7 | */ 8 | goog.module('test_files.file_comment.comment_with_text'); 9 | var module = module || { id: 'test_files/file_comment/comment_with_text.ts' }; 10 | goog.require('tslib'); 11 | console.log('hello'); 12 | -------------------------------------------------------------------------------- /test_files/file_comment/comment_with_text.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview 3 | * @suppress {undefinedVars} because we don't like them errors 4 | */ 5 | 6 | console.log('hello'); 7 | -------------------------------------------------------------------------------- /test_files/file_comment/export_star.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview fileoverview comment before export. transformer_util.ts has 3 | * special logic to handle comments before import/require() calls. This file 4 | * tests the export * case. 5 | */ 6 | 7 | export * from './comment_before_var'; 8 | -------------------------------------------------------------------------------- /test_files/file_comment/file_comment.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview added by tsickle 3 | * Generated from: test_files/file_comment/file_comment.ts 4 | */ 5 | goog.module('test_files.file_comment.file_comment'); 6 | var module = module || { id: 'test_files/file_comment/file_comment.ts' }; 7 | goog.require('tslib'); 8 | // This test verifies that initial comments don't confuse offsets. 9 | /** 10 | * @return {string} 11 | */ 12 | function foo() { 13 | return 'foo'; 14 | } 15 | -------------------------------------------------------------------------------- /test_files/file_comment/file_comment.ts: -------------------------------------------------------------------------------- 1 | // This test verifies that initial comments don't confuse offsets. 2 | function foo(): string { 3 | return 'foo'; 4 | } 5 | // More text here to exhibit the problem. 6 | -------------------------------------------------------------------------------- /test_files/file_comment/fileoverview_and_jsdoc.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview A file. 3 | * Generated from: test_files/file_comment/fileoverview_and_jsdoc.ts 4 | */ 5 | goog.module('test_files.file_comment.fileoverview_and_jsdoc'); 6 | var module = module || { id: 'test_files/file_comment/fileoverview_and_jsdoc.ts' }; 7 | goog.require('tslib'); 8 | /** 9 | * @deprecated Some Text 10 | * @type {number} 11 | */ 12 | const aVariable = 1; 13 | -------------------------------------------------------------------------------- /test_files/file_comment/fileoverview_and_jsdoc.ts: -------------------------------------------------------------------------------- 1 | /** @fileoverview A file. */ 2 | 3 | /** 4 | * @deprecated Some Text 5 | */ 6 | const aVariable = 1; 7 | -------------------------------------------------------------------------------- /test_files/file_comment/fileoverview_comment_add_suppress.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview a comment without a suppress tag. 3 | * Generated from: test_files/file_comment/fileoverview_comment_add_suppress.ts 4 | */ 5 | // here comes code. 6 | goog.module('test_files.file_comment.fileoverview_comment_add_suppress'); 7 | var module = module || { id: 'test_files/file_comment/fileoverview_comment_add_suppress.ts' }; 8 | goog.require('tslib'); 9 | /** @type {number} */ 10 | exports.x = 1; 11 | -------------------------------------------------------------------------------- /test_files/file_comment/fileoverview_comment_add_suppress.ts: -------------------------------------------------------------------------------- 1 | /** @fileoverview a comment without a suppress tag. */ 2 | 3 | // here comes code. 4 | export let x = 1; 5 | -------------------------------------------------------------------------------- /test_files/file_comment/fileoverview_comment_add_suppress_before_license.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @fileoverview a comment with a license tag. 4 | * 5 | * Generated from: test_files/file_comment/fileoverview_comment_add_suppress_before_license.ts 6 | * @license 7 | * Some license 8 | * 9 | */ 10 | // here comes code. 11 | goog.module('test_files.file_comment.fileoverview_comment_add_suppress_before_license'); 12 | var module = module || { id: 'test_files/file_comment/fileoverview_comment_add_suppress_before_license.ts' }; 13 | goog.require('tslib'); 14 | /** @type {number} */ 15 | exports.x = 1; 16 | -------------------------------------------------------------------------------- /test_files/file_comment/fileoverview_comment_add_suppress_before_license.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview a comment with a license tag. 3 | * 4 | * @license 5 | * Some license 6 | */ 7 | 8 | // here comes code. 9 | export let x = 1; 10 | -------------------------------------------------------------------------------- /test_files/file_comment/fileoverview_comment_merge_suppress.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @fileoverview Tests merging JSDoc tags in fileoverview comments. 4 | * Generated from: test_files/file_comment/fileoverview_comment_merge_suppress.ts 5 | * @suppress {extraRequire} 6 | * 7 | */ 8 | /** second comment here */ 9 | goog.module('test_files.file_comment.fileoverview_comment_merge_suppress'); 10 | var module = module || { id: 'test_files/file_comment/fileoverview_comment_merge_suppress.ts' }; 11 | goog.require('tslib'); 12 | console.log('code'); 13 | -------------------------------------------------------------------------------- /test_files/file_comment/fileoverview_comment_merge_suppress.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview Tests merging JSDoc tags in fileoverview comments. 3 | * @suppress {extraRequire} 4 | */ 5 | 6 | /** second comment here */ 7 | 8 | console.log('code'); 9 | -------------------------------------------------------------------------------- /test_files/file_comment/fileoverview_in_comment_text.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @fileoverview Tests that mere mentions of file overview tags in comment bodies don't get 4 | * reported as errors. 5 | * 6 | * Generated from: test_files/file_comment/fileoverview_in_comment_text.ts 7 | */ 8 | goog.module('test_files.file_comment.fileoverview_in_comment_text'); 9 | var module = module || { id: 'test_files/file_comment/fileoverview_in_comment_text.ts' }; 10 | goog.require('tslib'); 11 | /** 12 | * This is a function comment that talks about \@fileoverview, but isn't such a comment. 13 | * @return {void} 14 | */ 15 | function foo() { } 16 | exports.foo = foo; 17 | -------------------------------------------------------------------------------- /test_files/file_comment/fileoverview_in_comment_text.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview Tests that mere mentions of file overview tags in comment bodies don't get 3 | * reported as errors. 4 | */ 5 | 6 | /** 7 | * This is a function comment that talks about @fileoverview, but isn't such a comment. 8 | */ 9 | export function foo() {} 10 | -------------------------------------------------------------------------------- /test_files/file_comment/jsdoc_comment.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview added by tsickle 3 | * Generated from: test_files/file_comment/jsdoc_comment.ts 4 | */ 5 | goog.module('test_files.file_comment.jsdoc_comment'); 6 | var module = module || { id: 'test_files/file_comment/jsdoc_comment.ts' }; 7 | goog.require('tslib'); 8 | /** 9 | * This comment belongs to the class below. 10 | */ 11 | class ClassWithComment { 12 | } 13 | -------------------------------------------------------------------------------- /test_files/file_comment/jsdoc_comment.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This comment belongs to the class below. 3 | */ 4 | class ClassWithComment {} 5 | -------------------------------------------------------------------------------- /test_files/file_comment/latecomment.js: -------------------------------------------------------------------------------- 1 | // test_files/file_comment/latecomment.ts(3,1): warning TS0: file comments must be at the top of the file, separated from the file body by an empty line. 2 | /** 3 | * @fileoverview added by tsickle 4 | * Generated from: test_files/file_comment/latecomment.ts 5 | */ 6 | goog.module('test_files.file_comment.latecomment'); 7 | var module = module || { id: 'test_files/file_comment/latecomment.ts' }; 8 | goog.require('tslib'); 9 | /** @type {number} */ 10 | const someVariable = 1; 11 | /** 12 | * @fileoverview This file overview comment appears after the first statement in the file. 13 | */ 14 | console.log(someVariable + 2); 15 | -------------------------------------------------------------------------------- /test_files/file_comment/latecomment.ts: -------------------------------------------------------------------------------- 1 | const someVariable = 1; 2 | 3 | /** @fileoverview This file overview comment appears after the first statement in the file. */ 4 | 5 | console.log(someVariable + 2); 6 | 7 | export {}; 8 | -------------------------------------------------------------------------------- /test_files/file_comment/latecomment_front.js: -------------------------------------------------------------------------------- 1 | /** @license Here is a license comment. */ 2 | /** 3 | * @fileoverview with a late fileoverview comment before the first statement. 4 | * Generated from: test_files/file_comment/latecomment_front.ts 5 | */ 6 | goog.module('test_files.file_comment.latecomment_front'); 7 | var module = module || { id: 'test_files/file_comment/latecomment_front.ts' }; 8 | goog.require('tslib'); 9 | /** @type {number} */ 10 | const followedByCode = 1; 11 | -------------------------------------------------------------------------------- /test_files/file_comment/latecomment_front.ts: -------------------------------------------------------------------------------- 1 | /** @license Here is a license comment. */ 2 | 3 | /** @fileoverview with a late fileoverview comment before the first statement. */ 4 | 5 | const followedByCode = 1; 6 | 7 | export {}; 8 | -------------------------------------------------------------------------------- /test_files/file_comment/other_fileoverview_comments.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview added by tsickle 3 | * Generated from: test_files/file_comment/other_fileoverview_comments.ts 4 | * @modName {some_mod} 5 | */ 6 | goog.module('test_files.file_comment.other_fileoverview_comments'); 7 | var module = module || { id: 'test_files/file_comment/other_fileoverview_comments.ts' }; 8 | goog.require('tslib'); 9 | // @modName also belongs in a fileoverview comment, so must be merged. 10 | console.log('hello'); 11 | -------------------------------------------------------------------------------- /test_files/file_comment/other_fileoverview_comments.ts: -------------------------------------------------------------------------------- 1 | /** @modName {some_mod} */ 2 | 3 | // @modName also belongs in a fileoverview comment, so must be merged. 4 | console.log('hello'); 5 | -------------------------------------------------------------------------------- /test_files/file_comment/run_in_comment.js: -------------------------------------------------------------------------------- 1 | // test_files/file_comment/run_in_comment.ts(1,1): warning TS0: file comments must be at the top of the file, separated from the file body by an empty line. 2 | /** 3 | * @fileoverview added by tsickle 4 | * Generated from: test_files/file_comment/run_in_comment.ts 5 | */ 6 | goog.module('test_files.file_comment.run_in_comment'); 7 | var module = module || { id: 'test_files/file_comment/run_in_comment.ts' }; 8 | goog.require('tslib'); 9 | /** 10 | * @pintomodule Comment is not separated from file body as it should be. 11 | * @type {number} 12 | */ 13 | exports.x = 1; 14 | -------------------------------------------------------------------------------- /test_files/file_comment/run_in_comment.ts: -------------------------------------------------------------------------------- 1 | /** @pintomodule Comment is not separated from file body as it should be. */ 2 | export const x = 1; 3 | -------------------------------------------------------------------------------- /test_files/file_comment/side_effect_import.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @fileoverview This is a fileoverview comment preceding a side-effect import. 4 | * transformer_util.ts has special logic to handle comments before 5 | * import/require() calls. This file tests the side-effect import case. 6 | * 7 | * Generated from: test_files/file_comment/side_effect_import.ts 8 | */ 9 | goog.module('test_files.file_comment.side_effect_import'); 10 | var module = module || { id: 'test_files/file_comment/side_effect_import.ts' }; 11 | goog.require('tslib'); 12 | goog.require('test_files.file_comment.file_comment'); 13 | -------------------------------------------------------------------------------- /test_files/file_comment/side_effect_import.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview This is a fileoverview comment preceding a side-effect import. 3 | * transformer_util.ts has special logic to handle comments before 4 | * import/require() calls. This file tests the side-effect import case. 5 | */ 6 | 7 | import './file_comment'; 8 | -------------------------------------------------------------------------------- /test_files/functions/two_jsdoc_blocks.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview This text here matches the text below in length. 3 | */ 4 | 5 | 6 | 7 | 8 | /** 9 | * A comment. 10 | */ 11 | export function functionA(): boolean { 12 | return true; 13 | } 14 | 15 | /** 16 | * This comment is just as long as the @fileoverview 17 | * comment x 18 | */ 19 | export function functionB(): boolean { 20 | return true; 21 | } 22 | -------------------------------------------------------------------------------- /test_files/generic_extends/user.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview Tests template parameters in extends clauses. 3 | * @suppress {uselessCode} 4 | */ 5 | 6 | type Key = 'a'|'b'; 7 | 8 | interface SomethingGeneric { 9 | key: T; 10 | } 11 | 12 | // TODO: b/279145965 - Closure type annotation should emit generic type arg in 13 | // extends clause. 14 | interface SomethingExtendingSomethingGeneric extends 15 | SomethingGeneric { 16 | foo: unknown; 17 | } 18 | -------------------------------------------------------------------------------- /test_files/generic_fn_type/generic_fn_type.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview added by tsickle 3 | * Generated from: test_files/generic_fn_type/generic_fn_type.ts 4 | */ 5 | goog.module('test_files.generic_fn_type.generic_fn_type'); 6 | var module = module || { id: 'test_files/generic_fn_type/generic_fn_type.ts' }; 7 | goog.require('tslib'); 8 | /** 9 | * A function type that includes a generic type argument. Unsupported by 10 | * Closure, so tsickle should emit ?. 11 | * @type {function(?): ?} 12 | */ 13 | let genericFnType = (/** 14 | * @param {?} x 15 | * @return {?} 16 | */ 17 | (x) => x); 18 | /** @type {function(new:?, ?)} */ 19 | let genericCtorFnType; 20 | -------------------------------------------------------------------------------- /test_files/generic_fn_type/generic_fn_type.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * A function type that includes a generic type argument. Unsupported by 3 | * Closure, so tsickle should emit ?. 4 | */ 5 | let genericFnType: (t: T) => T = (x) => x; 6 | 7 | let genericCtorFnType: new(t: T) => T; 8 | -------------------------------------------------------------------------------- /test_files/generic_in_prop_access/user.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview Tests template parameters for identifier in property access 3 | * expression, where TypeScript narrows its type only on usage, i.e. in the 4 | * return statement below. 5 | * @suppress {uselessCode} 6 | */ 7 | 8 | type Key = 'a'|'b'; 9 | 10 | interface SomethingGeneric { 11 | key: T; 12 | } 13 | 14 | function hasThing( 15 | groupedThings: {[K in Key]?: Array>;}, key: T, 16 | thing: SomethingGeneric) { 17 | const things = groupedThings[key]!; 18 | return things.indexOf(thing) !== -1; 19 | } 20 | -------------------------------------------------------------------------------- /test_files/generic_local_var/generic_local_var.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview 3 | * @suppress {uselessCode} 4 | */ 5 | 6 | class Container { 7 | constructor(private tField: T) {} 8 | method(u: U) { 9 | const myT: T = this.tField; 10 | // Closure Compiler previously did not accept local variables using generic 11 | // types within a generic method's scope. This test now serves as a 12 | // regression test for the inverse, i.e. that tsickle now emits the type. 13 | const myU: U = u; 14 | console.log(myT, myU); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /test_files/generic_nested_classes/user.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview Tests template parameters for generic classes nested inside 3 | * another generic class. 4 | */ 5 | 6 | class Outer { 7 | outer() { 8 | class Inner

{ 9 | inner() { 10 | class VeryDeep {} 11 | const deep = new VeryDeep(); 12 | } 13 | } 14 | const inner = new Inner(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /test_files/generic_type_alias/generic_type_alias.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview added by tsickle 3 | * Generated from: test_files/generic_type_alias/generic_type_alias.ts 4 | */ 5 | goog.module('test_files.generic_type_alias.generic_type_alias'); 6 | var module = module || { id: 'test_files/generic_type_alias/generic_type_alias.ts' }; 7 | goog.require('tslib'); 8 | /** 9 | * A type alias including a generic type parameter. Unsupported by Closure, so 10 | * tsickle emits . 11 | * @typedef {!Array} 12 | */ 13 | exports.MyList; 14 | -------------------------------------------------------------------------------- /test_files/generic_type_alias/generic_type_alias.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * A type alias including a generic type parameter. Unsupported by Closure, so 3 | * tsickle emits . 4 | */ 5 | export type MyList = T[]; 6 | -------------------------------------------------------------------------------- /test_files/googmodule_esmodule.declaration.no_externs/some_module.d.ts: -------------------------------------------------------------------------------- 1 | // Original goog.module name: $some_prefix.test_files.googmodule_esmodule.declaration.some_module 2 | 3 | declare class Foo { 4 | private noStructuralTyping_Foo: {}; 5 | } 6 | export {Foo}; 7 | -------------------------------------------------------------------------------- /test_files/googmodule_esmodule.declaration.no_externs/some_module.js: -------------------------------------------------------------------------------- 1 | goog.module('$some_prefix.test_files.googmodule_esmodule.declaration.some_module'); 2 | 3 | class Foo {} 4 | 5 | exports.Foo = Foo; 6 | -------------------------------------------------------------------------------- /test_files/googmodule_esmodule.declaration.no_externs/user.d.ts: -------------------------------------------------------------------------------- 1 | //!! generated by tsickle from test_files/googmodule_esmodule.declaration.no_externs/user.ts 2 | import { Foo } from './some_module'; 3 | export interface Bar { 4 | foo: Foo; 5 | } 6 | declare global { 7 | namespace ಠ_ಠ.clutz { 8 | export { Bar as module$contents$test_files$googmodule_esmodule$declaration$no_externs$user_Bar }; 9 | export namespace module$exports$test_files$googmodule_esmodule$declaration$no_externs$user { 10 | export { Bar }; 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test_files/googmodule_esmodule.declaration.no_externs/user.ts: -------------------------------------------------------------------------------- 1 | import {Foo} from './some_module'; 2 | 3 | export interface Bar { 4 | foo: Foo 5 | } 6 | -------------------------------------------------------------------------------- /test_files/googmodule_esmodule.no_externs/some_module.d.ts: -------------------------------------------------------------------------------- 1 | // Original goog.module name: $some_prefix.test_files.googmodule_esmodule.some_module 2 | 3 | declare class Foo { 4 | private noStructuralTyping_Foo: {}; 5 | } 6 | export {Foo}; 7 | -------------------------------------------------------------------------------- /test_files/googmodule_esmodule.no_externs/some_module.js: -------------------------------------------------------------------------------- 1 | goog.module('$some_prefix.test_files.googmodule_esmodule.some_module'); 2 | 3 | class Foo {} 4 | 5 | exports.Foo = Foo; 6 | -------------------------------------------------------------------------------- /test_files/googmodule_esmodule.no_externs/user.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview added by tsickle 3 | * Generated from: test_files/googmodule_esmodule.no_externs/user.ts 4 | */ 5 | goog.module('test_files.googmodule_esmodule.no_externs.user'); 6 | var module = module || { id: 'test_files/googmodule_esmodule.no_externs/user.ts' }; 7 | goog.require('tslib'); 8 | const tsickle_some_module_1 = goog.requireType("$some_prefix.test_files.googmodule_esmodule.some_module"); 9 | const some_module_1 = goog.require('$some_prefix.test_files.googmodule_esmodule.some_module'); 10 | console.log(some_module_1.Foo); 11 | -------------------------------------------------------------------------------- /test_files/googmodule_esmodule.no_externs/user.ts: -------------------------------------------------------------------------------- 1 | import {Foo} from './some_module'; 2 | 3 | console.log(Foo); 4 | -------------------------------------------------------------------------------- /test_files/ignored_ambient_external_module/externs.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @externs 3 | * @suppress {checkTypes,const,duplicate,missingOverride} 4 | */ 5 | // NOTE: generated by tsickle, do not edit. 6 | // Generated from: test_files/ignored_ambient_external_module/ignored.d.ts 7 | // Derived from: declare module "ambient-external-module-ignored" 8 | /** @const */ 9 | var ambient_external_module_ignored = {}; 10 | /** 11 | * @record 12 | * @struct 13 | */ 14 | ambient_external_module_ignored.Ambient = function() {}; 15 | /** @type {string} */ 16 | ambient_external_module_ignored.Ambient.prototype.x; 17 | -------------------------------------------------------------------------------- /test_files/ignored_ambient_external_module/ignored.d.ts: -------------------------------------------------------------------------------- 1 | /** @fileoverview This file has been set to be ignored for type generation in the test runner. */ 2 | 3 | declare module 'ambient-external-module-ignored' { 4 | export interface Ambient { 5 | x: string; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test_files/ignored_ambient_external_module/user.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview Regression test for type-ignored ambient modules. 3 | * @suppress {uselessCode} 4 | */ 5 | 6 | // This import must not be emitted, not even as a 7 | // goog.requireType/forwardDeclare. 8 | import {Ambient} from 'ambient-external-module-ignored'; 9 | 10 | export class User { 11 | // This field should be emitted with a ? type. 12 | field: Ambient|null; 13 | 14 | constructor() { 15 | this.field = null; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /test_files/implement_reexported_interface/exporter.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview See user.ts for the actual test. 3 | * Generated from: test_files/implement_reexported_interface/exporter.ts 4 | */ 5 | goog.module('test_files.implement_reexported_interface.exporter'); 6 | var module = module || { id: 'test_files/implement_reexported_interface/exporter.ts' }; 7 | goog.require('tslib'); 8 | const tsickle_interface_1 = goog.requireType("test_files.implement_reexported_interface.interface"); 9 | /** @typedef {!tsickle_interface_1.ExportedInterface} */ 10 | exports.ExportedInterface; // re-export typedef 11 | -------------------------------------------------------------------------------- /test_files/implement_reexported_interface/exporter.ts: -------------------------------------------------------------------------------- 1 | /** @fileoverview See user.ts for the actual test. */ 2 | 3 | export {ExportedInterface} from './interface'; 4 | -------------------------------------------------------------------------------- /test_files/implement_reexported_interface/interface.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview See user.ts for the actual test. 3 | * @suppress {uselessCode} 4 | */ 5 | 6 | export interface ExportedInterface { 7 | fooStr: string; 8 | } 9 | -------------------------------------------------------------------------------- /test_files/implement_reexported_interface/user.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview Tests that a re-exported interface can be implemented. 3 | * 4 | * This reproduces a bug where tsickle would define re-exports as just 5 | * "ExportedInterface", not "!ExportedInterface", which would then crash Closure 6 | * Compiler as it creates a union type, which is unexpected for super 7 | * interfaces. 8 | * 9 | * @suppress {uselessCode} 10 | */ 11 | 12 | import {ExportedInterface} from './exporter'; 13 | 14 | class Test implements ExportedInterface { 15 | fooStr = 'a'; 16 | } 17 | -------------------------------------------------------------------------------- /test_files/import_alias/exporter.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview added by tsickle 3 | * Generated from: test_files/import_alias/exporter.ts 4 | */ 5 | goog.module('test_files.import_alias.exporter'); 6 | var module = module || { id: 'test_files/import_alias/exporter.ts' }; 7 | goog.require('tslib'); 8 | /** @type {number} */ 9 | const FOO = 1; 10 | exports.FOO = FOO; 11 | -------------------------------------------------------------------------------- /test_files/import_alias/exporter.ts: -------------------------------------------------------------------------------- 1 | const FOO = 1; 2 | 3 | export {FOO}; 4 | -------------------------------------------------------------------------------- /test_files/import_alias/importer.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview added by tsickle 3 | * Generated from: test_files/import_alias/importer.ts 4 | */ 5 | goog.module('test_files.import_alias.importer'); 6 | var module = module || { id: 'test_files/import_alias/importer.ts' }; 7 | goog.require('tslib'); 8 | const tsickle_exporter_1 = goog.requireType("test_files.import_alias.exporter"); 9 | const exporter_1 = goog.require('test_files.import_alias.exporter'); 10 | console.log(exporter_1.FOO); 11 | -------------------------------------------------------------------------------- /test_files/import_alias/importer.ts: -------------------------------------------------------------------------------- 1 | import {FOO} from './exporter'; 2 | 3 | console.log(FOO); 4 | -------------------------------------------------------------------------------- /test_files/import_by_path.declaration.no_externs/clutz_input.d.ts: -------------------------------------------------------------------------------- 1 | // Mocks for Clutz-generated .d.ts. 2 | 3 | declare namespace ಠ_ಠ.clutz.another.module { 4 | export class SomeClass {} 5 | } 6 | declare module 'goog:another.module' { 7 | import SomeClass = ಠ_ಠ.clutz.another.module.SomeClass; 8 | export {SomeClass}; 9 | } 10 | declare module 'google3/another/file' { 11 | import SomeClass = ಠ_ಠ.clutz.another.module.SomeClass; 12 | export {SomeClass}; 13 | const __clutz_actual_namespace: 'another.module'; 14 | } 15 | -------------------------------------------------------------------------------- /test_files/import_by_path.declaration.no_externs/decluser.ts: -------------------------------------------------------------------------------- 1 | import {SomeClass} from 'google3/another/file'; 2 | 3 | export class UsingPathImports { 4 | someField?: SomeClass; 5 | } 6 | -------------------------------------------------------------------------------- /test_files/import_by_path.declaration.no_externs/jsprovides.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview Description of this file. 3 | */ 4 | 5 | goog.module('another.module'); 6 | 7 | exports.SomeClass = class {}; 8 | -------------------------------------------------------------------------------- /test_files/import_by_path.no_externs/conflicting_multiple.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview Negative test: this TS file attempts to import a JS module that 3 | * provides multiple conflicting namespaces by path, which is an error. 4 | * @suppress {checkTypes} 5 | */ 6 | 7 | import {value} from 'google3/path/to/multiple_provides/conflicting'; 8 | console.error(value); 9 | -------------------------------------------------------------------------------- /test_files/import_by_path.no_externs/conflicting_multiple_bystar.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview Negative test: import by star reports errors for conflicting 3 | * symbols. 4 | * @suppress {checkTypes} 5 | */ 6 | 7 | import * as prefix from 'google3/path/to/multiple_provides/conflicting'; 8 | 9 | console.log(prefix.value); 10 | -------------------------------------------------------------------------------- /test_files/import_by_path.no_externs/conflicting_multiple_empty.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview Negative test for importing no symbols from a module, by path. 3 | * @suppress {checkTypes} 4 | */ 5 | 6 | import {/* intentionally empty */} from 'google3/path/to/multiple_provides/conflicting'; 7 | -------------------------------------------------------------------------------- /test_files/import_by_path.no_externs/conflicting_multiple_type.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview Negative test: import type reports errors for conflicting 3 | * symbols. 4 | * @suppress {checkTypes} 5 | */ 6 | 7 | import type {Type} from 'google3/path/to/multiple_provides/conflicting'; 8 | 9 | const z: Type = { 10 | x: 1 11 | }; 12 | console.log(z); 13 | -------------------------------------------------------------------------------- /test_files/import_by_path.no_externs/multiple_side_effect.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview Imports a module with conflicting provides, but with a 3 | * side-effect import. tsickle only reports an error when code imports a symbol 4 | * from a module with conflicting symbol exports, but not for a side effect 5 | * import. 6 | * @suppress {checkTypes} 7 | */ 8 | 9 | // This import produces a require for any of the provides defined in the given 10 | // file. This has the intended effect: the file will be required and thus 11 | // loaded. It does not matter which provide is required. 12 | import 'google3/path/to/multiple_provides/conflicting'; 13 | -------------------------------------------------------------------------------- /test_files/import_by_path.no_externs/user.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview Tests that tsickle emits goog namespace references when 3 | * importing modules by path. 4 | * @suppress {checkTypes} 5 | */ 6 | 7 | import * as ns from 'google3/path/to/otherfile'; 8 | import {someFunction} from 'google3/path/to/otherfile'; 9 | import {SomeType} from 'google3/path/to/typeonly'; 10 | 11 | console.log(someFunction(1) as SomeType); 12 | ns.someFunction(1); 13 | -------------------------------------------------------------------------------- /test_files/import_by_path.no_externs/user_default.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview Tests that tsickle emits goog namespace references when 3 | * importing modules by path, and handles named to default export conversion. 4 | * @suppress {checkTypes} 5 | */ 6 | 7 | import {MyClassDefaultExport} from 'google3/path/to/file'; 8 | 9 | console.log(new MyClassDefaultExport().someField); 10 | 11 | // Make sure that type annotations get emitted correctly. The type annotation 12 | // here must just refer to the module alias, without a ".MyClassDefaultExport". 13 | const typeUsage = new MyClassDefaultExport(); 14 | console.log(typeUsage); 15 | -------------------------------------------------------------------------------- /test_files/import_by_path.no_externs/using_multiple.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview Using a namespace that provides multiple, nested symbols. 3 | * @suppress {checkTypes} 4 | */ 5 | 6 | import {Nesting} from 'google3/path/to/multiple_provides/nesting'; 7 | console.error(new Nesting()); 8 | console.error(new Nesting.Inner()); 9 | -------------------------------------------------------------------------------- /test_files/import_default/exporter.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview added by tsickle 3 | * Generated from: test_files/import_default/exporter.ts 4 | */ 5 | goog.module('test_files.import_default.exporter'); 6 | var module = module || { id: 'test_files/import_default/exporter.ts' }; 7 | goog.require('tslib'); 8 | // tslint:disable-next-line:no-default-export 9 | class default_1 { 10 | } 11 | exports.default = default_1; 12 | ; 13 | -------------------------------------------------------------------------------- /test_files/import_default/exporter.ts: -------------------------------------------------------------------------------- 1 | // tslint:disable-next-line:no-default-export 2 | export default class {}; 3 | -------------------------------------------------------------------------------- /test_files/import_default/import_default.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview added by tsickle 3 | * Generated from: test_files/import_default/import_default.ts 4 | */ 5 | goog.module('test_files.import_default.import_default'); 6 | var module = module || { id: 'test_files/import_default/import_default.ts' }; 7 | goog.require('tslib'); 8 | const tsickle_exporter_1 = goog.requireType("test_files.import_default.exporter"); 9 | const exporter_1 = goog.require('test_files.import_default.exporter'); 10 | // Make sure that regular TypeScript default imports are emitted as a .default 11 | // property on the module symbol. 12 | console.log(new exporter_1.default()); 13 | -------------------------------------------------------------------------------- /test_files/import_default/import_default.ts: -------------------------------------------------------------------------------- 1 | import DefaultSymbol from './exporter'; 2 | 3 | // Make sure that regular TypeScript default imports are emitted as a .default 4 | // property on the module symbol. 5 | console.log(new DefaultSymbol()); 6 | -------------------------------------------------------------------------------- /test_files/import_empty/import_empty.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview Make sure tsickle does not crash on empty imports. 3 | * Generated from: test_files/import_empty/import_empty.ts 4 | */ 5 | goog.module('test_files.import_empty.import_empty'); 6 | var module = module || { id: 'test_files/import_empty/import_empty.ts' }; 7 | goog.require('tslib'); 8 | const tsickle_imported_1 = goog.requireType("test_files.import_empty.imported"); 9 | console.log('hello'); 10 | -------------------------------------------------------------------------------- /test_files/import_empty/import_empty.ts: -------------------------------------------------------------------------------- 1 | /** @fileoverview Make sure tsickle does not crash on empty imports. */ 2 | 3 | import {} from './imported'; 4 | 5 | console.log('hello'); 6 | -------------------------------------------------------------------------------- /test_files/import_empty/imported.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview added by tsickle 3 | * Generated from: test_files/import_empty/imported.ts 4 | */ 5 | goog.module('test_files.import_empty.imported'); 6 | var module = module || { id: 'test_files/import_empty/imported.ts' }; 7 | goog.require('tslib'); 8 | -------------------------------------------------------------------------------- /test_files/import_empty/imported.ts: -------------------------------------------------------------------------------- 1 | export {}; 2 | -------------------------------------------------------------------------------- /test_files/import_equals/exporter.d.ts: -------------------------------------------------------------------------------- 1 | export declare namespace exportedSymbol { 2 | export const valueInNamespace: number; 3 | } 4 | 5 | // Just "export", not "declare". It will still generate externs because Tsickle 6 | // generates externs for everything in a .d.ts file. 7 | export class Exported {} 8 | 9 | export namespace Exported { 10 | export class Nested {} 11 | } 12 | 13 | export namespace Exported.Nested { 14 | export enum Thing { 15 | ITEM = 1, 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /test_files/import_equals/exporter.js: -------------------------------------------------------------------------------- 1 | goog.module('test_files.import_equals.exporter'); 2 | 3 | exports.Exported = class {}; 4 | exports.Exported.Nested = class {}; 5 | /** @enum {number} */ 6 | exports.Exported.Nested.Thing = { 7 | ITEM: 1 8 | }; 9 | -------------------------------------------------------------------------------- /test_files/import_equals/import_equals_global.d.ts: -------------------------------------------------------------------------------- 1 | declare namespace __React { 2 | class X {} 3 | } 4 | 5 | declare namespace importEquals { 6 | import React = __React; 7 | } 8 | 9 | import React = __React; 10 | -------------------------------------------------------------------------------- /test_files/import_equals/import_equals_type_usage.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview Tests type only usage of symbols imported using import equals 3 | * syntax. TypeScript elides those imports, so type references have to use 4 | * tsickle's requireType symbols. 5 | */ 6 | 7 | import {Exported} from './exporter'; 8 | 9 | import Nested = Exported.Nested; 10 | import Thing = Exported.Nested.Thing; 11 | 12 | let exported: Exported|undefined; 13 | let nested: Nested|undefined; 14 | let thing: Thing|undefined; 15 | 16 | console.log(exported, nested, thing); 17 | -------------------------------------------------------------------------------- /test_files/import_from_goog.no_externs/closure_LegacyModule.js: -------------------------------------------------------------------------------- 1 | goog.module('closure.LegacyModule'); 2 | goog.module.declareLegacyNamespace(); 3 | 4 | const TransitiveType = goog.requireType('closure.TransitiveType'); 5 | 6 | class LocalClass { 7 | constructor() { 8 | /** @type {!TransitiveType} */ 9 | this.property; 10 | } 11 | } 12 | 13 | exports.LegacyExport = LocalClass; 14 | -------------------------------------------------------------------------------- /test_files/import_from_goog.no_externs/closure_Module.js: -------------------------------------------------------------------------------- 1 | // Matches decl.d.ts 2 | goog.module('closure.Module'); 3 | 4 | exports = class {}; 5 | -------------------------------------------------------------------------------- /test_files/import_from_goog.no_externs/closure_OtherModule.js: -------------------------------------------------------------------------------- 1 | // Matches decl.d.ts 2 | goog.module('closure.OtherModule'); 3 | 4 | exports.SymA = class {}; 5 | exports.SymB = class {}; 6 | -------------------------------------------------------------------------------- /test_files/import_from_goog.no_externs/transitive_type.js: -------------------------------------------------------------------------------- 1 | goog.module('closure.TransitiveType'); 2 | goog.module.declareLegacyNamespace(); 3 | 4 | class TransitiveType {} 5 | 6 | /** @typedef {string|number} */ 7 | TransitiveType.AttributeValue; 8 | 9 | exports = TransitiveType; 10 | -------------------------------------------------------------------------------- /test_files/import_only_types/import_only_types.ts: -------------------------------------------------------------------------------- 1 | import {Foo} from './types_only'; 2 | // const enums count as types for the purpose of importing. 3 | import {SomeInterface} from './types_and_constenum'; 4 | 5 | let x: Foo = {x: 'x'}; 6 | let y: SomeInterface = x; 7 | console.log(y); 8 | -------------------------------------------------------------------------------- /test_files/import_only_types/types_and_constenum.ts: -------------------------------------------------------------------------------- 1 | // const enum values are inlined, so even though const enums are values, 2 | // TypeScript might not generate any imports for them, which means modules 3 | // containing only types and const enums must be "force loaded". 4 | 5 | export const enum ConstEnum { 6 | BAR, 7 | BAZ 8 | } 9 | 10 | export interface SomeInterface {} 11 | -------------------------------------------------------------------------------- /test_files/import_only_types/types_only.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview Exports only types, but must still be goog.require'd for 3 | * Closure Compiler. 4 | * @suppress {uselessCode} 5 | */ 6 | 7 | export interface Foo { 8 | x: string; 9 | } 10 | 11 | export type Bar = number; 12 | 13 | /** A type that will be used within this file below. */ 14 | export type FnType = () => void; 15 | 16 | /** 17 | * Uses exported types to demonstrate that the symbols can be resolved locally. 18 | */ 19 | function doThing(a: Foo, b: FnType) {} 20 | -------------------------------------------------------------------------------- /test_files/import_prefixed/exporter.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview added by tsickle 3 | * Generated from: test_files/import_prefixed/exporter.ts 4 | */ 5 | goog.module('test_files.import_prefixed.exporter'); 6 | var module = module || { id: 'test_files/import_prefixed/exporter.ts' }; 7 | goog.require('tslib'); 8 | /** @type {number} */ 9 | exports.valueExport = 1; 10 | /** @typedef {(string|number)} */ 11 | exports.TypeExport; 12 | -------------------------------------------------------------------------------- /test_files/import_prefixed/exporter.ts: -------------------------------------------------------------------------------- 1 | export const valueExport = 1; 2 | export type TypeExport = string|number; 3 | -------------------------------------------------------------------------------- /test_files/import_prefixed/import_prefixed_mixed.ts: -------------------------------------------------------------------------------- 1 | // This file imports exporter with a prefix import (* as ...), and then uses the 2 | // import in a type and in a value position. 3 | 4 | import * as exporter from './exporter'; 5 | 6 | let someVar: exporter.TypeExport; 7 | console.log(exporter.valueExport); 8 | -------------------------------------------------------------------------------- /test_files/import_prefixed/import_prefixed_types.ts: -------------------------------------------------------------------------------- 1 | // This file imports exporter with a prefix import (* as ...), and then only 2 | // uses the import in a type position. 3 | // tsickle emits a goog.forwardDeclare for the type and uses it to refer to the 4 | // type TypeExport. 5 | 6 | import * as exporter from './exporter'; 7 | 8 | const someVar: exporter.TypeExport = 1; 9 | console.log(someVar); 10 | -------------------------------------------------------------------------------- /test_files/index_import/has_index/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview added by tsickle 3 | * Generated from: test_files/index_import/has_index/index.ts 4 | */ 5 | goog.module('test_files.index_import.has_index.index'); 6 | var module = module || { id: 'test_files/index_import/has_index/index.ts' }; 7 | goog.require('tslib'); 8 | /** @type {number} */ 9 | exports.a = 1; 10 | -------------------------------------------------------------------------------- /test_files/index_import/has_index/index.ts: -------------------------------------------------------------------------------- 1 | export const a = 1; 2 | -------------------------------------------------------------------------------- /test_files/index_import/has_index/relative.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview added by tsickle 3 | * Generated from: test_files/index_import/has_index/relative.ts 4 | */ 5 | goog.module('test_files.index_import.has_index.relative'); 6 | var module = module || { id: 'test_files/index_import/has_index/relative.ts' }; 7 | goog.require('tslib'); 8 | const tsickle_has_index_1 = goog.requireType("test_files.index_import.has_index.index"); 9 | -------------------------------------------------------------------------------- /test_files/index_import/has_index/relative.ts: -------------------------------------------------------------------------------- 1 | import {a as a2} from '../has_index'; 2 | 3 | import {a} from './'; 4 | -------------------------------------------------------------------------------- /test_files/index_import/lib.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview added by tsickle 3 | * Generated from: test_files/index_import/lib.ts 4 | */ 5 | goog.module('test_files.index_import.lib'); 6 | var module = module || { id: 'test_files/index_import/lib.ts' }; 7 | goog.require('tslib'); 8 | /** @type {number} */ 9 | exports.b = 2; 10 | -------------------------------------------------------------------------------- /test_files/index_import/lib.ts: -------------------------------------------------------------------------------- 1 | export const b = 2; 2 | -------------------------------------------------------------------------------- /test_files/index_import/node_modules/foo/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "main": "subdir/index.js" 3 | } -------------------------------------------------------------------------------- /test_files/index_import/node_modules/foo/subdir/index.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/angular/tsickle/2129d363a0562b7ca1acdf55945c22b7d16539a3/test_files/index_import/node_modules/foo/subdir/index.js -------------------------------------------------------------------------------- /test_files/index_import/user.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview added by tsickle 3 | * Generated from: test_files/index_import/user.ts 4 | */ 5 | goog.module('test_files.index_import.user'); 6 | var module = module || { id: 'test_files/index_import/user.ts' }; 7 | goog.require('tslib'); 8 | const tsickle_has_index_1 = goog.requireType("test_files.index_import.has_index.index"); 9 | const tsickle_lib_2 = goog.requireType("test_files.index_import.lib"); 10 | const has_index_1 = goog.require('test_files.index_import.has_index.index'); 11 | exports.a = has_index_1.a; 12 | const has_index_2 = has_index_1; 13 | -------------------------------------------------------------------------------- /test_files/index_import/user.ts: -------------------------------------------------------------------------------- 1 | /// 2 | import {a} from './has_index'; 3 | export {a} from './has_index'; 4 | export * from './has_index'; 5 | import {a as a2} from './has_index/index'; 6 | import {a as a3} from './has_index/index.js'; 7 | import {b} from './lib'; 8 | import * as foo from 'foo'; 9 | -------------------------------------------------------------------------------- /test_files/interface/implement_import.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview 3 | * @suppress {uselessCode} 4 | */ 5 | 6 | import {Point, User} from './interface'; 7 | 8 | class MyPoint implements Point { 9 | constructor(public x: number, public y: number) {} 10 | } 11 | 12 | class ImplementsUser implements User { 13 | constructor(public shoeSize: number) {} 14 | } 15 | 16 | // Note that the @extends JSDoc points to a different name than the extends 17 | // clause. Closure Compiler allows this as long as they both eventually resolve 18 | // to the same type. 19 | class ExtendsUser extends User { 20 | constructor() { 21 | super(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /test_files/interface/interface_extends.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview 3 | * @suppress {uselessCode} 4 | */ 5 | 6 | interface ParentInterface { 7 | x: number; 8 | } 9 | 10 | interface SubType extends ParentInterface { 11 | y: number; 12 | } 13 | 14 | interface SubMulti extends ParentInterface, SubType { 15 | z: number; 16 | } 17 | -------------------------------------------------------------------------------- /test_files/interface/interface_type_params.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview 3 | * @suppress {uselessCode} 4 | */ 5 | 6 | interface UpperBound { 7 | x: number; 8 | } 9 | 10 | interface WithTypeParam { 11 | tea: T; 12 | you: U; 13 | } 14 | -------------------------------------------------------------------------------- /test_files/interface_and_type.declaration/interface_and_type.d.ts: -------------------------------------------------------------------------------- 1 | //!! generated by tsickle from test_files/interface_and_type.declaration/interface_and_type.ts 2 | export interface Foo { 3 | } 4 | export type Bar = {}; 5 | declare global { 6 | namespace ಠ_ಠ.clutz { 7 | export { Bar as module$contents$test_files$interface_and_type$declaration$interface_and_type_Bar, Foo as module$contents$test_files$interface_and_type$declaration$interface_and_type_Foo }; 8 | export namespace module$exports$test_files$interface_and_type$declaration$interface_and_type { 9 | export { Bar, Foo }; 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test_files/interface_and_type.declaration/interface_and_type.ts: -------------------------------------------------------------------------------- 1 | export interface Foo {}; 2 | export type Bar = {}; -------------------------------------------------------------------------------- /test_files/internal.declaration/internal.d.ts: -------------------------------------------------------------------------------- 1 | // test_files/internal.declaration/internal.ts(27,18): error TS0: transformation of plain namespace not supported. (go/ts-merged-namespaces) 2 | //!! generated by tsickle from test_files/internal.declaration/internal.ts 3 | export {}; 4 | -------------------------------------------------------------------------------- /test_files/internal.declaration/internal.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/angular/tsickle/2129d363a0562b7ca1acdf55945c22b7d16539a3/test_files/internal.declaration/internal.js -------------------------------------------------------------------------------- /test_files/invalid_closure_properties/externs.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @externs 3 | * @suppress {checkTypes,const,duplicate,missingOverride} 4 | */ 5 | // NOTE: generated by tsickle, do not edit. 6 | // Generated from: test_files/invalid_closure_properties/invalid_closure_properties.ts 7 | /** @const */ 8 | var test_files$invalid_closure_properties$invalid_closure_properties = {}; 9 | /** @const {symbol} */ 10 | SymbolConstructor.prototype.observable; 11 | -------------------------------------------------------------------------------- /test_files/iterator/iterator.ts: -------------------------------------------------------------------------------- 1 | export {}; 2 | 3 | class MyIterable implements IterableIterator { 4 | [Symbol.iterator](): IterableIterator { 5 | return this; 6 | } 7 | next(...args: []|[string | undefined]): IteratorResult { 8 | return {done: true, value: 'x'}; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test_files/jsdoc/enum_tag.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview Checks that JSDoc `@enum` tags on an `enum` are flagged as 3 | * warnings. 4 | * @suppress {uselessCode} 5 | */ 6 | 7 | /** 8 | * @enum 9 | */ 10 | enum A { 11 | A, 12 | B 13 | } 14 | 15 | /** @enum */ 16 | enum B { 17 | A, 18 | B 19 | } 20 | 21 | /** 22 | * @enum {number} 23 | */ 24 | enum C { 25 | A = 10, 26 | B = 20 27 | } 28 | 29 | class SomeComponent { 30 | /** @enum {number} */ 31 | readonly MY_ENUM = { 32 | A: 10, 33 | B: 20, 34 | }; 35 | } 36 | -------------------------------------------------------------------------------- /test_files/jsdoc_types.untyped/default.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview added by tsickle 3 | * Generated from: test_files/jsdoc_types.untyped/default.ts 4 | */ 5 | goog.module('test_files.jsdoc_types.untyped.default'); 6 | var module = module || { id: 'test_files/jsdoc_types.untyped/default.ts' }; 7 | goog.require('tslib'); 8 | class DefaultClass { 9 | } 10 | exports.default = DefaultClass; 11 | -------------------------------------------------------------------------------- /test_files/jsdoc_types.untyped/default.ts: -------------------------------------------------------------------------------- 1 | export default class DefaultClass {} -------------------------------------------------------------------------------- /test_files/jsdoc_types.untyped/module1.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview 3 | * @suppress {uselessCode} 4 | */ 5 | 6 | export class Class {} 7 | export interface Interface { 8 | x: number; 9 | 'quoted-bad-name': string; 10 | } 11 | -------------------------------------------------------------------------------- /test_files/jsdoc_types.untyped/module2.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview 3 | * @suppress {uselessCode} 4 | */ 5 | 6 | export class ClassOne {} 7 | export class ClassTwo {} 8 | export interface Interface { 9 | x: number 10 | } 11 | export class ClassWithParams {} 12 | 13 | export type TypeAlias = number; 14 | export type TypeAliasWithParam = T[]; 15 | 16 | export let value = 3; 17 | -------------------------------------------------------------------------------- /test_files/jsdoc_types.untyped/nevertyped.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview This filename is specially marked in the tsickle test suite 3 | * runner so that its types are always {?}. 4 | * @suppress {uselessCode} 5 | */ 6 | 7 | export interface NeverTyped { 8 | foo: number; 9 | } 10 | -------------------------------------------------------------------------------- /test_files/jsdoc_types/default.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview added by tsickle 3 | * Generated from: test_files/jsdoc_types/default.ts 4 | */ 5 | goog.module('test_files.jsdoc_types.default'); 6 | var module = module || { id: 'test_files/jsdoc_types/default.ts' }; 7 | goog.require('tslib'); 8 | class DefaultClass { 9 | } 10 | exports.default = DefaultClass; 11 | -------------------------------------------------------------------------------- /test_files/jsdoc_types/default.ts: -------------------------------------------------------------------------------- 1 | export default class DefaultClass {} -------------------------------------------------------------------------------- /test_files/jsdoc_types/initialized_unknown.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview Tests that initialized variables that end up untyped (`?`) do not get an explicit 3 | * type annotation, so that Closure's type inference can kick in and possibly do a better job. 4 | */ 5 | 6 | import {NeverTyped} from '../jsdoc_types/nevertyped'; 7 | 8 | // This should not have a type annotation. 9 | const initializedUntyped: NeverTyped = { 10 | foo: 1 11 | }; 12 | 13 | // This should have a type annotation as the variable is not initialized. 14 | // tslint:disable-next-line:prefer-const 15 | let uninitializedUntyped: NeverTyped; 16 | -------------------------------------------------------------------------------- /test_files/jsdoc_types/module1.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview 3 | * @suppress {uselessCode} 4 | */ 5 | 6 | export class Class {} 7 | export interface Interface { 8 | x: number; 9 | 'quoted-bad-name': string; 10 | } 11 | -------------------------------------------------------------------------------- /test_files/jsdoc_types/module2.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview 3 | * @suppress {uselessCode} 4 | */ 5 | 6 | export class ClassOne {} 7 | export class ClassTwo {} 8 | export interface Interface { 9 | x: number 10 | } 11 | export class ClassWithParams {} 12 | 13 | export type TypeAlias = number; 14 | export type TypeAliasWithParam = T[]; 15 | 16 | export let value = 3; 17 | -------------------------------------------------------------------------------- /test_files/jsdoc_types/nevertyped.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview This filename is specially marked in the tsickle test suite 3 | * runner so that its types are always {?}. 4 | * @suppress {uselessCode} 5 | */ 6 | 7 | export interface NeverTyped { 8 | foo: number; 9 | } 10 | export interface NeverTypedTemplated { 11 | foo: T; 12 | } 13 | -------------------------------------------------------------------------------- /test_files/jsx.no_externs/jsx.tsx: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview Fake a subcomponent, just to exercise components within 3 | * components. 4 | * @suppress {checkTypes} 5 | */ 6 | 7 | declare var Component: any; 8 | 9 | let simple =

; 10 | 11 | let hello = 'hello'; 12 | let helloDiv =
13 | {hello} 14 | hello, world 15 | 16 |
; 17 | 18 | React.render(helloDiv, document.body!); 19 | 20 | -------------------------------------------------------------------------------- /test_files/methods/methods.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview 3 | * @suppress {uselessCode} 4 | */ 5 | 6 | class HasMethods { 7 | _f: number; 8 | 9 | one() {} 10 | two(a: string): number { 11 | return 1; 12 | } 13 | 14 | get f(): number { 15 | return this._f + 1; 16 | } 17 | set f(n: number) { 18 | this._f = n - 1; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /test_files/mixin/dtsdiagnostics.txt: -------------------------------------------------------------------------------- 1 | test_files/mixin/mixin.d.ts(1,1): warning TS0: unhandled type flags: Intersection 2 | test_files/mixin/mixin.d.ts(12,1): warning TS0: dropped extends: type without symbol 3 | -------------------------------------------------------------------------------- /test_files/mixin/mixin.d.ts: -------------------------------------------------------------------------------- 1 | declare function MyMixin {}>(base: T): 2 | T & MixinConstructor; 3 | 4 | interface MixinConstructor { 5 | new(...args: any[]): MyMixin; 6 | } 7 | 8 | interface MyMixin { 9 | mixinProp: string; 10 | } 11 | 12 | declare class MyClass extends MyMixin(HTMLElement) { 13 | classProp: string; 14 | } 15 | -------------------------------------------------------------------------------- /test_files/module.no_nstransform/module.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview added by tsickle 3 | * Generated from: test_files/module.no_nstransform/module.ts 4 | */ 5 | goog.module('test_files.module.no_nstransform.module'); 6 | var module = module || { id: 'test_files/module.no_nstransform/module.ts' }; 7 | goog.require('tslib'); 8 | // tslint:disable-next-line:no-namespace 9 | var Reflect; 10 | (function (Reflect) { 11 | Reflect.x = 1; 12 | })(Reflect || (Reflect = {})); 13 | console.log(Reflect.x); 14 | -------------------------------------------------------------------------------- /test_files/module.no_nstransform/module.ts: -------------------------------------------------------------------------------- 1 | // tslint:disable-next-line:no-namespace 2 | module Reflect { 3 | export const x = 1; 4 | } 5 | 6 | console.log(Reflect.x); 7 | -------------------------------------------------------------------------------- /test_files/module_symbol/generates_symbol.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview added by tsickle 3 | * Generated from: test_files/module_symbol/generates_symbol.ts 4 | */ 5 | goog.module('test_files.module_symbol.generates_symbol'); 6 | var module = module || { id: 'test_files/module_symbol/generates_symbol.ts' }; 7 | goog.require('tslib'); 8 | console.log(module.id); 9 | -------------------------------------------------------------------------------- /test_files/module_symbol/generates_symbol.ts: -------------------------------------------------------------------------------- 1 | console.log(module.id); 2 | export {}; 3 | -------------------------------------------------------------------------------- /test_files/module_symbol/module.d.ts: -------------------------------------------------------------------------------- 1 | // Necessary to allow generates_symbol.ts to compile. 2 | declare var module: {id: string}; 3 | -------------------------------------------------------------------------------- /test_files/module_symbol/preexisting_module_export.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview added by tsickle 3 | * Generated from: test_files/module_symbol/preexisting_module_export.ts 4 | */ 5 | goog.module('test_files.module_symbol.preexisting_module_export'); 6 | goog.require('tslib'); 7 | /** @type {number} */ 8 | exports.module = 12; 9 | -------------------------------------------------------------------------------- /test_files/module_symbol/preexisting_module_export.ts: -------------------------------------------------------------------------------- 1 | export const module = 12; 2 | -------------------------------------------------------------------------------- /test_files/module_symbol/preexisting_module_func.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview added by tsickle 3 | * Generated from: test_files/module_symbol/preexisting_module_func.ts 4 | */ 5 | goog.module('test_files.module_symbol.preexisting_module_func'); 6 | goog.require('tslib'); 7 | /** 8 | * @return {void} 9 | */ 10 | function module() { } 11 | -------------------------------------------------------------------------------- /test_files/module_symbol/preexisting_module_func.ts: -------------------------------------------------------------------------------- 1 | function module() {} 2 | export {}; 3 | -------------------------------------------------------------------------------- /test_files/module_symbol/preexisting_module_import.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview added by tsickle 3 | * Generated from: test_files/module_symbol/preexisting_module_import.ts 4 | */ 5 | goog.module('test_files.module_symbol.preexisting_module_import'); 6 | goog.require('tslib'); 7 | const tsickle_preexisting_module_export_1 = goog.requireType("test_files.module_symbol.preexisting_module_export"); 8 | -------------------------------------------------------------------------------- /test_files/module_symbol/preexisting_module_import.ts: -------------------------------------------------------------------------------- 1 | import {module} from './preexisting_module_export'; 2 | -------------------------------------------------------------------------------- /test_files/module_symbol/preexisting_module_type.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview added by tsickle 3 | * Generated from: test_files/module_symbol/preexisting_module_type.ts 4 | */ 5 | goog.module('test_files.module_symbol.preexisting_module_type'); 6 | goog.require('tslib'); 7 | /** @typedef {number} */ 8 | var module; 9 | -------------------------------------------------------------------------------- /test_files/module_symbol/preexisting_module_type.ts: -------------------------------------------------------------------------------- 1 | type module = number; 2 | export {}; 3 | -------------------------------------------------------------------------------- /test_files/module_symbol/preexisting_module_var.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview added by tsickle 3 | * Generated from: test_files/module_symbol/preexisting_module_var.ts 4 | */ 5 | goog.module('test_files.module_symbol.preexisting_module_var'); 6 | goog.require('tslib'); 7 | /** @type {number} */ 8 | const module = 12; 9 | -------------------------------------------------------------------------------- /test_files/module_symbol/preexisting_module_var.ts: -------------------------------------------------------------------------------- 1 | const module = 12; 2 | export {}; 3 | -------------------------------------------------------------------------------- /test_files/namespaced.no_nstransform/ambient_namespaced.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview added by tsickle 3 | * Generated from: test_files/namespaced.no_nstransform/ambient_namespaced.ts 4 | */ 5 | goog.module('test_files.namespaced.no_nstransform.ambient_namespaced'); 6 | var module = module || { id: 'test_files/namespaced.no_nstransform/ambient_namespaced.ts' }; 7 | goog.require('tslib'); 8 | /** @type {!decl.ns.one.NamespacedClass} */ 9 | let user; 10 | -------------------------------------------------------------------------------- /test_files/namespaced.no_nstransform/ambient_namespaced.ts: -------------------------------------------------------------------------------- 1 | declare namespace decl.ns.one { 2 | export class NamespacedClass { 3 | x: decl.ns.two.NamespacedClass; 4 | y: NamespacedClass; 5 | } 6 | } 7 | 8 | declare namespace decl.ns.two { 9 | export class NamespacedClass { 10 | x: NamespacedClass; 11 | y: decl.ns.one.NamespacedClass; 12 | } 13 | } 14 | 15 | let user: decl.ns.one.NamespacedClass; 16 | -------------------------------------------------------------------------------- /test_files/namespaced.no_nstransform/export_enum_in_namespace.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview tsickle's Closure compatible exported enum emit does not work in namespaces. Bar 3 | * below must be exported onto foo, which tsickle does by disabling its emit for namespace'd enums. 4 | */ 5 | 6 | // tslint:disable:no-namespace 7 | 8 | namespace foo { 9 | export enum Bar { 10 | X, 11 | Y, 12 | } 13 | console.log(Bar); // avoid an "unused assignment" error in Closure. 14 | } 15 | 16 | export {foo}; 17 | -------------------------------------------------------------------------------- /test_files/namespaced.no_nstransform/export_namespace.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview added by tsickle 3 | * Generated from: test_files/namespaced.no_nstransform/export_namespace.ts 4 | */ 5 | // tslint:disable:no-namespace 6 | goog.module('test_files.namespaced.no_nstransform.export_namespace'); 7 | var module = module || { id: 'test_files/namespaced.no_nstransform/export_namespace.ts' }; 8 | goog.require('tslib'); 9 | var valueNamespace; 10 | (function (valueNamespace) { 11 | class ValueClass { 12 | } 13 | valueNamespace.ValueClass = ValueClass; 14 | })(valueNamespace || (valueNamespace = {})); 15 | exports.valueNamespace = valueNamespace; 16 | -------------------------------------------------------------------------------- /test_files/namespaced.no_nstransform/export_namespace.ts: -------------------------------------------------------------------------------- 1 | // tslint:disable:no-namespace 2 | 3 | namespace valueNamespace { 4 | export class ValueClass {} 5 | } 6 | export {valueNamespace}; 7 | namespace typeNamespace { 8 | export interface Interface {} 9 | } 10 | export {typeNamespace}; 11 | -------------------------------------------------------------------------------- /test_files/namespaced.no_nstransform/local_namespace.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview added by tsickle 3 | * Generated from: test_files/namespaced.no_nstransform/local_namespace.ts 4 | */ 5 | goog.module('test_files.namespaced.no_nstransform.local_namespace'); 6 | var module = module || { id: 'test_files/namespaced.no_nstransform/local_namespace.ts' }; 7 | goog.require('tslib'); 8 | /** 9 | * \@someTag 10 | */ 11 | var unexported; 12 | (function (unexported) { 13 | class Unexported { 14 | } 15 | unexported.Unexported = Unexported; 16 | })(unexported || (unexported = {})); 17 | /** @type {?} */ 18 | let x; 19 | -------------------------------------------------------------------------------- /test_files/namespaced.no_nstransform/local_namespace.ts: -------------------------------------------------------------------------------- 1 | export {} 2 | 3 | /** @someTag */ 4 | namespace unexported { 5 | export class Unexported {} 6 | } 7 | 8 | let x: unexported.Unexported; 9 | -------------------------------------------------------------------------------- /test_files/namespaced.no_nstransform/user.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview added by tsickle 3 | * Generated from: test_files/namespaced.no_nstransform/user.ts 4 | */ 5 | goog.module('test_files.namespaced.no_nstransform.user'); 6 | var module = module || { id: 'test_files/namespaced.no_nstransform/user.ts' }; 7 | goog.require('tslib'); 8 | const tsickle_export_namespace_1 = goog.requireType("test_files.namespaced.no_nstransform.export_namespace"); 9 | const export_namespace_1 = goog.require('test_files.namespaced.no_nstransform.export_namespace'); 10 | /** @type {?} */ 11 | const x = new export_namespace_1.valueNamespace.ValueClass(); 12 | /** @type {?} */ 13 | let y; 14 | -------------------------------------------------------------------------------- /test_files/namespaced.no_nstransform/user.ts: -------------------------------------------------------------------------------- 1 | import {typeNamespace, valueNamespace} from './export_namespace'; 2 | 3 | const x = new valueNamespace.ValueClass(); 4 | let y: typeNamespace.Interface; 5 | -------------------------------------------------------------------------------- /test_files/nested_folder.declaration/inner_folder/nested.d.ts: -------------------------------------------------------------------------------- 1 | //!! generated by tsickle from test_files/nested_folder.declaration/inner_folder/nested.ts 2 | export declare const x = 1; 3 | declare global { 4 | namespace ಠ_ಠ.clutz { 5 | export { x as module$contents$test_files$nested_folder$declaration$inner_folder$nested_x }; 6 | export namespace module$exports$test_files$nested_folder$declaration$inner_folder$nested { 7 | export { x }; 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test_files/nested_folder.declaration/inner_folder/nested.ts: -------------------------------------------------------------------------------- 1 | export const x = 1; -------------------------------------------------------------------------------- /test_files/no_dollar_type_reference.no_externs/closure_x.js: -------------------------------------------------------------------------------- 1 | goog.module('closure.x'); 2 | 3 | class X {} 4 | 5 | /** @enum */ 6 | X.Nested = { 7 | A: 0, 8 | B: 1 9 | }; 10 | 11 | exports = X; -------------------------------------------------------------------------------- /test_files/no_dollar_type_reference.no_externs/closure_y.js: -------------------------------------------------------------------------------- 1 | goog.module('closure.y'); 2 | 3 | const X = goog.require('closure.x'); 4 | 5 | /** @return {!X.Nested} */ 6 | exports.getNested = function() { 7 | return Math.random() < 0.5 ? 8 | X.Nested.A : X.Nested.B; 9 | } -------------------------------------------------------------------------------- /test_files/no_dollar_type_reference.no_externs/import.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview added by tsickle 3 | * Generated from: test_files/no_dollar_type_reference.no_externs/import.ts 4 | */ 5 | goog.module('test_files.no_dollar_type_reference.no_externs.import'); 6 | var module = module || { id: 'test_files/no_dollar_type_reference.no_externs/import.ts' }; 7 | goog.require('tslib'); 8 | const tsickle_y_1 = goog.requireType("closure.y"); 9 | const tsickle_x_2 = goog.requireType("closure.x"); 10 | const goog_closure_y_1 = goog.require('closure.y'); 11 | /** @type {!tsickle_x_2.Nested} */ 12 | exports.nested = (0, goog_closure_y_1.getNested)(); 13 | -------------------------------------------------------------------------------- /test_files/no_dollar_type_reference.no_externs/import.ts: -------------------------------------------------------------------------------- 1 | import {getNested} from 'goog:closure.y'; 2 | 3 | export const nested = getNested(); -------------------------------------------------------------------------------- /test_files/no_exports.declaration/no_exports.d.ts: -------------------------------------------------------------------------------- 1 | //!! generated by tsickle from test_files/no_exports.declaration/no_exports.ts 2 | declare const x = 1; 3 | -------------------------------------------------------------------------------- /test_files/no_exports.declaration/no_exports.ts: -------------------------------------------------------------------------------- 1 | const x = 1; -------------------------------------------------------------------------------- /test_files/optional/optional.ts: -------------------------------------------------------------------------------- 1 | function optionalArgument(x: number, y?: string) { 2 | } 3 | optionalArgument(1); 4 | 5 | class OptionalTest { 6 | constructor(a: string, b?: string) {} 7 | method(c: string = 'hi') {} 8 | } 9 | 10 | let optionalTest = new OptionalTest('a'); 11 | optionalTest.method(); 12 | -------------------------------------------------------------------------------- /test_files/overload_with_this_parameter/externs.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @externs 3 | * @suppress {checkTypes,const,duplicate,missingOverride} 4 | */ 5 | // NOTE: generated by tsickle, do not edit. 6 | // Generated from: test_files/overload_with_this_parameter/overload_with_this_parameter.d.ts 7 | /** 8 | * @record 9 | * @struct 10 | */ 11 | function Foo() {} 12 | 13 | /** 14 | * @public 15 | * @this {!Foo|void} 16 | * @param {boolean|string|(undefined|number)=} x 17 | * @param {number=} y 18 | * @return {boolean|string|!Array} 19 | */ 20 | Foo.prototype.bar = function(x, y) {}; 21 | -------------------------------------------------------------------------------- /test_files/overload_with_this_parameter/overload_with_this_parameter.d.ts: -------------------------------------------------------------------------------- 1 | interface Foo { 2 | // Not all signatures have a this parameter. Should still generate proper 3 | // jsdoc. 4 | bar(this: Foo, x: boolean, y: number): boolean; 5 | bar(this: void, x: string): string; 6 | bar(x?: number): any[]; 7 | } 8 | -------------------------------------------------------------------------------- /test_files/parameter_properties/parameter_properties.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview 3 | * @suppress {uselessCode} 4 | */ 5 | 6 | class ParamProps { 7 | // The @export below should not show up in the output ctor. 8 | constructor( 9 | /** @export */ public publicExportedP: string, 10 | /* foo */ public publicP: string, 11 | protected protectedP: string, 12 | private privateP: string, 13 | readonly readonlyP: string, 14 | public readonly publicReadonlyP: string, 15 | ) {} 16 | } 17 | -------------------------------------------------------------------------------- /test_files/partial/partial.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview 3 | * @suppress {uselessCode} 4 | */ 5 | 6 | export {}; 7 | 8 | interface Base { 9 | foo: string; 10 | } 11 | 12 | class Derived implements Partial { 13 | foo: string|undefined; 14 | useFoo() { 15 | this.foo = undefined; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /test_files/private_field/private_field.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview Tests the generation of private field accessors from Tsickle. 3 | * They do not generate any externs, as they do not exist on the class 4 | * themselves when downleveled by TypeScript. 5 | * @suppress {checkTypes,uselessCode} 6 | */ 7 | 8 | export {}; 9 | 10 | class ContainsPrivateField { 11 | #someField: string; 12 | 13 | constructor(arg: string) { 14 | this.#someField = arg; 15 | } 16 | 17 | setSomeField(value: string) { 18 | this.#someField = value; 19 | } 20 | 21 | getSomeField() { 22 | return this.#someField; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /test_files/promiseconstructor/promiseconstructor.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview typeof Promise actually resolves to "PromiseConstructor" in 3 | * TypeScript, which is a type that doesn't exist in Closure's type world. This 4 | * code passes the e2e test because closure_externs.js declares 5 | * PromiseConstructor. 6 | * @suppress {checkTypes} 7 | */ 8 | 9 | function f(promiseCtor?: typeof Promise): Promise { 10 | return promiseCtor ? new promiseCtor((res, rej) => res()) : Promise.resolve(); 11 | } 12 | -------------------------------------------------------------------------------- /test_files/promisectorlike/promisectorlike.ts: -------------------------------------------------------------------------------- 1 | function toPromise(ctorLike: PromiseConstructorLike): Promise { 2 | return new ctorLike((resolve, reject) => { 3 | reject('grumpycat'); 4 | }) as Promise; 5 | } 6 | -------------------------------------------------------------------------------- /test_files/promiselike/promiselike.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview added by tsickle 3 | * Generated from: test_files/promiselike/promiselike.ts 4 | */ 5 | goog.module('test_files.promiselike.promiselike'); 6 | var module = module || { id: 'test_files/promiselike/promiselike.ts' }; 7 | goog.require('tslib'); 8 | /** @type {!PromiseLike} */ 9 | let promiseLikeOfString; 10 | -------------------------------------------------------------------------------- /test_files/promiselike/promiselike.ts: -------------------------------------------------------------------------------- 1 | let promiseLikeOfString: PromiseLike; 2 | -------------------------------------------------------------------------------- /test_files/protected/protected.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview This test checks that we emit \@private/\@protected where 3 | * necessary. 4 | * @suppress {uselessCode} 5 | */ 6 | 7 | export {}; 8 | 9 | class Protected { 10 | private privateMember: string; 11 | protected protectedMember: string; 12 | private privateMethod() {} 13 | protected protectedMethod() {} 14 | 15 | constructor( 16 | private anotherPrivate: string, 17 | protected anotherProtected: string, 18 | ) {} 19 | } 20 | 21 | abstract class Abstract { 22 | protected abstract foo(): void; 23 | } 24 | -------------------------------------------------------------------------------- /test_files/readonly/externs.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @externs 3 | * @suppress {checkTypes,const,duplicate,missingOverride} 4 | */ 5 | // NOTE: generated by tsickle, do not edit. 6 | // Generated from: test_files/readonly/readonly.ts 7 | /** @const */ 8 | var test_files$readonly$readonly = {}; 9 | /** 10 | * @record 11 | * @struct 12 | */ 13 | function DeclaredInterface() {} 14 | /** @const {string} */ 15 | DeclaredInterface.prototype.prop; 16 | -------------------------------------------------------------------------------- /test_files/recursive_union/recursive_union.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview Reproduces a reported crash in tsickle with recursive union 3 | * types. 4 | */ 5 | 6 | /** Recursive union type representing valid JSON values. */ 7 | export type JsonValue = 8 | JsonValue[]|boolean|null|number|string|{[property: string]: JsonValue}; 9 | 10 | /** A value using the type. */ 11 | export const validJson: JsonValue = { 12 | a: 'b', 13 | c: {d: 'f', g: 8} 14 | }; 15 | -------------------------------------------------------------------------------- /test_files/reexport.declaration/export.ts: -------------------------------------------------------------------------------- 1 | export const NUM_CONSTANT = 3; 2 | export const OTHER = 1; 3 | 4 | const NON_DIRECT = 0; 5 | export {NON_DIRECT}; 6 | 7 | const NON_DIRECT_TO_BE_RENAMED = 0; 8 | export {NON_DIRECT_TO_BE_RENAMED as NEW_NAME}; 9 | -------------------------------------------------------------------------------- /test_files/reexport.declaration/import_reexport.d.ts: -------------------------------------------------------------------------------- 1 | //!! generated by tsickle from test_files/reexport.declaration/import_reexport.ts 2 | import { NUM_CONSTANT } from './export'; 3 | export { NUM_CONSTANT }; 4 | declare global { 5 | namespace ಠ_ಠ.clutz { 6 | export { NUM_CONSTANT as module$contents$test_files$reexport$declaration$import_reexport_NUM_CONSTANT }; 7 | export namespace module$exports$test_files$reexport$declaration$import_reexport { 8 | export { NUM_CONSTANT }; 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test_files/reexport.declaration/import_reexport.ts: -------------------------------------------------------------------------------- 1 | import { NUM_CONSTANT } from './export'; 2 | export { NUM_CONSTANT }; 3 | -------------------------------------------------------------------------------- /test_files/reexport.declaration/reexport.d.ts: -------------------------------------------------------------------------------- 1 | //!! generated by tsickle from test_files/reexport.declaration/reexport.ts 2 | export * from './export'; 3 | -------------------------------------------------------------------------------- /test_files/reexport.declaration/reexport.ts: -------------------------------------------------------------------------------- 1 | // reexport_named.ts exports symbols, but doesn't import any of them, so 2 | // its .d.ts shouldn't have any clutz aliases in it. 3 | export * from './export'; 4 | -------------------------------------------------------------------------------- /test_files/reexport.declaration/reexport_named.d.ts: -------------------------------------------------------------------------------- 1 | //!! generated by tsickle from test_files/reexport.declaration/reexport_named.ts 2 | export { OTHER, NUM_CONSTANT } from './export'; 3 | -------------------------------------------------------------------------------- /test_files/reexport.declaration/reexport_named.ts: -------------------------------------------------------------------------------- 1 | // reexport_named.ts exports symbols, but doesn't import any of them, so 2 | // its .d.ts shouldn't have any clutz aliases in it. 3 | export { OTHER, NUM_CONSTANT } from './export'; 4 | -------------------------------------------------------------------------------- /test_files/reexport.declaration/renamed_export.d.ts: -------------------------------------------------------------------------------- 1 | //!! generated by tsickle from test_files/reexport.declaration/renamed_export.ts 2 | import { OTHER } from './export'; 3 | export { OTHER as MOTHER }; 4 | declare global { 5 | namespace ಠ_ಠ.clutz { 6 | export { OTHER as module$contents$test_files$reexport$declaration$renamed_export_MOTHER }; 7 | export namespace module$exports$test_files$reexport$declaration$renamed_export { 8 | export { OTHER as MOTHER }; 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test_files/reexport.declaration/renamed_export.ts: -------------------------------------------------------------------------------- 1 | import {OTHER} from './export'; 2 | export {OTHER as MOTHER}; 3 | -------------------------------------------------------------------------------- /test_files/rest_parameters_generic_empty/rest_parameters_generic_empty.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview Tests what happens when a rest args (...x) param is 3 | * instantiated in a context where it creates a zero-argument function. 4 | */ 5 | 6 | export {}; 7 | 8 | function returnsRestArgFn(fn: (...args: A) => void): 9 | (...args: A) => void { 10 | return fn; 11 | } 12 | 13 | const zeroRestArguments = returnsRestArgFn(() => {}); 14 | console.log(zeroRestArguments); 15 | -------------------------------------------------------------------------------- /test_files/rest_parameters_tuple/rest_parameters_tuple.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview Tests that complex union/tuple types for rest parameters get emitted as a fallback 3 | * '?' unknown type. 4 | */ 5 | 6 | export function fn(...args: [number]|[string, number]) {} 7 | -------------------------------------------------------------------------------- /test_files/scope_collision/collision.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview 3 | * TODO(b/195232797): remove the checkTypes suppression 4 | * @suppress {checkTypes,uselessCode} 5 | */ 6 | 7 | export {} 8 | 9 | interface MyType { 10 | propA: string; 11 | } 12 | 13 | type MyTypeAlias = MyType; 14 | 15 | (function() { 16 | // TODO(b/195232797): Should emit MyTypeAlias 17 | class MyType implements MyTypeAlias { 18 | propA: string = 'a'; 19 | propB: string = 'b'; 20 | } 21 | 22 | // TODO(b/195232797): Should emit MyTypeAlias 23 | function test(a: MyTypeAlias, b: MyType): string { 24 | return a.propA + b.propB; 25 | } 26 | 27 | return test; 28 | })(); 29 | -------------------------------------------------------------------------------- /test_files/side_effect_import/module1.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @fileoverview A module for importing from the main test. 4 | * 5 | * Generated from: test_files/side_effect_import/module1.ts 6 | */ 7 | goog.module('test_files.side_effect_import.module1'); 8 | var module = module || { id: 'test_files/side_effect_import/module1.ts' }; 9 | goog.require('tslib'); 10 | class Mod1 { 11 | } 12 | exports.Mod1 = Mod1; 13 | -------------------------------------------------------------------------------- /test_files/side_effect_import/module1.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview A module for importing from the main test. 3 | */ 4 | 5 | export class Mod1 {} 6 | -------------------------------------------------------------------------------- /test_files/side_effect_import/module2.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @fileoverview A module for importing from the main test. 4 | * 5 | * Generated from: test_files/side_effect_import/module2.ts 6 | */ 7 | goog.module('test_files.side_effect_import.module2'); 8 | var module = module || { id: 'test_files/side_effect_import/module2.ts' }; 9 | goog.require('tslib'); 10 | class Mod2 { 11 | } 12 | exports.Mod2 = Mod2; 13 | -------------------------------------------------------------------------------- /test_files/side_effect_import/module2.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview A module for importing from the main test. 3 | */ 4 | 5 | export class Mod2 {} 6 | -------------------------------------------------------------------------------- /test_files/side_effect_import/side_effect_import.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview Use some side-effect imports and verify that tsickle generates 3 | * proper module code from them. 4 | */ 5 | 6 | // tslint:disable 7 | 8 | import './module1'; 9 | import './module2'; 10 | 11 | import {Mod1} from './module1'; 12 | import {Mod2} from './module2'; 13 | 14 | // Use one as a type and the other as a value. 15 | let x = new Mod1(); 16 | let y: Mod2; 17 | -------------------------------------------------------------------------------- /test_files/static/static.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview 3 | * @suppress {uselessCode} 4 | */ 5 | 6 | class Static { 7 | // This should not become a stub declaration. 8 | static bar = 3; 9 | // private statics also should work. 10 | private static baz: number = 3; 11 | } 12 | -------------------------------------------------------------------------------- /test_files/string_manipulations/uncapitalize_lowercase.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @fileoverview A short test that ensures that string manipulation types (such 4 | * as `Uncapitalize`) are converted to a generic `string` type. 5 | * 6 | * Generated from: test_files/string_manipulations/uncapitalize_lowercase.ts 7 | */ 8 | goog.module('test_files.string_manipulations.uncapitalize_lowercase'); 9 | var module = module || { id: 'test_files/string_manipulations/uncapitalize_lowercase.ts' }; 10 | goog.require('tslib'); 11 | /** @typedef {string} */ 12 | var StringManipulation; 13 | /** @type {string} */ 14 | const T = 'something'; 15 | console.log(T); 16 | -------------------------------------------------------------------------------- /test_files/string_manipulations/uncapitalize_lowercase.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview A short test that ensures that string manipulation types (such 3 | * as `Uncapitalize`) are converted to a generic `string` type. 4 | */ 5 | 6 | export {}; 7 | 8 | type StringManipulation = Uncapitalize>; 9 | 10 | const T: StringManipulation<'something'> = 'something'; 11 | console.log(T); 12 | -------------------------------------------------------------------------------- /test_files/structural.untyped/structural.untyped.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview Ensure that a class is structurally equivalent to an object 3 | * literal with the same fields. 4 | * @suppress {uselessCode} 5 | */ 6 | 7 | class StructuralTest { 8 | field1: string; 9 | method(): string { 10 | return this.field1; 11 | } 12 | } 13 | 14 | // The function expects a StructuralTest, but we pass it an object 15 | // literal. 16 | function expectsAStructuralTest(st: StructuralTest) {} 17 | expectsAStructuralTest({field1: 'hi', method: () => 'hi'}); 18 | -------------------------------------------------------------------------------- /test_files/symbol/symbol.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview 3 | * @suppress {uselessCode} 4 | */ 5 | const uniqueSymbol: unique symbol = Symbol('my symbol'); 6 | 7 | function usingSymbol(symbolTyped: symbol) { 8 | console.log(symbolTyped); 9 | } 10 | 11 | interface ComputedSymbol { 12 | [uniqueSymbol](): number; 13 | } 14 | 15 | usingSymbol(uniqueSymbol); 16 | -------------------------------------------------------------------------------- /test_files/transitive_symbol_type_only/exporter.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @fileoverview 4 | * Generated from: test_files/transitive_symbol_type_only/exporter.ts 5 | * @suppress {uselessCode} 6 | * 7 | */ 8 | goog.module('test_files.transitive_symbol_type_only.exporter'); 9 | var module = module || { id: 'test_files/transitive_symbol_type_only/exporter.ts' }; 10 | goog.require('tslib'); 11 | /** 12 | * @record 13 | */ 14 | function ExportedInterface() { } 15 | exports.ExportedInterface = ExportedInterface; 16 | /* istanbul ignore if */ 17 | if (false) { 18 | /** 19 | * @type {number} 20 | * @public 21 | */ 22 | ExportedInterface.prototype.x; 23 | } 24 | -------------------------------------------------------------------------------- /test_files/transitive_symbol_type_only/exporter.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview 3 | * @suppress {uselessCode} 4 | */ 5 | 6 | export interface ExportedInterface { 7 | x: number; 8 | } 9 | -------------------------------------------------------------------------------- /test_files/transitive_symbol_type_only/reexporter.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview added by tsickle 3 | * Generated from: test_files/transitive_symbol_type_only/reexporter.ts 4 | */ 5 | goog.module('test_files.transitive_symbol_type_only.reexporter'); 6 | var module = module || { id: 'test_files/transitive_symbol_type_only/reexporter.ts' }; 7 | goog.require('tslib'); 8 | const tsickle_exporter_1 = goog.requireType("test_files.transitive_symbol_type_only.exporter"); 9 | /** @typedef {(null|string|!tsickle_exporter_1.ExportedInterface)} */ 10 | exports.UsesExportedInterface; 11 | -------------------------------------------------------------------------------- /test_files/transitive_symbol_type_only/reexporter.ts: -------------------------------------------------------------------------------- 1 | import { ExportedInterface } from "./exporter"; 2 | 3 | export type UsesExportedInterface = ExportedInterface|null|string; 4 | -------------------------------------------------------------------------------- /test_files/transitive_symbol_type_only/transitive_symbol_type_only.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview This file uses a type alias that references a type defined in another file. The 3 | * test makes sure there is no hard goog.require for the transitive file, as that breaks strict 4 | * dependency checking in some systems. 5 | */ 6 | 7 | import {UsesExportedInterface} from './reexporter'; 8 | 9 | export const val: UsesExportedInterface = 'val'; 10 | -------------------------------------------------------------------------------- /test_files/ts_migration_exports_shim.no_externs.puretransform.declaration/correct_default_type.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview An example export to be re-exported. 3 | * @suppress {visibility} :test_files_compilation_test 4 | */ 5 | goog.module('test_files.ts_migration_exports_shim.no_externs.puretransform.declaration.correct_default_type'); 6 | var module = module || { id: 'test_files/ts_migration_exports_shim.no_externs.puretransform.declaration/correct_default_type.ts' }; 7 | goog.require('tslib'); 8 | class MyDefaultType { 9 | } 10 | exports.MyDefaultType = MyDefaultType; 11 | -------------------------------------------------------------------------------- /test_files/ts_migration_exports_shim.no_externs.puretransform.declaration/correct_default_type.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview An example export to be re-exported. 3 | * @suppress {visibility} :test_files_compilation_test 4 | */ 5 | 6 | export class MyDefaultType { 7 | shouldBeANumber: number; 8 | } 9 | 10 | goog.tsMigrationExportsShim('project.MyDefaultType', {} as MyDefaultType); 11 | -------------------------------------------------------------------------------- /test_files/ts_migration_exports_shim.no_externs.puretransform.declaration/correct_default_type_shorthand.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview An example export to be re-exported. 3 | * @suppress {visibility} :test_files_compilation_test 4 | */ 5 | goog.module('test_files.ts_migration_exports_shim.no_externs.puretransform.declaration.correct_default_type_shorthand'); 6 | var module = module || { id: 'test_files/ts_migration_exports_shim.no_externs.puretransform.declaration/correct_default_type_shorthand.ts' }; 7 | goog.require('tslib'); 8 | class MyDefaultType { 9 | } 10 | exports.MyDefaultType = MyDefaultType; 11 | -------------------------------------------------------------------------------- /test_files/ts_migration_exports_shim.no_externs.puretransform.declaration/correct_default_type_shorthand.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview An example export to be re-exported. 3 | * @suppress {visibility} :test_files_compilation_test 4 | */ 5 | 6 | export class MyDefaultType { 7 | shouldBeANumber: number; 8 | } 9 | 10 | goog.tsMigrationDefaultExportsShim('project.MyDefaultType.shorthand'); 11 | -------------------------------------------------------------------------------- /test_files/ts_migration_exports_shim.no_externs.puretransform.declaration/correct_default_value.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview An example export to be re-exported. 3 | * @suppress {visibility} :test_files_compilation_test 4 | */ 5 | goog.module('test_files.ts_migration_exports_shim.no_externs.puretransform.declaration.correct_default_value'); 6 | var module = module || { id: 'test_files/ts_migration_exports_shim.no_externs.puretransform.declaration/correct_default_value.ts' }; 7 | goog.require('tslib'); 8 | class MyDefaultClass { 9 | constructor() { 10 | this.field = 1; 11 | } 12 | } 13 | exports.MyDefaultClass = MyDefaultClass; 14 | -------------------------------------------------------------------------------- /test_files/ts_migration_exports_shim.no_externs.puretransform.declaration/correct_default_value.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview An example export to be re-exported. 3 | * @suppress {visibility} :test_files_compilation_test 4 | */ 5 | 6 | export class MyDefaultClass { 7 | field = 1; 8 | } 9 | 10 | goog.tsMigrationExportsShim('project.MyDefaultClass', MyDefaultClass); 11 | -------------------------------------------------------------------------------- /test_files/ts_migration_exports_shim.no_externs.puretransform.declaration/correct_default_value_shorthand.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview An example export to be re-exported. 3 | * @suppress {visibility} :test_files_compilation_test 4 | */ 5 | 6 | export class MyDefaultClass { 7 | field = 1; 8 | } 9 | 10 | goog.tsMigrationDefaultExportsShim('project.MyDefaultClass.shorthand'); 11 | -------------------------------------------------------------------------------- /test_files/ts_migration_exports_shim.no_externs.puretransform.declaration/correct_named.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview An example export to be re-exported. 3 | * @suppress {visibility} :test_files_compilation_test 4 | */ 5 | goog.module('test_files.ts_migration_exports_shim.no_externs.puretransform.declaration.correct_named'); 6 | var module = module || { id: 'test_files/ts_migration_exports_shim.no_externs.puretransform.declaration/correct_named.ts' }; 7 | goog.require('tslib'); 8 | class MyNamedClass { 9 | constructor() { 10 | this.field = 1; 11 | } 12 | } 13 | exports.MyNamedClass = MyNamedClass; 14 | -------------------------------------------------------------------------------- /test_files/ts_migration_exports_shim.no_externs.puretransform.declaration/correct_named.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview An example export to be re-exported. 3 | * @suppress {visibility} :test_files_compilation_test 4 | */ 5 | 6 | export class MyNamedClass { 7 | field = 1; 8 | } 9 | 10 | goog.tsMigrationExportsShim('project.named', {MyRenamedClass: MyNamedClass}); 11 | goog.tsMigrationExportsShimDeclareLegacyNamespace(); 12 | -------------------------------------------------------------------------------- /test_files/ts_migration_exports_shim.no_externs.puretransform.declaration/correct_named_shorthand.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview An example export to be re-exported. 3 | * @suppress {visibility} :test_files_compilation_test 4 | */ 5 | goog.module('test_files.ts_migration_exports_shim.no_externs.puretransform.declaration.correct_named_shorthand'); 6 | var module = module || { id: 'test_files/ts_migration_exports_shim.no_externs.puretransform.declaration/correct_named_shorthand.ts' }; 7 | goog.require('tslib'); 8 | class MyNamedClass { 9 | constructor() { 10 | this.field = 1; 11 | } 12 | } 13 | exports.MyNamedClass = MyNamedClass; 14 | -------------------------------------------------------------------------------- /test_files/ts_migration_exports_shim.no_externs.puretransform.declaration/correct_named_shorthand.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview An example export to be re-exported. 3 | * @suppress {visibility} :test_files_compilation_test 4 | */ 5 | 6 | export class MyNamedClass { 7 | field = 1; 8 | } 9 | 10 | goog.tsMigrationNamedExportsShim('project.named.shorthand'); 11 | -------------------------------------------------------------------------------- /test_files/ts_migration_exports_shim.no_externs/bad_default_shorthand_with_more_than_one_export.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview negative tests for the tsMigrationDefaultExportsShim 3 | * transformation. 4 | * 5 | * Suppress expected errors for :test_files_compilation_test 6 | * @suppress {checkTypes,visibility} 7 | */ 8 | 9 | export const Foo = 42; 10 | export interface I {} 11 | 12 | // Default exports in JavaScript only make sense when the corresponding 13 | // TypeScript has exactly one export. 14 | goog.tsMigrationDefaultExportsShim('requires.exactly.one.export'); 15 | -------------------------------------------------------------------------------- /test_files/ts_migration_exports_shim.no_externs/bad_default_shorthand_with_no_exports.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview negative tests for the tsMigrationDefaultExportsShim 3 | * transformation. 4 | * 5 | * Suppress expected errors for :test_files_compilation_test 6 | * @suppress {checkTypes,visibility} 7 | */ 8 | 9 | // Default exports in JavaScript only make sense when the corresponding 10 | // TypeScript has exactly one export. 11 | goog.tsMigrationDefaultExportsShim('requires.exactly.one.export'); 12 | -------------------------------------------------------------------------------- /test_files/ts_migration_exports_shim.no_externs/bad_dln_only.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview negative test for the tsMigrationExportsShim transformation for 3 | * tsMigrationExportsShimDeclareLegacyNamespace. 4 | * 5 | * Suppress expected errors for :test_files_compilation_test 6 | * @suppress {checkTypes,visibility} 7 | */ 8 | 9 | export const exported = 1; 10 | 11 | // Needs normal TSMES call as well. 12 | goog.tsMigrationExportsShimDeclareLegacyNamespace(); 13 | -------------------------------------------------------------------------------- /test_files/ts_migration_exports_shim.no_externs/correct_default_shorthand.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview An example export to be re-exported. 3 | * @suppress {uselessCode} 4 | */ 5 | 6 | export interface MyDefaultType { 7 | field: number; 8 | } 9 | 10 | goog.tsMigrationDefaultExportsShim('project.CorrectDefaultShorthand'); 11 | goog.tsMigrationExportsShimDeclareLegacyNamespace(); 12 | -------------------------------------------------------------------------------- /test_files/ts_migration_exports_shim.no_externs/correct_default_shorthand.tsmes.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview generator:ts_migration_exports_shim.ts 3 | * original_file:third_party/javascript/node_modules/tsickle/test_files/ts_migration_exports_shim.no_externs/correct_default_shorthand.ts 4 | * pintomodule absent in original_file 5 | */ 6 | goog.module('project.CorrectDefaultShorthand'); 7 | goog.module.declareLegacyNamespace(); 8 | var mainModule = goog.require('test_files.ts_migration_exports_shim.no_externs.correct_default_shorthand'); 9 | exports = mainModule.MyDefaultType; 10 | -------------------------------------------------------------------------------- /test_files/ts_migration_exports_shim.no_externs/correct_default_type.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview An example export to be re-exported. 3 | * @suppress {uselessCode} 4 | */ 5 | 6 | export interface MyDefaultType { 7 | field: number; 8 | } 9 | 10 | goog.tsMigrationExportsShim('project.MyDefaultType', {} as MyDefaultType); 11 | -------------------------------------------------------------------------------- /test_files/ts_migration_exports_shim.no_externs/correct_default_type.tsmes.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview generator:ts_migration_exports_shim.ts 3 | * original_file:third_party/javascript/node_modules/tsickle/test_files/ts_migration_exports_shim.no_externs/correct_default_type.ts 4 | * pintomodule absent in original_file 5 | */ 6 | goog.module('project.MyDefaultType'); 7 | var mainModule = goog.require('test_files.ts_migration_exports_shim.no_externs.correct_default_type'); 8 | exports = mainModule.MyDefaultType; 9 | -------------------------------------------------------------------------------- /test_files/ts_migration_exports_shim.no_externs/correct_default_type_literal.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview added by tsickle 3 | * Generated from: test_files/ts_migration_exports_shim.no_externs/correct_default_type_literal.ts 4 | */ 5 | goog.module('test_files.ts_migration_exports_shim.no_externs.correct_default_type_literal'); 6 | var module = module || { id: 'test_files/ts_migration_exports_shim.no_externs/correct_default_type_literal.ts' }; 7 | goog.require('tslib'); 8 | /** 9 | * An example export to be re-exported. 10 | * @typedef {string} 11 | */ 12 | exports.DefaultTypeLiteral; 13 | -------------------------------------------------------------------------------- /test_files/ts_migration_exports_shim.no_externs/correct_default_type_literal.ts: -------------------------------------------------------------------------------- 1 | /** An example export to be re-exported. */ 2 | export type DefaultTypeLiteral = string; 3 | 4 | goog.tsMigrationExportsShim( 5 | 'project.MyDefaultTypeLiteral', {} as DefaultTypeLiteral); 6 | -------------------------------------------------------------------------------- /test_files/ts_migration_exports_shim.no_externs/correct_default_type_literal.tsmes.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview generator:ts_migration_exports_shim.ts 3 | * original_file:third_party/javascript/node_modules/tsickle/test_files/ts_migration_exports_shim.no_externs/correct_default_type_literal.ts 4 | * pintomodule absent in original_file 5 | */ 6 | goog.module('project.MyDefaultTypeLiteral'); 7 | var mainModule = goog.require('test_files.ts_migration_exports_shim.no_externs.correct_default_type_literal'); 8 | exports = mainModule.DefaultTypeLiteral; 9 | -------------------------------------------------------------------------------- /test_files/ts_migration_exports_shim.no_externs/correct_default_value.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview An example export to be re-exported. 3 | * @suppress {uselessCode} 4 | */ 5 | 6 | export class MyDefaultClass { 7 | field = 1; 8 | } 9 | 10 | goog.tsMigrationExportsShim('project.MyDefaultClass', MyDefaultClass); 11 | -------------------------------------------------------------------------------- /test_files/ts_migration_exports_shim.no_externs/correct_default_value.tsmes.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview generator:ts_migration_exports_shim.ts 3 | * original_file:third_party/javascript/node_modules/tsickle/test_files/ts_migration_exports_shim.no_externs/correct_default_value.ts 4 | * pintomodule absent in original_file 5 | */ 6 | goog.module('project.MyDefaultClass'); 7 | var mainModule = goog.require('test_files.ts_migration_exports_shim.no_externs.correct_default_value'); 8 | exports = mainModule.MyDefaultClass; 9 | -------------------------------------------------------------------------------- /test_files/ts_migration_exports_shim.no_externs/correct_default_with_re_export.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @fileoverview An example export with a re-export to be re-exported via TSMES. 4 | * Generated from: test_files/ts_migration_exports_shim.no_externs/correct_default_with_re_export.ts 5 | * @suppress {uselessCode} 6 | * 7 | */ 8 | goog.module('test_files.ts_migration_exports_shim.no_externs.correct_default_with_re_export'); 9 | var module = module || { id: 'test_files/ts_migration_exports_shim.no_externs/correct_default_with_re_export.ts' }; 10 | goog.require('tslib'); 11 | class Foo { 12 | } 13 | exports.Bar = Foo; 14 | -------------------------------------------------------------------------------- /test_files/ts_migration_exports_shim.no_externs/correct_default_with_re_export.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview An example export with a re-export to be re-exported via TSMES. 3 | * @suppress {uselessCode} 4 | */ 5 | 6 | class Foo {} 7 | 8 | export {Foo as Bar}; 9 | 10 | goog.tsMigrationDefaultExportsShim('works.with.rexport.of.Bar'); 11 | -------------------------------------------------------------------------------- /test_files/ts_migration_exports_shim.no_externs/correct_default_with_re_export.tsmes.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview generator:ts_migration_exports_shim.ts 3 | * original_file:third_party/javascript/node_modules/tsickle/test_files/ts_migration_exports_shim.no_externs/correct_default_with_re_export.ts 4 | * pintomodule absent in original_file 5 | */ 6 | goog.module('works.with.rexport.of.Bar'); 7 | var mainModule = goog.require('test_files.ts_migration_exports_shim.no_externs.correct_default_with_re_export'); 8 | exports = mainModule.Bar; 9 | -------------------------------------------------------------------------------- /test_files/ts_migration_exports_shim.no_externs/correct_named.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview An example export to be re-exported. 3 | * @suppress {uselessCode} 4 | */ 5 | 6 | export class MyNamedClass { 7 | field = 1; 8 | } 9 | 10 | export interface AnInterface { 11 | shouldBeANumber: number; 12 | } 13 | 14 | goog.tsMigrationExportsShim('project.named', { 15 | MyRenamedClass: MyNamedClass, 16 | AnInterfaceRenamed: {} as AnInterface, 17 | }); 18 | -------------------------------------------------------------------------------- /test_files/ts_migration_exports_shim.no_externs/correct_named.tsmes.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview generator:ts_migration_exports_shim.ts 3 | * original_file:third_party/javascript/node_modules/tsickle/test_files/ts_migration_exports_shim.no_externs/correct_named.ts 4 | * pintomodule absent in original_file 5 | */ 6 | goog.module('project.named'); 7 | var mainModule = goog.require('test_files.ts_migration_exports_shim.no_externs.correct_named'); 8 | exports.MyRenamedClass = mainModule.MyNamedClass; 9 | exports.AnInterfaceRenamed = mainModule.AnInterface; 10 | -------------------------------------------------------------------------------- /test_files/ts_migration_exports_shim.no_externs/correct_named_shorthand.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview An example export to be re-exported. 3 | * @suppress {uselessCode} 4 | */ 5 | 6 | export interface MyIntrface { 7 | field: number; 8 | } 9 | 10 | export type MyTypeLiteral = string; 11 | 12 | interface MyNotExportedThing { 13 | aFieldOnMyNotExportedThing: boolean; 14 | } 15 | 16 | goog.tsMigrationNamedExportsShim('project.CorrectNamedShorthand'); 17 | -------------------------------------------------------------------------------- /test_files/ts_migration_exports_shim.no_externs/correct_named_shorthand.tsmes.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview generator:ts_migration_exports_shim.ts 3 | * original_file:third_party/javascript/node_modules/tsickle/test_files/ts_migration_exports_shim.no_externs/correct_named_shorthand.ts 4 | * pintomodule absent in original_file 5 | */ 6 | goog.module('project.CorrectNamedShorthand'); 7 | var mainModule = goog.require('test_files.ts_migration_exports_shim.no_externs.correct_named_shorthand'); 8 | exports.MyIntrface = mainModule.MyIntrface; 9 | exports.MyTypeLiteral = mainModule.MyTypeLiteral; 10 | -------------------------------------------------------------------------------- /test_files/ts_migration_exports_shim.no_externs/pintomodule.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @fileoverview This file is marked as a pintomodule, which must be propagated 4 | * into the .tsmes.closure.js file. 5 | * Generated from: test_files/ts_migration_exports_shim.no_externs/pintomodule.ts 6 | * @pintomodule 7 | * 8 | */ 9 | goog.module('test_files.ts_migration_exports_shim.no_externs.pintomodule'); 10 | var module = module || { id: 'test_files/ts_migration_exports_shim.no_externs/pintomodule.ts' }; 11 | goog.require('tslib'); 12 | /** @type {number} */ 13 | exports.NOTHING = 0; 14 | -------------------------------------------------------------------------------- /test_files/ts_migration_exports_shim.no_externs/pintomodule.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview This file is marked as a pintomodule, which must be propagated 3 | * into the .tsmes.closure.js file. 4 | * @pintomodule 5 | */ 6 | 7 | export const NOTHING = 0; 8 | 9 | goog.tsMigrationExportsShim('test.pintomodule', NOTHING); 10 | -------------------------------------------------------------------------------- /test_files/ts_migration_exports_shim.no_externs/pintomodule.tsmes.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview generator:ts_migration_exports_shim.ts 3 | * original_file:third_party/javascript/node_modules/tsickle/test_files/ts_migration_exports_shim.no_externs/pintomodule.ts 4 | * @pintomodule found in original_file 5 | */ 6 | goog.module('test.pintomodule'); 7 | var mainModule = goog.require('test_files.ts_migration_exports_shim.no_externs.pintomodule'); 8 | exports = mainModule.NOTHING; 9 | -------------------------------------------------------------------------------- /test_files/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "experimentalDecorators": true, 4 | "module": "commonjs", 5 | "lib": [ 6 | "es5", 7 | "es6", 8 | "es2015.collection", 9 | "es2015.iterable", 10 | "es2015.core", 11 | "dom" 12 | ], 13 | "jsx": "react", 14 | "target": "es2015", 15 | "strict": true 16 | }, 17 | "include": [ 18 | "**/*.ts" 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /test_files/type/externs.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @externs 3 | * @suppress {checkTypes,const,duplicate,missingOverride} 4 | */ 5 | // NOTE: generated by tsickle, do not edit. 6 | // Generated from: test_files/type/type.ts 7 | /** @const */ 8 | var test_files$type$type = {}; 9 | /** @type {boolean} */ 10 | Array.prototype.monkeyPatch; 11 | -------------------------------------------------------------------------------- /test_files/type_alias_imported/elided_comment.ts: -------------------------------------------------------------------------------- 1 | // Test that comments in the input file that are not emitted don't mess up emit. 2 | import {XY} from './type_alias_exporter'; 3 | 4 | let xy: XY|null = null; 5 | -------------------------------------------------------------------------------- /test_files/type_alias_imported/export_constant.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview See comments in type_alias_imported. 3 | * Generated from: test_files/type_alias_imported/export_constant.ts 4 | */ 5 | goog.module('test_files.type_alias_imported.export_constant'); 6 | var module = module || { id: 'test_files/type_alias_imported/export_constant.ts' }; 7 | goog.require('tslib'); 8 | /** @type {number} */ 9 | exports.SOME_CONSTANT = 1; 10 | -------------------------------------------------------------------------------- /test_files/type_alias_imported/export_constant.ts: -------------------------------------------------------------------------------- 1 | /** @fileoverview See comments in type_alias_imported. */ 2 | 3 | export const SOME_CONSTANT = 1; 4 | -------------------------------------------------------------------------------- /test_files/type_alias_imported/type_alias_declare.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview Declares the symbols used in union types in 3 | * type_alias_exporter. These symbols must ultimately be imported by 4 | * type_alias_imported. 5 | * @suppress {uselessCode} 6 | */ 7 | 8 | export interface X { 9 | x: string; 10 | } 11 | -------------------------------------------------------------------------------- /test_files/type_alias_imported/type_alias_default_exporter.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview Declares a type alias as default export. This allows testing that the appropriate 3 | * type reference is created (no .default property). 4 | */ 5 | 6 | import {X} from './type_alias_declare'; 7 | 8 | export class Z {} 9 | 10 | type DefaultExport = X|Z; 11 | export default DefaultExport; 12 | -------------------------------------------------------------------------------- /test_files/type_alias_imported/type_alias_exporter.ts: -------------------------------------------------------------------------------- 1 | import {X} from './type_alias_declare'; 2 | // Export a type alias that references types from this file that, in turn, are 3 | // not imported at the use site in type_alias_imported. This is a regression 4 | // test for a bug where tsickle would accidentally inline the union type "X|Y" 5 | // instead of emitting the alias "XY" at the use site. 6 | 7 | export class Y {} 8 | export type XY = X|Y; 9 | -------------------------------------------------------------------------------- /test_files/type_and_value/module.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview TypeAndValue is both a type and a value, which is allowed in 3 | * TypeScript but disallowed in Closure. 4 | * @suppress {uselessCode} 5 | */ 6 | 7 | export interface TypeAndValue { 8 | z: number; 9 | } 10 | export var TypeAndValue = 3; 11 | 12 | export interface TemplatizedTypeAndValue { 13 | z: T 14 | } 15 | export var TemplatizedTypeAndValue = 1; 16 | 17 | export class Class { 18 | z: number; 19 | } 20 | 21 | export enum Enum { 22 | A 23 | } 24 | -------------------------------------------------------------------------------- /test_files/type_and_value/typing.d.ts: -------------------------------------------------------------------------------- 1 | // This file defines a type and value in a d.ts, to verify the 2 | // externs-related logic. 3 | 4 | declare interface ExtTypeAndValue { z: number; } 5 | declare var ExtTypeAndValue: number; 6 | 7 | declare enum ExtEnum { A } 8 | -------------------------------------------------------------------------------- /test_files/type_guard_fn/type_guard_fn.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview added by tsickle 3 | * Generated from: test_files/type_guard_fn/type_guard_fn.ts 4 | */ 5 | goog.module('test_files.type_guard_fn.type_guard_fn'); 6 | var module = module || { id: 'test_files/type_guard_fn/type_guard_fn.ts' }; 7 | goog.require('tslib'); 8 | /** 9 | * @param {*} a 10 | * @return {boolean} 11 | */ 12 | function isBoolean(a) { 13 | return typeof a === 'string'; 14 | } 15 | exports.isBoolean = isBoolean; 16 | /** 17 | * @template T 18 | * @param {!Object} obj 19 | * @return {boolean} 20 | */ 21 | function isThenable(obj) { 22 | return true; 23 | } 24 | -------------------------------------------------------------------------------- /test_files/type_guard_fn/type_guard_fn.ts: -------------------------------------------------------------------------------- 1 | export function isBoolean(a: {}): a is string { 2 | return typeof a === 'string'; 3 | } 4 | 5 | function isThenable(obj: object): obj is PromiseLike { 6 | return true; 7 | } 8 | -------------------------------------------------------------------------------- /test_files/type_propaccess.no_externs/clutzed_namespace.d.ts: -------------------------------------------------------------------------------- 1 | declare namespace ಠ_ಠ.clutz.type_propaccess.nested.clazz { 2 | class ClutzedClassWithNested {} 3 | namespace ClutzedClassWithNested { 4 | export class NestedClutzedClass {} 5 | } 6 | } 7 | 8 | declare module 'goog:type_propaccess.nested.clazz' { 9 | import alias = ಠ_ಠ.clutz.type_propaccess.nested.clazz; 10 | export = alias; 11 | } 12 | -------------------------------------------------------------------------------- /test_files/type_propaccess.no_externs/nested_clazz.js: -------------------------------------------------------------------------------- 1 | goog.provide('type_propaccess.nested.clazz'); 2 | 3 | type_propaccess.nested.clazz.ClutzedClassWithNested = class {}; 4 | 5 | type_propaccess.nested.clazz.ClutzedClassWithNested.NestedClutzedClass = class {}; 6 | -------------------------------------------------------------------------------- /test_files/type_propaccess.no_externs/type_propaccess.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @fileoverview 4 | * Generated from: test_files/type_propaccess.no_externs/type_propaccess.ts 5 | * @suppress {checkTypes} 6 | * 7 | */ 8 | goog.module('test_files.type_propaccess.no_externs.type_propaccess'); 9 | var module = module || { id: 'test_files/type_propaccess.no_externs/type_propaccess.ts' }; 10 | goog.require('tslib'); 11 | const tsickle_clazz_1 = goog.requireType("type_propaccess.nested.clazz"); 12 | /** @type {(null|!tsickle_clazz_1.ClutzedClassWithNested.NestedClutzedClass)} */ 13 | const x = null; 14 | -------------------------------------------------------------------------------- /test_files/type_propaccess.no_externs/type_propaccess.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview 3 | * @suppress {checkTypes} 4 | */ 5 | 6 | import {ClutzedClassWithNested} from 'goog:type_propaccess.nested.clazz'; 7 | 8 | const x: ClutzedClassWithNested.NestedClutzedClass|null = null; 9 | -------------------------------------------------------------------------------- /test_files/typedef.untyped/typedef.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview added by tsickle 3 | * Generated from: test_files/typedef.untyped/typedef.ts 4 | */ 5 | goog.module('test_files.typedef.untyped.typedef'); 6 | var module = module || { id: 'test_files/typedef.untyped/typedef.ts' }; 7 | goog.require('tslib'); 8 | /** @typedef {?} */ 9 | var MyType; 10 | /** @type {?} */ 11 | var y = 3; 12 | /** @typedef {?} */ 13 | var Recursive; 14 | /** @typedef {?} */ 15 | exports.ExportedType; 16 | -------------------------------------------------------------------------------- /test_files/typedef.untyped/typedef.ts: -------------------------------------------------------------------------------- 1 | type MyType = number; 2 | var y: MyType = 3; 3 | 4 | type Recursive = {value: number, next: Recursive}; 5 | 6 | export type ExportedType = string; 7 | -------------------------------------------------------------------------------- /test_files/typedef/typedef.ts: -------------------------------------------------------------------------------- 1 | type MyType = number; 2 | var y: MyType = 3; 3 | 4 | export type Recursive = {value: number, next: Recursive}; 5 | 6 | export type ExportedType = string; 7 | 8 | // tsickle introduces aliases when defining local typedefs. Make sure that the typedef can still be 9 | // used before its definition, because local typedefs are resolved to their underlying type when 10 | // emitting types. 11 | const useTypedefBeforeDefinition: UsedBeforeDefinition = 1; 12 | export type UsedBeforeDefinition = number; 13 | -------------------------------------------------------------------------------- /test_files/typeof_namespace/dtsdiagnostics.txt: -------------------------------------------------------------------------------- 1 | test_files/typeof_namespace/exported_namespace.d.ts(6,1): warning TS0: anonymous type has no symbol 2 | -------------------------------------------------------------------------------- /test_files/typeof_namespace/exported_namespace.d.ts: -------------------------------------------------------------------------------- 1 | declare namespace fooNs { 2 | const prop: string; 3 | } 4 | 5 | // TODO: b/280338932 - Emits {?}, but should emit {typeof test_files$...namespace.foo} 6 | export type foo = typeof fooNs; 7 | -------------------------------------------------------------------------------- /test_files/typeof_namespace/externs.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @externs 3 | * @suppress {checkTypes,const,duplicate,missingOverride} 4 | */ 5 | // NOTE: generated by tsickle, do not edit. 6 | // Generated from: test_files/typeof_namespace/exported_namespace.d.ts 7 | /** @const */ 8 | var test_files$typeof_namespace$exported_namespace = {}; 9 | /** @const */ 10 | test_files$typeof_namespace$exported_namespace.fooNs = {}; 11 | /** @type {string} */ 12 | test_files$typeof_namespace$exported_namespace.fooNs.prop; 13 | 14 | /** @typedef {?} */ 15 | test_files$typeof_namespace$exported_namespace.foo; 16 | -------------------------------------------------------------------------------- /test_files/underscore/export_underscore.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview added by tsickle 3 | * Generated from: test_files/underscore/export_underscore.ts 4 | */ 5 | goog.module('test_files.underscore.export_underscore'); 6 | var module = module || { id: 'test_files/underscore/export_underscore.ts' }; 7 | goog.require('tslib'); 8 | /** @type {number} */ 9 | exports.__test = 1; 10 | -------------------------------------------------------------------------------- /test_files/underscore/export_underscore.ts: -------------------------------------------------------------------------------- 1 | export var __test = 1; 2 | 3 | -------------------------------------------------------------------------------- /test_files/underscore/externs.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @externs 3 | * @suppress {checkTypes,const,duplicate,missingOverride} 4 | */ 5 | // NOTE: generated by tsickle, do not edit. 6 | // Generated from: test_files/underscore/underscore.ts 7 | /** @const */ 8 | var test_files$underscore$underscore = {}; 9 | /** @const */ 10 | var __NS = {}; 11 | /** @type {number} */ 12 | __NS.__ns1; 13 | -------------------------------------------------------------------------------- /test_files/use_closure_externs/externs.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @externs 3 | * @suppress {checkTypes,const,duplicate,missingOverride} 4 | */ 5 | // NOTE: generated by tsickle, do not edit. 6 | // Generated from: test_files/use_closure_externs/use_closure_externs_decl.d.ts 7 | /** @type {string} */ 8 | ImportMeta.prototype.url; 9 | -------------------------------------------------------------------------------- /test_files/use_closure_externs/use_closure_externs.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview A source file that uses types that are used in .d.ts files, but 3 | * that are not available or use different names in Closure's externs. 4 | * @suppress {checkTypes} 5 | */ 6 | 7 | let x: NodeListOf = document.getElementsByName('p'); 8 | console.log(x); 9 | 10 | const res: RegExpExecArray|null = /asd/.exec('asd asd')!; 11 | console.log(res); 12 | let a: ReadonlyArray = ['']; 13 | let m: ReadonlyMap = new Map(); 14 | let s: ReadonlySet = new Set(); 15 | 16 | export {}; 17 | -------------------------------------------------------------------------------- /test_files/use_closure_externs/use_closure_externs_decl.d.ts: -------------------------------------------------------------------------------- 1 | interface ImportMeta { 2 | url: string; 3 | } 4 | -------------------------------------------------------------------------------- /test_files/variables/variables.ts: -------------------------------------------------------------------------------- 1 | export {}; 2 | 3 | var v1: string; 4 | var v2: string, v3: number; 5 | 6 | // Tests that tsickle emits a precise type for the inferred anonymous type of `inferred`. 7 | 8 | const inferred = {a: 1, b: [{c: '2'}]}; 9 | 10 | export const v4 = 1; 11 | export let v5: string, v6 = 1; 12 | 13 | let v7 = 1, v8 = 1; 14 | -------------------------------------------------------------------------------- /third_party/tslib/README.google: -------------------------------------------------------------------------------- 1 | URL: https://github.com/Microsoft/tslib 2 | License: Apache 2.0 3 | Description: 4 | tslib.js contains a version of the 'tslib' library, modified to work with 5 | the Closure compiler. 6 | 7 | When building using tsickle, we pass --importHelpers to the TypeScript compiler 8 | so it uses this module instead. 9 | -------------------------------------------------------------------------------- /third_party/tslib/externs.js: -------------------------------------------------------------------------------- 1 | /** @externs */ 2 | 3 | Symbol.asyncIterator; 4 | --------------------------------------------------------------------------------