Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the 'awaited' type operator #35998

Merged
merged 25 commits into from
Mar 20, 2020
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
1ffda9f
Add the 'awaited' type operator
rbuckton Jan 4, 2020
a981148
Merge branch 'master' into awaitedType2
rbuckton Feb 17, 2020
e7174b1
Add script to manually add reviewers to a PR when GH 'Suggested Revie…
rbuckton Feb 17, 2020
65c7377
Fix lint error in review script
rbuckton Feb 24, 2020
7e57fed
Merge branch 'master' into awaitedType2
rbuckton Feb 28, 2020
8ccb983
Only defer generic awaited type for possible thenable
rbuckton Mar 2, 2020
7ea8940
Merge branch 'master' into awaitedType2
rbuckton Mar 2, 2020
624db27
Add variance-like behavior for awaited
rbuckton Mar 4, 2020
95d7316
Merge branch 'master' into awaitedType2
rbuckton Mar 10, 2020
d9ff357
Switch awaited type params to 'unreliable' variance
rbuckton Mar 10, 2020
a980ffa
fix typo in inferTypes
rbuckton Mar 11, 2020
eaff435
Merge branch 'master' into awaitedType2
rbuckton Mar 16, 2020
17d7981
LKG without syntax in lib
rbuckton Mar 16, 2020
53e0aaa
LKG with new syntax in lib
rbuckton Mar 16, 2020
3164a0c
Add 'strictAwaitedTypes' flag
rbuckton Mar 17, 2020
8a5ed7f
Merge branch 'master' into awaitedType2
rbuckton Mar 17, 2020
ec879a5
Treat strictAwaitedTypes as strict-mode flag
rbuckton Mar 17, 2020
76ae7c8
Rename TAll, remove duplicate definition of 'race'
rbuckton Mar 17, 2020
bc83e41
Apply suggestions from code review
rbuckton Mar 18, 2020
a9aa2fd
Merge branch 'master' into awaitedType2
rbuckton Mar 18, 2020
a005b9c
Fix inference priority
rbuckton Mar 19, 2020
8bbcefd
Update comment to isGenericAwaitableType
rbuckton Mar 19, 2020
04c3b6c
Add overloads for then/catch to Promise
rbuckton Mar 20, 2020
5abdee7
Add inference heuristic for T | PromiseLike<T> (for any PromiseLike)
rbuckton Mar 20, 2020
b9f29c7
Remove strictAwaitedTypes flag
rbuckton Mar 20, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 9 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
/built/local/**
/tests/**
/lib/**
/src/lib/*.generated.d.ts
/src/lib/*.generated.d.ts

# TODO: Remove the following once typescript-eslint supports `awaited`:
/src/lib/es5.d.ts
/src/lib/es2015.iterable.d.ts
/src/lib/es2015.promise.d.ts
/src/lib/es2018.promise.d.ts
/src/lib/es2020.promise.d.ts
/src/lib/esnext.promise.d.ts
9 changes: 7 additions & 2 deletions lib/cs/diagnosticMessages.generated.json
Original file line number Diff line number Diff line change
Expand Up @@ -758,10 +758,12 @@
"Only_amd_and_system_modules_are_supported_alongside_0_6082": "Spolu s --{0} se podporují jenom moduly amd a system.",
"Only_emit_d_ts_declaration_files_6014": "Bude vydávat jen soubory deklarací .d.ts.",
"Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_clas_9002": "V klauzuli třídy extends se aktuálně podporují jenom identifikátory nebo kvalifikované názvy s volitelnými argumenty typu.",
"Only_named_exports_may_use_export_type_1383": "Jenom pojmenované exporty mohou používat typ exportu.",
"Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword_2340": "Prostřednictvím klíčového slova super jsou přístupné jenom veřejné a chráněné metody základní třídy.",
"Operator_0_cannot_be_applied_to_type_1_2736": "Operátor {0} se nedá použít na typ {1}.",
"Operator_0_cannot_be_applied_to_types_1_and_2_2365": "Operátor {0} nejde použít u typů {1} a {2}.",
"Option_0_can_only_be_specified_in_tsconfig_json_file_6064": "Možnost {0} je možné zadat jenom v souboru tsconfig.json.",
"Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_false_or_null_on_command_line_6230": "Možnost {0} jde zadat jenom v souboru tsconfig.json nebo nastavit na příkazovém řádku na hodnotu false nebo null.",
"Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_null_on_command_line_6064": "Možnost {0} jde zadat jenom v souboru tsconfig.json nebo nastavit na příkazovém řádku na hodnotu null.",
"Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided_5051": "Možnost {0} jde použít jenom při zadání možnosti --inlineSourceMap nebo možnosti --sourceMap.",
"Option_0_cannot_be_specified_when_option_target_is_ES3_5048": "Když je možnost target nastavená na ES3, možnost {0} se nedá zadat.",
"Option_0_cannot_be_specified_with_option_1_5053": "Možnosti {0} a {1} nejde zadat zároveň.",
Expand Down Expand Up @@ -1035,7 +1037,7 @@
"Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object_2470": "Odkaz Symbol neodkazuje na globální objekt konstruktoru Symbol.",
"Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_supp_6228": "Synchronně volat zpětná volání a aktualizovat stav sledování adresářů na platformách, které nepodporují nativně rekurzivní sledování",
"Syntax_Colon_0_6023": "Syntaxe: {0}",
"Tag_0_expects_at_least_1_arguments_but_the_JSX_factory_2_provides_at_most_3_6229": "Tag '{0}' expects at least '{1}' arguments, but the JSX factory '{2}' provides at most '{3}'.",
"Tag_0_expects_at_least_1_arguments_but_the_JSX_factory_2_provides_at_most_3_6229": "Značka {0} očekává nejmíň {1} argumentů, ale objekt pro vytváření JSX {2} poskytuje maximálně {3}.",
"Tagged_template_expressions_are_not_permitted_in_an_optional_chain_1358": "Označené výrazy šablony se v nepovinném řetězu nepovolují.",
"The_0_modifier_can_only_be_used_in_TypeScript_files_8009": "Modifikátor {0} se dá používat jen v typescriptových souborech.",
"The_0_operator_cannot_be_applied_to_type_symbol_2469": "Operátor {0} nejde použít u typu symbol.",
Expand Down Expand Up @@ -1180,6 +1182,7 @@
"Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member_1320": "Typ operandu await musí být buď platný příslib, nebo nesmí obsahovat člen then, který se dá volat.",
"Type_of_computed_property_s_value_is_0_which_is_not_assignable_to_type_1_2418": "Typ hodnoty počítané vlastnosti je {0} a nedá se přiřadit do typu {1}.",
"Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_con_1322": "Typ iterovaných elementů yield* musí být buď platný příslib, nebo nesmí obsahovat člen then, který se dá volat.",
"Type_of_property_0_circularly_references_itself_in_mapped_type_1_2615": "Typ vlastnosti {0} cyklicky odkazuje sám na sebe v mapovaném typu {1}.",
"Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_cal_1321": "Typ operandu yield v asynchronním generátoru musí být buď platný příslib, nebo nesmí obsahovat člen then, který se dá volat.",
"Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cau_7038": "Typ pochází z tohoto importu. Import stylu oboru názvů není možné zavolat ani vytvořit a při běhu způsobí chybu. Zvažte možnost použít tady místo toho výchozí import nebo požadavek na import.",
"Type_parameter_0_has_a_circular_constraint_2313": "Parametr typu {0} má cyklické omezení.",
Expand Down Expand Up @@ -1237,6 +1240,7 @@
"Unterminated_template_literal_1160": "Neukončený literál šablony",
"Untyped_function_calls_may_not_accept_type_arguments_2347": "Volání netypové funkce nemusí přijmout argumenty typu.",
"Unused_label_7028": "Nepoužívaný popisek",
"Unused_ts_expect_error_directive_2578": "Nepoužitá direktiva @ts-expect-error",
"Updating_output_of_project_0_6373": "Aktualizuje se výstup projektu {0}...",
"Updating_output_timestamps_of_project_0_6359": "Aktualizují se výstupní časová razítka projektu {0}...",
"Updating_unchanged_output_timestamps_of_project_0_6371": "Aktualizují se nezměněná výstupní časová razítka projektu {0}...",
Expand Down Expand Up @@ -1340,6 +1344,7 @@
"file_6025": "soubor",
"get_and_set_accessor_must_have_the_same_this_type_2682": "Přístupové objekty get a set musí mít stejný typ this.",
"get_and_set_accessor_must_have_the_same_type_2380": "Přístupový objekt get a set musí obsahovat stejný typ.",
"get_and_set_accessors_cannot_declare_this_parameters_2784": "Přístupové objekty get a set nemůžou deklarovat parametry this.",
"implements_clause_already_seen_1175": "Klauzule implements se už jednou vyskytla.",
"implements_clauses_can_only_be_used_in_TypeScript_files_8005": "Klauzule implements se dají používat jen v typescriptových souborech.",
"import_can_only_be_used_in_TypeScript_files_8002": "import = se dá používat jen v typescriptových souborech.",
Expand Down
4 changes: 4 additions & 0 deletions lib/de/diagnosticMessages.generated.json
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,7 @@
"Only_amd_and_system_modules_are_supported_alongside_0_6082": "Nur die Module \"amd\" und \"system\" werden in Verbindung mit --{0} unterstützt.",
"Only_emit_d_ts_declaration_files_6014": "Geben Sie nur .d.ts-Deklarationsdateien aus.",
"Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_clas_9002": "Derzeit werden nur Bezeichner/qualifizierte Namen mit optionalen Typargumenten in den \"extends\"-Klauseln einer Klasse unterstützt.",
"Only_named_exports_may_use_export_type_1383": "\"Exporttyp\" kann nur von benannten Exporten verwendet werden.",
"Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword_2340": "Nur auf öffentliche und geschützte Methoden der Basisklasse kann über das Schlüsselwort \"super\" zugegriffen werden.",
"Operator_0_cannot_be_applied_to_type_1_2736": "Der Operator \"{0}\" kann nicht auf den Typ \"{1}\" angewendet werden.",
"Operator_0_cannot_be_applied_to_types_1_and_2_2365": "Der Operator \"{0}\" darf nicht auf die Typen \"{1}\" und \"{2}\" angewendet werden.",
Expand Down Expand Up @@ -1181,6 +1182,7 @@
"Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member_1320": "Der Typ des \"await\"-Operanden muss entweder eine gültige Zusage sein oder darf keinen aufrufbaren \"then\"-Member enthalten.",
"Type_of_computed_property_s_value_is_0_which_is_not_assignable_to_type_1_2418": "Der Typ des Werts der berechneten Eigenschaft lautet \"{0}\" und kann dem Typ \"{1}\" nicht zugewiesen werden.",
"Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_con_1322": "Der Typ iterierter Elemente eines \"yield*\"-Operanden muss entweder eine gültige Zusage sein oder darf keinen aufrufbaren \"then\"-Member enthalten.",
"Type_of_property_0_circularly_references_itself_in_mapped_type_1_2615": "Der Typ der Eigenschaft \"{0}\" verweist im zugeordneten Typ \"{1}\" auf sich selbst.",
"Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_cal_1321": "Der Typ eines \"yield\"-Operanden in einem asynchronen Generator muss entweder eine gültige Zusage sein oder darf keinen aufrufbaren \"then\"-Member enthalten.",
"Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cau_7038": "Der Typ stammt aus diesem Import. Ein Import im Namespacestil kann nicht aufgerufen oder erstellt werden und verursacht zur Laufzeit einen Fehler. Erwägen Sie hier stattdessen die Verwendung eines Standardimports oder die Verwendung von \"import require\".",
"Type_parameter_0_has_a_circular_constraint_2313": "Der Typparameter \"{0}\" weist eine zirkuläre Einschränkung auf.",
Expand Down Expand Up @@ -1238,6 +1240,7 @@
"Unterminated_template_literal_1160": "Nicht abgeschlossenes Vorlagenliteral.",
"Untyped_function_calls_may_not_accept_type_arguments_2347": "Nicht typisierte Funktionsaufrufe dürfen keine Typargumente annehmen.",
"Unused_label_7028": "Nicht verwendete Bezeichnung.",
"Unused_ts_expect_error_directive_2578": "Nicht verwendete @ts-expect-error-Direktive.",
"Updating_output_of_project_0_6373": "Ausgabe von Projekt \"{0}\" wird aktualisiert...",
"Updating_output_timestamps_of_project_0_6359": "Ausgabezeitstempel von Projekt \"{0}\" werden aktualisiert...",
"Updating_unchanged_output_timestamps_of_project_0_6371": "Unveränderte Ausgabezeitstempel von Projekt \"{0}\" werden aktualisiert...",
Expand Down Expand Up @@ -1341,6 +1344,7 @@
"file_6025": "Datei",
"get_and_set_accessor_must_have_the_same_this_type_2682": "Die get- und set-Accessoren müssen den gleichen this-Typ aufweisen.",
"get_and_set_accessor_must_have_the_same_type_2380": "Die get- und set-Zugriffsmethoden müssen den gleichen Typ aufweisen.",
"get_and_set_accessors_cannot_declare_this_parameters_2784": "get- und set-Zugriffsmethoden können keine this-Parameter deklarieren.",
"implements_clause_already_seen_1175": "Die implements-Klausel ist bereits vorhanden.",
"implements_clauses_can_only_be_used_in_TypeScript_files_8005": "implements-Klauseln können nur in TypeScript-Dateien verwendet werden.",
"import_can_only_be_used_in_TypeScript_files_8002": "\"import... =\" kann nur in TypeScript-Dateien verwendet werden.",
Expand Down
9 changes: 7 additions & 2 deletions lib/es/diagnosticMessages.generated.json
Original file line number Diff line number Diff line change
Expand Up @@ -758,10 +758,12 @@
"Only_amd_and_system_modules_are_supported_alongside_0_6082": "Solo los módulos \"amd\" y \"system\" se admiten con --{0}.",
"Only_emit_d_ts_declaration_files_6014": "Solo deben emitirse archivos de declaración \".d.ts\".",
"Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_clas_9002": "Actualmente, solo se admiten identificadores o nombres completos con argumentos de tipo opcional en la cláusula \"extends\" de una clase.",
"Only_named_exports_may_use_export_type_1383": "Solo las exportaciones con nombre pueden usar \"tipo de exportación\".",
"Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword_2340": "Solo es posible tener acceso a los métodos públicos y protegidos de la clase base mediante la palabra clave \"super\".",
"Operator_0_cannot_be_applied_to_type_1_2736": "El operador \"{0}\" no se puede aplicar al tipo \"{1}\".",
"Operator_0_cannot_be_applied_to_types_1_and_2_2365": "El operador '{0}' no se puede aplicar a los tipos '{1}' y '{2}'.",
"Option_0_can_only_be_specified_in_tsconfig_json_file_6064": "La opción '{0}' solo se puede especificar en el archivo 'tsconfig.json'.",
"Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_false_or_null_on_command_line_6230": "La opción \"{0}\" solo puede especificarse en el archivo \"tsconfig.json\" o establecerse en \"false\" o \"null\" en la línea de comandos.",
"Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_null_on_command_line_6064": "La opción \"{0}\" solo puede especificarse en el archivo \"tsconfig.json\" o establecerse en \"null\" en la línea de comandos.",
"Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided_5051": "La opción '{0}' solo se puede usar cuando se proporciona '--inlineSourceMap' o '--sourceMap'.",
"Option_0_cannot_be_specified_when_option_target_is_ES3_5048": "No se puede especificar la opción \"{0}\" cuando la opción \"target\" es \"ES3\".",
"Option_0_cannot_be_specified_with_option_1_5053": "La opción '{0}' no se puede especificar con la opción '{1}'.",
Expand Down Expand Up @@ -1035,7 +1037,7 @@
"Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object_2470": "La referencia \"Symbol\" no hace referencia al objeto de constructor Symbol global.",
"Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_supp_6228": "Llame a las devoluciones de llamada de forma sincrónica y actualice el estado de los monitores de directorio en las plataformas que no admitan la supervisión recursiva de forma nativa.",
"Syntax_Colon_0_6023": "Sintaxis: {0}",
"Tag_0_expects_at_least_1_arguments_but_the_JSX_factory_2_provides_at_most_3_6229": "Tag '{0}' expects at least '{1}' arguments, but the JSX factory '{2}' provides at most '{3}'.",
"Tag_0_expects_at_least_1_arguments_but_the_JSX_factory_2_provides_at_most_3_6229": "La etiqueta \"{0}\" espera al menos \"{1}\" argumentos, pero el generador de JSX \"{2}\" proporciona como máximo \"{3}\".",
"Tagged_template_expressions_are_not_permitted_in_an_optional_chain_1358": "No se permiten expresiones de plantilla con etiquetas en una cadena opcional.",
"The_0_modifier_can_only_be_used_in_TypeScript_files_8009": "El modificador \"{0}\" solo se puede usar en los archivos TypeScript.",
"The_0_operator_cannot_be_applied_to_type_symbol_2469": "El operador '{0}' no se puede aplicar al tipo \"symbol\".",
Expand Down Expand Up @@ -1180,6 +1182,7 @@
"Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member_1320": "El tipo de operando \"await\" debe ser una promesa válida o no debe contener un miembro \"then\" invocable.",
"Type_of_computed_property_s_value_is_0_which_is_not_assignable_to_type_1_2418": "El tipo de valor de la propiedad calculada es \"{0}\", que no se puede asignar al tipo \"{1}\".",
"Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_con_1322": "El tipo de elementos iterados de un operando \"yield*\" debe ser una promesa válida o no debe contener un miembro \"then\" invocable.",
"Type_of_property_0_circularly_references_itself_in_mapped_type_1_2615": "El tipo de propiedad \"{0}\" hace referencia circular a sí misma en el tipo asignado \"{1}\".",
"Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_cal_1321": "El tipo de operando \"yield\" en un generador asincrónico debe ser una promesa válida o no debe contener un miembro \"then\" invocable.",
"Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cau_7038": "El tipo se origina en esta importación. No se puede construir ni llamar a una importación de estilo de espacio de nombres y provocará un error en tiempo de ejecución. Considere la posibilidad de usar una importación predeterminada o requerir la importación aquí.",
"Type_parameter_0_has_a_circular_constraint_2313": "El parámetro de tipo '{0}' tiene una restricción circular.",
Expand Down Expand Up @@ -1237,6 +1240,7 @@
"Unterminated_template_literal_1160": "Literal de plantilla sin terminar.",
"Untyped_function_calls_may_not_accept_type_arguments_2347": "Las llamadas a función sin tipo no pueden aceptar argumentos de tipo.",
"Unused_label_7028": "Etiqueta no usada.",
"Unused_ts_expect_error_directive_2578": "Directiva \"@ts-expect-error\" no usada.",
"Updating_output_of_project_0_6373": "Actualizando la salida del proyecto \"{0}\"...",
"Updating_output_timestamps_of_project_0_6359": "Actualizando las marcas de hora de salida del proyecto \"{0}\"...",
"Updating_unchanged_output_timestamps_of_project_0_6371": "Actualizando las marcas de hora de salida no modificadas del proyecto \"{0}\"...",
Expand Down Expand Up @@ -1340,6 +1344,7 @@
"file_6025": "archivo",
"get_and_set_accessor_must_have_the_same_this_type_2682": "Los descriptores de acceso 'get' y 'set' deben tener el mismo tipo 'this'.",
"get_and_set_accessor_must_have_the_same_type_2380": "Los descriptores de acceso \"get\" y \"set\" deben tener el mismo tipo.",
"get_and_set_accessors_cannot_declare_this_parameters_2784": "Los descriptores de acceso \"get\" y \"set\" no pueden declarar parámetros \"this\".",
"implements_clause_already_seen_1175": "La cláusula \"implements\" ya se ha visto.",
"implements_clauses_can_only_be_used_in_TypeScript_files_8005": "Las cláusulas \"implements\" solo se pueden usar en los archivos TypeScript.",
"import_can_only_be_used_in_TypeScript_files_8002": "\"import ... =\" solo se puede usar en los archivos TypeScript.",
Expand Down