From c89a80736e9d7e1ef7633f493a761414237f60ab Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Thu, 27 Dec 2018 19:46:21 +0900 Subject: [PATCH 01/34] add ES2019 target --- src/compiler/binder.ts | 2 +- src/compiler/commandLineParser.ts | 3 +- src/compiler/diagnosticMessages.json | 2 +- src/compiler/transformer.ts | 4 ++ src/compiler/transformers/es2019.ts | 37 ++++++++++++++ src/compiler/transformers/esnext.ts | 13 ----- src/compiler/tsconfig.json | 1 + src/compiler/types.ts | 51 ++++++++++--------- src/compiler/utilities.ts | 1 + .../unittests/config/commandLineParsing.ts | 2 +- .../config/convertCompilerOptionsFromJson.ts | 2 +- .../reference/api/tsserverlibrary.d.ts | 5 +- tests/baselines/reference/api/typescript.d.ts | 5 +- ...xt.js => emitter.noCatchBinding.es2019.js} | 7 +-- .../emitter.noCatchBinding.es2019.symbols | 11 ++++ ...es => emitter.noCatchBinding.es2019.types} | 3 +- .../emitter.noCatchBinding.esnext.symbols | 10 ---- .../tsconfig.json | 2 +- .../tsconfig.json | 2 +- .../tsconfig.json | 2 +- .../tsconfig.json | 2 +- .../tsconfig.json | 2 +- .../tsconfig.json | 2 +- .../tsconfig.json | 2 +- .../tsconfig.json | 2 +- .../tsconfig.json | 2 +- .../emitter.noCatchBinding.es2019.ts} | 4 +- 27 files changed, 110 insertions(+), 71 deletions(-) create mode 100644 src/compiler/transformers/es2019.ts rename tests/baselines/reference/{emitter.noCatchBinding.esnext.js => emitter.noCatchBinding.es2019.js} (73%) create mode 100644 tests/baselines/reference/emitter.noCatchBinding.es2019.symbols rename tests/baselines/reference/{emitter.noCatchBinding.esnext.types => emitter.noCatchBinding.es2019.types} (57%) delete mode 100644 tests/baselines/reference/emitter.noCatchBinding.esnext.symbols rename tests/cases/conformance/emitter/{esnext/noCatchBinding/emitter.noCatchBinding.esnext.ts => es2019/noCatchBinding/emitter.noCatchBinding.es2019.ts} (85%) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 7216af4e817..79fef8b4e61 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -3259,7 +3259,7 @@ namespace ts { let transformFlags = subtreeFlags; if (!node.variableDeclaration) { - transformFlags |= TransformFlags.AssertESNext; + transformFlags |= TransformFlags.AssertES2019; } else if (isBindingPattern(node.variableDeclaration.name)) { transformFlags |= TransformFlags.AssertES2015; diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 43275605e23..053e09d48db 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -197,6 +197,7 @@ namespace ts { es2016: ScriptTarget.ES2016, es2017: ScriptTarget.ES2017, es2018: ScriptTarget.ES2018, + es2019: ScriptTarget.ES2019, esnext: ScriptTarget.ESNext, }), affectsSourceFile: true, @@ -204,7 +205,7 @@ namespace ts { paramType: Diagnostics.VERSION, showInSimplifiedHelpView: true, category: Diagnostics.Basic_Options, - description: Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_ES2018_or_ESNEXT, + description: Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_ES2018_ES2019_or_ESNEXT, }, { name: "module", diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index b0dfb85ce6d..ee2d3532e50 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -3065,7 +3065,7 @@ "category": "Message", "code": 6014 }, - "Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'.": { + "Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'.": { "category": "Message", "code": 6015 }, diff --git a/src/compiler/transformer.ts b/src/compiler/transformer.ts index fdcaadb4040..0d04b5667a9 100644 --- a/src/compiler/transformer.ts +++ b/src/compiler/transformer.ts @@ -42,6 +42,10 @@ namespace ts { transformers.push(transformESNext); } + if (languageVersion < ScriptTarget.ES2019) { + transformers.push(transformES2019); + } + if (languageVersion < ScriptTarget.ES2017) { transformers.push(transformES2017); } diff --git a/src/compiler/transformers/es2019.ts b/src/compiler/transformers/es2019.ts new file mode 100644 index 00000000000..7dfd17481eb --- /dev/null +++ b/src/compiler/transformers/es2019.ts @@ -0,0 +1,37 @@ +/*@internal*/ +namespace ts { + export function transformES2019(context: TransformationContext) { + return chainBundle(transformSourceFile); + + function transformSourceFile(node: SourceFile) { + if (node.isDeclarationFile) { + return node; + } + + return visitEachChild(node, visitor, context); + } + + function visitor(node: Node): VisitResult { + if ((node.transformFlags & TransformFlags.ContainsES2019) === 0) { + return node; + } + switch (node.kind) { + case SyntaxKind.CatchClause: + return visitCatchClause(node as CatchClause); + default: + return visitEachChild(node, visitor, context); + } + } + + function visitCatchClause(node: CatchClause): CatchClause { + if (!node.variableDeclaration) { + return updateCatchClause( + node, + createVariableDeclaration(createTempVariable(/*recordTempVariable*/ undefined)), + visitNode(node.block, visitor, isBlock) + ); + } + return visitEachChild(node, visitor, context); + } + } +} diff --git a/src/compiler/transformers/esnext.ts b/src/compiler/transformers/esnext.ts index cd62cca2c9d..a19396ec63c 100644 --- a/src/compiler/transformers/esnext.ts +++ b/src/compiler/transformers/esnext.ts @@ -105,8 +105,6 @@ namespace ts { return visitExpressionStatement(node as ExpressionStatement); case SyntaxKind.ParenthesizedExpression: return visitParenthesizedExpression(node as ParenthesizedExpression, noDestructuringValue); - case SyntaxKind.CatchClause: - return visitCatchClause(node as CatchClause); case SyntaxKind.PropertyAccessExpression: if (capturedSuperProperties && isPropertyAccessExpression(node) && node.expression.kind === SyntaxKind.SuperKeyword) { capturedSuperProperties.set(node.name.escapedText, true); @@ -249,17 +247,6 @@ namespace ts { return visitEachChild(node, noDestructuringValue ? visitorNoDestructuringValue : visitor, context); } - function visitCatchClause(node: CatchClause): CatchClause { - if (!node.variableDeclaration) { - return updateCatchClause( - node, - createVariableDeclaration(createTempVariable(/*recordTempVariable*/ undefined)), - visitNode(node.block, visitor, isBlock) - ); - } - return visitEachChild(node, visitor, context); - } - /** * Visits a BinaryExpression that contains a destructuring assignment. * diff --git a/src/compiler/tsconfig.json b/src/compiler/tsconfig.json index c41f47f3c4a..e5f6e9f83ba 100644 --- a/src/compiler/tsconfig.json +++ b/src/compiler/tsconfig.json @@ -30,6 +30,7 @@ "transformers/destructuring.ts", "transformers/ts.ts", "transformers/es2017.ts", + "transformers/es2019.ts", "transformers/esnext.ts", "transformers/jsx.ts", "transformers/es2016.ts", diff --git a/src/compiler/types.ts b/src/compiler/types.ts index b70b4e4d3d0..a4285cfd775 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -4646,7 +4646,8 @@ namespace ts { ES2016 = 3, ES2017 = 4, ES2018 = 5, - ESNext = 6, + ES2019 = 6, + ESNext = 7, JSON = 100, Latest = ESNext, } @@ -5034,32 +5035,33 @@ namespace ts { ContainsTypeScript = 1 << 1, ContainsJsx = 1 << 2, ContainsESNext = 1 << 3, - ContainsES2017 = 1 << 4, - ContainsES2016 = 1 << 5, - ES2015 = 1 << 6, - ContainsES2015 = 1 << 7, - Generator = 1 << 8, - ContainsGenerator = 1 << 9, - DestructuringAssignment = 1 << 10, - ContainsDestructuringAssignment = 1 << 11, + ContainsES2019 = 1 << 4, + ContainsES2017 = 1 << 5, + ContainsES2016 = 1 << 6, + ES2015 = 1 << 7, + ContainsES2015 = 1 << 8, + Generator = 1 << 9, + ContainsGenerator = 1 << 10, + DestructuringAssignment = 1 << 11, + ContainsDestructuringAssignment = 1 << 12, // Markers // - Flags used to indicate that a subtree contains a specific transformation. - ContainsTypeScriptClassSyntax = 1 << 12, // Decorators, Property Initializers, Parameter Property Initializers - ContainsLexicalThis = 1 << 13, - ContainsCapturedLexicalThis = 1 << 14, - ContainsLexicalThisInComputedPropertyName = 1 << 15, - ContainsDefaultValueAssignments = 1 << 16, - ContainsRestOrSpread = 1 << 17, - ContainsObjectRestOrSpread = 1 << 18, - ContainsComputedPropertyName = 1 << 19, - ContainsBlockScopedBinding = 1 << 20, - ContainsBindingPattern = 1 << 21, - ContainsYield = 1 << 22, - ContainsHoistedDeclarationOrCompletion = 1 << 23, - ContainsDynamicImport = 1 << 24, - Super = 1 << 25, - ContainsSuper = 1 << 26, + ContainsTypeScriptClassSyntax = 1 << 13, // Decorators, Property Initializers, Parameter Property Initializers + ContainsLexicalThis = 1 << 14, + ContainsCapturedLexicalThis = 1 << 15, + ContainsLexicalThisInComputedPropertyName = 1 << 16, + ContainsDefaultValueAssignments = 1 << 17, + ContainsRestOrSpread = 1 << 18, + ContainsObjectRestOrSpread = 1 << 19, + ContainsComputedPropertyName = 1 << 20, + ContainsBlockScopedBinding = 1 << 21, + ContainsBindingPattern = 1 << 22, + ContainsYield = 1 << 23, + ContainsHoistedDeclarationOrCompletion = 1 << 24, + ContainsDynamicImport = 1 << 25, + Super = 1 << 26, + ContainsSuper = 1 << 27, // Please leave this as 1 << 29. // It is the maximum bit we can set before we outgrow the size of a v8 small integer (SMI) on an x86 system. @@ -5071,6 +5073,7 @@ namespace ts { AssertTypeScript = TypeScript | ContainsTypeScript, AssertJsx = ContainsJsx, AssertESNext = ContainsESNext, + AssertES2019 = ContainsES2019, AssertES2017 = ContainsES2017, AssertES2016 = ContainsES2016, AssertES2015 = ES2015 | ContainsES2015, diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 23c92216c56..357026d354f 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -4601,6 +4601,7 @@ namespace ts { switch (options.target) { case ScriptTarget.ESNext: return "lib.esnext.full.d.ts"; + case ScriptTarget.ES2019: case ScriptTarget.ES2018: return "lib.es2018.full.d.ts"; case ScriptTarget.ES2017: diff --git a/src/testRunner/unittests/config/commandLineParsing.ts b/src/testRunner/unittests/config/commandLineParsing.ts index 25fa3a45050..14639381a87 100644 --- a/src/testRunner/unittests/config/commandLineParsing.ts +++ b/src/testRunner/unittests/config/commandLineParsing.ts @@ -161,7 +161,7 @@ namespace ts { start: undefined, length: undefined, }, { - messageText: "Argument for '--target' option must be: 'es3', 'es5', 'es6', 'es2015', 'es2016', 'es2017', 'es2018', 'esnext'.", + messageText: "Argument for '--target' option must be: 'es3', 'es5', 'es6', 'es2015', 'es2016', 'es2017', 'es2018', 'es2019', 'esnext'.", category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category, code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code, diff --git a/src/testRunner/unittests/config/convertCompilerOptionsFromJson.ts b/src/testRunner/unittests/config/convertCompilerOptionsFromJson.ts index 318bc0ceb26..e28acd241b7 100644 --- a/src/testRunner/unittests/config/convertCompilerOptionsFromJson.ts +++ b/src/testRunner/unittests/config/convertCompilerOptionsFromJson.ts @@ -238,7 +238,7 @@ namespace ts { file: undefined, start: 0, length: 0, - messageText: "Argument for '--target' option must be: 'es3', 'es5', 'es6', 'es2015', 'es2016', 'es2017', 'es2018', 'esnext'.", + messageText: "Argument for '--target' option must be: 'es3', 'es5', 'es6', 'es2015', 'es2016', 'es2017', 'es2018', 'es2019', 'esnext'.", code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code, category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category }] diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 91f492ddd1d..d8ad3955edc 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -2566,9 +2566,10 @@ declare namespace ts { ES2016 = 3, ES2017 = 4, ES2018 = 5, - ESNext = 6, + ES2019 = 6, + ESNext = 7, JSON = 100, - Latest = 6 + Latest = 7 } enum LanguageVariant { Standard = 0, diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 0e693f698f2..7465a4500cc 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -2566,9 +2566,10 @@ declare namespace ts { ES2016 = 3, ES2017 = 4, ES2018 = 5, - ESNext = 6, + ES2019 = 6, + ESNext = 7, JSON = 100, - Latest = 6 + Latest = 7 } enum LanguageVariant { Standard = 0, diff --git a/tests/baselines/reference/emitter.noCatchBinding.esnext.js b/tests/baselines/reference/emitter.noCatchBinding.es2019.js similarity index 73% rename from tests/baselines/reference/emitter.noCatchBinding.esnext.js rename to tests/baselines/reference/emitter.noCatchBinding.es2019.js index f47a947ca1a..c33657960de 100644 --- a/tests/baselines/reference/emitter.noCatchBinding.esnext.js +++ b/tests/baselines/reference/emitter.noCatchBinding.es2019.js @@ -1,13 +1,14 @@ -//// [emitter.noCatchBinding.esnext.ts] +//// [emitter.noCatchBinding.es2019.ts] function f() { try { } catch { } try { } catch { try { } catch { } } try { } catch { } finally { } -} +} -//// [emitter.noCatchBinding.esnext.js] + +//// [emitter.noCatchBinding.es2019.js] function f() { try { } catch { } diff --git a/tests/baselines/reference/emitter.noCatchBinding.es2019.symbols b/tests/baselines/reference/emitter.noCatchBinding.es2019.symbols new file mode 100644 index 00000000000..54dc63597d4 --- /dev/null +++ b/tests/baselines/reference/emitter.noCatchBinding.es2019.symbols @@ -0,0 +1,11 @@ +=== tests/cases/conformance/emitter/es2019/noCatchBinding/emitter.noCatchBinding.es2019.ts === +function f() { +>f : Symbol(f, Decl(emitter.noCatchBinding.es2019.ts, 0, 0)) + + try { } catch { } + try { } catch { + try { } catch { } + } + try { } catch { } finally { } +} + diff --git a/tests/baselines/reference/emitter.noCatchBinding.esnext.types b/tests/baselines/reference/emitter.noCatchBinding.es2019.types similarity index 57% rename from tests/baselines/reference/emitter.noCatchBinding.esnext.types rename to tests/baselines/reference/emitter.noCatchBinding.es2019.types index 70c2b728a5d..79647b35dc4 100644 --- a/tests/baselines/reference/emitter.noCatchBinding.esnext.types +++ b/tests/baselines/reference/emitter.noCatchBinding.es2019.types @@ -1,4 +1,4 @@ -=== tests/cases/conformance/emitter/esnext/noCatchBinding/emitter.noCatchBinding.esnext.ts === +=== tests/cases/conformance/emitter/es2019/noCatchBinding/emitter.noCatchBinding.es2019.ts === function f() { >f : () => void @@ -8,3 +8,4 @@ function f() { } try { } catch { } finally { } } + diff --git a/tests/baselines/reference/emitter.noCatchBinding.esnext.symbols b/tests/baselines/reference/emitter.noCatchBinding.esnext.symbols deleted file mode 100644 index 91242f5b01c..00000000000 --- a/tests/baselines/reference/emitter.noCatchBinding.esnext.symbols +++ /dev/null @@ -1,10 +0,0 @@ -=== tests/cases/conformance/emitter/esnext/noCatchBinding/emitter.noCatchBinding.esnext.ts === -function f() { ->f : Symbol(f, Decl(emitter.noCatchBinding.esnext.ts, 0, 0)) - - try { } catch { } - try { } catch { - try { } catch { } - } - try { } catch { } finally { } -} diff --git a/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json b/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json index ac5ebf02160..b7f98718a83 100644 --- a/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { /* Basic Options */ - "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */ + "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */ "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ // "lib": [], /* Specify library files to be included in the compilation. */ // "allowJs": true, /* Allow javascript files to be compiled. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with advanced options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with advanced options/tsconfig.json index 0e4adce88d2..452ec708540 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with advanced options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with advanced options/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { /* Basic Options */ - "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */ + "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */ "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ // "lib": [], /* Specify library files to be included in the compilation. */ // "allowJs": true, /* Allow javascript files to be compiled. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json index 211bcb97d5f..edd4a72bd8a 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { /* Basic Options */ - "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */ + "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */ "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ // "lib": [], /* Specify library files to be included in the compilation. */ // "allowJs": true, /* Allow javascript files to be compiled. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json index 8c3d7be38ec..d6edb9d5c68 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { /* Basic Options */ - "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */ + "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */ "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ // "lib": [], /* Specify library files to be included in the compilation. */ // "allowJs": true, /* Allow javascript files to be compiled. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json index b8dfce1ff43..ad38b2ad884 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { /* Basic Options */ - "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */ + "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */ "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ // "lib": [], /* Specify library files to be included in the compilation. */ // "allowJs": true, /* Allow javascript files to be compiled. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json index 60cccb8b3b3..b0107d9d742 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { /* Basic Options */ - "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */ + "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */ "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ "lib": ["es5","es2015.promise"], /* Specify library files to be included in the compilation. */ // "allowJs": true, /* Allow javascript files to be compiled. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json index ac5ebf02160..b7f98718a83 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { /* Basic Options */ - "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */ + "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */ "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ // "lib": [], /* Specify library files to be included in the compilation. */ // "allowJs": true, /* Allow javascript files to be compiled. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json index 81641589d59..8263ed18aae 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { /* Basic Options */ - "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */ + "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */ "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ "lib": ["es5","es2015.core"], /* Specify library files to be included in the compilation. */ // "allowJs": true, /* Allow javascript files to be compiled. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json index 826babfd625..69249714660 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { /* Basic Options */ - "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */ + "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */ "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ // "lib": [], /* Specify library files to be included in the compilation. */ // "allowJs": true, /* Allow javascript files to be compiled. */ diff --git a/tests/cases/conformance/emitter/esnext/noCatchBinding/emitter.noCatchBinding.esnext.ts b/tests/cases/conformance/emitter/es2019/noCatchBinding/emitter.noCatchBinding.es2019.ts similarity index 85% rename from tests/cases/conformance/emitter/esnext/noCatchBinding/emitter.noCatchBinding.esnext.ts rename to tests/cases/conformance/emitter/es2019/noCatchBinding/emitter.noCatchBinding.es2019.ts index 8e87b3c8c8f..d9dfb1bcd9a 100644 --- a/tests/cases/conformance/emitter/esnext/noCatchBinding/emitter.noCatchBinding.esnext.ts +++ b/tests/cases/conformance/emitter/es2019/noCatchBinding/emitter.noCatchBinding.es2019.ts @@ -1,8 +1,8 @@ -// @target: esnext +// @target: es2019 function f() { try { } catch { } try { } catch { try { } catch { } } try { } catch { } finally { } -} \ No newline at end of file +} From 1d8a2ea38c301f3ddda39aa4bdae8fe6d7c33ffe Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Sun, 6 Jan 2019 11:42:55 +0900 Subject: [PATCH 02/34] Symbol.prototype.description hit stage 4 --- src/compiler/commandLineParser.ts | 3 ++- src/compiler/utilities.ts | 1 + src/lib/es2019.d.ts | 2 ++ src/lib/es2019.full.d.ts | 5 +++++ .../{esnext.symbol.d.ts => es2019.symbol.d.ts} | 0 src/lib/esnext.d.ts | 3 +-- src/lib/libs.json | 4 +++- .../unittests/config/commandLineParsing.ts | 6 +++--- tests/baselines/reference/bigintIndex.symbols | 2 +- tests/baselines/reference/dynamicNames.symbols | 2 +- .../reference/dynamicNamesErrors.symbols | 8 ++++---- .../objectLiteralPropertyImplicitlyAny.symbols | 2 +- .../unionTypeWithIndexSignature.symbols | 2 +- .../baselines/reference/uniqueSymbols.symbols | 18 +++++++++--------- .../uniqueSymbolsDeclarations.symbols | 18 +++++++++--------- .../reference/uniqueSymbolsErrors.symbols | 2 +- 16 files changed, 44 insertions(+), 34 deletions(-) create mode 100644 src/lib/es2019.d.ts create mode 100644 src/lib/es2019.full.d.ts rename src/lib/{esnext.symbol.d.ts => es2019.symbol.d.ts} (100%) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 053e09d48db..69f829d0379 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -15,6 +15,7 @@ namespace ts { ["es2016", "lib.es2016.d.ts"], ["es2017", "lib.es2017.d.ts"], ["es2018", "lib.es2018.d.ts"], + ["es2019", "lib.es2019.d.ts"], ["esnext", "lib.esnext.d.ts"], // Host only ["dom", "lib.dom.d.ts"], @@ -41,8 +42,8 @@ namespace ts { ["es2018.intl", "lib.es2018.intl.d.ts"], ["es2018.promise", "lib.es2018.promise.d.ts"], ["es2018.regexp", "lib.es2018.regexp.d.ts"], + ["es2019.symbol", "lib.es2019.symbol.d.ts"], ["esnext.array", "lib.esnext.array.d.ts"], - ["esnext.symbol", "lib.esnext.symbol.d.ts"], ["esnext.asynciterable", "lib.esnext.asynciterable.d.ts"], ["esnext.intl", "lib.esnext.intl.d.ts"], ["esnext.bigint", "lib.esnext.bigint.d.ts"] diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 357026d354f..ca83129bb3f 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -4602,6 +4602,7 @@ namespace ts { case ScriptTarget.ESNext: return "lib.esnext.full.d.ts"; case ScriptTarget.ES2019: + return "lib.es2019.full.d.ts"; case ScriptTarget.ES2018: return "lib.es2018.full.d.ts"; case ScriptTarget.ES2017: diff --git a/src/lib/es2019.d.ts b/src/lib/es2019.d.ts new file mode 100644 index 00000000000..60b8787d587 --- /dev/null +++ b/src/lib/es2019.d.ts @@ -0,0 +1,2 @@ +/// +/// diff --git a/src/lib/es2019.full.d.ts b/src/lib/es2019.full.d.ts new file mode 100644 index 00000000000..2056578133e --- /dev/null +++ b/src/lib/es2019.full.d.ts @@ -0,0 +1,5 @@ +/// +/// +/// +/// +/// diff --git a/src/lib/esnext.symbol.d.ts b/src/lib/es2019.symbol.d.ts similarity index 100% rename from src/lib/esnext.symbol.d.ts rename to src/lib/es2019.symbol.d.ts diff --git a/src/lib/esnext.d.ts b/src/lib/esnext.d.ts index 45d7e1d96c9..6e73347bf3a 100644 --- a/src/lib/esnext.d.ts +++ b/src/lib/esnext.d.ts @@ -1,6 +1,5 @@ -/// +/// /// /// /// -/// /// diff --git a/src/lib/libs.json b/src/lib/libs.json index 3077181af6e..17b54324e9d 100644 --- a/src/lib/libs.json +++ b/src/lib/libs.json @@ -6,6 +6,7 @@ "es2016", "es2017", "es2018", + "es2019", "esnext", // Host only "dom.generated", @@ -32,10 +33,10 @@ "es2018.regexp", "es2018.promise", "es2018.intl", + "es2019.symbol", "esnext.asynciterable", "esnext.array", "esnext.bigint", - "esnext.symbol", "esnext.intl", // Default libraries "es5.full", @@ -43,6 +44,7 @@ "es2016.full", "es2017.full", "es2018.full", + "es2019.full", "esnext.full" ], "paths": { diff --git a/src/testRunner/unittests/config/commandLineParsing.ts b/src/testRunner/unittests/config/commandLineParsing.ts index 14639381a87..8d49fde6e42 100644 --- a/src/testRunner/unittests/config/commandLineParsing.ts +++ b/src/testRunner/unittests/config/commandLineParsing.ts @@ -57,7 +57,7 @@ namespace ts { assertParseResult(["--lib", "es5,invalidOption", "0.ts"], { errors: [{ - messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.", + messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.symbol', 'esnext.array', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.", category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category, code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code, file: undefined, @@ -259,7 +259,7 @@ namespace ts { assertParseResult(["--lib", "es5,", "es7", "0.ts"], { errors: [{ - messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.", + messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.symbol', 'esnext.array', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.", category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category, code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code, file: undefined, @@ -278,7 +278,7 @@ namespace ts { assertParseResult(["--lib", "es5, ", "es7", "0.ts"], { errors: [{ - messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.", + messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.symbol', 'esnext.array', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.", category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category, code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code, file: undefined, diff --git a/tests/baselines/reference/bigintIndex.symbols b/tests/baselines/reference/bigintIndex.symbols index c115a0f9daf..c0aea092753 100644 --- a/tests/baselines/reference/bigintIndex.symbols +++ b/tests/baselines/reference/bigintIndex.symbols @@ -34,7 +34,7 @@ key = "abc"; key = Symbol(); >key : Symbol(key, Decl(a.ts, 9, 3)) ->Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.esnext.symbol.d.ts, --, --)) +>Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2019.symbol.d.ts, --, --)) key = 123n; // should error >key : Symbol(key, Decl(a.ts, 9, 3)) diff --git a/tests/baselines/reference/dynamicNames.symbols b/tests/baselines/reference/dynamicNames.symbols index cfed2817d1d..08f7be94fd5 100644 --- a/tests/baselines/reference/dynamicNames.symbols +++ b/tests/baselines/reference/dynamicNames.symbols @@ -7,7 +7,7 @@ export const c1 = 1; export const s0 = Symbol(); >s0 : Symbol(s0, Decl(module.ts, 2, 12)) ->Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.esnext.symbol.d.ts, --, --)) +>Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2019.symbol.d.ts, --, --)) export interface T0 { >T0 : Symbol(T0, Decl(module.ts, 2, 27)) diff --git a/tests/baselines/reference/dynamicNamesErrors.symbols b/tests/baselines/reference/dynamicNamesErrors.symbols index de0d98df453..95fa0cd751e 100644 --- a/tests/baselines/reference/dynamicNamesErrors.symbols +++ b/tests/baselines/reference/dynamicNamesErrors.symbols @@ -62,19 +62,19 @@ t2 = t1; const x = Symbol(); >x : Symbol(x, Decl(dynamicNamesErrors.ts, 26, 5)) ->Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.esnext.symbol.d.ts, --, --)) +>Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2019.symbol.d.ts, --, --)) const y = Symbol(); >y : Symbol(y, Decl(dynamicNamesErrors.ts, 27, 5)) ->Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.esnext.symbol.d.ts, --, --)) +>Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2019.symbol.d.ts, --, --)) const z = Symbol(); >z : Symbol(z, Decl(dynamicNamesErrors.ts, 28, 5)) ->Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.esnext.symbol.d.ts, --, --)) +>Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2019.symbol.d.ts, --, --)) const w = Symbol(); >w : Symbol(w, Decl(dynamicNamesErrors.ts, 29, 5)) ->Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.esnext.symbol.d.ts, --, --)) +>Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2019.symbol.d.ts, --, --)) export interface InterfaceMemberVisibility { >InterfaceMemberVisibility : Symbol(InterfaceMemberVisibility, Decl(dynamicNamesErrors.ts, 29, 19)) diff --git a/tests/baselines/reference/objectLiteralPropertyImplicitlyAny.symbols b/tests/baselines/reference/objectLiteralPropertyImplicitlyAny.symbols index ae29ff8bb9e..7f61190b91f 100644 --- a/tests/baselines/reference/objectLiteralPropertyImplicitlyAny.symbols +++ b/tests/baselines/reference/objectLiteralPropertyImplicitlyAny.symbols @@ -2,7 +2,7 @@ const foo = Symbol.for("foo"); >foo : Symbol(foo, Decl(objectLiteralPropertyImplicitlyAny.ts, 0, 5)) >Symbol.for : Symbol(SymbolConstructor.for, Decl(lib.es2015.symbol.d.ts, --, --)) ->Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.esnext.symbol.d.ts, --, --)) +>Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2019.symbol.d.ts, --, --)) >for : Symbol(SymbolConstructor.for, Decl(lib.es2015.symbol.d.ts, --, --)) const o = { [foo]: undefined }; diff --git a/tests/baselines/reference/unionTypeWithIndexSignature.symbols b/tests/baselines/reference/unionTypeWithIndexSignature.symbols index b207423057b..8d38cbb6403 100644 --- a/tests/baselines/reference/unionTypeWithIndexSignature.symbols +++ b/tests/baselines/reference/unionTypeWithIndexSignature.symbols @@ -87,7 +87,7 @@ num['0'] = 'ok' const sym = Symbol() >sym : Symbol(sym, Decl(unionTypeWithIndexSignature.ts, 18, 5)) ->Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.esnext.symbol.d.ts, --, --)) +>Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2019.symbol.d.ts, --, --)) type Both = { s: number, '0': number, [sym]: boolean } | { [n: number]: number, [s: string]: string | number } >Both : Symbol(Both, Decl(unionTypeWithIndexSignature.ts, 18, 20)) diff --git a/tests/baselines/reference/uniqueSymbols.symbols b/tests/baselines/reference/uniqueSymbols.symbols index 6fef1873082..af2cfa74f82 100644 --- a/tests/baselines/reference/uniqueSymbols.symbols +++ b/tests/baselines/reference/uniqueSymbols.symbols @@ -2,15 +2,15 @@ // declarations with call initializer const constCall = Symbol(); >constCall : Symbol(constCall, Decl(uniqueSymbols.ts, 1, 5)) ->Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.esnext.symbol.d.ts, --, --)) +>Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2019.symbol.d.ts, --, --)) let letCall = Symbol(); >letCall : Symbol(letCall, Decl(uniqueSymbols.ts, 2, 3)) ->Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.esnext.symbol.d.ts, --, --)) +>Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2019.symbol.d.ts, --, --)) var varCall = Symbol(); >varCall : Symbol(varCall, Decl(uniqueSymbols.ts, 3, 3)) ->Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.esnext.symbol.d.ts, --, --)) +>Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2019.symbol.d.ts, --, --)) // ambient declaration with type declare const constType: unique symbol; @@ -19,7 +19,7 @@ declare const constType: unique symbol; // declaration with type and call initializer const constTypeAndCall: unique symbol = Symbol(); >constTypeAndCall : Symbol(constTypeAndCall, Decl(uniqueSymbols.ts, 9, 5)) ->Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.esnext.symbol.d.ts, --, --)) +>Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2019.symbol.d.ts, --, --)) // declaration from initializer const constInitToConstCall = constCall; @@ -152,26 +152,26 @@ class C { static readonly readonlyStaticCall = Symbol(); >readonlyStaticCall : Symbol(C.readonlyStaticCall, Decl(uniqueSymbols.ts, 56, 9)) ->Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.esnext.symbol.d.ts, --, --)) +>Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2019.symbol.d.ts, --, --)) static readonly readonlyStaticType: unique symbol; >readonlyStaticType : Symbol(C.readonlyStaticType, Decl(uniqueSymbols.ts, 57, 50)) static readonly readonlyStaticTypeAndCall: unique symbol = Symbol(); >readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbols.ts, 58, 54)) ->Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.esnext.symbol.d.ts, --, --)) +>Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2019.symbol.d.ts, --, --)) static readwriteStaticCall = Symbol(); >readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbols.ts, 59, 72)) ->Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.esnext.symbol.d.ts, --, --)) +>Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2019.symbol.d.ts, --, --)) readonly readonlyCall = Symbol(); >readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbols.ts, 60, 42)) ->Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.esnext.symbol.d.ts, --, --)) +>Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2019.symbol.d.ts, --, --)) readwriteCall = Symbol(); >readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbols.ts, 62, 37)) ->Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.esnext.symbol.d.ts, --, --)) +>Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2019.symbol.d.ts, --, --)) } declare const c: C; >c : Symbol(c, Decl(uniqueSymbols.ts, 65, 13)) diff --git a/tests/baselines/reference/uniqueSymbolsDeclarations.symbols b/tests/baselines/reference/uniqueSymbolsDeclarations.symbols index 485b31af0fd..6e3ae6d6a46 100644 --- a/tests/baselines/reference/uniqueSymbolsDeclarations.symbols +++ b/tests/baselines/reference/uniqueSymbolsDeclarations.symbols @@ -2,15 +2,15 @@ // declarations with call initializer const constCall = Symbol(); >constCall : Symbol(constCall, Decl(uniqueSymbolsDeclarations.ts, 1, 5)) ->Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.esnext.symbol.d.ts, --, --)) +>Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2019.symbol.d.ts, --, --)) let letCall = Symbol(); >letCall : Symbol(letCall, Decl(uniqueSymbolsDeclarations.ts, 2, 3)) ->Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.esnext.symbol.d.ts, --, --)) +>Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2019.symbol.d.ts, --, --)) var varCall = Symbol(); >varCall : Symbol(varCall, Decl(uniqueSymbolsDeclarations.ts, 3, 3)) ->Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.esnext.symbol.d.ts, --, --)) +>Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2019.symbol.d.ts, --, --)) // ambient declaration with type declare const constType: unique symbol; @@ -19,7 +19,7 @@ declare const constType: unique symbol; // declaration with type and call initializer const constTypeAndCall: unique symbol = Symbol(); >constTypeAndCall : Symbol(constTypeAndCall, Decl(uniqueSymbolsDeclarations.ts, 9, 5)) ->Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.esnext.symbol.d.ts, --, --)) +>Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2019.symbol.d.ts, --, --)) // declaration from initializer const constInitToConstCall = constCall; @@ -152,26 +152,26 @@ class C { static readonly readonlyStaticCall = Symbol(); >readonlyStaticCall : Symbol(C.readonlyStaticCall, Decl(uniqueSymbolsDeclarations.ts, 56, 9)) ->Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.esnext.symbol.d.ts, --, --)) +>Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2019.symbol.d.ts, --, --)) static readonly readonlyStaticType: unique symbol; >readonlyStaticType : Symbol(C.readonlyStaticType, Decl(uniqueSymbolsDeclarations.ts, 57, 50)) static readonly readonlyStaticTypeAndCall: unique symbol = Symbol(); >readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbolsDeclarations.ts, 58, 54)) ->Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.esnext.symbol.d.ts, --, --)) +>Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2019.symbol.d.ts, --, --)) static readwriteStaticCall = Symbol(); >readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbolsDeclarations.ts, 59, 72)) ->Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.esnext.symbol.d.ts, --, --)) +>Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2019.symbol.d.ts, --, --)) readonly readonlyCall = Symbol(); >readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbolsDeclarations.ts, 60, 42)) ->Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.esnext.symbol.d.ts, --, --)) +>Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2019.symbol.d.ts, --, --)) readwriteCall = Symbol(); >readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbolsDeclarations.ts, 62, 37)) ->Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.esnext.symbol.d.ts, --, --)) +>Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2019.symbol.d.ts, --, --)) } declare const c: C; >c : Symbol(c, Decl(uniqueSymbolsDeclarations.ts, 65, 13)) diff --git a/tests/baselines/reference/uniqueSymbolsErrors.symbols b/tests/baselines/reference/uniqueSymbolsErrors.symbols index affcd6f096b..2e2b552225a 100644 --- a/tests/baselines/reference/uniqueSymbolsErrors.symbols +++ b/tests/baselines/reference/uniqueSymbolsErrors.symbols @@ -238,5 +238,5 @@ declare const invalidIntersection: unique symbol | unique symbol; // https://github.com/Microsoft/TypeScript/issues/21584 const shouldNotBeAssignable: string = Symbol(); >shouldNotBeAssignable : Symbol(shouldNotBeAssignable, Decl(uniqueSymbolsErrors.ts, 86, 5)) ->Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.esnext.symbol.d.ts, --, --)) +>Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2019.symbol.d.ts, --, --)) From 52a9cfb0a9de3f0c0f36a77bb976330a0a57f6df Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Wed, 6 Feb 2019 14:23:49 -0800 Subject: [PATCH 03/34] Infer to partially homomorphic mapped types (such as Pick) --- src/compiler/checker.ts | 45 ++++++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ce06e84b2fd..aa5007065fc 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14570,11 +14570,24 @@ namespace ts { return undefined; } - function inferFromMappedTypeConstraint(source: Type, target: Type, constraintType: Type): boolean { + function inferToHomomorphicMappedType(source: Type, target: MappedType, constraintType: IndexType) { + const inference = getInferenceInfoForType(constraintType.type); + if (inference && !inference.isFixed) { + const inferredType = inferTypeForHomomorphicMappedType(source, target, constraintType); + if (inferredType) { + const savePriority = priority; + priority |= InferencePriority.HomomorphicMappedType; + inferFromTypes(inferredType, inference.typeParameter); + priority = savePriority; + } + } + } + + function inferToMappedType(source: Type, target: MappedType, constraintType: Type): boolean { if (constraintType.flags & TypeFlags.Union) { let result = false; for (const type of (constraintType as UnionType).types) { - result = inferFromMappedTypeConstraint(source, target, type) || result; + result = inferToMappedType(source, target, type) || result; } return result; } @@ -14583,31 +14596,31 @@ namespace ts { // where T is a type variable. Use inferTypeForHomomorphicMappedType to infer a suitable source // type and then make a secondary inference from that type to T. We make a secondary inference // such that direct inferences to T get priority over inferences to Partial, for example. - const inference = getInferenceInfoForType((constraintType).type); - if (inference && !inference.isFixed) { - const inferredType = inferTypeForHomomorphicMappedType(source, target, constraintType as IndexType); - if (inferredType) { - const savePriority = priority; - priority |= InferencePriority.HomomorphicMappedType; - inferFromTypes(inferredType, inference.typeParameter); - priority = savePriority; - } - } + inferToHomomorphicMappedType(source, target, constraintType); return true; } if (constraintType.flags & TypeFlags.TypeParameter) { - // We're inferring from some source type S to a mapped type { [P in T]: X }, where T is a type - // parameter. Infer from 'keyof S' to T and infer from a union of each property type in S to X. + // We're inferring from some source type S to a mapped type { [P in K]: X }, where K is a type + // parameter. First infer from 'keyof S' to K. const savePriority = priority; priority |= InferencePriority.MappedTypeConstraint; inferFromTypes(getIndexType(source), constraintType); priority = savePriority; + // If K is constrained to an index type keyof T, where T is a type parameter, proceed to make + // the same inferences as we would for a homomorphic mapped type { [P in keyof T]: X } (this + // enables us to make meaningful inferences when the target is a Pick). Otherwise, infer + // from a union of the property types in the source to the template type X. + const extendedConstraint = getConstraintOfType(constraintType); + if (extendedConstraint && extendedConstraint.flags & TypeFlags.Index) { + inferToHomomorphicMappedType(source, target, extendedConstraint); + return true; + } const valueTypes = compact([ getIndexTypeOfType(source, IndexKind.String), getIndexTypeOfType(source, IndexKind.Number), ...map(getPropertiesOfType(source), getTypeOfSymbol) ]); - inferFromTypes(getUnionType(valueTypes), getTemplateTypeFromMappedType(target)); + inferFromTypes(getUnionType(valueTypes), getTemplateTypeFromMappedType(target)); return true; } return false; @@ -14622,7 +14635,7 @@ namespace ts { } if (getObjectFlags(target) & ObjectFlags.Mapped) { const constraintType = getConstraintTypeFromMappedType(target); - if (inferFromMappedTypeConstraint(source, target, constraintType)) { + if (inferToMappedType(source, target, constraintType)) { return; } } From 62c62f4f87bfcf96e3f0e0500b453187b39f3c89 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Wed, 6 Feb 2019 15:41:43 -0800 Subject: [PATCH 04/34] Add tests --- .../mapped/isomorphicMappedTypeInference.ts | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/tests/cases/conformance/types/mapped/isomorphicMappedTypeInference.ts b/tests/cases/conformance/types/mapped/isomorphicMappedTypeInference.ts index 14bb765a840..534d50c367e 100644 --- a/tests/cases/conformance/types/mapped/isomorphicMappedTypeInference.ts +++ b/tests/cases/conformance/types/mapped/isomorphicMappedTypeInference.ts @@ -152,4 +152,27 @@ var g2 = applySpec({ foo: { bar: { baz: (x: any) => true } } }); const foo = (object: T, partial: Partial) => object; let o = {a: 5, b: 7}; foo(o, {b: 9}); -o = foo(o, {b: 9}); \ No newline at end of file +o = foo(o, {b: 9}); + +// Inferring to { [P in K]: X }, where K extends keyof T, produces same inferences as +// inferring to { [P in keyof T]: X }. + +declare function f20(obj: Pick): T; +declare function f21(obj: Pick): K; +declare function f22(obj: Boxified>): T; + +let x0 = f20({ foo: 42, bar: "hello" }); +let x1 = f21({ foo: 42, bar: "hello" }); +let x2 = f22({ foo: { value: 42} , bar: { value: "hello" } }); + +// Repro from #29765 + +function getProps(obj: T, list: K[]): Pick { + return {} as any; +} + +const myAny: any = {}; + +const o1 = getProps(myAny, ['foo', 'bar']); + +const o2: { foo: any; bar: any } = getProps(myAny, ['foo', 'bar']); From 262e3c1ae294cef6e1075fa53a4d60481c700494 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Wed, 6 Feb 2019 15:41:51 -0800 Subject: [PATCH 05/34] Accept new baselines --- .../isomorphicMappedTypeInference.js | 55 +++++++++++- .../isomorphicMappedTypeInference.symbols | 90 +++++++++++++++++++ .../isomorphicMappedTypeInference.types | 85 ++++++++++++++++++ 3 files changed, 229 insertions(+), 1 deletion(-) diff --git a/tests/baselines/reference/isomorphicMappedTypeInference.js b/tests/baselines/reference/isomorphicMappedTypeInference.js index 58912244432..6cfc2ec7350 100644 --- a/tests/baselines/reference/isomorphicMappedTypeInference.js +++ b/tests/baselines/reference/isomorphicMappedTypeInference.js @@ -149,7 +149,31 @@ var g2 = applySpec({ foo: { bar: { baz: (x: any) => true } } }); const foo = (object: T, partial: Partial) => object; let o = {a: 5, b: 7}; foo(o, {b: 9}); -o = foo(o, {b: 9}); +o = foo(o, {b: 9}); + +// Inferring to { [P in K]: X }, where K extends keyof T, produces same inferences as +// inferring to { [P in keyof T]: X }. + +declare function f20(obj: Pick): T; +declare function f21(obj: Pick): K; +declare function f22(obj: Boxified>): T; + +let x0 = f20({ foo: 42, bar: "hello" }); +let x1 = f21({ foo: 42, bar: "hello" }); +let x2 = f22({ foo: { value: 42} , bar: { value: "hello" } }); + +// Repro from #29765 + +function getProps(obj: T, list: K[]): Pick { + return {} as any; +} + +const myAny: any = {}; + +const o1 = getProps(myAny, ['foo', 'bar']); + +const o2: { foo: any; bar: any } = getProps(myAny, ['foo', 'bar']); + //// [isomorphicMappedTypeInference.js] function box(x) { @@ -255,6 +279,16 @@ var foo = function (object, partial) { return object; }; var o = { a: 5, b: 7 }; foo(o, { b: 9 }); o = foo(o, { b: 9 }); +var x0 = f20({ foo: 42, bar: "hello" }); +var x1 = f21({ foo: 42, bar: "hello" }); +var x2 = f22({ foo: { value: 42 }, bar: { value: "hello" } }); +// Repro from #29765 +function getProps(obj, list) { + return {}; +} +var myAny = {}; +var o1 = getProps(myAny, ['foo', 'bar']); +var o2 = getProps(myAny, ['foo', 'bar']); //// [isomorphicMappedTypeInference.d.ts] @@ -323,3 +357,22 @@ declare let o: { a: number; b: number; }; +declare function f20(obj: Pick): T; +declare function f21(obj: Pick): K; +declare function f22(obj: Boxified>): T; +declare let x0: { + foo: number; + bar: string; +}; +declare let x1: "foo" | "bar"; +declare let x2: { + foo: number; + bar: string; +}; +declare function getProps(obj: T, list: K[]): Pick; +declare const myAny: any; +declare const o1: Pick; +declare const o2: { + foo: any; + bar: any; +}; diff --git a/tests/baselines/reference/isomorphicMappedTypeInference.symbols b/tests/baselines/reference/isomorphicMappedTypeInference.symbols index d36ebc7a4a5..6f999f91dc4 100644 --- a/tests/baselines/reference/isomorphicMappedTypeInference.symbols +++ b/tests/baselines/reference/isomorphicMappedTypeInference.symbols @@ -486,3 +486,93 @@ o = foo(o, {b: 9}); >o : Symbol(o, Decl(isomorphicMappedTypeInference.ts, 148, 3)) >b : Symbol(b, Decl(isomorphicMappedTypeInference.ts, 150, 12)) +// Inferring to { [P in K]: X }, where K extends keyof T, produces same inferences as +// inferring to { [P in keyof T]: X }. + +declare function f20(obj: Pick): T; +>f20 : Symbol(f20, Decl(isomorphicMappedTypeInference.ts, 150, 19)) +>T : Symbol(T, Decl(isomorphicMappedTypeInference.ts, 155, 21)) +>K : Symbol(K, Decl(isomorphicMappedTypeInference.ts, 155, 23)) +>T : Symbol(T, Decl(isomorphicMappedTypeInference.ts, 155, 21)) +>obj : Symbol(obj, Decl(isomorphicMappedTypeInference.ts, 155, 43)) +>Pick : Symbol(Pick, Decl(lib.es5.d.ts, --, --)) +>T : Symbol(T, Decl(isomorphicMappedTypeInference.ts, 155, 21)) +>K : Symbol(K, Decl(isomorphicMappedTypeInference.ts, 155, 23)) +>T : Symbol(T, Decl(isomorphicMappedTypeInference.ts, 155, 21)) + +declare function f21(obj: Pick): K; +>f21 : Symbol(f21, Decl(isomorphicMappedTypeInference.ts, 155, 63)) +>T : Symbol(T, Decl(isomorphicMappedTypeInference.ts, 156, 21)) +>K : Symbol(K, Decl(isomorphicMappedTypeInference.ts, 156, 23)) +>T : Symbol(T, Decl(isomorphicMappedTypeInference.ts, 156, 21)) +>obj : Symbol(obj, Decl(isomorphicMappedTypeInference.ts, 156, 43)) +>Pick : Symbol(Pick, Decl(lib.es5.d.ts, --, --)) +>T : Symbol(T, Decl(isomorphicMappedTypeInference.ts, 156, 21)) +>K : Symbol(K, Decl(isomorphicMappedTypeInference.ts, 156, 23)) +>K : Symbol(K, Decl(isomorphicMappedTypeInference.ts, 156, 23)) + +declare function f22(obj: Boxified>): T; +>f22 : Symbol(f22, Decl(isomorphicMappedTypeInference.ts, 156, 63)) +>T : Symbol(T, Decl(isomorphicMappedTypeInference.ts, 157, 21)) +>K : Symbol(K, Decl(isomorphicMappedTypeInference.ts, 157, 23)) +>T : Symbol(T, Decl(isomorphicMappedTypeInference.ts, 157, 21)) +>obj : Symbol(obj, Decl(isomorphicMappedTypeInference.ts, 157, 43)) +>Boxified : Symbol(Boxified, Decl(isomorphicMappedTypeInference.ts, 2, 1)) +>Pick : Symbol(Pick, Decl(lib.es5.d.ts, --, --)) +>T : Symbol(T, Decl(isomorphicMappedTypeInference.ts, 157, 21)) +>K : Symbol(K, Decl(isomorphicMappedTypeInference.ts, 157, 23)) +>T : Symbol(T, Decl(isomorphicMappedTypeInference.ts, 157, 21)) + +let x0 = f20({ foo: 42, bar: "hello" }); +>x0 : Symbol(x0, Decl(isomorphicMappedTypeInference.ts, 159, 3)) +>f20 : Symbol(f20, Decl(isomorphicMappedTypeInference.ts, 150, 19)) +>foo : Symbol(foo, Decl(isomorphicMappedTypeInference.ts, 159, 14)) +>bar : Symbol(bar, Decl(isomorphicMappedTypeInference.ts, 159, 23)) + +let x1 = f21({ foo: 42, bar: "hello" }); +>x1 : Symbol(x1, Decl(isomorphicMappedTypeInference.ts, 160, 3)) +>f21 : Symbol(f21, Decl(isomorphicMappedTypeInference.ts, 155, 63)) +>foo : Symbol(foo, Decl(isomorphicMappedTypeInference.ts, 160, 14)) +>bar : Symbol(bar, Decl(isomorphicMappedTypeInference.ts, 160, 23)) + +let x2 = f22({ foo: { value: 42} , bar: { value: "hello" } }); +>x2 : Symbol(x2, Decl(isomorphicMappedTypeInference.ts, 161, 3)) +>f22 : Symbol(f22, Decl(isomorphicMappedTypeInference.ts, 156, 63)) +>foo : Symbol(foo, Decl(isomorphicMappedTypeInference.ts, 161, 14)) +>value : Symbol(value, Decl(isomorphicMappedTypeInference.ts, 161, 21)) +>bar : Symbol(bar, Decl(isomorphicMappedTypeInference.ts, 161, 34)) +>value : Symbol(value, Decl(isomorphicMappedTypeInference.ts, 161, 41)) + +// Repro from #29765 + +function getProps(obj: T, list: K[]): Pick { +>getProps : Symbol(getProps, Decl(isomorphicMappedTypeInference.ts, 161, 62)) +>T : Symbol(T, Decl(isomorphicMappedTypeInference.ts, 165, 18)) +>K : Symbol(K, Decl(isomorphicMappedTypeInference.ts, 165, 20)) +>T : Symbol(T, Decl(isomorphicMappedTypeInference.ts, 165, 18)) +>obj : Symbol(obj, Decl(isomorphicMappedTypeInference.ts, 165, 40)) +>T : Symbol(T, Decl(isomorphicMappedTypeInference.ts, 165, 18)) +>list : Symbol(list, Decl(isomorphicMappedTypeInference.ts, 165, 47)) +>K : Symbol(K, Decl(isomorphicMappedTypeInference.ts, 165, 20)) +>Pick : Symbol(Pick, Decl(lib.es5.d.ts, --, --)) +>T : Symbol(T, Decl(isomorphicMappedTypeInference.ts, 165, 18)) +>K : Symbol(K, Decl(isomorphicMappedTypeInference.ts, 165, 20)) + + return {} as any; +} + +const myAny: any = {}; +>myAny : Symbol(myAny, Decl(isomorphicMappedTypeInference.ts, 169, 5)) + +const o1 = getProps(myAny, ['foo', 'bar']); +>o1 : Symbol(o1, Decl(isomorphicMappedTypeInference.ts, 171, 5)) +>getProps : Symbol(getProps, Decl(isomorphicMappedTypeInference.ts, 161, 62)) +>myAny : Symbol(myAny, Decl(isomorphicMappedTypeInference.ts, 169, 5)) + +const o2: { foo: any; bar: any } = getProps(myAny, ['foo', 'bar']); +>o2 : Symbol(o2, Decl(isomorphicMappedTypeInference.ts, 173, 5)) +>foo : Symbol(foo, Decl(isomorphicMappedTypeInference.ts, 173, 11)) +>bar : Symbol(bar, Decl(isomorphicMappedTypeInference.ts, 173, 21)) +>getProps : Symbol(getProps, Decl(isomorphicMappedTypeInference.ts, 161, 62)) +>myAny : Symbol(myAny, Decl(isomorphicMappedTypeInference.ts, 169, 5)) + diff --git a/tests/baselines/reference/isomorphicMappedTypeInference.types b/tests/baselines/reference/isomorphicMappedTypeInference.types index 4488fa27daf..b37175b5eed 100644 --- a/tests/baselines/reference/isomorphicMappedTypeInference.types +++ b/tests/baselines/reference/isomorphicMappedTypeInference.types @@ -507,3 +507,88 @@ o = foo(o, {b: 9}); >b : number >9 : 9 +// Inferring to { [P in K]: X }, where K extends keyof T, produces same inferences as +// inferring to { [P in keyof T]: X }. + +declare function f20(obj: Pick): T; +>f20 : (obj: Pick) => T +>obj : Pick + +declare function f21(obj: Pick): K; +>f21 : (obj: Pick) => K +>obj : Pick + +declare function f22(obj: Boxified>): T; +>f22 : (obj: Boxified>) => T +>obj : Boxified> + +let x0 = f20({ foo: 42, bar: "hello" }); +>x0 : { foo: number; bar: string; } +>f20({ foo: 42, bar: "hello" }) : { foo: number; bar: string; } +>f20 : (obj: Pick) => T +>{ foo: 42, bar: "hello" } : { foo: number; bar: string; } +>foo : number +>42 : 42 +>bar : string +>"hello" : "hello" + +let x1 = f21({ foo: 42, bar: "hello" }); +>x1 : "foo" | "bar" +>f21({ foo: 42, bar: "hello" }) : "foo" | "bar" +>f21 : (obj: Pick) => K +>{ foo: 42, bar: "hello" } : { foo: number; bar: string; } +>foo : number +>42 : 42 +>bar : string +>"hello" : "hello" + +let x2 = f22({ foo: { value: 42} , bar: { value: "hello" } }); +>x2 : { foo: number; bar: string; } +>f22({ foo: { value: 42} , bar: { value: "hello" } }) : { foo: number; bar: string; } +>f22 : (obj: Boxified>) => T +>{ foo: { value: 42} , bar: { value: "hello" } } : { foo: { value: number; }; bar: { value: string; }; } +>foo : { value: number; } +>{ value: 42} : { value: number; } +>value : number +>42 : 42 +>bar : { value: string; } +>{ value: "hello" } : { value: string; } +>value : string +>"hello" : "hello" + +// Repro from #29765 + +function getProps(obj: T, list: K[]): Pick { +>getProps : (obj: T, list: K[]) => Pick +>obj : T +>list : K[] + + return {} as any; +>{} as any : any +>{} : {} +} + +const myAny: any = {}; +>myAny : any +>{} : {} + +const o1 = getProps(myAny, ['foo', 'bar']); +>o1 : Pick +>getProps(myAny, ['foo', 'bar']) : Pick +>getProps : (obj: T, list: K[]) => Pick +>myAny : any +>['foo', 'bar'] : ("foo" | "bar")[] +>'foo' : "foo" +>'bar' : "bar" + +const o2: { foo: any; bar: any } = getProps(myAny, ['foo', 'bar']); +>o2 : { foo: any; bar: any; } +>foo : any +>bar : any +>getProps(myAny, ['foo', 'bar']) : Pick +>getProps : (obj: T, list: K[]) => Pick +>myAny : any +>['foo', 'bar'] : ("foo" | "bar")[] +>'foo' : "foo" +>'bar' : "bar" + From 582526929b0b8e44fc28579083038520d9c55d7b Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Thu, 7 Feb 2019 10:27:50 +0900 Subject: [PATCH 06/34] restore flags --- src/compiler/types.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/compiler/types.ts b/src/compiler/types.ts index a2054243e04..0ea375d0755 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -5046,14 +5046,14 @@ namespace ts { ContainsTypeScript = 1 << 1, ContainsJsx = 1 << 2, ContainsESNext = 1 << 3, - ContainsES2017 = 1 << 5, - ContainsES2016 = 1 << 6, - ES2015 = 1 << 7, - ContainsES2015 = 1 << 8, - Generator = 1 << 9, - ContainsGenerator = 1 << 10, - DestructuringAssignment = 1 << 11, - ContainsDestructuringAssignment = 1 << 12, + ContainsES2017 = 1 << 4, + ContainsES2016 = 1 << 5, + ES2015 = 1 << 6, + ContainsES2015 = 1 << 7, + Generator = 1 << 8, + ContainsGenerator = 1 << 9, + DestructuringAssignment = 1 << 10, + ContainsDestructuringAssignment = 1 << 11, // Markers // - Flags used to indicate that a subtree contains a specific transformation. From 40a4bd0a958a3aaa70b6d209607f3501adf3cdad Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Thu, 7 Feb 2019 10:45:44 +0900 Subject: [PATCH 07/34] revive esnext.symbol --- src/compiler/commandLineParser.ts | 1 + src/testRunner/unittests/config/commandLineParsing.ts | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index e7db3748d02..676e6e3520b 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -44,6 +44,7 @@ namespace ts { ["es2018.regexp", "lib.es2018.regexp.d.ts"], ["es2019.symbol", "lib.es2019.symbol.d.ts"], ["esnext.array", "lib.esnext.array.d.ts"], + ["esnext.symbol", "lib.es2019.symbol.d.ts"], ["esnext.asynciterable", "lib.esnext.asynciterable.d.ts"], ["esnext.intl", "lib.esnext.intl.d.ts"], ["esnext.bigint", "lib.esnext.bigint.d.ts"] diff --git a/src/testRunner/unittests/config/commandLineParsing.ts b/src/testRunner/unittests/config/commandLineParsing.ts index 8d49fde6e42..a79ebea1c69 100644 --- a/src/testRunner/unittests/config/commandLineParsing.ts +++ b/src/testRunner/unittests/config/commandLineParsing.ts @@ -57,7 +57,7 @@ namespace ts { assertParseResult(["--lib", "es5,invalidOption", "0.ts"], { errors: [{ - messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.symbol', 'esnext.array', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.", + messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.symbol', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.", category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category, code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code, file: undefined, @@ -259,7 +259,7 @@ namespace ts { assertParseResult(["--lib", "es5,", "es7", "0.ts"], { errors: [{ - messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.symbol', 'esnext.array', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.", + messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.symbol', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.", category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category, code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code, file: undefined, @@ -278,7 +278,7 @@ namespace ts { assertParseResult(["--lib", "es5, ", "es7", "0.ts"], { errors: [{ - messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.symbol', 'esnext.array', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.", + messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.symbol', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.", category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category, code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code, file: undefined, From f525a89e87069e8934db097829dc9ff74bf10d3b Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Fri, 8 Feb 2019 00:10:34 +0900 Subject: [PATCH 08/34] Array.prototype.{flat,flatMap} hit stage 4 --- lib/lib.esnext.d.ts | 1 - src/compiler/commandLineParser.ts | 3 ++- src/lib/{esnext.array.d.ts => es2019.array.d.ts} | 0 src/lib/es2019.d.ts | 1 + src/lib/libs.json | 2 +- .../unittests/config/commandLineParsing.ts | 6 +++--- tests/baselines/reference/arrayFlatMap.symbols | 14 +++++++------- tests/cases/compiler/arrayFlatMap.ts | 2 +- 8 files changed, 15 insertions(+), 14 deletions(-) rename src/lib/{esnext.array.d.ts => es2019.array.d.ts} (100%) diff --git a/lib/lib.esnext.d.ts b/lib/lib.esnext.d.ts index f213999684d..59d33ab80f4 100644 --- a/lib/lib.esnext.d.ts +++ b/lib/lib.esnext.d.ts @@ -20,7 +20,6 @@ and limitations under the License. /// /// -/// /// /// /// diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 676e6e3520b..81884b9c75d 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -42,8 +42,9 @@ namespace ts { ["es2018.intl", "lib.es2018.intl.d.ts"], ["es2018.promise", "lib.es2018.promise.d.ts"], ["es2018.regexp", "lib.es2018.regexp.d.ts"], + ["es2019.array", "lib.es2019.array.d.ts"], ["es2019.symbol", "lib.es2019.symbol.d.ts"], - ["esnext.array", "lib.esnext.array.d.ts"], + ["esnext.array", "lib.es2019.array.d.ts"], ["esnext.symbol", "lib.es2019.symbol.d.ts"], ["esnext.asynciterable", "lib.esnext.asynciterable.d.ts"], ["esnext.intl", "lib.esnext.intl.d.ts"], diff --git a/src/lib/esnext.array.d.ts b/src/lib/es2019.array.d.ts similarity index 100% rename from src/lib/esnext.array.d.ts rename to src/lib/es2019.array.d.ts diff --git a/src/lib/es2019.d.ts b/src/lib/es2019.d.ts index 60b8787d587..217d82a219c 100644 --- a/src/lib/es2019.d.ts +++ b/src/lib/es2019.d.ts @@ -1,2 +1,3 @@ /// +/// /// diff --git a/src/lib/libs.json b/src/lib/libs.json index 17b54324e9d..f1afe448f9f 100644 --- a/src/lib/libs.json +++ b/src/lib/libs.json @@ -33,9 +33,9 @@ "es2018.regexp", "es2018.promise", "es2018.intl", + "es2019.array", "es2019.symbol", "esnext.asynciterable", - "esnext.array", "esnext.bigint", "esnext.intl", // Default libraries diff --git a/src/testRunner/unittests/config/commandLineParsing.ts b/src/testRunner/unittests/config/commandLineParsing.ts index a79ebea1c69..387715fe82a 100644 --- a/src/testRunner/unittests/config/commandLineParsing.ts +++ b/src/testRunner/unittests/config/commandLineParsing.ts @@ -57,7 +57,7 @@ namespace ts { assertParseResult(["--lib", "es5,invalidOption", "0.ts"], { errors: [{ - messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.symbol', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.", + messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.symbol', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.", category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category, code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code, file: undefined, @@ -259,7 +259,7 @@ namespace ts { assertParseResult(["--lib", "es5,", "es7", "0.ts"], { errors: [{ - messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.symbol', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.", + messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.symbol', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.", category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category, code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code, file: undefined, @@ -278,7 +278,7 @@ namespace ts { assertParseResult(["--lib", "es5, ", "es7", "0.ts"], { errors: [{ - messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.symbol', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.", + messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.symbol', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.", category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category, code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code, file: undefined, diff --git a/tests/baselines/reference/arrayFlatMap.symbols b/tests/baselines/reference/arrayFlatMap.symbols index 0a97341657b..b3a8d55721a 100644 --- a/tests/baselines/reference/arrayFlatMap.symbols +++ b/tests/baselines/reference/arrayFlatMap.symbols @@ -4,17 +4,17 @@ const array: number[] = []; const readonlyArray: ReadonlyArray = []; >readonlyArray : Symbol(readonlyArray, Decl(arrayFlatMap.ts, 1, 5)) ->ReadonlyArray : Symbol(ReadonlyArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.esnext.array.d.ts, --, --)) +>ReadonlyArray : Symbol(ReadonlyArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --)) array.flatMap((): ReadonlyArray => []); // ok ->array.flatMap : Symbol(Array.flatMap, Decl(lib.esnext.array.d.ts, --, --)) +>array.flatMap : Symbol(Array.flatMap, Decl(lib.es2019.array.d.ts, --, --)) >array : Symbol(array, Decl(arrayFlatMap.ts, 0, 5)) ->flatMap : Symbol(Array.flatMap, Decl(lib.esnext.array.d.ts, --, --)) ->ReadonlyArray : Symbol(ReadonlyArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.esnext.array.d.ts, --, --)) +>flatMap : Symbol(Array.flatMap, Decl(lib.es2019.array.d.ts, --, --)) +>ReadonlyArray : Symbol(ReadonlyArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --)) readonlyArray.flatMap((): ReadonlyArray => []); // ok ->readonlyArray.flatMap : Symbol(ReadonlyArray.flatMap, Decl(lib.esnext.array.d.ts, --, --)) +>readonlyArray.flatMap : Symbol(ReadonlyArray.flatMap, Decl(lib.es2019.array.d.ts, --, --)) >readonlyArray : Symbol(readonlyArray, Decl(arrayFlatMap.ts, 1, 5)) ->flatMap : Symbol(ReadonlyArray.flatMap, Decl(lib.esnext.array.d.ts, --, --)) ->ReadonlyArray : Symbol(ReadonlyArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.esnext.array.d.ts, --, --)) +>flatMap : Symbol(ReadonlyArray.flatMap, Decl(lib.es2019.array.d.ts, --, --)) +>ReadonlyArray : Symbol(ReadonlyArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --)) diff --git a/tests/cases/compiler/arrayFlatMap.ts b/tests/cases/compiler/arrayFlatMap.ts index dc67bf02490..98f84e78773 100644 --- a/tests/cases/compiler/arrayFlatMap.ts +++ b/tests/cases/compiler/arrayFlatMap.ts @@ -1,4 +1,4 @@ -// @lib: esnext +// @lib: es2019 const array: number[] = []; const readonlyArray: ReadonlyArray = []; From b3c179540a3b095d23d67baed57f8779809a34fb Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Fri, 8 Feb 2019 00:51:23 +0900 Subject: [PATCH 09/34] String.prototype.{trimStart,trimEnd} hit stage 4 --- src/compiler/commandLineParser.ts | 1 + src/lib/es2019.d.ts | 1 + src/lib/es2019.string.d.ts | 13 +++++++ src/lib/libs.json | 1 + .../unittests/config/commandLineParsing.ts | 6 ++-- tests/baselines/reference/bigintIndex.symbols | 2 +- tests/baselines/reference/stringTrim.js | 14 ++++++++ tests/baselines/reference/stringTrim.symbols | 24 +++++++++++++ tests/baselines/reference/stringTrim.types | 36 +++++++++++++++++++ tests/cases/compiler/stringTrim.ts | 7 ++++ 10 files changed, 101 insertions(+), 4 deletions(-) create mode 100644 src/lib/es2019.string.d.ts create mode 100644 tests/baselines/reference/stringTrim.js create mode 100644 tests/baselines/reference/stringTrim.symbols create mode 100644 tests/baselines/reference/stringTrim.types create mode 100644 tests/cases/compiler/stringTrim.ts diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 81884b9c75d..35aeb67df8f 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -43,6 +43,7 @@ namespace ts { ["es2018.promise", "lib.es2018.promise.d.ts"], ["es2018.regexp", "lib.es2018.regexp.d.ts"], ["es2019.array", "lib.es2019.array.d.ts"], + ["es2019.string", "lib.es2019.string.d.ts"], ["es2019.symbol", "lib.es2019.symbol.d.ts"], ["esnext.array", "lib.es2019.array.d.ts"], ["esnext.symbol", "lib.es2019.symbol.d.ts"], diff --git a/src/lib/es2019.d.ts b/src/lib/es2019.d.ts index 217d82a219c..b25f9e1d76a 100644 --- a/src/lib/es2019.d.ts +++ b/src/lib/es2019.d.ts @@ -1,3 +1,4 @@ /// /// +/// /// diff --git a/src/lib/es2019.string.d.ts b/src/lib/es2019.string.d.ts new file mode 100644 index 00000000000..a0cde55c2e5 --- /dev/null +++ b/src/lib/es2019.string.d.ts @@ -0,0 +1,13 @@ +interface String { + /** Removes the trailing white space and line terminator characters from a string. */ + trimEnd(): string; + + /** Removes the leading white space and line terminator characters from a string. */ + trimStart(): string; + + /** Removes the trailing white space and line terminator characters from a string. */ + trimLeft(): string; + + /** Removes the leading white space and line terminator characters from a string. */ + trimRight(): string; +} diff --git a/src/lib/libs.json b/src/lib/libs.json index f1afe448f9f..cb4e6fc053f 100644 --- a/src/lib/libs.json +++ b/src/lib/libs.json @@ -34,6 +34,7 @@ "es2018.promise", "es2018.intl", "es2019.array", + "es2019.string", "es2019.symbol", "esnext.asynciterable", "esnext.bigint", diff --git a/src/testRunner/unittests/config/commandLineParsing.ts b/src/testRunner/unittests/config/commandLineParsing.ts index 387715fe82a..3baf12bd431 100644 --- a/src/testRunner/unittests/config/commandLineParsing.ts +++ b/src/testRunner/unittests/config/commandLineParsing.ts @@ -57,7 +57,7 @@ namespace ts { assertParseResult(["--lib", "es5,invalidOption", "0.ts"], { errors: [{ - messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.symbol', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.", + messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.string', 'es2019.symbol', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.", category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category, code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code, file: undefined, @@ -259,7 +259,7 @@ namespace ts { assertParseResult(["--lib", "es5,", "es7", "0.ts"], { errors: [{ - messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.symbol', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.", + messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.string', 'es2019.symbol', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.", category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category, code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code, file: undefined, @@ -278,7 +278,7 @@ namespace ts { assertParseResult(["--lib", "es5, ", "es7", "0.ts"], { errors: [{ - messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.symbol', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.", + messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.string', 'es2019.symbol', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.", category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category, code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code, file: undefined, diff --git a/tests/baselines/reference/bigintIndex.symbols b/tests/baselines/reference/bigintIndex.symbols index c0aea092753..dff23a016ee 100644 --- a/tests/baselines/reference/bigintIndex.symbols +++ b/tests/baselines/reference/bigintIndex.symbols @@ -53,7 +53,7 @@ typedArray[bigNum] = 0xAA; // should error typedArray[String(bigNum)] = 0xAA; >typedArray : Symbol(typedArray, Decl(a.ts, 17, 5)) ->String : Symbol(String, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --) ... and 2 more) +>String : Symbol(String, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --) ... and 3 more) >bigNum : Symbol(bigNum, Decl(a.ts, 16, 5)) typedArray["1"] = 0xBB; diff --git a/tests/baselines/reference/stringTrim.js b/tests/baselines/reference/stringTrim.js new file mode 100644 index 00000000000..973df9c1ebb --- /dev/null +++ b/tests/baselines/reference/stringTrim.js @@ -0,0 +1,14 @@ +//// [stringTrim.ts] +var trimmed: string; +trimmed = "abcde".trimEnd(); +trimmed = "abcde".trimStart(); +trimmed = "abcde".trimLeft(); +trimmed = "abcde".trimRight(); + + +//// [stringTrim.js] +var trimmed; +trimmed = "abcde".trimEnd(); +trimmed = "abcde".trimStart(); +trimmed = "abcde".trimLeft(); +trimmed = "abcde".trimRight(); diff --git a/tests/baselines/reference/stringTrim.symbols b/tests/baselines/reference/stringTrim.symbols new file mode 100644 index 00000000000..00f7b34d166 --- /dev/null +++ b/tests/baselines/reference/stringTrim.symbols @@ -0,0 +1,24 @@ +=== tests/cases/compiler/stringTrim.ts === +var trimmed: string; +>trimmed : Symbol(trimmed, Decl(stringTrim.ts, 0, 3)) + +trimmed = "abcde".trimEnd(); +>trimmed : Symbol(trimmed, Decl(stringTrim.ts, 0, 3)) +>"abcde".trimEnd : Symbol(String.trimEnd, Decl(lib.es2019.string.d.ts, --, --)) +>trimEnd : Symbol(String.trimEnd, Decl(lib.es2019.string.d.ts, --, --)) + +trimmed = "abcde".trimStart(); +>trimmed : Symbol(trimmed, Decl(stringTrim.ts, 0, 3)) +>"abcde".trimStart : Symbol(String.trimStart, Decl(lib.es2019.string.d.ts, --, --)) +>trimStart : Symbol(String.trimStart, Decl(lib.es2019.string.d.ts, --, --)) + +trimmed = "abcde".trimLeft(); +>trimmed : Symbol(trimmed, Decl(stringTrim.ts, 0, 3)) +>"abcde".trimLeft : Symbol(String.trimLeft, Decl(lib.es2019.string.d.ts, --, --)) +>trimLeft : Symbol(String.trimLeft, Decl(lib.es2019.string.d.ts, --, --)) + +trimmed = "abcde".trimRight(); +>trimmed : Symbol(trimmed, Decl(stringTrim.ts, 0, 3)) +>"abcde".trimRight : Symbol(String.trimRight, Decl(lib.es2019.string.d.ts, --, --)) +>trimRight : Symbol(String.trimRight, Decl(lib.es2019.string.d.ts, --, --)) + diff --git a/tests/baselines/reference/stringTrim.types b/tests/baselines/reference/stringTrim.types new file mode 100644 index 00000000000..5da0b98fb1a --- /dev/null +++ b/tests/baselines/reference/stringTrim.types @@ -0,0 +1,36 @@ +=== tests/cases/compiler/stringTrim.ts === +var trimmed: string; +>trimmed : string + +trimmed = "abcde".trimEnd(); +>trimmed = "abcde".trimEnd() : string +>trimmed : string +>"abcde".trimEnd() : string +>"abcde".trimEnd : () => string +>"abcde" : "abcde" +>trimEnd : () => string + +trimmed = "abcde".trimStart(); +>trimmed = "abcde".trimStart() : string +>trimmed : string +>"abcde".trimStart() : string +>"abcde".trimStart : () => string +>"abcde" : "abcde" +>trimStart : () => string + +trimmed = "abcde".trimLeft(); +>trimmed = "abcde".trimLeft() : string +>trimmed : string +>"abcde".trimLeft() : string +>"abcde".trimLeft : () => string +>"abcde" : "abcde" +>trimLeft : () => string + +trimmed = "abcde".trimRight(); +>trimmed = "abcde".trimRight() : string +>trimmed : string +>"abcde".trimRight() : string +>"abcde".trimRight : () => string +>"abcde" : "abcde" +>trimRight : () => string + diff --git a/tests/cases/compiler/stringTrim.ts b/tests/cases/compiler/stringTrim.ts new file mode 100644 index 00000000000..d0329b87749 --- /dev/null +++ b/tests/cases/compiler/stringTrim.ts @@ -0,0 +1,7 @@ +// @target: es2019 + +var trimmed: string; +trimmed = "abcde".trimEnd(); +trimmed = "abcde".trimStart(); +trimmed = "abcde".trimLeft(); +trimmed = "abcde".trimRight(); From 343edb6702af5d384cd4fc25d5a8c64d7638f3f6 Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Fri, 8 Feb 2019 06:59:04 +0900 Subject: [PATCH 10/34] restore lib/* --- lib/lib.esnext.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/lib.esnext.d.ts b/lib/lib.esnext.d.ts index 59d33ab80f4..f213999684d 100644 --- a/lib/lib.esnext.d.ts +++ b/lib/lib.esnext.d.ts @@ -20,6 +20,7 @@ and limitations under the License. /// /// +/// /// /// /// From f46c0a45979669daf2067c3990bf604a7d35dcaf Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 8 Feb 2019 06:49:13 -0800 Subject: [PATCH 11/34] Process more complex constraints as per CR feedback --- src/compiler/checker.ts | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index aa5007065fc..bdb645a0003 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14570,19 +14570,8 @@ namespace ts { return undefined; } - function inferToHomomorphicMappedType(source: Type, target: MappedType, constraintType: IndexType) { - const inference = getInferenceInfoForType(constraintType.type); - if (inference && !inference.isFixed) { - const inferredType = inferTypeForHomomorphicMappedType(source, target, constraintType); - if (inferredType) { - const savePriority = priority; - priority |= InferencePriority.HomomorphicMappedType; - inferFromTypes(inferredType, inference.typeParameter); - priority = savePriority; - } - } - } - + // target: { [P in 'a' | 'b' | keyof T | keyof U]: XXX } + // source: { a: xxx, b: xxx, c: xxx, d: xxx } function inferToMappedType(source: Type, target: MappedType, constraintType: Type): boolean { if (constraintType.flags & TypeFlags.Union) { let result = false; @@ -14596,7 +14585,16 @@ namespace ts { // where T is a type variable. Use inferTypeForHomomorphicMappedType to infer a suitable source // type and then make a secondary inference from that type to T. We make a secondary inference // such that direct inferences to T get priority over inferences to Partial, for example. - inferToHomomorphicMappedType(source, target, constraintType); + const inference = getInferenceInfoForType((constraintType).type); + if (inference && !inference.isFixed) { + const inferredType = inferTypeForHomomorphicMappedType(source, target, constraintType); + if (inferredType) { + const savePriority = priority; + priority |= InferencePriority.HomomorphicMappedType; + inferFromTypes(inferredType, inference.typeParameter); + priority = savePriority; + } + } return true; } if (constraintType.flags & TypeFlags.TypeParameter) { @@ -14606,15 +14604,16 @@ namespace ts { priority |= InferencePriority.MappedTypeConstraint; inferFromTypes(getIndexType(source), constraintType); priority = savePriority; - // If K is constrained to an index type keyof T, where T is a type parameter, proceed to make - // the same inferences as we would for a homomorphic mapped type { [P in keyof T]: X } (this - // enables us to make meaningful inferences when the target is a Pick). Otherwise, infer - // from a union of the property types in the source to the template type X. + // If K is constrained to a type C, also infer to C. Thus, for a mapped type { [P in K]: X }, + // where K extends keyof T, we make the same inferences as for a homomorphic mapped type + // { [P in keyof T]: X }. This enables us to make meaningful inferences when the target is a + // Pick. const extendedConstraint = getConstraintOfType(constraintType); - if (extendedConstraint && extendedConstraint.flags & TypeFlags.Index) { - inferToHomomorphicMappedType(source, target, extendedConstraint); + if (extendedConstraint && inferToMappedType(source, target, extendedConstraint)) { return true; } + // If no inferences can be made to K's constraint, infer from a union of the property types + // in the source to the template type X. const valueTypes = compact([ getIndexTypeOfType(source, IndexKind.String), getIndexTypeOfType(source, IndexKind.Number), From e49320d1db82ae4e281914ab3b6c4d101da4e16d Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 8 Feb 2019 06:49:26 -0800 Subject: [PATCH 12/34] Add more tests --- .../conformance/types/mapped/isomorphicMappedTypeInference.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/cases/conformance/types/mapped/isomorphicMappedTypeInference.ts b/tests/cases/conformance/types/mapped/isomorphicMappedTypeInference.ts index 534d50c367e..031cf840d33 100644 --- a/tests/cases/conformance/types/mapped/isomorphicMappedTypeInference.ts +++ b/tests/cases/conformance/types/mapped/isomorphicMappedTypeInference.ts @@ -160,10 +160,14 @@ o = foo(o, {b: 9}); declare function f20(obj: Pick): T; declare function f21(obj: Pick): K; declare function f22(obj: Boxified>): T; +declare function f23(obj: Pick): T; +declare function f24(obj: Pick): T & U; let x0 = f20({ foo: 42, bar: "hello" }); let x1 = f21({ foo: 42, bar: "hello" }); let x2 = f22({ foo: { value: 42} , bar: { value: "hello" } }); +let x3 = f23({ foo: 42, bar: "hello" }); +let x4 = f24({ foo: 42, bar: "hello" }); // Repro from #29765 From 8652158ead4af506a604d70ad80becba7ddccea9 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 8 Feb 2019 06:49:33 -0800 Subject: [PATCH 13/34] Accept new baselines --- .../isomorphicMappedTypeInference.js | 19 ++++ .../isomorphicMappedTypeInference.symbols | 100 ++++++++++++------ .../isomorphicMappedTypeInference.types | 28 +++++ 3 files changed, 117 insertions(+), 30 deletions(-) diff --git a/tests/baselines/reference/isomorphicMappedTypeInference.js b/tests/baselines/reference/isomorphicMappedTypeInference.js index 6cfc2ec7350..aa904e9afa1 100644 --- a/tests/baselines/reference/isomorphicMappedTypeInference.js +++ b/tests/baselines/reference/isomorphicMappedTypeInference.js @@ -157,10 +157,14 @@ o = foo(o, {b: 9}); declare function f20(obj: Pick): T; declare function f21(obj: Pick): K; declare function f22(obj: Boxified>): T; +declare function f23(obj: Pick): T; +declare function f24(obj: Pick): T & U; let x0 = f20({ foo: 42, bar: "hello" }); let x1 = f21({ foo: 42, bar: "hello" }); let x2 = f22({ foo: { value: 42} , bar: { value: "hello" } }); +let x3 = f23({ foo: 42, bar: "hello" }); +let x4 = f24({ foo: 42, bar: "hello" }); // Repro from #29765 @@ -282,6 +286,8 @@ o = foo(o, { b: 9 }); var x0 = f20({ foo: 42, bar: "hello" }); var x1 = f21({ foo: 42, bar: "hello" }); var x2 = f22({ foo: { value: 42 }, bar: { value: "hello" } }); +var x3 = f23({ foo: 42, bar: "hello" }); +var x4 = f24({ foo: 42, bar: "hello" }); // Repro from #29765 function getProps(obj, list) { return {}; @@ -360,6 +366,8 @@ declare let o: { declare function f20(obj: Pick): T; declare function f21(obj: Pick): K; declare function f22(obj: Boxified>): T; +declare function f23(obj: Pick): T; +declare function f24(obj: Pick): T & U; declare let x0: { foo: number; bar: string; @@ -369,6 +377,17 @@ declare let x2: { foo: number; bar: string; }; +declare let x3: { + foo: number; + bar: string; +}; +declare let x4: { + foo: number; + bar: string; +} & { + foo: number; + bar: string; +}; declare function getProps(obj: T, list: K[]): Pick; declare const myAny: any; declare const o1: Pick; diff --git a/tests/baselines/reference/isomorphicMappedTypeInference.symbols b/tests/baselines/reference/isomorphicMappedTypeInference.symbols index 6f999f91dc4..3192be13ff6 100644 --- a/tests/baselines/reference/isomorphicMappedTypeInference.symbols +++ b/tests/baselines/reference/isomorphicMappedTypeInference.symbols @@ -523,56 +523,96 @@ declare function f22(obj: Boxified>): T; >K : Symbol(K, Decl(isomorphicMappedTypeInference.ts, 157, 23)) >T : Symbol(T, Decl(isomorphicMappedTypeInference.ts, 157, 21)) +declare function f23(obj: Pick): T; +>f23 : Symbol(f23, Decl(isomorphicMappedTypeInference.ts, 157, 73)) +>T : Symbol(T, Decl(isomorphicMappedTypeInference.ts, 158, 21)) +>U : Symbol(U, Decl(isomorphicMappedTypeInference.ts, 158, 23)) +>T : Symbol(T, Decl(isomorphicMappedTypeInference.ts, 158, 21)) +>K : Symbol(K, Decl(isomorphicMappedTypeInference.ts, 158, 42)) +>U : Symbol(U, Decl(isomorphicMappedTypeInference.ts, 158, 23)) +>obj : Symbol(obj, Decl(isomorphicMappedTypeInference.ts, 158, 56)) +>Pick : Symbol(Pick, Decl(lib.es5.d.ts, --, --)) +>T : Symbol(T, Decl(isomorphicMappedTypeInference.ts, 158, 21)) +>K : Symbol(K, Decl(isomorphicMappedTypeInference.ts, 158, 42)) +>T : Symbol(T, Decl(isomorphicMappedTypeInference.ts, 158, 21)) + +declare function f24(obj: Pick): T & U; +>f24 : Symbol(f24, Decl(isomorphicMappedTypeInference.ts, 158, 76)) +>T : Symbol(T, Decl(isomorphicMappedTypeInference.ts, 159, 21)) +>U : Symbol(U, Decl(isomorphicMappedTypeInference.ts, 159, 23)) +>K : Symbol(K, Decl(isomorphicMappedTypeInference.ts, 159, 26)) +>T : Symbol(T, Decl(isomorphicMappedTypeInference.ts, 159, 21)) +>U : Symbol(U, Decl(isomorphicMappedTypeInference.ts, 159, 23)) +>obj : Symbol(obj, Decl(isomorphicMappedTypeInference.ts, 159, 56)) +>Pick : Symbol(Pick, Decl(lib.es5.d.ts, --, --)) +>T : Symbol(T, Decl(isomorphicMappedTypeInference.ts, 159, 21)) +>U : Symbol(U, Decl(isomorphicMappedTypeInference.ts, 159, 23)) +>K : Symbol(K, Decl(isomorphicMappedTypeInference.ts, 159, 26)) +>T : Symbol(T, Decl(isomorphicMappedTypeInference.ts, 159, 21)) +>U : Symbol(U, Decl(isomorphicMappedTypeInference.ts, 159, 23)) + let x0 = f20({ foo: 42, bar: "hello" }); ->x0 : Symbol(x0, Decl(isomorphicMappedTypeInference.ts, 159, 3)) +>x0 : Symbol(x0, Decl(isomorphicMappedTypeInference.ts, 161, 3)) >f20 : Symbol(f20, Decl(isomorphicMappedTypeInference.ts, 150, 19)) ->foo : Symbol(foo, Decl(isomorphicMappedTypeInference.ts, 159, 14)) ->bar : Symbol(bar, Decl(isomorphicMappedTypeInference.ts, 159, 23)) +>foo : Symbol(foo, Decl(isomorphicMappedTypeInference.ts, 161, 14)) +>bar : Symbol(bar, Decl(isomorphicMappedTypeInference.ts, 161, 23)) let x1 = f21({ foo: 42, bar: "hello" }); ->x1 : Symbol(x1, Decl(isomorphicMappedTypeInference.ts, 160, 3)) +>x1 : Symbol(x1, Decl(isomorphicMappedTypeInference.ts, 162, 3)) >f21 : Symbol(f21, Decl(isomorphicMappedTypeInference.ts, 155, 63)) ->foo : Symbol(foo, Decl(isomorphicMappedTypeInference.ts, 160, 14)) ->bar : Symbol(bar, Decl(isomorphicMappedTypeInference.ts, 160, 23)) +>foo : Symbol(foo, Decl(isomorphicMappedTypeInference.ts, 162, 14)) +>bar : Symbol(bar, Decl(isomorphicMappedTypeInference.ts, 162, 23)) let x2 = f22({ foo: { value: 42} , bar: { value: "hello" } }); ->x2 : Symbol(x2, Decl(isomorphicMappedTypeInference.ts, 161, 3)) +>x2 : Symbol(x2, Decl(isomorphicMappedTypeInference.ts, 163, 3)) >f22 : Symbol(f22, Decl(isomorphicMappedTypeInference.ts, 156, 63)) ->foo : Symbol(foo, Decl(isomorphicMappedTypeInference.ts, 161, 14)) ->value : Symbol(value, Decl(isomorphicMappedTypeInference.ts, 161, 21)) ->bar : Symbol(bar, Decl(isomorphicMappedTypeInference.ts, 161, 34)) ->value : Symbol(value, Decl(isomorphicMappedTypeInference.ts, 161, 41)) +>foo : Symbol(foo, Decl(isomorphicMappedTypeInference.ts, 163, 14)) +>value : Symbol(value, Decl(isomorphicMappedTypeInference.ts, 163, 21)) +>bar : Symbol(bar, Decl(isomorphicMappedTypeInference.ts, 163, 34)) +>value : Symbol(value, Decl(isomorphicMappedTypeInference.ts, 163, 41)) + +let x3 = f23({ foo: 42, bar: "hello" }); +>x3 : Symbol(x3, Decl(isomorphicMappedTypeInference.ts, 164, 3)) +>f23 : Symbol(f23, Decl(isomorphicMappedTypeInference.ts, 157, 73)) +>foo : Symbol(foo, Decl(isomorphicMappedTypeInference.ts, 164, 14)) +>bar : Symbol(bar, Decl(isomorphicMappedTypeInference.ts, 164, 23)) + +let x4 = f24({ foo: 42, bar: "hello" }); +>x4 : Symbol(x4, Decl(isomorphicMappedTypeInference.ts, 165, 3)) +>f24 : Symbol(f24, Decl(isomorphicMappedTypeInference.ts, 158, 76)) +>foo : Symbol(foo, Decl(isomorphicMappedTypeInference.ts, 165, 14)) +>bar : Symbol(bar, Decl(isomorphicMappedTypeInference.ts, 165, 23)) // Repro from #29765 function getProps(obj: T, list: K[]): Pick { ->getProps : Symbol(getProps, Decl(isomorphicMappedTypeInference.ts, 161, 62)) ->T : Symbol(T, Decl(isomorphicMappedTypeInference.ts, 165, 18)) ->K : Symbol(K, Decl(isomorphicMappedTypeInference.ts, 165, 20)) ->T : Symbol(T, Decl(isomorphicMappedTypeInference.ts, 165, 18)) ->obj : Symbol(obj, Decl(isomorphicMappedTypeInference.ts, 165, 40)) ->T : Symbol(T, Decl(isomorphicMappedTypeInference.ts, 165, 18)) ->list : Symbol(list, Decl(isomorphicMappedTypeInference.ts, 165, 47)) ->K : Symbol(K, Decl(isomorphicMappedTypeInference.ts, 165, 20)) +>getProps : Symbol(getProps, Decl(isomorphicMappedTypeInference.ts, 165, 40)) +>T : Symbol(T, Decl(isomorphicMappedTypeInference.ts, 169, 18)) +>K : Symbol(K, Decl(isomorphicMappedTypeInference.ts, 169, 20)) +>T : Symbol(T, Decl(isomorphicMappedTypeInference.ts, 169, 18)) +>obj : Symbol(obj, Decl(isomorphicMappedTypeInference.ts, 169, 40)) +>T : Symbol(T, Decl(isomorphicMappedTypeInference.ts, 169, 18)) +>list : Symbol(list, Decl(isomorphicMappedTypeInference.ts, 169, 47)) +>K : Symbol(K, Decl(isomorphicMappedTypeInference.ts, 169, 20)) >Pick : Symbol(Pick, Decl(lib.es5.d.ts, --, --)) ->T : Symbol(T, Decl(isomorphicMappedTypeInference.ts, 165, 18)) ->K : Symbol(K, Decl(isomorphicMappedTypeInference.ts, 165, 20)) +>T : Symbol(T, Decl(isomorphicMappedTypeInference.ts, 169, 18)) +>K : Symbol(K, Decl(isomorphicMappedTypeInference.ts, 169, 20)) return {} as any; } const myAny: any = {}; ->myAny : Symbol(myAny, Decl(isomorphicMappedTypeInference.ts, 169, 5)) +>myAny : Symbol(myAny, Decl(isomorphicMappedTypeInference.ts, 173, 5)) const o1 = getProps(myAny, ['foo', 'bar']); ->o1 : Symbol(o1, Decl(isomorphicMappedTypeInference.ts, 171, 5)) ->getProps : Symbol(getProps, Decl(isomorphicMappedTypeInference.ts, 161, 62)) ->myAny : Symbol(myAny, Decl(isomorphicMappedTypeInference.ts, 169, 5)) +>o1 : Symbol(o1, Decl(isomorphicMappedTypeInference.ts, 175, 5)) +>getProps : Symbol(getProps, Decl(isomorphicMappedTypeInference.ts, 165, 40)) +>myAny : Symbol(myAny, Decl(isomorphicMappedTypeInference.ts, 173, 5)) const o2: { foo: any; bar: any } = getProps(myAny, ['foo', 'bar']); ->o2 : Symbol(o2, Decl(isomorphicMappedTypeInference.ts, 173, 5)) ->foo : Symbol(foo, Decl(isomorphicMappedTypeInference.ts, 173, 11)) ->bar : Symbol(bar, Decl(isomorphicMappedTypeInference.ts, 173, 21)) ->getProps : Symbol(getProps, Decl(isomorphicMappedTypeInference.ts, 161, 62)) ->myAny : Symbol(myAny, Decl(isomorphicMappedTypeInference.ts, 169, 5)) +>o2 : Symbol(o2, Decl(isomorphicMappedTypeInference.ts, 177, 5)) +>foo : Symbol(foo, Decl(isomorphicMappedTypeInference.ts, 177, 11)) +>bar : Symbol(bar, Decl(isomorphicMappedTypeInference.ts, 177, 21)) +>getProps : Symbol(getProps, Decl(isomorphicMappedTypeInference.ts, 165, 40)) +>myAny : Symbol(myAny, Decl(isomorphicMappedTypeInference.ts, 173, 5)) diff --git a/tests/baselines/reference/isomorphicMappedTypeInference.types b/tests/baselines/reference/isomorphicMappedTypeInference.types index b37175b5eed..1f1fa0d200a 100644 --- a/tests/baselines/reference/isomorphicMappedTypeInference.types +++ b/tests/baselines/reference/isomorphicMappedTypeInference.types @@ -522,6 +522,14 @@ declare function f22(obj: Boxified>): T; >f22 : (obj: Boxified>) => T >obj : Boxified> +declare function f23(obj: Pick): T; +>f23 : (obj: Pick) => T +>obj : Pick + +declare function f24(obj: Pick): T & U; +>f24 : (obj: Pick) => T & U +>obj : Pick + let x0 = f20({ foo: 42, bar: "hello" }); >x0 : { foo: number; bar: string; } >f20({ foo: 42, bar: "hello" }) : { foo: number; bar: string; } @@ -556,6 +564,26 @@ let x2 = f22({ foo: { value: 42} , bar: { value: "hello" } }); >value : string >"hello" : "hello" +let x3 = f23({ foo: 42, bar: "hello" }); +>x3 : { foo: number; bar: string; } +>f23({ foo: 42, bar: "hello" }) : { foo: number; bar: string; } +>f23 : (obj: Pick) => T +>{ foo: 42, bar: "hello" } : { foo: number; bar: string; } +>foo : number +>42 : 42 +>bar : string +>"hello" : "hello" + +let x4 = f24({ foo: 42, bar: "hello" }); +>x4 : { foo: number; bar: string; } & { foo: number; bar: string; } +>f24({ foo: 42, bar: "hello" }) : { foo: number; bar: string; } & { foo: number; bar: string; } +>f24 : (obj: Pick) => T & U +>{ foo: 42, bar: "hello" } : { foo: number; bar: string; } +>foo : number +>42 : 42 +>bar : string +>"hello" : "hello" + // Repro from #29765 function getProps(obj: T, list: K[]): Pick { From 040401205ba51d036b9ec234ff2f2341ceac96b9 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 8 Feb 2019 06:53:39 -0800 Subject: [PATCH 14/34] Delete wayward comment --- src/compiler/checker.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index bdb645a0003..b550710861c 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14570,8 +14570,6 @@ namespace ts { return undefined; } - // target: { [P in 'a' | 'b' | keyof T | keyof U]: XXX } - // source: { a: xxx, b: xxx, c: xxx, d: xxx } function inferToMappedType(source: Type, target: MappedType, constraintType: Type): boolean { if (constraintType.flags & TypeFlags.Union) { let result = false; From 61a05018cba05d223aee07432a697fe316d5ed36 Mon Sep 17 00:00:00 2001 From: TypeScript Bot Date: Fri, 8 Feb 2019 10:49:28 -0800 Subject: [PATCH 15/34] Update user baselines (#29800) --- .../user/chrome-devtools-frontend.log | 274 +++++++++++++++--- tests/baselines/reference/user/npm.log | 4 +- 2 files changed, 232 insertions(+), 46 deletions(-) diff --git a/tests/baselines/reference/user/chrome-devtools-frontend.log b/tests/baselines/reference/user/chrome-devtools-frontend.log index 7ae2531d383..3c86f06756a 100644 --- a/tests/baselines/reference/user/chrome-devtools-frontend.log +++ b/tests/baselines/reference/user/chrome-devtools-frontend.log @@ -1,16 +1,16 @@ Exit Code: 1 Standard output: -../../../../built/local/lib.dom.d.ts(2388,11): error TS2300: Duplicate identifier 'CSSRule'. -../../../../built/local/lib.dom.d.ts(2407,13): error TS2300: Duplicate identifier 'CSSRule'. -../../../../built/local/lib.dom.d.ts(3267,11): error TS2300: Duplicate identifier 'Comment'. -../../../../built/local/lib.dom.d.ts(3270,13): error TS2300: Duplicate identifier 'Comment'. -../../../../built/local/lib.dom.d.ts(4963,11): error TS2300: Duplicate identifier 'Event'. -../../../../built/local/lib.dom.d.ts(5023,13): error TS2300: Duplicate identifier 'Event'. -../../../../built/local/lib.dom.d.ts(11214,11): error TS2300: Duplicate identifier 'Position'. -../../../../built/local/lib.dom.d.ts(11959,11): error TS2300: Duplicate identifier 'Request'. -../../../../built/local/lib.dom.d.ts(12039,13): error TS2300: Duplicate identifier 'Request'. -../../../../built/local/lib.dom.d.ts(16513,11): error TS2300: Duplicate identifier 'Window'. -../../../../built/local/lib.dom.d.ts(16644,13): error TS2300: Duplicate identifier 'Window'. +../../../../built/local/lib.dom.d.ts(2439,11): error TS2300: Duplicate identifier 'CSSRule'. +../../../../built/local/lib.dom.d.ts(2458,13): error TS2300: Duplicate identifier 'CSSRule'. +../../../../built/local/lib.dom.d.ts(3339,11): error TS2300: Duplicate identifier 'Comment'. +../../../../built/local/lib.dom.d.ts(3342,13): error TS2300: Duplicate identifier 'Comment'. +../../../../built/local/lib.dom.d.ts(5032,11): error TS2300: Duplicate identifier 'Event'. +../../../../built/local/lib.dom.d.ts(5092,13): error TS2300: Duplicate identifier 'Event'. +../../../../built/local/lib.dom.d.ts(11453,11): error TS2300: Duplicate identifier 'Position'. +../../../../built/local/lib.dom.d.ts(12214,11): error TS2300: Duplicate identifier 'Request'. +../../../../built/local/lib.dom.d.ts(12294,13): error TS2300: Duplicate identifier 'Request'. +../../../../built/local/lib.dom.d.ts(16941,11): error TS2300: Duplicate identifier 'Window'. +../../../../built/local/lib.dom.d.ts(17073,13): error TS2300: Duplicate identifier 'Window'. ../../../../built/local/lib.es5.d.ts(1416,11): error TS2300: Duplicate identifier 'ArrayLike'. ../../../../built/local/lib.es5.d.ts(1452,6): error TS2300: Duplicate identifier 'Record'. ../../../../node_modules/@types/node/index.d.ts(150,13): error TS2403: Subsequent variable declarations must have the same type. Variable 'module' must be of type '{}', but here has type 'NodeModule'. @@ -158,7 +158,7 @@ node_modules/chrome-devtools-frontend/front_end/accessibility/AXBreadcrumbsPane. node_modules/chrome-devtools-frontend/front_end/accessibility/AXBreadcrumbsPane.js(391,50): error TS2345: Argument of type '0' is not assignable to parameter of type 'string'. node_modules/chrome-devtools-frontend/front_end/accessibility/AXBreadcrumbsPane.js(393,50): error TS2345: Argument of type '-1' is not assignable to parameter of type 'string'. node_modules/chrome-devtools-frontend/front_end/accessibility/AXBreadcrumbsPane.js(396,27): error TS2339: Property 'focus' does not exist on type 'Element'. -node_modules/chrome-devtools-frontend/front_end/accessibility/AXBreadcrumbsPane.js(447,26): error TS2339: Property 'breadcrumb' does not exist on type 'Node'. +node_modules/chrome-devtools-frontend/front_end/accessibility/AXBreadcrumbsPane.js(447,26): error TS2339: Property 'breadcrumb' does not exist on type 'ChildNode'. node_modules/chrome-devtools-frontend/front_end/accessibility/AXBreadcrumbsPane.js(457,30): error TS2339: Property 'breadcrumb' does not exist on type 'Node'. node_modules/chrome-devtools-frontend/front_end/accessibility/AXBreadcrumbsPane.js(473,24): error TS2694: Namespace 'Protocol' has no exported member 'Accessibility'. node_modules/chrome-devtools-frontend/front_end/accessibility/AXBreadcrumbsPane.js(481,17): error TS2339: Property 'setTextContentTruncatedIfNeeded' does not exist on type 'Element'. @@ -699,10 +699,6 @@ node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighth node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(9093,1): error TS2554: Expected 0-2 arguments, but got 3. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(9117,1): error TS2554: Expected 0-2 arguments, but got 3. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(9467,15): error TS2339: Property 'axe' does not exist on type 'Window'. -node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(9708,34): error TS2345: Argument of type 'any[][]' is not assignable to parameter of type 'readonly [any, any][]'. - Type 'any[]' is missing the following properties from type '[any, any]': 0, 1 -node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(9948,10): error TS2693: 'ShadowRoot' only refers to a type, but is being used as a value here. -node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(9969,4): error TS2693: 'ShadowRoot' only refers to a type, but is being used as a value here. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(10092,16): error TS2304: Cannot find name 'd41d8cd98f00b204e9800998ecf8427e_LibraryDetectorTests'. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(10513,19): error TS2488: Type 'NodeListOf' must have a '[Symbol.iterator]()' method that returns an iterator. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(10811,19): error TS2304: Cannot find name 'getElementsInDocument'. @@ -3981,7 +3977,7 @@ node_modules/chrome-devtools-frontend/front_end/console/ConsoleSidebar.js(107,9) node_modules/chrome-devtools-frontend/front_end/console/ConsoleSidebar.js(111,9): error TS2339: Property 'ConsoleSidebar' does not exist on type '{ new (): Console; prototype: Console; }'. node_modules/chrome-devtools-frontend/front_end/console/ConsoleSidebar.js(119,47): error TS2339: Property 'createChild' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/console/ConsoleSidebar.js(122,25): error TS2345: Argument of type 'Element' is not assignable to parameter of type 'Icon'. - Type 'Element' is missing the following properties from type 'Icon': createdCallback, _descriptor, _spriteSheet, _iconType, and 116 more. + Type 'Element' is missing the following properties from type 'Icon': createdCallback, _descriptor, _spriteSheet, _iconType, and 117 more. node_modules/chrome-devtools-frontend/front_end/console/ConsoleSidebar.js(133,9): error TS2339: Property 'ConsoleSidebar' does not exist on type '{ new (): Console; prototype: Console; }'. node_modules/chrome-devtools-frontend/front_end/console/ConsoleSidebar.js(147,27): error TS2322: Type 'Element' is not assignable to type 'Icon'. node_modules/chrome-devtools-frontend/front_end/console/ConsoleSidebar.js(177,60): error TS2555: Expected at least 2 arguments, but got 1. @@ -5065,8 +5061,6 @@ node_modules/chrome-devtools-frontend/front_end/dom_extension/DOMExtension.js(25 node_modules/chrome-devtools-frontend/front_end/dom_extension/DOMExtension.js(253,61): error TS2339: Property 'host' does not exist on type 'Node'. node_modules/chrome-devtools-frontend/front_end/dom_extension/DOMExtension.js(254,17): error TS2339: Property 'host' does not exist on type 'Node'. node_modules/chrome-devtools-frontend/front_end/dom_extension/DOMExtension.js(261,16): error TS2339: Property 'getComponentSelection' does not exist on type 'Node'. -node_modules/chrome-devtools-frontend/front_end/dom_extension/DOMExtension.js(265,28): error TS2693: 'ShadowRoot' only refers to a type, but is being used as a value here. -node_modules/chrome-devtools-frontend/front_end/dom_extension/DOMExtension.js(265,48): error TS2339: Property 'getSelection' does not exist on type 'Node & ParentNode'. node_modules/chrome-devtools-frontend/front_end/dom_extension/DOMExtension.js(265,70): error TS2339: Property 'window' does not exist on type 'Node'. node_modules/chrome-devtools-frontend/front_end/dom_extension/DOMExtension.js(271,16): error TS2339: Property 'hasSelection' does not exist on type 'Node'. node_modules/chrome-devtools-frontend/front_end/dom_extension/DOMExtension.js(273,23): error TS2339: Property 'querySelectorAll' does not exist on type 'Node'. @@ -5149,7 +5143,7 @@ node_modules/chrome-devtools-frontend/front_end/dom_extension/DOMExtension.js(74 node_modules/chrome-devtools-frontend/front_end/dom_extension/DOMExtension.js(745,48): error TS2339: Property 'pageX' does not exist on type 'Event'. node_modules/chrome-devtools-frontend/front_end/dom_extension/DOMExtension.js(745,60): error TS2339: Property 'pageY' does not exist on type 'Event'. node_modules/chrome-devtools-frontend/front_end/dom_extension/DOMExtension.js(753,20): error TS2339: Property 'deepElementFromPoint' does not exist on type 'Document'. -node_modules/chrome-devtools-frontend/front_end/dom_extension/DOMExtension.js(761,5): error TS2740: Type 'ShadowRoot' is missing the following properties from type 'Document': URL, alinkColor, all, anchors, and 169 more. +node_modules/chrome-devtools-frontend/front_end/dom_extension/DOMExtension.js(761,5): error TS2740: Type 'ShadowRoot' is missing the following properties from type 'Document': URL, alinkColor, all, anchors, and 174 more. node_modules/chrome-devtools-frontend/front_end/dom_extension/DOMExtension.js(766,28): error TS2339: Property 'deepElementFromPoint' does not exist on type 'DocumentFragment'. node_modules/chrome-devtools-frontend/front_end/dom_extension/DOMExtension.js(766,70): error TS2339: Property 'deepElementFromPoint' does not exist on type 'Document'. node_modules/chrome-devtools-frontend/front_end/dom_extension/DOMExtension.js(771,20): error TS2339: Property 'deepActiveElement' does not exist on type 'Document'. @@ -5367,7 +5361,7 @@ node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeElement.js( node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeElement.js(575,10): error TS2339: Property 'style' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeElement.js(576,10): error TS2339: Property 'style' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeElement.js(580,10): error TS2339: Property 'scrollIntoViewIfNeeded' does not exist on type 'Element'. -node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeElement.js(592,20): error TS2339: Property 'classList' does not exist on type 'Node'. +node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeElement.js(592,20): error TS2339: Property 'classList' does not exist on type 'ChildNode'. node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeElement.js(600,41): error TS2339: Property 'isAncestor' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeElement.js(632,27): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeElement.js(655,26): error TS2339: Property 'getComponentSelection' does not exist on type 'Element'. @@ -5377,7 +5371,6 @@ node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeElement.js( node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeElement.js(738,14): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeElement.js(739,14): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeElement.js(762,13): error TS2339: Property 'style' does not exist on type 'ChildNode'. -node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeElement.js(763,7): error TS2739: Type 'Node' is missing the following properties from type 'ChildNode': after, before, remove, replaceWith node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeElement.js(767,32): error TS2339: Property 'style' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeElement.js(772,10): error TS2339: Property 'runtime' does not exist on type 'Window'. node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeElement.js(796,24): error TS2339: Property 'setMultilineEditing' does not exist on type 'TreeOutline'. @@ -5385,7 +5378,6 @@ node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeElement.js( node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeElement.js(803,60): error TS2339: Property 'visibleWidth' does not exist on type 'TreeOutline'. node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeElement.js(828,34): error TS2339: Property 'style' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeElement.js(832,15): error TS2339: Property 'style' does not exist on type 'ChildNode'. -node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeElement.js(833,9): error TS2322: Type 'Node' is not assignable to type 'ChildNode'. node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeElement.js(837,26): error TS2339: Property 'setMultilineEditing' does not exist on type 'TreeOutline'. node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeElement.js(851,18): error TS2339: Property 'altKey' does not exist on type 'Event'. node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeElement.js(851,35): error TS2339: Property 'shiftKey' does not exist on type 'Event'. @@ -5466,7 +5458,7 @@ node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeOutline.js( node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeOutline.js(755,33): error TS2339: Property 'enclosingNodeOrSelfWithClass' does not exist on type 'EventTarget'. node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeOutline.js(758,36): error TS2339: Property 'enclosingNodeOrSelfWithClass' does not exist on type 'EventTarget'. node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeOutline.js(813,22): error TS2339: Property 'index' does not exist on type 'DOMNode'. -node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeOutline.js(920,9): error TS2740: Type 'Node & ParentNode' is missing the following properties from type 'Element': assignedSlot, attributes, classList, className, and 63 more. +node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeOutline.js(920,9): error TS2740: Type 'Node & ParentNode' is missing the following properties from type 'Element': assignedSlot, attributes, classList, className, and 64 more. node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeOutline.js(930,13): error TS2339: Property 'type' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeOutline.js(1010,22): error TS2694: Namespace 'Common' has no exported member 'Event'. node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeOutline.js(1025,22): error TS2694: Namespace 'Common' has no exported member 'Event'. @@ -5658,14 +5650,13 @@ node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(10 node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(1040,69): error TS2339: Property 'selectorText' does not exist on type 'CSSRule'. node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(1055,24): error TS2339: Property '_section' does not exist on type 'ChildNode'. node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(1056,29): error TS2339: Property '_section' does not exist on type 'ChildNode'. -node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(1057,7): error TS2322: Type 'Node' is not assignable to type 'ChildNode'. node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(1073,24): error TS2339: Property '_section' does not exist on type 'ChildNode'. node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(1074,29): error TS2339: Property '_section' does not exist on type 'ChildNode'. -node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(1075,7): error TS2322: Type 'Node' is not assignable to type 'ChildNode'. -node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(1087,7): error TS2740: Type 'Node' is missing the following properties from type 'Element': assignedSlot, attributes, classList, className, and 71 more. +node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(1075,7): error TS2739: Type 'Node' is missing the following properties from type 'ChildNode': after, before, remove, replaceWith +node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(1087,7): error TS2740: Type 'ChildNode' is missing the following properties from type 'Element': assignedSlot, attributes, classList, className, and 68 more. node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(1088,38): error TS2339: Property '_section' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(1090,36): error TS2339: Property '_section' does not exist on type 'Element'. -node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(1099,7): error TS2322: Type 'Node' is not assignable to type 'Element'. +node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(1099,7): error TS2740: Type 'Node' is missing the following properties from type 'Element': assignedSlot, attributes, classList, className, and 72 more. node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(1100,38): error TS2339: Property '_section' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(1102,36): error TS2339: Property '_section' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(1106,22): error TS2694: Namespace 'Common' has no exported member 'Event'. @@ -6143,7 +6134,6 @@ node_modules/chrome-devtools-frontend/front_end/extensions/ExtensionServer.js(13 node_modules/chrome-devtools-frontend/front_end/extensions/ExtensionServer.js(161,5): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/extensions/ExtensionServer.js(219,43): error TS2694: Namespace 'Protocol' has no exported member 'Network'. node_modules/chrome-devtools-frontend/front_end/extensions/ExtensionServer.js(244,54): error TS2339: Property 'traverseNextNode' does not exist on type 'HTMLElement'. -node_modules/chrome-devtools-frontend/front_end/extensions/ExtensionServer.js(245,27): error TS2693: 'ShadowRoot' only refers to a type, but is being used as a value here. node_modules/chrome-devtools-frontend/front_end/extensions/ExtensionServer.js(463,53): error TS2345: Argument of type '{ url: string; type: string; }' is not assignable to parameter of type '{ contentURL(): string; contentType(): ResourceType; contentEncoded(): Promise; requestContent(): Promise; searchInContent(query: string, caseSensitive: boolean, isRegex: boolean): Promise<...>; }'. Type '{ url: string; type: string; }' is missing the following properties from type '{ contentURL(): string; contentType(): ResourceType; contentEncoded(): Promise; requestContent(): Promise; searchInContent(query: string, caseSensitive: boolean, isRegex: boolean): Promise<...>; }': contentURL, contentType, contentEncoded, requestContent, searchInContent node_modules/chrome-devtools-frontend/front_end/extensions/ExtensionServer.js(471,22): error TS2339: Property 'valuesArray' does not exist on type 'Map; requestContent(): Promise; searchInContent(query: string, caseSensitive: boolean, isRegex: boolean): Promise<...>; }>'. @@ -6927,7 +6917,6 @@ node_modules/chrome-devtools-frontend/front_end/layer_viewer/Layers3DView.js(852 node_modules/chrome-devtools-frontend/front_end/layer_viewer/Layers3DView.js(858,13): error TS2339: Property 'image' does not exist on type 'WebGLTexture'. node_modules/chrome-devtools-frontend/front_end/layer_viewer/Layers3DView.js(861,81): error TS2339: Property 'image' does not exist on type 'WebGLTexture'. node_modules/chrome-devtools-frontend/front_end/layer_viewer/Layers3DView.js(928,26): error TS2694: Namespace 'SDK' has no exported member 'SnapshotWithRect'. -node_modules/chrome-devtools-frontend/front_end/layer_viewer/Layers3DView.js(932,39): error TS2345: Argument of type 'any[][]' is not assignable to parameter of type 'readonly [any, any][]'. node_modules/chrome-devtools-frontend/front_end/layer_viewer/Layers3DView.js(1080,24): error TS2694: Namespace 'Protocol' has no exported member 'DOM'. node_modules/chrome-devtools-frontend/front_end/layer_viewer/Layers3DView.js(1098,15): error TS2304: Cannot find name 'CSSMatrix'. node_modules/chrome-devtools-frontend/front_end/layer_viewer/Layers3DView.js(1143,19): error TS2694: Namespace 'SDK' has no exported member 'SnapshotWithRect'. @@ -8059,8 +8048,8 @@ node_modules/chrome-devtools-frontend/front_end/perf_ui/TimelineGrid.js(189,25): node_modules/chrome-devtools-frontend/front_end/perf_ui/TimelineGrid.js(196,23): error TS2339: Property '_labelElement' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/perf_ui/TimelineGrid.js(199,15): error TS2339: Property 'style' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/perf_ui/TimelineGrid.js(200,23): error TS2339: Property 'style' does not exist on type 'Element'. -node_modules/chrome-devtools-frontend/front_end/perf_ui/TimelineGrid.js(210,7): error TS2322: Type 'Node' is not assignable to type 'Element'. -node_modules/chrome-devtools-frontend/front_end/perf_ui/TimelineGrid.js(215,7): error TS2322: Type 'Node' is not assignable to type 'Element'. +node_modules/chrome-devtools-frontend/front_end/perf_ui/TimelineGrid.js(210,7): error TS2322: Type 'ChildNode' is not assignable to type 'Element'. +node_modules/chrome-devtools-frontend/front_end/perf_ui/TimelineGrid.js(215,7): error TS2322: Type 'ChildNode' is not assignable to type 'Element'. node_modules/chrome-devtools-frontend/front_end/perf_ui/TimelineGrid.js(267,21): error TS2339: Property 'DividersData' does not exist on type 'typeof TimelineGrid'. node_modules/chrome-devtools-frontend/front_end/perf_ui/TimelineGrid.js(277,15): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. node_modules/chrome-devtools-frontend/front_end/perf_ui/TimelineGrid.js(284,15): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. @@ -8343,7 +8332,212 @@ node_modules/chrome-devtools-frontend/front_end/product_registry/ProductRegistry node_modules/chrome-devtools-frontend/front_end/product_registry/ProductRegistry.js(34,15): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. node_modules/chrome-devtools-frontend/front_end/product_registry/ProductRegistry.js(55,41): error TS2694: Namespace 'ProductRegistry.Registry' has no exported member 'ProductEntry'. node_modules/chrome-devtools-frontend/front_end/product_registry/ProductRegistry.js(72,26): error TS2339: Property 'ProductEntry' does not exist on type 'typeof Registry'. -node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(1488,1): error TS2590: Expression produces a union type that is too complex to represent. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(1559,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(1563,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(1604,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(1605,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(1606,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(1865,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(2136,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(2136,64): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(2136,86): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(2208,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(2269,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(2270,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(2322,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(2323,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(2503,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(2856,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(2857,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(2858,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(2859,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(2860,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(2861,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(2862,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(2863,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(2864,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(2865,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(3126,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(3572,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(3573,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(3574,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(3575,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(3576,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(3747,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(3748,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(3770,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(3771,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(3772,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(3773,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(3774,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(3775,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(3776,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(3780,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(3819,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(3826,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(3873,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(3874,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(3957,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(3958,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(4068,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(4069,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(4138,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(4139,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(4203,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(4230,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(4260,104): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(4264,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(4265,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(4266,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(4312,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(4480,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(4832,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(4833,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(4834,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(4835,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(5127,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(5137,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(5159,70): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(5175,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(5186,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(5202,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(5249,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(5522,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(5523,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(5524,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(5525,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(5539,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(5565,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(5612,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(5613,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(5614,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(5615,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(5616,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(5617,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(5618,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(5619,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(5684,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(5789,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(5820,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(5852,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(5858,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(5859,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(5860,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(5970,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(5971,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(5972,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6145,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6151,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6152,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6153,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6154,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6180,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6181,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6182,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6183,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6184,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6185,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6186,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6187,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6193,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6194,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6195,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6196,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6197,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6198,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6199,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6217,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6218,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6225,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6227,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6228,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6229,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6230,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6231,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6232,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6233,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6243,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6270,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6272,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6276,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6294,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6296,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6297,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6298,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6299,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6300,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6303,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6305,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6323,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6324,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6325,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6326,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6327,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6333,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6334,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6335,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6336,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6337,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6338,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6339,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6340,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6341,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6342,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6343,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6344,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6345,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6346,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6347,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6348,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6349,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6350,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6351,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6360,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6361,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6362,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6363,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6364,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6365,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6369,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6382,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6388,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6389,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6404,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6405,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6406,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6425,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6441,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6442,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6445,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6481,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6521,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6560,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6573,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6574,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6575,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6576,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6577,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6578,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6579,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6580,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6581,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6582,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6583,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6615,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6620,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6629,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6637,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6661,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6668,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6675,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6689,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6690,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6699,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6726,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6735,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6737,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6738,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6741,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryImpl.js(27,41): error TS2694: Namespace 'ProductRegistry.Registry' has no exported member 'ProductEntry'. node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryImpl.js(103,67): error TS2694: Namespace 'ProductRegistry.Registry' has no exported member 'ProductEntry'. node_modules/chrome-devtools-frontend/front_end/profiler/BottomUpProfileDataGrid.js(83,15): error TS2339: Property '_remainingNodeInfos' does not exist on type 'ProfileDataGridNode'. @@ -8772,8 +8966,6 @@ node_modules/chrome-devtools-frontend/front_end/profiler/ProfileView.js(57,23): node_modules/chrome-devtools-frontend/front_end/profiler/ProfileView.js(78,46): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/profiler/ProfileView.js(79,46): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/profiler/ProfileView.js(80,45): error TS2555: Expected at least 2 arguments, but got 1. -node_modules/chrome-devtools-frontend/front_end/profiler/ProfileView.js(84,17): error TS2345: Argument of type '(string | Element)[][]' is not assignable to parameter of type 'readonly [any, any][]'. - Type '(string | Element)[]' is missing the following properties from type '[any, any]': 0, 1 node_modules/chrome-devtools-frontend/front_end/profiler/ProfileView.js(136,59): error TS2339: Property 'profile' does not exist on type 'ProfileView'. node_modules/chrome-devtools-frontend/front_end/profiler/ProfileView.js(136,78): error TS2339: Property 'adjustedTotal' does not exist on type 'ProfileView'. node_modules/chrome-devtools-frontend/front_end/profiler/ProfileView.js(147,59): error TS2339: Property 'profile' does not exist on type 'ProfileView'. @@ -10730,7 +10922,6 @@ node_modules/chrome-devtools-frontend/front_end/source_frame/XMLView.js(54,59): node_modules/chrome-devtools-frontend/front_end/source_frame/XMLView.js(73,28): error TS2339: Property 'setSearchRegex' does not exist on type 'TreeElement'. node_modules/chrome-devtools-frontend/front_end/source_frame/XMLView.js(80,23): error TS2339: Property 'setSearchRegex' does not exist on type 'TreeElement'. node_modules/chrome-devtools-frontend/front_end/source_frame/XMLView.js(223,35): error TS2339: Property 'childElementCount' does not exist on type 'Node'. -node_modules/chrome-devtools-frontend/front_end/source_frame/XMLView.js(242,7): error TS2322: Type 'Node' is not assignable to type 'ChildNode'. node_modules/chrome-devtools-frontend/front_end/source_frame/XMLView.js(290,24): error TS2339: Property 'tagName' does not exist on type 'Node'. node_modules/chrome-devtools-frontend/front_end/source_frame/XMLView.js(296,31): error TS2339: Property 'attributes' does not exist on type 'Node'. node_modules/chrome-devtools-frontend/front_end/source_frame/XMLView.js(305,20): error TS2339: Property 'childElementCount' does not exist on type 'Node'. @@ -10860,8 +11051,6 @@ node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSid node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(80,71): error TS2339: Property 'uiLocation' does not exist on type 'V'. node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(81,60): error TS2339: Property 'breakpoint' does not exist on type 'V'. node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(82,62): error TS2339: Property 'breakpoint' does not exist on type 'V'. -node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(87,7): error TS2322: Type 'Node' is not assignable to type 'ChildNode'. -node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(92,7): error TS2322: Type 'Node' is not assignable to type 'ChildNode'. node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(119,5): error TS2322: Type 'Promise' is not assignable to type 'Promise'. node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(141,29): error TS2339: Property 'enclosingNodeOrSelfWithClass' does not exist on type 'EventTarget'. node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(156,33): error TS2339: Property 'checkboxElement' does not exist on type 'EventTarget'. @@ -11345,8 +11534,6 @@ node_modules/chrome-devtools-frontend/front_end/sources_test_runner/SourcesTestR node_modules/chrome-devtools-frontend/front_end/sources_test_runner/SourcesTestRunner.js(129,11): error TS2339: Property 'pushAll' does not exist on type 'any[]'. node_modules/chrome-devtools-frontend/front_end/terminal/TerminalWidget.js(29,54): error TS2339: Property 'createChild' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/terminal/TerminalWidget.js(30,65): error TS2555: Expected at least 2 arguments, but got 1. -node_modules/chrome-devtools-frontend/front_end/terminal/TerminalWidget.js(139,9): error TS2322: Type 'Node' is not assignable to type 'ChildNode'. -node_modules/chrome-devtools-frontend/front_end/terminal/TerminalWidget.js(146,7): error TS2322: Type 'Node' is not assignable to type 'ChildNode'. node_modules/chrome-devtools-frontend/front_end/terminal/xterm.js/addons/fit/fit.js(19,34): error TS2307: Cannot find module '../../xterm'. node_modules/chrome-devtools-frontend/front_end/terminal/xterm.js/addons/fit/fit.js(20,21): error TS2304: Cannot find name 'define'. node_modules/chrome-devtools-frontend/front_end/terminal/xterm.js/addons/fit/fit.js(24,5): error TS2304: Cannot find name 'define'. @@ -11500,7 +11687,6 @@ node_modules/chrome-devtools-frontend/front_end/test_runner/TestRunner.js(683,28 node_modules/chrome-devtools-frontend/front_end/test_runner/TestRunner.js(717,24): error TS2694: Namespace 'TestRunner' has no exported member 'CustomFormatters'. node_modules/chrome-devtools-frontend/front_end/test_runner/TestRunner.js(748,24): error TS2694: Namespace 'TestRunner' has no exported member 'CustomFormatters'. node_modules/chrome-devtools-frontend/front_end/test_runner/TestRunner.js(777,22): error TS2339: Property 'attributes' does not exist on type 'Node'. -node_modules/chrome-devtools-frontend/front_end/test_runner/TestRunner.js(783,46): error TS2322: Type 'Node' is not assignable to type 'ChildNode'. node_modules/chrome-devtools-frontend/front_end/test_runner/TestRunner.js(785,14): error TS2339: Property 'shadowRoot' does not exist on type 'Node'. node_modules/chrome-devtools-frontend/front_end/test_runner/TestRunner.js(786,39): error TS2339: Property 'shadowRoot' does not exist on type 'Node'. node_modules/chrome-devtools-frontend/front_end/test_runner/TestRunner.js(805,12): error TS2339: Property 'shadowRoot' does not exist on type 'Node'. @@ -11742,7 +11928,7 @@ node_modules/chrome-devtools-frontend/front_end/timeline/TimelineEventOverview.j node_modules/chrome-devtools-frontend/front_end/timeline/TimelineEventOverview.js(246,68): error TS2339: Property 'peekLast' does not exist on type 'any[]'. node_modules/chrome-devtools-frontend/front_end/timeline/TimelineEventOverview.js(248,81): error TS2339: Property '_overviewIndex' does not exist on type 'TimelineCategory'. node_modules/chrome-devtools-frontend/front_end/timeline/TimelineEventOverview.js(384,7): error TS2322: Type 'Promise HTMLImageElement>' is not assignable to type 'Promise'. - Type 'new (width?: number, height?: number) => HTMLImageElement' is missing the following properties from type 'HTMLImageElement': align, alt, border, complete, and 259 more. + Type 'new (width?: number, height?: number) => HTMLImageElement' is missing the following properties from type 'HTMLImageElement': align, alt, border, complete, and 261 more. node_modules/chrome-devtools-frontend/front_end/timeline/TimelineEventOverview.js(457,17): error TS2339: Property 'createChild' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/timeline/TimelineEventOverview.js(483,24): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/timeline/TimelineEventOverview.js(524,28): error TS2339: Property 'peekLast' does not exist on type 'TimelineFrame[]'. @@ -12252,7 +12438,7 @@ node_modules/chrome-devtools-frontend/front_end/timeline/TimelineUIUtils.js(1652 node_modules/chrome-devtools-frontend/front_end/timeline/TimelineUIUtils.js(1657,64): error TS2345: Argument of type 'new (width?: number, height?: number) => HTMLImageElement' is not assignable to parameter of type 'Node'. node_modules/chrome-devtools-frontend/front_end/timeline/TimelineUIUtils.js(1664,11): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/timeline/TimelineUIUtils.js(1665,67): error TS2555: Expected at least 2 arguments, but got 1. -node_modules/chrome-devtools-frontend/front_end/timeline/TimelineUIUtils.js(1675,5): error TS2740: Type 'DocumentFragment' is missing the following properties from type 'Element': assignedSlot, attributes, classList, className, and 63 more. +node_modules/chrome-devtools-frontend/front_end/timeline/TimelineUIUtils.js(1675,5): error TS2740: Type 'DocumentFragment' is missing the following properties from type 'Element': assignedSlot, attributes, classList, className, and 64 more. node_modules/chrome-devtools-frontend/front_end/timeline/TimelineUIUtils.js(1684,30): error TS2339: Property 'millisToString' does not exist on type 'NumberConstructor'. node_modules/chrome-devtools-frontend/front_end/timeline/TimelineUIUtils.js(1685,16): error TS2339: Property 'millisToString' does not exist on type 'NumberConstructor'. node_modules/chrome-devtools-frontend/front_end/timeline/TimelineUIUtils.js(1687,13): error TS2339: Property 'createTextChild' does not exist on type 'Element'. @@ -13027,7 +13213,7 @@ node_modules/chrome-devtools-frontend/front_end/ui/TextPrompt.js(592,35): error node_modules/chrome-devtools-frontend/front_end/ui/TextPrompt.js(601,32): error TS2339: Property 'isAncestor' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/ui/TextPrompt.js(610,54): error TS2339: Property 'isAncestor' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/ui/TextPrompt.js(622,35): error TS2339: Property 'getComponentSelection' does not exist on type 'Element'. -node_modules/chrome-devtools-frontend/front_end/ui/TextPrompt.js(627,7): error TS2740: Type 'ChildNode' is missing the following properties from type 'Element': assignedSlot, attributes, classList, className, and 67 more. +node_modules/chrome-devtools-frontend/front_end/ui/TextPrompt.js(627,7): error TS2322: Type 'ChildNode' is not assignable to type 'Element'. node_modules/chrome-devtools-frontend/front_end/ui/Toolbar.js(43,50): error TS2339: Property 'createChild' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/ui/Toolbar.js(48,45): error TS2339: Property 'createChild' does not exist on type 'DocumentFragment'. node_modules/chrome-devtools-frontend/front_end/ui/Toolbar.js(75,24): error TS2694: Namespace 'Common' has no exported member 'Event'. diff --git a/tests/baselines/reference/user/npm.log b/tests/baselines/reference/user/npm.log index 91a408b91d7..525a1007870 100644 --- a/tests/baselines/reference/user/npm.log +++ b/tests/baselines/reference/user/npm.log @@ -802,9 +802,9 @@ node_modules/npm/lib/utils/error-handler.js(146,27): error TS2339: Property 'con node_modules/npm/lib/utils/error-handler.js(166,14): error TS2339: Property 'code' does not exist on type 'Error'. node_modules/npm/lib/utils/error-handler.js(167,16): error TS2339: Property 'code' does not exist on type 'Error'. node_modules/npm/lib/utils/error-handler.js(168,8): error TS2339: Property 'code' does not exist on type 'Error'. -node_modules/npm/lib/utils/error-handler.js(186,40): error TS2345: Argument of type '{ (value: any, replacer?: ((key: string, value: any) => any) | undefined, space?: string | number | undefined): string; (value: any, replacer?: (string | number)[] | null | undefined, space?: string | ... 1 more ... | undefined): string; }' is not assignable to parameter of type '(value: string, index: number, array: string[]) => string'. +node_modules/npm/lib/utils/error-handler.js(186,40): error TS2345: Argument of type '{ (value: any, replacer?: ((this: any, key: string, value: any) => any) | undefined, space?: string | number | undefined): string; (value: any, replacer?: (string | number)[] | null | undefined, space?: string | ... 1 more ... | undefined): string; }' is not assignable to parameter of type '(value: string, index: number, array: string[]) => string'. Types of parameters 'replacer' and 'index' are incompatible. - Type 'number' is not assignable to type '((key: string, value: any) => any) | undefined'. + Type 'number' is not assignable to type '((this: any, key: string, value: any) => any) | undefined'. node_modules/npm/lib/utils/error-handler.js(188,33): error TS2339: Property 'version' does not exist on type 'typeof EventEmitter'. node_modules/npm/lib/utils/error-handler.js(205,11): error TS2339: Property 'config' does not exist on type 'typeof EventEmitter'. node_modules/npm/lib/utils/error-handler.js(208,18): error TS2339: Property 'code' does not exist on type 'Error'. From bbf559b9c7fd21b984d7cb538140c74e3d6a6b45 Mon Sep 17 00:00:00 2001 From: TypeScript Bot Date: Fri, 8 Feb 2019 11:03:58 -0800 Subject: [PATCH 16/34] Update user baselines (#29826) --- .../reference/user/chrome-devtools-frontend.log | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/baselines/reference/user/chrome-devtools-frontend.log b/tests/baselines/reference/user/chrome-devtools-frontend.log index 3c86f06756a..55c189a92d6 100644 --- a/tests/baselines/reference/user/chrome-devtools-frontend.log +++ b/tests/baselines/reference/user/chrome-devtools-frontend.log @@ -3751,6 +3751,7 @@ node_modules/chrome-devtools-frontend/front_end/common/ParsedURL.js(152,25): err node_modules/chrome-devtools-frontend/front_end/common/ParsedURL.js(161,25): error TS2339: Property 'asParsedURL' does not exist on type 'string'. node_modules/chrome-devtools-frontend/front_end/common/ParsedURL.js(211,34): error TS2339: Property 'asParsedURL' does not exist on type 'string'. node_modules/chrome-devtools-frontend/front_end/common/ParsedURL.js(215,29): error TS2339: Property 'asParsedURL' does not exist on type 'string'. +node_modules/chrome-devtools-frontend/front_end/common/ParsedURL.js(318,32): error TS2554: Expected 0 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/common/ParsedURL.js(375,18): error TS2339: Property 'asParsedURL' does not exist on type 'String'. node_modules/chrome-devtools-frontend/front_end/common/SegmentedRange.js(48,37): error TS2339: Property 'lowerBound' does not exist on type 'Segment[]'. node_modules/chrome-devtools-frontend/front_end/common/Settings.js(49,10): error TS2339: Property 'runtime' does not exist on type 'Window'. @@ -3902,6 +3903,7 @@ node_modules/chrome-devtools-frontend/front_end/console/ConsoleContextSelector.j node_modules/chrome-devtools-frontend/front_end/console/ConsoleContextSelector.js(192,22): error TS2694: Namespace 'Common' has no exported member 'Event'. node_modules/chrome-devtools-frontend/front_end/console/ConsoleContextSelector.js(200,22): error TS2694: Namespace 'Common' has no exported member 'Event'. node_modules/chrome-devtools-frontend/front_end/console/ConsoleContextSelector.js(255,28): error TS2339: Property 'createChild' does not exist on type 'DocumentFragment'. +node_modules/chrome-devtools-frontend/front_end/console/ConsoleContextSelector.js(256,27): error TS2554: Expected 0 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/console/ConsoleContextSelector.js(257,31): error TS2339: Property 'createChild' does not exist on type 'DocumentFragment'. node_modules/chrome-devtools-frontend/front_end/console/ConsoleContextSelector.js(264,13): error TS2339: Property 'style' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/console/ConsoleContextSelector.js(279,14): error TS2555: Expected at least 2 arguments, but got 1. @@ -4180,6 +4182,7 @@ node_modules/chrome-devtools-frontend/front_end/console/ConsoleViewMessage.js(70 node_modules/chrome-devtools-frontend/front_end/console/ConsoleViewMessage.js(733,19): error TS2339: Property 'removeChildren' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/console/ConsoleViewMessage.js(735,35): error TS2339: Property 'createChild' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/console/ConsoleViewMessage.js(736,31): error TS2555: Expected at least 2 arguments, but got 1. +node_modules/chrome-devtools-frontend/front_end/console/ConsoleViewMessage.js(750,27): error TS2554: Expected 0 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/console/ConsoleViewMessage.js(803,34): error TS2339: Property 'style' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/console/ConsoleViewMessage.js(804,31): error TS2339: Property 'style' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/console/ConsoleViewMessage.js(806,43): error TS2339: Property 'style' does not exist on type 'Element'. @@ -4517,6 +4520,7 @@ node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(98,48): er node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(109,26): error TS2352: Conversion of type 'DataGridNode' to type 'NODE_TYPE' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(121,17): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(123,17): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. +node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(134,29): error TS2554: Expected 0 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(135,15): error TS2339: Property 'title' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(139,15): error TS2339: Property 'title' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(159,33): error TS2694: Namespace 'DataGrid.DataGrid' has no exported member 'ColumnDescriptor'. @@ -7751,6 +7755,7 @@ node_modules/chrome-devtools-frontend/front_end/object_ui/JavaScriptAutocomplete node_modules/chrome-devtools-frontend/front_end/object_ui/JavaScriptAutocomplete.js(471,33): error TS2339: Property 'CompletionGroup' does not exist on type 'typeof JavaScriptAutocomplete'. node_modules/chrome-devtools-frontend/front_end/object_ui/ObjectPopoverHelper.js(82,35): error TS2694: Namespace 'SDK.DebuggerModel' has no exported member 'FunctionDetails'. node_modules/chrome-devtools-frontend/front_end/object_ui/ObjectPopoverHelper.js(91,29): error TS2339: Property 'createChild' does not exist on type 'Element'. +node_modules/chrome-devtools-frontend/front_end/object_ui/ObjectPopoverHelper.js(108,23): error TS2554: Expected 0 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/object_ui/ObjectPopoverHelper.js(114,48): error TS2339: Property 'createChild' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/object_ui/ObjectPopoverHelper.js(129,7): error TS2722: Cannot invoke an object which is possibly 'undefined'. node_modules/chrome-devtools-frontend/front_end/object_ui/ObjectPopoverHelper.js(145,50): error TS2339: Property 'createChild' does not exist on type 'Element'. @@ -7763,6 +7768,7 @@ node_modules/chrome-devtools-frontend/front_end/object_ui/ObjectPropertiesSectio node_modules/chrome-devtools-frontend/front_end/object_ui/ObjectPropertiesSection.js(181,18): error TS2339: Property 'title' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/object_ui/ObjectPropertiesSection.js(207,22): error TS2339: Property 'createChild' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/object_ui/ObjectPropertiesSection.js(209,22): error TS2339: Property 'createTextChild' does not exist on type 'Element'. +node_modules/chrome-devtools-frontend/front_end/object_ui/ObjectPropertiesSection.js(209,38): error TS2554: Expected 0 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/object_ui/ObjectPropertiesSection.js(211,22): error TS2339: Property 'createTextChild' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/object_ui/ObjectPropertiesSection.js(263,20): error TS2339: Property 'title' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/object_ui/ObjectPropertiesSection.js(268,22): error TS2339: Property 'setTextContentTruncatedIfNeeded' does not exist on type 'Element'. @@ -8242,6 +8248,7 @@ node_modules/chrome-devtools-frontend/front_end/platform/utilities.js(125,15): e node_modules/chrome-devtools-frontend/front_end/platform/utilities.js(125,39): error TS2339: Property 'regexSpecialCharacters' does not exist on type 'StringConstructor'. node_modules/chrome-devtools-frontend/front_end/platform/utilities.js(132,8): error TS2339: Property 'filterRegex' does not exist on type 'StringConstructor'. node_modules/chrome-devtools-frontend/front_end/platform/utilities.js(133,27): error TS2339: Property 'regexSpecialCharacters' does not exist on type 'StringConstructor'. +node_modules/chrome-devtools-frontend/front_end/platform/utilities.js(198,1): error TS2322: Type '(maxLength: number) => string' is not assignable to type '() => string'. node_modules/chrome-devtools-frontend/front_end/platform/utilities.js(250,8): error TS2339: Property 'hashCode' does not exist on type 'StringConstructor'. node_modules/chrome-devtools-frontend/front_end/platform/utilities.js(275,8): error TS2339: Property 'isDigitAt' does not exist on type 'StringConstructor'. node_modules/chrome-devtools-frontend/front_end/platform/utilities.js(320,8): error TS2339: Property 'naturalOrderComparator' does not exist on type 'StringConstructor'. @@ -11052,6 +11059,7 @@ node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSid node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(81,60): error TS2339: Property 'breakpoint' does not exist on type 'V'. node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(82,62): error TS2339: Property 'breakpoint' does not exist on type 'V'. node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(119,5): error TS2322: Type 'Promise' is not assignable to type 'Promise'. +node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(131,38): error TS2554: Expected 0 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(141,29): error TS2339: Property 'enclosingNodeOrSelfWithClass' does not exist on type 'EventTarget'. node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(156,33): error TS2339: Property 'checkboxElement' does not exist on type 'EventTarget'. node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(159,11): error TS2339: Property 'consume' does not exist on type 'Event'. @@ -13399,6 +13407,7 @@ node_modules/chrome-devtools-frontend/front_end/ui/UIUtils.js(1561,11): error TS node_modules/chrome-devtools-frontend/front_end/ui/UIUtils.js(1562,17): error TS2339: Property 'value' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/ui/UIUtils.js(1570,25): error TS2339: Property 'value' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/ui/UIUtils.js(1574,11): error TS2339: Property 'value' does not exist on type 'Element'. +node_modules/chrome-devtools-frontend/front_end/ui/UIUtils.js(1633,64): error TS2554: Expected 0 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/ui/UIUtils.js(1646,40): error TS2339: Property '_textWidthCache' does not exist on type '(context: CanvasRenderingContext2D, text: string) => number'. node_modules/chrome-devtools-frontend/front_end/ui/UIUtils.js(1649,25): error TS2339: Property '_textWidthCache' does not exist on type '(context: CanvasRenderingContext2D, text: string) => number'. node_modules/chrome-devtools-frontend/front_end/ui/UIUtils.js(1715,20): error TS2339: Property 'type' does not exist on type 'Element'. From 1aca1dd036928ce56173bb93e4478af6b28b464a Mon Sep 17 00:00:00 2001 From: Matt McCutchen Date: Wed, 10 Oct 2018 19:30:50 -0400 Subject: [PATCH 17/34] Make the assignability rule for conditional types require the check types and distributivity to be identical. Fixes #27118. --- src/compiler/checker.ts | 9 +- .../reference/conditionalTypes2.errors.txt | 122 +-- .../baselines/reference/conditionalTypes2.js | 121 +-- .../reference/conditionalTypes2.symbols | 870 +++++++++--------- .../reference/conditionalTypes2.types | 115 +-- .../types/conditional/conditionalTypes2.ts | 57 +- 6 files changed, 607 insertions(+), 687 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f7cc72c534d..2d7c65fdde0 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -12693,10 +12693,11 @@ namespace ts { else if (source.flags & TypeFlags.Conditional) { if (target.flags & TypeFlags.Conditional) { // Two conditional types 'T1 extends U1 ? X1 : Y1' and 'T2 extends U2 ? X2 : Y2' are related if - // one of T1 and T2 is related to the other, U1 and U2 are identical types, X1 is related to X2, - // and Y1 is related to Y2. - if (isTypeIdenticalTo((source).extendsType, (target).extendsType) && - (isRelatedTo((source).checkType, (target).checkType) || isRelatedTo((target).checkType, (source).checkType))) { + // they have the same distributivity, T1 and T2 are identical types, U1 and U2 are identical + // types, X1 is related to X2, and Y1 is related to Y2. + if ((source).root.isDistributive === (target).root.isDistributive && + isTypeIdenticalTo((source).extendsType, (target).extendsType) && + isTypeIdenticalTo((source).checkType, (target).checkType)) { if (result = isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), reportErrors)) { result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), reportErrors); } diff --git a/tests/baselines/reference/conditionalTypes2.errors.txt b/tests/baselines/reference/conditionalTypes2.errors.txt index a1a23b6da18..343a0a8412c 100644 --- a/tests/baselines/reference/conditionalTypes2.errors.txt +++ b/tests/baselines/reference/conditionalTypes2.errors.txt @@ -1,29 +1,38 @@ -tests/cases/conformance/types/conditional/conditionalTypes2.ts(15,5): error TS2322: Type 'Covariant' is not assignable to type 'Covariant'. - Type 'A' is not assignable to type 'B'. -tests/cases/conformance/types/conditional/conditionalTypes2.ts(19,5): error TS2322: Type 'Contravariant' is not assignable to type 'Contravariant'. - Type 'A' is not assignable to type 'B'. -tests/cases/conformance/types/conditional/conditionalTypes2.ts(24,5): error TS2322: Type 'Invariant' is not assignable to type 'Invariant'. +tests/cases/conformance/types/conditional/conditionalTypes2.ts(16,5): error TS2322: Type 'Covariant' is not assignable to type 'Covariant'. + Types of property 'foo' are incompatible. + Type 'B extends string ? B : number' is not assignable to type 'A extends string ? A : number'. +tests/cases/conformance/types/conditional/conditionalTypes2.ts(17,5): error TS2322: Type 'Covariant' is not assignable to type 'Covariant'. + Types of property 'foo' are incompatible. + Type 'A extends string ? A : number' is not assignable to type 'B extends string ? B : number'. +tests/cases/conformance/types/conditional/conditionalTypes2.ts(21,5): error TS2322: Type 'Contravariant' is not assignable to type 'Contravariant'. + Types of property 'foo' are incompatible. + Type 'B extends string ? keyof B : number' is not assignable to type 'A extends string ? keyof A : number'. +tests/cases/conformance/types/conditional/conditionalTypes2.ts(22,5): error TS2322: Type 'Contravariant' is not assignable to type 'Contravariant'. + Types of property 'foo' are incompatible. + Type 'A extends string ? keyof A : number' is not assignable to type 'B extends string ? keyof B : number'. +tests/cases/conformance/types/conditional/conditionalTypes2.ts(26,5): error TS2322: Type 'Invariant' is not assignable to type 'Invariant'. Types of property 'foo' are incompatible. Type 'B extends string ? keyof B : B' is not assignable to type 'A extends string ? keyof A : A'. - Type 'keyof B' is not assignable to type 'keyof A'. - Type 'string | number | symbol' is not assignable to type 'keyof A'. - Type 'string' is not assignable to type 'keyof A'. -tests/cases/conformance/types/conditional/conditionalTypes2.ts(25,5): error TS2322: Type 'Invariant' is not assignable to type 'Invariant'. +tests/cases/conformance/types/conditional/conditionalTypes2.ts(27,5): error TS2322: Type 'Invariant' is not assignable to type 'Invariant'. Types of property 'foo' are incompatible. Type 'A extends string ? keyof A : A' is not assignable to type 'B extends string ? keyof B : B'. - Type 'A' is not assignable to type 'B'. -tests/cases/conformance/types/conditional/conditionalTypes2.ts(73,12): error TS2345: Argument of type 'Extract, Bar>' is not assignable to parameter of type '{ foo: string; bat: string; }'. +tests/cases/conformance/types/conditional/conditionalTypes2.ts(75,12): error TS2345: Argument of type 'Extract, Bar>' is not assignable to parameter of type '{ foo: string; bat: string; }'. Property 'bat' is missing in type 'Bar & Foo' but required in type '{ foo: string; bat: string; }'. Type 'Extract' is not assignable to type '{ foo: string; bat: string; }'. Property 'bat' is missing in type 'Bar & Foo' but required in type '{ foo: string; bat: string; }'. -tests/cases/conformance/types/conditional/conditionalTypes2.ts(74,12): error TS2345: Argument of type 'Extract' is not assignable to parameter of type '{ foo: string; bat: string; }'. +tests/cases/conformance/types/conditional/conditionalTypes2.ts(76,12): error TS2345: Argument of type 'Extract' is not assignable to parameter of type '{ foo: string; bat: string; }'. Property 'bat' is missing in type 'Foo & Bar' but required in type '{ foo: string; bat: string; }'. -tests/cases/conformance/types/conditional/conditionalTypes2.ts(75,12): error TS2345: Argument of type 'Extract2' is not assignable to parameter of type '{ foo: string; bat: string; }'. +tests/cases/conformance/types/conditional/conditionalTypes2.ts(77,12): error TS2345: Argument of type 'Extract2' is not assignable to parameter of type '{ foo: string; bat: string; }'. Type 'T extends Bar ? T : never' is not assignable to type '{ foo: string; bat: string; }'. Type 'Bar & Foo & T' is not assignable to type '{ foo: string; bat: string; }'. +tests/cases/conformance/types/conditional/conditionalTypes2.ts(165,5): error TS2322: Type 'MyElement' is not assignable to type 'MyElement'. +tests/cases/conformance/types/conditional/conditionalTypes2.ts(170,5): error TS2322: Type 'MyAcceptor' is not assignable to type 'MyAcceptor'. +tests/cases/conformance/types/conditional/conditionalTypes2.ts(177,5): error TS2322: Type 'Dist' is not assignable to type 'Aux<{ a: T; }>'. -==== tests/cases/conformance/types/conditional/conditionalTypes2.ts (7 errors) ==== +==== tests/cases/conformance/types/conditional/conditionalTypes2.ts (12 errors) ==== + // #27118: Conditional types are now invariant in the check type. + interface Covariant { foo: T extends string ? T : number; } @@ -37,19 +46,29 @@ tests/cases/conformance/types/conditional/conditionalTypes2.ts(75,12): error TS2 } function f1(a: Covariant, b: Covariant) { - a = b; + a = b; // Error + ~ +!!! error TS2322: Type 'Covariant' is not assignable to type 'Covariant'. +!!! error TS2322: Types of property 'foo' are incompatible. +!!! error TS2322: Type 'B extends string ? B : number' is not assignable to type 'A extends string ? A : number'. b = a; // Error ~ !!! error TS2322: Type 'Covariant' is not assignable to type 'Covariant'. -!!! error TS2322: Type 'A' is not assignable to type 'B'. +!!! error TS2322: Types of property 'foo' are incompatible. +!!! error TS2322: Type 'A extends string ? A : number' is not assignable to type 'B extends string ? B : number'. } function f2(a: Contravariant, b: Contravariant) { a = b; // Error ~ !!! error TS2322: Type 'Contravariant' is not assignable to type 'Contravariant'. -!!! error TS2322: Type 'A' is not assignable to type 'B'. - b = a; +!!! error TS2322: Types of property 'foo' are incompatible. +!!! error TS2322: Type 'B extends string ? keyof B : number' is not assignable to type 'A extends string ? keyof A : number'. + b = a; // Error + ~ +!!! error TS2322: Type 'Contravariant' is not assignable to type 'Contravariant'. +!!! error TS2322: Types of property 'foo' are incompatible. +!!! error TS2322: Type 'A extends string ? keyof A : number' is not assignable to type 'B extends string ? keyof B : number'. } function f3(a: Invariant, b: Invariant) { @@ -58,15 +77,11 @@ tests/cases/conformance/types/conditional/conditionalTypes2.ts(75,12): error TS2 !!! error TS2322: Type 'Invariant' is not assignable to type 'Invariant'. !!! error TS2322: Types of property 'foo' are incompatible. !!! error TS2322: Type 'B extends string ? keyof B : B' is not assignable to type 'A extends string ? keyof A : A'. -!!! error TS2322: Type 'keyof B' is not assignable to type 'keyof A'. -!!! error TS2322: Type 'string | number | symbol' is not assignable to type 'keyof A'. -!!! error TS2322: Type 'string' is not assignable to type 'keyof A'. b = a; // Error ~ !!! error TS2322: Type 'Invariant' is not assignable to type 'Invariant'. !!! error TS2322: Types of property 'foo' are incompatible. !!! error TS2322: Type 'A extends string ? keyof A : A' is not assignable to type 'B extends string ? keyof B : B'. -!!! error TS2322: Type 'A' is not assignable to type 'B'. } // Extract is a T that is known to be a Function @@ -120,13 +135,13 @@ tests/cases/conformance/types/conditional/conditionalTypes2.ts(75,12): error TS2 !!! error TS2345: Property 'bat' is missing in type 'Bar & Foo' but required in type '{ foo: string; bat: string; }'. !!! error TS2345: Type 'Extract' is not assignable to type '{ foo: string; bat: string; }'. !!! error TS2345: Property 'bat' is missing in type 'Bar & Foo' but required in type '{ foo: string; bat: string; }'. -!!! related TS2728 tests/cases/conformance/types/conditional/conditionalTypes2.ts:62:43: 'bat' is declared here. -!!! related TS2728 tests/cases/conformance/types/conditional/conditionalTypes2.ts:62:43: 'bat' is declared here. +!!! related TS2728 tests/cases/conformance/types/conditional/conditionalTypes2.ts:64:43: 'bat' is declared here. +!!! related TS2728 tests/cases/conformance/types/conditional/conditionalTypes2.ts:64:43: 'bat' is declared here. fooBat(y); // Error ~ !!! error TS2345: Argument of type 'Extract' is not assignable to parameter of type '{ foo: string; bat: string; }'. !!! error TS2345: Property 'bat' is missing in type 'Foo & Bar' but required in type '{ foo: string; bat: string; }'. -!!! related TS2728 tests/cases/conformance/types/conditional/conditionalTypes2.ts:62:43: 'bat' is declared here. +!!! related TS2728 tests/cases/conformance/types/conditional/conditionalTypes2.ts:64:43: 'bat' is declared here. fooBat(z); // Error ~ !!! error TS2345: Argument of type 'Extract2' is not assignable to parameter of type '{ foo: string; bat: string; }'. @@ -134,38 +149,6 @@ tests/cases/conformance/types/conditional/conditionalTypes2.ts(75,12): error TS2 !!! error TS2345: Type 'Bar & Foo & T' is not assignable to type '{ foo: string; bat: string; }'. } - // Repros from #22860 - - class Opt { - toVector(): Vector { - return undefined; - } - } - - interface Seq { - tail(): Opt>; - } - - class Vector implements Seq { - tail(): Opt> { - return undefined; - } - partition2(predicate:(v:T)=>v is U): [Vector,Vector>]; - partition2(predicate:(x:T)=>boolean): [Vector,Vector]; - partition2(predicate:(v:T)=>boolean): [Vector,Vector] { - return undefined; - } - } - - interface A1 { - bat: B1>; - } - - interface B1 extends A1 { - bat: B1>; - boom: T extends any ? true : true - } - // Repro from #22899 declare function toString1(value: object | Function): string ; @@ -246,4 +229,29 @@ tests/cases/conformance/types/conditional/conditionalTypes2.ts(75,12): error TS2 }; type PCCA = ProductComplementComplement['a']; type PCCB = ProductComplementComplement['b']; + + // Repros from #27118 + + type MyElement = [A] extends [[infer E]] ? E : never; + function oops(arg: MyElement): MyElement { + return arg; // Unsound, should be error + ~~~~~~~~~~~ +!!! error TS2322: Type 'MyElement' is not assignable to type 'MyElement'. + } + + type MyAcceptor = [A] extends [[infer E]] ? (arg: E) => void : never; + function oops2(arg: MyAcceptor): MyAcceptor { + return arg; // Unsound, should be error + ~~~~~~~~~~~ +!!! error TS2322: Type 'MyAcceptor' is not assignable to type 'MyAcceptor'. + } + + type Dist = T extends number ? number : string; + type Aux = A["a"] extends number ? number : string; + type Nondist = Aux<{a: T}>; + function oops3(arg: Dist): Nondist { + return arg; // Unsound, should be error + ~~~~~~~~~~~ +!!! error TS2322: Type 'Dist' is not assignable to type 'Aux<{ a: T; }>'. + } \ No newline at end of file diff --git a/tests/baselines/reference/conditionalTypes2.js b/tests/baselines/reference/conditionalTypes2.js index 4f4f35e821a..c59c996711d 100644 --- a/tests/baselines/reference/conditionalTypes2.js +++ b/tests/baselines/reference/conditionalTypes2.js @@ -1,4 +1,6 @@ //// [conditionalTypes2.ts] +// #27118: Conditional types are now invariant in the check type. + interface Covariant { foo: T extends string ? T : number; } @@ -12,13 +14,13 @@ interface Invariant { } function f1(a: Covariant, b: Covariant) { - a = b; + a = b; // Error b = a; // Error } function f2(a: Contravariant, b: Contravariant) { a = b; // Error - b = a; + b = a; // Error } function f3(a: Invariant, b: Invariant) { @@ -76,38 +78,6 @@ function f21(x: Extract, Bar>, y: Extract, z: E fooBat(z); // Error } -// Repros from #22860 - -class Opt { - toVector(): Vector { - return undefined; - } -} - -interface Seq { - tail(): Opt>; -} - -class Vector implements Seq { - tail(): Opt> { - return undefined; - } - partition2(predicate:(v:T)=>v is U): [Vector,Vector>]; - partition2(predicate:(x:T)=>boolean): [Vector,Vector]; - partition2(predicate:(v:T)=>boolean): [Vector,Vector] { - return undefined; - } -} - -interface A1 { - bat: B1>; -} - -interface B1 extends A1 { - bat: B1>; - boom: T extends any ? true : true -} - // Repro from #22899 declare function toString1(value: object | Function): string ; @@ -188,17 +158,37 @@ type ProductComplementComplement = { }; type PCCA = ProductComplementComplement['a']; type PCCB = ProductComplementComplement['b']; + +// Repros from #27118 + +type MyElement = [A] extends [[infer E]] ? E : never; +function oops(arg: MyElement): MyElement { + return arg; // Unsound, should be error +} + +type MyAcceptor = [A] extends [[infer E]] ? (arg: E) => void : never; +function oops2(arg: MyAcceptor): MyAcceptor { + return arg; // Unsound, should be error +} + +type Dist = T extends number ? number : string; +type Aux = A["a"] extends number ? number : string; +type Nondist = Aux<{a: T}>; +function oops3(arg: Dist): Nondist { + return arg; // Unsound, should be error +} //// [conditionalTypes2.js] "use strict"; +// #27118: Conditional types are now invariant in the check type. function f1(a, b) { - a = b; + a = b; // Error b = a; // Error } function f2(a, b) { a = b; // Error - b = a; + b = a; // Error } function f3(a, b) { a = b; // Error @@ -239,32 +229,21 @@ function f21(x, y, z) { fooBat(y); // Error fooBat(z); // Error } -// Repros from #22860 -var Opt = /** @class */ (function () { - function Opt() { - } - Opt.prototype.toVector = function () { - return undefined; - }; - return Opt; -}()); -var Vector = /** @class */ (function () { - function Vector() { - } - Vector.prototype.tail = function () { - return undefined; - }; - Vector.prototype.partition2 = function (predicate) { - return undefined; - }; - return Vector; -}()); function foo(value) { if (isFunction(value)) { toString1(value); toString2(value); } } +function oops(arg) { + return arg; // Unsound, should be error +} +function oops2(arg) { + return arg; // Unsound, should be error +} +function oops3(arg) { + return arg; // Unsound, should be error +} //// [conditionalTypes2.d.ts] @@ -302,24 +281,6 @@ declare function fooBat(x: { declare type Extract2 = T extends U ? T extends V ? T : never : never; declare function f20(x: Extract, Bar>, y: Extract, z: Extract2): void; declare function f21(x: Extract, Bar>, y: Extract, z: Extract2): void; -declare class Opt { - toVector(): Vector; -} -interface Seq { - tail(): Opt>; -} -declare class Vector implements Seq { - tail(): Opt>; - partition2(predicate: (v: T) => v is U): [Vector, Vector>]; - partition2(predicate: (x: T) => boolean): [Vector, Vector]; -} -interface A1 { - bat: B1>; -} -interface B1 extends A1 { - bat: B1>; - boom: T extends any ? true : true; -} declare function toString1(value: object | Function): string; declare function toString2(value: Function): string; declare function foo(value: T): void; @@ -392,3 +353,15 @@ declare type ProductComplementComplement = { }; declare type PCCA = ProductComplementComplement['a']; declare type PCCB = ProductComplementComplement['b']; +declare type MyElement = [A] extends [[infer E]] ? E : never; +declare function oops(arg: MyElement): MyElement; +declare type MyAcceptor = [A] extends [[infer E]] ? (arg: E) => void : never; +declare function oops2(arg: MyAcceptor): MyAcceptor; +declare type Dist = T extends number ? number : string; +declare type Aux = A["a"] extends number ? number : string; +declare type Nondist = Aux<{ + a: T; +}>; +declare function oops3(arg: Dist): Nondist; diff --git a/tests/baselines/reference/conditionalTypes2.symbols b/tests/baselines/reference/conditionalTypes2.symbols index b164d26e450..7bbf837eece 100644 --- a/tests/baselines/reference/conditionalTypes2.symbols +++ b/tests/baselines/reference/conditionalTypes2.symbols @@ -1,687 +1,655 @@ === tests/cases/conformance/types/conditional/conditionalTypes2.ts === +// #27118: Conditional types are now invariant in the check type. + interface Covariant { >Covariant : Symbol(Covariant, Decl(conditionalTypes2.ts, 0, 0)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 0, 20)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 2, 20)) foo: T extends string ? T : number; ->foo : Symbol(Covariant.foo, Decl(conditionalTypes2.ts, 0, 24)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 0, 20)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 0, 20)) +>foo : Symbol(Covariant.foo, Decl(conditionalTypes2.ts, 2, 24)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 2, 20)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 2, 20)) } interface Contravariant { ->Contravariant : Symbol(Contravariant, Decl(conditionalTypes2.ts, 2, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 4, 24)) +>Contravariant : Symbol(Contravariant, Decl(conditionalTypes2.ts, 4, 1)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 6, 24)) foo: T extends string ? keyof T : number; ->foo : Symbol(Contravariant.foo, Decl(conditionalTypes2.ts, 4, 28)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 4, 24)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 4, 24)) +>foo : Symbol(Contravariant.foo, Decl(conditionalTypes2.ts, 6, 28)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 6, 24)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 6, 24)) } interface Invariant { ->Invariant : Symbol(Invariant, Decl(conditionalTypes2.ts, 6, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 8, 20)) +>Invariant : Symbol(Invariant, Decl(conditionalTypes2.ts, 8, 1)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 10, 20)) foo: T extends string ? keyof T : T; ->foo : Symbol(Invariant.foo, Decl(conditionalTypes2.ts, 8, 24)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 8, 20)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 8, 20)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 8, 20)) +>foo : Symbol(Invariant.foo, Decl(conditionalTypes2.ts, 10, 24)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 10, 20)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 10, 20)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 10, 20)) } function f1(a: Covariant, b: Covariant) { ->f1 : Symbol(f1, Decl(conditionalTypes2.ts, 10, 1)) ->A : Symbol(A, Decl(conditionalTypes2.ts, 12, 12)) ->B : Symbol(B, Decl(conditionalTypes2.ts, 12, 14)) ->A : Symbol(A, Decl(conditionalTypes2.ts, 12, 12)) ->a : Symbol(a, Decl(conditionalTypes2.ts, 12, 28)) +>f1 : Symbol(f1, Decl(conditionalTypes2.ts, 12, 1)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 14, 12)) +>B : Symbol(B, Decl(conditionalTypes2.ts, 14, 14)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 14, 12)) +>a : Symbol(a, Decl(conditionalTypes2.ts, 14, 28)) >Covariant : Symbol(Covariant, Decl(conditionalTypes2.ts, 0, 0)) ->A : Symbol(A, Decl(conditionalTypes2.ts, 12, 12)) ->b : Symbol(b, Decl(conditionalTypes2.ts, 12, 44)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 14, 12)) +>b : Symbol(b, Decl(conditionalTypes2.ts, 14, 44)) >Covariant : Symbol(Covariant, Decl(conditionalTypes2.ts, 0, 0)) ->B : Symbol(B, Decl(conditionalTypes2.ts, 12, 14)) +>B : Symbol(B, Decl(conditionalTypes2.ts, 14, 14)) - a = b; ->a : Symbol(a, Decl(conditionalTypes2.ts, 12, 28)) ->b : Symbol(b, Decl(conditionalTypes2.ts, 12, 44)) + a = b; // Error +>a : Symbol(a, Decl(conditionalTypes2.ts, 14, 28)) +>b : Symbol(b, Decl(conditionalTypes2.ts, 14, 44)) b = a; // Error ->b : Symbol(b, Decl(conditionalTypes2.ts, 12, 44)) ->a : Symbol(a, Decl(conditionalTypes2.ts, 12, 28)) +>b : Symbol(b, Decl(conditionalTypes2.ts, 14, 44)) +>a : Symbol(a, Decl(conditionalTypes2.ts, 14, 28)) } function f2(a: Contravariant, b: Contravariant) { ->f2 : Symbol(f2, Decl(conditionalTypes2.ts, 15, 1)) ->A : Symbol(A, Decl(conditionalTypes2.ts, 17, 12)) ->B : Symbol(B, Decl(conditionalTypes2.ts, 17, 14)) ->A : Symbol(A, Decl(conditionalTypes2.ts, 17, 12)) ->a : Symbol(a, Decl(conditionalTypes2.ts, 17, 28)) ->Contravariant : Symbol(Contravariant, Decl(conditionalTypes2.ts, 2, 1)) ->A : Symbol(A, Decl(conditionalTypes2.ts, 17, 12)) ->b : Symbol(b, Decl(conditionalTypes2.ts, 17, 48)) ->Contravariant : Symbol(Contravariant, Decl(conditionalTypes2.ts, 2, 1)) ->B : Symbol(B, Decl(conditionalTypes2.ts, 17, 14)) +>f2 : Symbol(f2, Decl(conditionalTypes2.ts, 17, 1)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 19, 12)) +>B : Symbol(B, Decl(conditionalTypes2.ts, 19, 14)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 19, 12)) +>a : Symbol(a, Decl(conditionalTypes2.ts, 19, 28)) +>Contravariant : Symbol(Contravariant, Decl(conditionalTypes2.ts, 4, 1)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 19, 12)) +>b : Symbol(b, Decl(conditionalTypes2.ts, 19, 48)) +>Contravariant : Symbol(Contravariant, Decl(conditionalTypes2.ts, 4, 1)) +>B : Symbol(B, Decl(conditionalTypes2.ts, 19, 14)) a = b; // Error ->a : Symbol(a, Decl(conditionalTypes2.ts, 17, 28)) ->b : Symbol(b, Decl(conditionalTypes2.ts, 17, 48)) +>a : Symbol(a, Decl(conditionalTypes2.ts, 19, 28)) +>b : Symbol(b, Decl(conditionalTypes2.ts, 19, 48)) - b = a; ->b : Symbol(b, Decl(conditionalTypes2.ts, 17, 48)) ->a : Symbol(a, Decl(conditionalTypes2.ts, 17, 28)) + b = a; // Error +>b : Symbol(b, Decl(conditionalTypes2.ts, 19, 48)) +>a : Symbol(a, Decl(conditionalTypes2.ts, 19, 28)) } function f3(a: Invariant, b: Invariant) { ->f3 : Symbol(f3, Decl(conditionalTypes2.ts, 20, 1)) ->A : Symbol(A, Decl(conditionalTypes2.ts, 22, 12)) ->B : Symbol(B, Decl(conditionalTypes2.ts, 22, 14)) ->A : Symbol(A, Decl(conditionalTypes2.ts, 22, 12)) ->a : Symbol(a, Decl(conditionalTypes2.ts, 22, 28)) ->Invariant : Symbol(Invariant, Decl(conditionalTypes2.ts, 6, 1)) ->A : Symbol(A, Decl(conditionalTypes2.ts, 22, 12)) ->b : Symbol(b, Decl(conditionalTypes2.ts, 22, 44)) ->Invariant : Symbol(Invariant, Decl(conditionalTypes2.ts, 6, 1)) ->B : Symbol(B, Decl(conditionalTypes2.ts, 22, 14)) +>f3 : Symbol(f3, Decl(conditionalTypes2.ts, 22, 1)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 24, 12)) +>B : Symbol(B, Decl(conditionalTypes2.ts, 24, 14)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 24, 12)) +>a : Symbol(a, Decl(conditionalTypes2.ts, 24, 28)) +>Invariant : Symbol(Invariant, Decl(conditionalTypes2.ts, 8, 1)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 24, 12)) +>b : Symbol(b, Decl(conditionalTypes2.ts, 24, 44)) +>Invariant : Symbol(Invariant, Decl(conditionalTypes2.ts, 8, 1)) +>B : Symbol(B, Decl(conditionalTypes2.ts, 24, 14)) a = b; // Error ->a : Symbol(a, Decl(conditionalTypes2.ts, 22, 28)) ->b : Symbol(b, Decl(conditionalTypes2.ts, 22, 44)) +>a : Symbol(a, Decl(conditionalTypes2.ts, 24, 28)) +>b : Symbol(b, Decl(conditionalTypes2.ts, 24, 44)) b = a; // Error ->b : Symbol(b, Decl(conditionalTypes2.ts, 22, 44)) ->a : Symbol(a, Decl(conditionalTypes2.ts, 22, 28)) +>b : Symbol(b, Decl(conditionalTypes2.ts, 24, 44)) +>a : Symbol(a, Decl(conditionalTypes2.ts, 24, 28)) } // Extract is a T that is known to be a Function function isFunction(value: T): value is Extract { ->isFunction : Symbol(isFunction, Decl(conditionalTypes2.ts, 25, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 28, 20)) ->value : Symbol(value, Decl(conditionalTypes2.ts, 28, 23)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 28, 20)) ->value : Symbol(value, Decl(conditionalTypes2.ts, 28, 23)) +>isFunction : Symbol(isFunction, Decl(conditionalTypes2.ts, 27, 1)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 30, 20)) +>value : Symbol(value, Decl(conditionalTypes2.ts, 30, 23)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 30, 20)) +>value : Symbol(value, Decl(conditionalTypes2.ts, 30, 23)) >Extract : Symbol(Extract, Decl(lib.es5.d.ts, --, --)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 28, 20)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 30, 20)) >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) return typeof value === "function"; ->value : Symbol(value, Decl(conditionalTypes2.ts, 28, 23)) +>value : Symbol(value, Decl(conditionalTypes2.ts, 30, 23)) } function getFunction(item: T) { ->getFunction : Symbol(getFunction, Decl(conditionalTypes2.ts, 30, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 32, 21)) ->item : Symbol(item, Decl(conditionalTypes2.ts, 32, 24)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 32, 21)) +>getFunction : Symbol(getFunction, Decl(conditionalTypes2.ts, 32, 1)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 34, 21)) +>item : Symbol(item, Decl(conditionalTypes2.ts, 34, 24)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 34, 21)) if (isFunction(item)) { ->isFunction : Symbol(isFunction, Decl(conditionalTypes2.ts, 25, 1)) ->item : Symbol(item, Decl(conditionalTypes2.ts, 32, 24)) +>isFunction : Symbol(isFunction, Decl(conditionalTypes2.ts, 27, 1)) +>item : Symbol(item, Decl(conditionalTypes2.ts, 34, 24)) return item; ->item : Symbol(item, Decl(conditionalTypes2.ts, 32, 24)) +>item : Symbol(item, Decl(conditionalTypes2.ts, 34, 24)) } throw new Error(); >Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) } function f10(x: T) { ->f10 : Symbol(f10, Decl(conditionalTypes2.ts, 37, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 39, 13)) ->x : Symbol(x, Decl(conditionalTypes2.ts, 39, 16)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 39, 13)) +>f10 : Symbol(f10, Decl(conditionalTypes2.ts, 39, 1)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 41, 13)) +>x : Symbol(x, Decl(conditionalTypes2.ts, 41, 16)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 41, 13)) if (isFunction(x)) { ->isFunction : Symbol(isFunction, Decl(conditionalTypes2.ts, 25, 1)) ->x : Symbol(x, Decl(conditionalTypes2.ts, 39, 16)) +>isFunction : Symbol(isFunction, Decl(conditionalTypes2.ts, 27, 1)) +>x : Symbol(x, Decl(conditionalTypes2.ts, 41, 16)) const f: Function = x; ->f : Symbol(f, Decl(conditionalTypes2.ts, 41, 13)) +>f : Symbol(f, Decl(conditionalTypes2.ts, 43, 13)) >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->x : Symbol(x, Decl(conditionalTypes2.ts, 39, 16)) +>x : Symbol(x, Decl(conditionalTypes2.ts, 41, 16)) const t: T = x; ->t : Symbol(t, Decl(conditionalTypes2.ts, 42, 13)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 39, 13)) ->x : Symbol(x, Decl(conditionalTypes2.ts, 39, 16)) +>t : Symbol(t, Decl(conditionalTypes2.ts, 44, 13)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 41, 13)) +>x : Symbol(x, Decl(conditionalTypes2.ts, 41, 16)) } } function f11(x: string | (() => string) | undefined) { ->f11 : Symbol(f11, Decl(conditionalTypes2.ts, 44, 1)) ->x : Symbol(x, Decl(conditionalTypes2.ts, 46, 13)) +>f11 : Symbol(f11, Decl(conditionalTypes2.ts, 46, 1)) +>x : Symbol(x, Decl(conditionalTypes2.ts, 48, 13)) if (isFunction(x)) { ->isFunction : Symbol(isFunction, Decl(conditionalTypes2.ts, 25, 1)) ->x : Symbol(x, Decl(conditionalTypes2.ts, 46, 13)) +>isFunction : Symbol(isFunction, Decl(conditionalTypes2.ts, 27, 1)) +>x : Symbol(x, Decl(conditionalTypes2.ts, 48, 13)) x(); ->x : Symbol(x, Decl(conditionalTypes2.ts, 46, 13)) +>x : Symbol(x, Decl(conditionalTypes2.ts, 48, 13)) } } function f12(x: string | (() => string) | undefined) { ->f12 : Symbol(f12, Decl(conditionalTypes2.ts, 50, 1)) ->x : Symbol(x, Decl(conditionalTypes2.ts, 52, 13)) +>f12 : Symbol(f12, Decl(conditionalTypes2.ts, 52, 1)) +>x : Symbol(x, Decl(conditionalTypes2.ts, 54, 13)) const f = getFunction(x); // () => string ->f : Symbol(f, Decl(conditionalTypes2.ts, 53, 9)) ->getFunction : Symbol(getFunction, Decl(conditionalTypes2.ts, 30, 1)) ->x : Symbol(x, Decl(conditionalTypes2.ts, 52, 13)) +>f : Symbol(f, Decl(conditionalTypes2.ts, 55, 9)) +>getFunction : Symbol(getFunction, Decl(conditionalTypes2.ts, 32, 1)) +>x : Symbol(x, Decl(conditionalTypes2.ts, 54, 13)) f(); ->f : Symbol(f, Decl(conditionalTypes2.ts, 53, 9)) +>f : Symbol(f, Decl(conditionalTypes2.ts, 55, 9)) } type Foo = { foo: string }; ->Foo : Symbol(Foo, Decl(conditionalTypes2.ts, 55, 1)) ->foo : Symbol(foo, Decl(conditionalTypes2.ts, 57, 12)) +>Foo : Symbol(Foo, Decl(conditionalTypes2.ts, 57, 1)) +>foo : Symbol(foo, Decl(conditionalTypes2.ts, 59, 12)) type Bar = { bar: string }; ->Bar : Symbol(Bar, Decl(conditionalTypes2.ts, 57, 27)) ->bar : Symbol(bar, Decl(conditionalTypes2.ts, 58, 12)) +>Bar : Symbol(Bar, Decl(conditionalTypes2.ts, 59, 27)) +>bar : Symbol(bar, Decl(conditionalTypes2.ts, 60, 12)) declare function fooBar(x: { foo: string, bar: string }): void; ->fooBar : Symbol(fooBar, Decl(conditionalTypes2.ts, 58, 27)) ->x : Symbol(x, Decl(conditionalTypes2.ts, 60, 24)) ->foo : Symbol(foo, Decl(conditionalTypes2.ts, 60, 28)) ->bar : Symbol(bar, Decl(conditionalTypes2.ts, 60, 41)) +>fooBar : Symbol(fooBar, Decl(conditionalTypes2.ts, 60, 27)) +>x : Symbol(x, Decl(conditionalTypes2.ts, 62, 24)) +>foo : Symbol(foo, Decl(conditionalTypes2.ts, 62, 28)) +>bar : Symbol(bar, Decl(conditionalTypes2.ts, 62, 41)) declare function fooBat(x: { foo: string, bat: string }): void; ->fooBat : Symbol(fooBat, Decl(conditionalTypes2.ts, 60, 63)) ->x : Symbol(x, Decl(conditionalTypes2.ts, 61, 24)) ->foo : Symbol(foo, Decl(conditionalTypes2.ts, 61, 28)) ->bat : Symbol(bat, Decl(conditionalTypes2.ts, 61, 41)) +>fooBat : Symbol(fooBat, Decl(conditionalTypes2.ts, 62, 63)) +>x : Symbol(x, Decl(conditionalTypes2.ts, 63, 24)) +>foo : Symbol(foo, Decl(conditionalTypes2.ts, 63, 28)) +>bat : Symbol(bat, Decl(conditionalTypes2.ts, 63, 41)) type Extract2 = T extends U ? T extends V ? T : never : never; ->Extract2 : Symbol(Extract2, Decl(conditionalTypes2.ts, 61, 63)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 63, 14)) ->U : Symbol(U, Decl(conditionalTypes2.ts, 63, 16)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 63, 19)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 63, 14)) ->U : Symbol(U, Decl(conditionalTypes2.ts, 63, 16)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 63, 14)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 63, 19)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 63, 14)) +>Extract2 : Symbol(Extract2, Decl(conditionalTypes2.ts, 63, 63)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 65, 14)) +>U : Symbol(U, Decl(conditionalTypes2.ts, 65, 16)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 65, 19)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 65, 14)) +>U : Symbol(U, Decl(conditionalTypes2.ts, 65, 16)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 65, 14)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 65, 19)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 65, 14)) function f20(x: Extract, Bar>, y: Extract, z: Extract2) { ->f20 : Symbol(f20, Decl(conditionalTypes2.ts, 63, 71)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 65, 13)) ->x : Symbol(x, Decl(conditionalTypes2.ts, 65, 16)) +>f20 : Symbol(f20, Decl(conditionalTypes2.ts, 65, 71)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 67, 13)) +>x : Symbol(x, Decl(conditionalTypes2.ts, 67, 16)) >Extract : Symbol(Extract, Decl(lib.es5.d.ts, --, --)) >Extract : Symbol(Extract, Decl(lib.es5.d.ts, --, --)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 65, 13)) ->Foo : Symbol(Foo, Decl(conditionalTypes2.ts, 55, 1)) ->Bar : Symbol(Bar, Decl(conditionalTypes2.ts, 57, 27)) ->y : Symbol(y, Decl(conditionalTypes2.ts, 65, 49)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 67, 13)) +>Foo : Symbol(Foo, Decl(conditionalTypes2.ts, 57, 1)) +>Bar : Symbol(Bar, Decl(conditionalTypes2.ts, 59, 27)) +>y : Symbol(y, Decl(conditionalTypes2.ts, 67, 49)) >Extract : Symbol(Extract, Decl(lib.es5.d.ts, --, --)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 65, 13)) ->Foo : Symbol(Foo, Decl(conditionalTypes2.ts, 55, 1)) ->Bar : Symbol(Bar, Decl(conditionalTypes2.ts, 57, 27)) ->z : Symbol(z, Decl(conditionalTypes2.ts, 65, 75)) ->Extract2 : Symbol(Extract2, Decl(conditionalTypes2.ts, 61, 63)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 65, 13)) ->Foo : Symbol(Foo, Decl(conditionalTypes2.ts, 55, 1)) ->Bar : Symbol(Bar, Decl(conditionalTypes2.ts, 57, 27)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 67, 13)) +>Foo : Symbol(Foo, Decl(conditionalTypes2.ts, 57, 1)) +>Bar : Symbol(Bar, Decl(conditionalTypes2.ts, 59, 27)) +>z : Symbol(z, Decl(conditionalTypes2.ts, 67, 75)) +>Extract2 : Symbol(Extract2, Decl(conditionalTypes2.ts, 63, 63)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 67, 13)) +>Foo : Symbol(Foo, Decl(conditionalTypes2.ts, 57, 1)) +>Bar : Symbol(Bar, Decl(conditionalTypes2.ts, 59, 27)) fooBar(x); ->fooBar : Symbol(fooBar, Decl(conditionalTypes2.ts, 58, 27)) ->x : Symbol(x, Decl(conditionalTypes2.ts, 65, 16)) +>fooBar : Symbol(fooBar, Decl(conditionalTypes2.ts, 60, 27)) +>x : Symbol(x, Decl(conditionalTypes2.ts, 67, 16)) fooBar(y); ->fooBar : Symbol(fooBar, Decl(conditionalTypes2.ts, 58, 27)) ->y : Symbol(y, Decl(conditionalTypes2.ts, 65, 49)) +>fooBar : Symbol(fooBar, Decl(conditionalTypes2.ts, 60, 27)) +>y : Symbol(y, Decl(conditionalTypes2.ts, 67, 49)) fooBar(z); ->fooBar : Symbol(fooBar, Decl(conditionalTypes2.ts, 58, 27)) ->z : Symbol(z, Decl(conditionalTypes2.ts, 65, 75)) +>fooBar : Symbol(fooBar, Decl(conditionalTypes2.ts, 60, 27)) +>z : Symbol(z, Decl(conditionalTypes2.ts, 67, 75)) } function f21(x: Extract, Bar>, y: Extract, z: Extract2) { ->f21 : Symbol(f21, Decl(conditionalTypes2.ts, 69, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 71, 13)) ->x : Symbol(x, Decl(conditionalTypes2.ts, 71, 16)) +>f21 : Symbol(f21, Decl(conditionalTypes2.ts, 71, 1)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 73, 13)) +>x : Symbol(x, Decl(conditionalTypes2.ts, 73, 16)) >Extract : Symbol(Extract, Decl(lib.es5.d.ts, --, --)) >Extract : Symbol(Extract, Decl(lib.es5.d.ts, --, --)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 71, 13)) ->Foo : Symbol(Foo, Decl(conditionalTypes2.ts, 55, 1)) ->Bar : Symbol(Bar, Decl(conditionalTypes2.ts, 57, 27)) ->y : Symbol(y, Decl(conditionalTypes2.ts, 71, 49)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 73, 13)) +>Foo : Symbol(Foo, Decl(conditionalTypes2.ts, 57, 1)) +>Bar : Symbol(Bar, Decl(conditionalTypes2.ts, 59, 27)) +>y : Symbol(y, Decl(conditionalTypes2.ts, 73, 49)) >Extract : Symbol(Extract, Decl(lib.es5.d.ts, --, --)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 71, 13)) ->Foo : Symbol(Foo, Decl(conditionalTypes2.ts, 55, 1)) ->Bar : Symbol(Bar, Decl(conditionalTypes2.ts, 57, 27)) ->z : Symbol(z, Decl(conditionalTypes2.ts, 71, 75)) ->Extract2 : Symbol(Extract2, Decl(conditionalTypes2.ts, 61, 63)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 71, 13)) ->Foo : Symbol(Foo, Decl(conditionalTypes2.ts, 55, 1)) ->Bar : Symbol(Bar, Decl(conditionalTypes2.ts, 57, 27)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 73, 13)) +>Foo : Symbol(Foo, Decl(conditionalTypes2.ts, 57, 1)) +>Bar : Symbol(Bar, Decl(conditionalTypes2.ts, 59, 27)) +>z : Symbol(z, Decl(conditionalTypes2.ts, 73, 75)) +>Extract2 : Symbol(Extract2, Decl(conditionalTypes2.ts, 63, 63)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 73, 13)) +>Foo : Symbol(Foo, Decl(conditionalTypes2.ts, 57, 1)) +>Bar : Symbol(Bar, Decl(conditionalTypes2.ts, 59, 27)) fooBat(x); // Error ->fooBat : Symbol(fooBat, Decl(conditionalTypes2.ts, 60, 63)) ->x : Symbol(x, Decl(conditionalTypes2.ts, 71, 16)) +>fooBat : Symbol(fooBat, Decl(conditionalTypes2.ts, 62, 63)) +>x : Symbol(x, Decl(conditionalTypes2.ts, 73, 16)) fooBat(y); // Error ->fooBat : Symbol(fooBat, Decl(conditionalTypes2.ts, 60, 63)) ->y : Symbol(y, Decl(conditionalTypes2.ts, 71, 49)) +>fooBat : Symbol(fooBat, Decl(conditionalTypes2.ts, 62, 63)) +>y : Symbol(y, Decl(conditionalTypes2.ts, 73, 49)) fooBat(z); // Error ->fooBat : Symbol(fooBat, Decl(conditionalTypes2.ts, 60, 63)) ->z : Symbol(z, Decl(conditionalTypes2.ts, 71, 75)) -} - -// Repros from #22860 - -class Opt { ->Opt : Symbol(Opt, Decl(conditionalTypes2.ts, 75, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 79, 10)) - - toVector(): Vector { ->toVector : Symbol(Opt.toVector, Decl(conditionalTypes2.ts, 79, 14)) ->Vector : Symbol(Vector, Decl(conditionalTypes2.ts, 87, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 79, 10)) - - return undefined; ->undefined : Symbol(undefined) - } -} - -interface Seq { ->Seq : Symbol(Seq, Decl(conditionalTypes2.ts, 83, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 85, 14)) - - tail(): Opt>; ->tail : Symbol(Seq.tail, Decl(conditionalTypes2.ts, 85, 18)) ->Opt : Symbol(Opt, Decl(conditionalTypes2.ts, 75, 1)) ->Seq : Symbol(Seq, Decl(conditionalTypes2.ts, 83, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 85, 14)) -} - -class Vector implements Seq { ->Vector : Symbol(Vector, Decl(conditionalTypes2.ts, 87, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 89, 13)) ->Seq : Symbol(Seq, Decl(conditionalTypes2.ts, 83, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 89, 13)) - - tail(): Opt> { ->tail : Symbol(Vector.tail, Decl(conditionalTypes2.ts, 89, 35)) ->Opt : Symbol(Opt, Decl(conditionalTypes2.ts, 75, 1)) ->Vector : Symbol(Vector, Decl(conditionalTypes2.ts, 87, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 89, 13)) - - return undefined; ->undefined : Symbol(undefined) - } - partition2(predicate:(v:T)=>v is U): [Vector,Vector>]; ->partition2 : Symbol(Vector.partition2, Decl(conditionalTypes2.ts, 92, 5), Decl(conditionalTypes2.ts, 93, 88), Decl(conditionalTypes2.ts, 94, 64)) ->U : Symbol(U, Decl(conditionalTypes2.ts, 93, 15)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 89, 13)) ->predicate : Symbol(predicate, Decl(conditionalTypes2.ts, 93, 28)) ->v : Symbol(v, Decl(conditionalTypes2.ts, 93, 39)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 89, 13)) ->v : Symbol(v, Decl(conditionalTypes2.ts, 93, 39)) ->U : Symbol(U, Decl(conditionalTypes2.ts, 93, 15)) ->Vector : Symbol(Vector, Decl(conditionalTypes2.ts, 87, 1)) ->U : Symbol(U, Decl(conditionalTypes2.ts, 93, 15)) ->Vector : Symbol(Vector, Decl(conditionalTypes2.ts, 87, 1)) ->Exclude : Symbol(Exclude, Decl(lib.es5.d.ts, --, --)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 89, 13)) ->U : Symbol(U, Decl(conditionalTypes2.ts, 93, 15)) - - partition2(predicate:(x:T)=>boolean): [Vector,Vector]; ->partition2 : Symbol(Vector.partition2, Decl(conditionalTypes2.ts, 92, 5), Decl(conditionalTypes2.ts, 93, 88), Decl(conditionalTypes2.ts, 94, 64)) ->predicate : Symbol(predicate, Decl(conditionalTypes2.ts, 94, 15)) ->x : Symbol(x, Decl(conditionalTypes2.ts, 94, 26)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 89, 13)) ->Vector : Symbol(Vector, Decl(conditionalTypes2.ts, 87, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 89, 13)) ->Vector : Symbol(Vector, Decl(conditionalTypes2.ts, 87, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 89, 13)) - - partition2(predicate:(v:T)=>boolean): [Vector,Vector] { ->partition2 : Symbol(Vector.partition2, Decl(conditionalTypes2.ts, 92, 5), Decl(conditionalTypes2.ts, 93, 88), Decl(conditionalTypes2.ts, 94, 64)) ->U : Symbol(U, Decl(conditionalTypes2.ts, 95, 15)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 89, 13)) ->predicate : Symbol(predicate, Decl(conditionalTypes2.ts, 95, 28)) ->v : Symbol(v, Decl(conditionalTypes2.ts, 95, 39)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 89, 13)) ->Vector : Symbol(Vector, Decl(conditionalTypes2.ts, 87, 1)) ->U : Symbol(U, Decl(conditionalTypes2.ts, 95, 15)) ->Vector : Symbol(Vector, Decl(conditionalTypes2.ts, 87, 1)) - - return undefined; ->undefined : Symbol(undefined) - } -} - -interface A1 { ->A1 : Symbol(A1, Decl(conditionalTypes2.ts, 98, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 100, 13)) - - bat: B1>; ->bat : Symbol(A1.bat, Decl(conditionalTypes2.ts, 100, 17)) ->B1 : Symbol(B1, Decl(conditionalTypes2.ts, 102, 1)) ->A1 : Symbol(A1, Decl(conditionalTypes2.ts, 98, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 100, 13)) -} - -interface B1 extends A1 { ->B1 : Symbol(B1, Decl(conditionalTypes2.ts, 102, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 104, 13)) ->A1 : Symbol(A1, Decl(conditionalTypes2.ts, 98, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 104, 13)) - - bat: B1>; ->bat : Symbol(B1.bat, Decl(conditionalTypes2.ts, 104, 31)) ->B1 : Symbol(B1, Decl(conditionalTypes2.ts, 102, 1)) ->B1 : Symbol(B1, Decl(conditionalTypes2.ts, 102, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 104, 13)) - - boom: T extends any ? true : true ->boom : Symbol(B1.boom, Decl(conditionalTypes2.ts, 105, 19)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 104, 13)) +>fooBat : Symbol(fooBat, Decl(conditionalTypes2.ts, 62, 63)) +>z : Symbol(z, Decl(conditionalTypes2.ts, 73, 75)) } // Repro from #22899 declare function toString1(value: object | Function): string ; ->toString1 : Symbol(toString1, Decl(conditionalTypes2.ts, 107, 1)) ->value : Symbol(value, Decl(conditionalTypes2.ts, 111, 27)) +>toString1 : Symbol(toString1, Decl(conditionalTypes2.ts, 77, 1)) +>value : Symbol(value, Decl(conditionalTypes2.ts, 81, 27)) >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) declare function toString2(value: Function): string ; ->toString2 : Symbol(toString2, Decl(conditionalTypes2.ts, 111, 62)) ->value : Symbol(value, Decl(conditionalTypes2.ts, 112, 27)) +>toString2 : Symbol(toString2, Decl(conditionalTypes2.ts, 81, 62)) +>value : Symbol(value, Decl(conditionalTypes2.ts, 82, 27)) >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) function foo(value: T) { ->foo : Symbol(foo, Decl(conditionalTypes2.ts, 112, 53)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 114, 13)) ->value : Symbol(value, Decl(conditionalTypes2.ts, 114, 16)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 114, 13)) +>foo : Symbol(foo, Decl(conditionalTypes2.ts, 82, 53)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 84, 13)) +>value : Symbol(value, Decl(conditionalTypes2.ts, 84, 16)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 84, 13)) if (isFunction(value)) { ->isFunction : Symbol(isFunction, Decl(conditionalTypes2.ts, 25, 1)) ->value : Symbol(value, Decl(conditionalTypes2.ts, 114, 16)) +>isFunction : Symbol(isFunction, Decl(conditionalTypes2.ts, 27, 1)) +>value : Symbol(value, Decl(conditionalTypes2.ts, 84, 16)) toString1(value); ->toString1 : Symbol(toString1, Decl(conditionalTypes2.ts, 107, 1)) ->value : Symbol(value, Decl(conditionalTypes2.ts, 114, 16)) +>toString1 : Symbol(toString1, Decl(conditionalTypes2.ts, 77, 1)) +>value : Symbol(value, Decl(conditionalTypes2.ts, 84, 16)) toString2(value); ->toString2 : Symbol(toString2, Decl(conditionalTypes2.ts, 111, 62)) ->value : Symbol(value, Decl(conditionalTypes2.ts, 114, 16)) +>toString2 : Symbol(toString2, Decl(conditionalTypes2.ts, 81, 62)) +>value : Symbol(value, Decl(conditionalTypes2.ts, 84, 16)) } } // Repro from #23052 type A = ->A : Symbol(A, Decl(conditionalTypes2.ts, 119, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 123, 7)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 123, 9)) ->E : Symbol(E, Decl(conditionalTypes2.ts, 123, 12)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 89, 1)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 93, 7)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 93, 9)) +>E : Symbol(E, Decl(conditionalTypes2.ts, 93, 12)) T extends object ->T : Symbol(T, Decl(conditionalTypes2.ts, 123, 7)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 93, 7)) ? { [Q in { [P in keyof T]: T[P] extends V ? P : P; }[keyof T]]: A; } ->Q : Symbol(Q, Decl(conditionalTypes2.ts, 125, 9)) ->P : Symbol(P, Decl(conditionalTypes2.ts, 125, 17)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 123, 7)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 123, 7)) ->P : Symbol(P, Decl(conditionalTypes2.ts, 125, 17)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 123, 9)) ->P : Symbol(P, Decl(conditionalTypes2.ts, 125, 17)) ->P : Symbol(P, Decl(conditionalTypes2.ts, 125, 17)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 123, 7)) ->A : Symbol(A, Decl(conditionalTypes2.ts, 119, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 123, 7)) ->Q : Symbol(Q, Decl(conditionalTypes2.ts, 125, 9)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 123, 9)) ->E : Symbol(E, Decl(conditionalTypes2.ts, 123, 12)) +>Q : Symbol(Q, Decl(conditionalTypes2.ts, 95, 9)) +>P : Symbol(P, Decl(conditionalTypes2.ts, 95, 17)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 93, 7)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 93, 7)) +>P : Symbol(P, Decl(conditionalTypes2.ts, 95, 17)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 93, 9)) +>P : Symbol(P, Decl(conditionalTypes2.ts, 95, 17)) +>P : Symbol(P, Decl(conditionalTypes2.ts, 95, 17)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 93, 7)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 89, 1)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 93, 7)) +>Q : Symbol(Q, Decl(conditionalTypes2.ts, 95, 9)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 93, 9)) +>E : Symbol(E, Decl(conditionalTypes2.ts, 93, 12)) : T extends V ? T : never; ->T : Symbol(T, Decl(conditionalTypes2.ts, 123, 7)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 123, 9)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 123, 7)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 93, 7)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 93, 9)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 93, 7)) type B = ->B : Symbol(B, Decl(conditionalTypes2.ts, 126, 30)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 128, 7)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 128, 9)) +>B : Symbol(B, Decl(conditionalTypes2.ts, 96, 30)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 98, 7)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 98, 9)) T extends object ->T : Symbol(T, Decl(conditionalTypes2.ts, 128, 7)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 98, 7)) ? { [Q in { [P in keyof T]: T[P] extends V ? P : P; }[keyof T]]: B; } ->Q : Symbol(Q, Decl(conditionalTypes2.ts, 130, 9)) ->P : Symbol(P, Decl(conditionalTypes2.ts, 130, 17)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 128, 7)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 128, 7)) ->P : Symbol(P, Decl(conditionalTypes2.ts, 130, 17)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 128, 9)) ->P : Symbol(P, Decl(conditionalTypes2.ts, 130, 17)) ->P : Symbol(P, Decl(conditionalTypes2.ts, 130, 17)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 128, 7)) ->B : Symbol(B, Decl(conditionalTypes2.ts, 126, 30)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 128, 7)) ->Q : Symbol(Q, Decl(conditionalTypes2.ts, 130, 9)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 128, 9)) +>Q : Symbol(Q, Decl(conditionalTypes2.ts, 100, 9)) +>P : Symbol(P, Decl(conditionalTypes2.ts, 100, 17)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 98, 7)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 98, 7)) +>P : Symbol(P, Decl(conditionalTypes2.ts, 100, 17)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 98, 9)) +>P : Symbol(P, Decl(conditionalTypes2.ts, 100, 17)) +>P : Symbol(P, Decl(conditionalTypes2.ts, 100, 17)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 98, 7)) +>B : Symbol(B, Decl(conditionalTypes2.ts, 96, 30)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 98, 7)) +>Q : Symbol(Q, Decl(conditionalTypes2.ts, 100, 9)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 98, 9)) : T extends V ? T : never; ->T : Symbol(T, Decl(conditionalTypes2.ts, 128, 7)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 128, 9)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 128, 7)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 98, 7)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 98, 9)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 98, 7)) type C = ->C : Symbol(C, Decl(conditionalTypes2.ts, 131, 30)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 133, 7)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 133, 9)) ->E : Symbol(E, Decl(conditionalTypes2.ts, 133, 12)) +>C : Symbol(C, Decl(conditionalTypes2.ts, 101, 30)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 103, 7)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 103, 9)) +>E : Symbol(E, Decl(conditionalTypes2.ts, 103, 12)) { [Q in { [P in keyof T]: T[P] extends V ? P : P; }[keyof T]]: C; }; ->Q : Symbol(Q, Decl(conditionalTypes2.ts, 134, 5)) ->P : Symbol(P, Decl(conditionalTypes2.ts, 134, 13)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 133, 7)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 133, 7)) ->P : Symbol(P, Decl(conditionalTypes2.ts, 134, 13)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 133, 9)) ->P : Symbol(P, Decl(conditionalTypes2.ts, 134, 13)) ->P : Symbol(P, Decl(conditionalTypes2.ts, 134, 13)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 133, 7)) ->C : Symbol(C, Decl(conditionalTypes2.ts, 131, 30)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 133, 7)) ->Q : Symbol(Q, Decl(conditionalTypes2.ts, 134, 5)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 133, 9)) ->E : Symbol(E, Decl(conditionalTypes2.ts, 133, 12)) +>Q : Symbol(Q, Decl(conditionalTypes2.ts, 104, 5)) +>P : Symbol(P, Decl(conditionalTypes2.ts, 104, 13)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 103, 7)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 103, 7)) +>P : Symbol(P, Decl(conditionalTypes2.ts, 104, 13)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 103, 9)) +>P : Symbol(P, Decl(conditionalTypes2.ts, 104, 13)) +>P : Symbol(P, Decl(conditionalTypes2.ts, 104, 13)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 103, 7)) +>C : Symbol(C, Decl(conditionalTypes2.ts, 101, 30)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 103, 7)) +>Q : Symbol(Q, Decl(conditionalTypes2.ts, 104, 5)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 103, 9)) +>E : Symbol(E, Decl(conditionalTypes2.ts, 103, 12)) // Repro from #23100 type A2 = ->A2 : Symbol(A2, Decl(conditionalTypes2.ts, 134, 82)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 138, 8)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 138, 10)) ->E : Symbol(E, Decl(conditionalTypes2.ts, 138, 13)) +>A2 : Symbol(A2, Decl(conditionalTypes2.ts, 104, 82)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 108, 8)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 108, 10)) +>E : Symbol(E, Decl(conditionalTypes2.ts, 108, 13)) T extends object ? T extends any[] ? T : { [Q in keyof T]: A2; } : T; ->T : Symbol(T, Decl(conditionalTypes2.ts, 138, 8)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 138, 8)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 138, 8)) ->Q : Symbol(Q, Decl(conditionalTypes2.ts, 139, 48)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 138, 8)) ->A2 : Symbol(A2, Decl(conditionalTypes2.ts, 134, 82)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 138, 8)) ->Q : Symbol(Q, Decl(conditionalTypes2.ts, 139, 48)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 138, 10)) ->E : Symbol(E, Decl(conditionalTypes2.ts, 138, 13)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 138, 8)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 108, 8)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 108, 8)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 108, 8)) +>Q : Symbol(Q, Decl(conditionalTypes2.ts, 109, 48)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 108, 8)) +>A2 : Symbol(A2, Decl(conditionalTypes2.ts, 104, 82)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 108, 8)) +>Q : Symbol(Q, Decl(conditionalTypes2.ts, 109, 48)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 108, 10)) +>E : Symbol(E, Decl(conditionalTypes2.ts, 108, 13)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 108, 8)) type B2 = ->B2 : Symbol(B2, Decl(conditionalTypes2.ts, 139, 85)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 141, 8)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 141, 10)) +>B2 : Symbol(B2, Decl(conditionalTypes2.ts, 109, 85)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 111, 8)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 111, 10)) T extends object ? T extends any[] ? T : { [Q in keyof T]: B2; } : T; ->T : Symbol(T, Decl(conditionalTypes2.ts, 141, 8)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 141, 8)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 141, 8)) ->Q : Symbol(Q, Decl(conditionalTypes2.ts, 142, 48)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 141, 8)) ->B2 : Symbol(B2, Decl(conditionalTypes2.ts, 139, 85)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 141, 8)) ->Q : Symbol(Q, Decl(conditionalTypes2.ts, 142, 48)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 141, 10)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 141, 8)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 111, 8)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 111, 8)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 111, 8)) +>Q : Symbol(Q, Decl(conditionalTypes2.ts, 112, 48)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 111, 8)) +>B2 : Symbol(B2, Decl(conditionalTypes2.ts, 109, 85)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 111, 8)) +>Q : Symbol(Q, Decl(conditionalTypes2.ts, 112, 48)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 111, 10)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 111, 8)) type C2 = ->C2 : Symbol(C2, Decl(conditionalTypes2.ts, 142, 82)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 144, 8)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 144, 10)) ->E : Symbol(E, Decl(conditionalTypes2.ts, 144, 13)) +>C2 : Symbol(C2, Decl(conditionalTypes2.ts, 112, 82)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 114, 8)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 114, 10)) +>E : Symbol(E, Decl(conditionalTypes2.ts, 114, 13)) T extends object ? { [Q in keyof T]: C2; } : T; ->T : Symbol(T, Decl(conditionalTypes2.ts, 144, 8)) ->Q : Symbol(Q, Decl(conditionalTypes2.ts, 145, 26)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 144, 8)) ->C2 : Symbol(C2, Decl(conditionalTypes2.ts, 142, 82)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 144, 8)) ->Q : Symbol(Q, Decl(conditionalTypes2.ts, 145, 26)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 144, 10)) ->E : Symbol(E, Decl(conditionalTypes2.ts, 144, 13)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 144, 8)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 114, 8)) +>Q : Symbol(Q, Decl(conditionalTypes2.ts, 115, 26)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 114, 8)) +>C2 : Symbol(C2, Decl(conditionalTypes2.ts, 112, 82)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 114, 8)) +>Q : Symbol(Q, Decl(conditionalTypes2.ts, 115, 26)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 114, 10)) +>E : Symbol(E, Decl(conditionalTypes2.ts, 114, 13)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 114, 8)) // Repro from #28654 type MaybeTrue = true extends T["b"] ? "yes" : "no"; ->MaybeTrue : Symbol(MaybeTrue, Decl(conditionalTypes2.ts, 145, 63)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 149, 15)) ->b : Symbol(b, Decl(conditionalTypes2.ts, 149, 26)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 149, 15)) +>MaybeTrue : Symbol(MaybeTrue, Decl(conditionalTypes2.ts, 115, 63)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 119, 15)) +>b : Symbol(b, Decl(conditionalTypes2.ts, 119, 26)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 119, 15)) type T0 = MaybeTrue<{ b: never }> // "no" ->T0 : Symbol(T0, Decl(conditionalTypes2.ts, 149, 78)) ->MaybeTrue : Symbol(MaybeTrue, Decl(conditionalTypes2.ts, 145, 63)) ->b : Symbol(b, Decl(conditionalTypes2.ts, 151, 21)) +>T0 : Symbol(T0, Decl(conditionalTypes2.ts, 119, 78)) +>MaybeTrue : Symbol(MaybeTrue, Decl(conditionalTypes2.ts, 115, 63)) +>b : Symbol(b, Decl(conditionalTypes2.ts, 121, 21)) type T1 = MaybeTrue<{ b: false }>; // "no" ->T1 : Symbol(T1, Decl(conditionalTypes2.ts, 151, 33)) ->MaybeTrue : Symbol(MaybeTrue, Decl(conditionalTypes2.ts, 145, 63)) ->b : Symbol(b, Decl(conditionalTypes2.ts, 152, 21)) +>T1 : Symbol(T1, Decl(conditionalTypes2.ts, 121, 33)) +>MaybeTrue : Symbol(MaybeTrue, Decl(conditionalTypes2.ts, 115, 63)) +>b : Symbol(b, Decl(conditionalTypes2.ts, 122, 21)) type T2 = MaybeTrue<{ b: true }>; // "yes" ->T2 : Symbol(T2, Decl(conditionalTypes2.ts, 152, 34)) ->MaybeTrue : Symbol(MaybeTrue, Decl(conditionalTypes2.ts, 145, 63)) ->b : Symbol(b, Decl(conditionalTypes2.ts, 153, 21)) +>T2 : Symbol(T2, Decl(conditionalTypes2.ts, 122, 34)) +>MaybeTrue : Symbol(MaybeTrue, Decl(conditionalTypes2.ts, 115, 63)) +>b : Symbol(b, Decl(conditionalTypes2.ts, 123, 21)) type T3 = MaybeTrue<{ b: boolean }>; // "yes" ->T3 : Symbol(T3, Decl(conditionalTypes2.ts, 153, 33)) ->MaybeTrue : Symbol(MaybeTrue, Decl(conditionalTypes2.ts, 145, 63)) ->b : Symbol(b, Decl(conditionalTypes2.ts, 154, 21)) +>T3 : Symbol(T3, Decl(conditionalTypes2.ts, 123, 33)) +>MaybeTrue : Symbol(MaybeTrue, Decl(conditionalTypes2.ts, 115, 63)) +>b : Symbol(b, Decl(conditionalTypes2.ts, 124, 21)) // Repro from #28824 type Union = 'a' | 'b'; ->Union : Symbol(Union, Decl(conditionalTypes2.ts, 154, 36)) +>Union : Symbol(Union, Decl(conditionalTypes2.ts, 124, 36)) type Product = { f1: A, f2: B}; ->Product : Symbol(Product, Decl(conditionalTypes2.ts, 158, 23)) ->A : Symbol(A, Decl(conditionalTypes2.ts, 159, 13)) ->Union : Symbol(Union, Decl(conditionalTypes2.ts, 154, 36)) ->B : Symbol(B, Decl(conditionalTypes2.ts, 159, 29)) ->f1 : Symbol(f1, Decl(conditionalTypes2.ts, 159, 36)) ->A : Symbol(A, Decl(conditionalTypes2.ts, 159, 13)) ->f2 : Symbol(f2, Decl(conditionalTypes2.ts, 159, 43)) ->B : Symbol(B, Decl(conditionalTypes2.ts, 159, 29)) +>Product : Symbol(Product, Decl(conditionalTypes2.ts, 128, 23)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 129, 13)) +>Union : Symbol(Union, Decl(conditionalTypes2.ts, 124, 36)) +>B : Symbol(B, Decl(conditionalTypes2.ts, 129, 29)) +>f1 : Symbol(f1, Decl(conditionalTypes2.ts, 129, 36)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 129, 13)) +>f2 : Symbol(f2, Decl(conditionalTypes2.ts, 129, 43)) +>B : Symbol(B, Decl(conditionalTypes2.ts, 129, 29)) type ProductUnion = Product<'a', 0> | Product<'b', 1>; ->ProductUnion : Symbol(ProductUnion, Decl(conditionalTypes2.ts, 159, 51)) ->Product : Symbol(Product, Decl(conditionalTypes2.ts, 158, 23)) ->Product : Symbol(Product, Decl(conditionalTypes2.ts, 158, 23)) +>ProductUnion : Symbol(ProductUnion, Decl(conditionalTypes2.ts, 129, 51)) +>Product : Symbol(Product, Decl(conditionalTypes2.ts, 128, 23)) +>Product : Symbol(Product, Decl(conditionalTypes2.ts, 128, 23)) // {a: "b"; b: "a"} type UnionComplement = { ->UnionComplement : Symbol(UnionComplement, Decl(conditionalTypes2.ts, 160, 54)) +>UnionComplement : Symbol(UnionComplement, Decl(conditionalTypes2.ts, 130, 54)) [K in Union]: Exclude ->K : Symbol(K, Decl(conditionalTypes2.ts, 164, 3)) ->Union : Symbol(Union, Decl(conditionalTypes2.ts, 154, 36)) +>K : Symbol(K, Decl(conditionalTypes2.ts, 134, 3)) +>Union : Symbol(Union, Decl(conditionalTypes2.ts, 124, 36)) >Exclude : Symbol(Exclude, Decl(lib.es5.d.ts, --, --)) ->Union : Symbol(Union, Decl(conditionalTypes2.ts, 154, 36)) ->K : Symbol(K, Decl(conditionalTypes2.ts, 164, 3)) +>Union : Symbol(Union, Decl(conditionalTypes2.ts, 124, 36)) +>K : Symbol(K, Decl(conditionalTypes2.ts, 134, 3)) }; type UCA = UnionComplement['a']; ->UCA : Symbol(UCA, Decl(conditionalTypes2.ts, 165, 2)) ->UnionComplement : Symbol(UnionComplement, Decl(conditionalTypes2.ts, 160, 54)) +>UCA : Symbol(UCA, Decl(conditionalTypes2.ts, 135, 2)) +>UnionComplement : Symbol(UnionComplement, Decl(conditionalTypes2.ts, 130, 54)) type UCB = UnionComplement['b']; ->UCB : Symbol(UCB, Decl(conditionalTypes2.ts, 166, 32)) ->UnionComplement : Symbol(UnionComplement, Decl(conditionalTypes2.ts, 160, 54)) +>UCB : Symbol(UCB, Decl(conditionalTypes2.ts, 136, 32)) +>UnionComplement : Symbol(UnionComplement, Decl(conditionalTypes2.ts, 130, 54)) // {a: "a"; b: "b"} type UnionComplementComplement = { ->UnionComplementComplement : Symbol(UnionComplementComplement, Decl(conditionalTypes2.ts, 167, 32)) +>UnionComplementComplement : Symbol(UnionComplementComplement, Decl(conditionalTypes2.ts, 137, 32)) [K in Union]: Exclude> ->K : Symbol(K, Decl(conditionalTypes2.ts, 171, 3)) ->Union : Symbol(Union, Decl(conditionalTypes2.ts, 154, 36)) +>K : Symbol(K, Decl(conditionalTypes2.ts, 141, 3)) +>Union : Symbol(Union, Decl(conditionalTypes2.ts, 124, 36)) >Exclude : Symbol(Exclude, Decl(lib.es5.d.ts, --, --)) ->Union : Symbol(Union, Decl(conditionalTypes2.ts, 154, 36)) +>Union : Symbol(Union, Decl(conditionalTypes2.ts, 124, 36)) >Exclude : Symbol(Exclude, Decl(lib.es5.d.ts, --, --)) ->Union : Symbol(Union, Decl(conditionalTypes2.ts, 154, 36)) ->K : Symbol(K, Decl(conditionalTypes2.ts, 171, 3)) +>Union : Symbol(Union, Decl(conditionalTypes2.ts, 124, 36)) +>K : Symbol(K, Decl(conditionalTypes2.ts, 141, 3)) }; type UCCA = UnionComplementComplement['a']; ->UCCA : Symbol(UCCA, Decl(conditionalTypes2.ts, 172, 2)) ->UnionComplementComplement : Symbol(UnionComplementComplement, Decl(conditionalTypes2.ts, 167, 32)) +>UCCA : Symbol(UCCA, Decl(conditionalTypes2.ts, 142, 2)) +>UnionComplementComplement : Symbol(UnionComplementComplement, Decl(conditionalTypes2.ts, 137, 32)) type UCCB = UnionComplementComplement['b']; ->UCCB : Symbol(UCCB, Decl(conditionalTypes2.ts, 173, 43)) ->UnionComplementComplement : Symbol(UnionComplementComplement, Decl(conditionalTypes2.ts, 167, 32)) +>UCCB : Symbol(UCCB, Decl(conditionalTypes2.ts, 143, 43)) +>UnionComplementComplement : Symbol(UnionComplementComplement, Decl(conditionalTypes2.ts, 137, 32)) // {a: Product<'b', 1>; b: Product<'a', 0>} type ProductComplement = { ->ProductComplement : Symbol(ProductComplement, Decl(conditionalTypes2.ts, 174, 43)) +>ProductComplement : Symbol(ProductComplement, Decl(conditionalTypes2.ts, 144, 43)) [K in Union]: Exclude ->K : Symbol(K, Decl(conditionalTypes2.ts, 178, 3)) ->Union : Symbol(Union, Decl(conditionalTypes2.ts, 154, 36)) +>K : Symbol(K, Decl(conditionalTypes2.ts, 148, 3)) +>Union : Symbol(Union, Decl(conditionalTypes2.ts, 124, 36)) >Exclude : Symbol(Exclude, Decl(lib.es5.d.ts, --, --)) ->ProductUnion : Symbol(ProductUnion, Decl(conditionalTypes2.ts, 159, 51)) ->f1 : Symbol(f1, Decl(conditionalTypes2.ts, 178, 39)) ->K : Symbol(K, Decl(conditionalTypes2.ts, 178, 3)) +>ProductUnion : Symbol(ProductUnion, Decl(conditionalTypes2.ts, 129, 51)) +>f1 : Symbol(f1, Decl(conditionalTypes2.ts, 148, 39)) +>K : Symbol(K, Decl(conditionalTypes2.ts, 148, 3)) }; type PCA = ProductComplement['a']; ->PCA : Symbol(PCA, Decl(conditionalTypes2.ts, 179, 2)) ->ProductComplement : Symbol(ProductComplement, Decl(conditionalTypes2.ts, 174, 43)) +>PCA : Symbol(PCA, Decl(conditionalTypes2.ts, 149, 2)) +>ProductComplement : Symbol(ProductComplement, Decl(conditionalTypes2.ts, 144, 43)) type PCB = ProductComplement['b']; ->PCB : Symbol(PCB, Decl(conditionalTypes2.ts, 180, 34)) ->ProductComplement : Symbol(ProductComplement, Decl(conditionalTypes2.ts, 174, 43)) +>PCB : Symbol(PCB, Decl(conditionalTypes2.ts, 150, 34)) +>ProductComplement : Symbol(ProductComplement, Decl(conditionalTypes2.ts, 144, 43)) // {a: Product<'a', 0>; b: Product<'b', 1>} type ProductComplementComplement = { ->ProductComplementComplement : Symbol(ProductComplementComplement, Decl(conditionalTypes2.ts, 181, 34)) +>ProductComplementComplement : Symbol(ProductComplementComplement, Decl(conditionalTypes2.ts, 151, 34)) [K in Union]: Exclude> ->K : Symbol(K, Decl(conditionalTypes2.ts, 185, 3)) ->Union : Symbol(Union, Decl(conditionalTypes2.ts, 154, 36)) +>K : Symbol(K, Decl(conditionalTypes2.ts, 155, 3)) +>Union : Symbol(Union, Decl(conditionalTypes2.ts, 124, 36)) >Exclude : Symbol(Exclude, Decl(lib.es5.d.ts, --, --)) ->ProductUnion : Symbol(ProductUnion, Decl(conditionalTypes2.ts, 159, 51)) +>ProductUnion : Symbol(ProductUnion, Decl(conditionalTypes2.ts, 129, 51)) >Exclude : Symbol(Exclude, Decl(lib.es5.d.ts, --, --)) ->ProductUnion : Symbol(ProductUnion, Decl(conditionalTypes2.ts, 159, 51)) ->f1 : Symbol(f1, Decl(conditionalTypes2.ts, 185, 61)) ->K : Symbol(K, Decl(conditionalTypes2.ts, 185, 3)) +>ProductUnion : Symbol(ProductUnion, Decl(conditionalTypes2.ts, 129, 51)) +>f1 : Symbol(f1, Decl(conditionalTypes2.ts, 155, 61)) +>K : Symbol(K, Decl(conditionalTypes2.ts, 155, 3)) }; type PCCA = ProductComplementComplement['a']; ->PCCA : Symbol(PCCA, Decl(conditionalTypes2.ts, 186, 2)) ->ProductComplementComplement : Symbol(ProductComplementComplement, Decl(conditionalTypes2.ts, 181, 34)) +>PCCA : Symbol(PCCA, Decl(conditionalTypes2.ts, 156, 2)) +>ProductComplementComplement : Symbol(ProductComplementComplement, Decl(conditionalTypes2.ts, 151, 34)) type PCCB = ProductComplementComplement['b']; ->PCCB : Symbol(PCCB, Decl(conditionalTypes2.ts, 187, 45)) ->ProductComplementComplement : Symbol(ProductComplementComplement, Decl(conditionalTypes2.ts, 181, 34)) +>PCCB : Symbol(PCCB, Decl(conditionalTypes2.ts, 157, 45)) +>ProductComplementComplement : Symbol(ProductComplementComplement, Decl(conditionalTypes2.ts, 151, 34)) + +// Repros from #27118 + +type MyElement = [A] extends [[infer E]] ? E : never; +>MyElement : Symbol(MyElement, Decl(conditionalTypes2.ts, 158, 45)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 162, 15)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 162, 15)) +>E : Symbol(E, Decl(conditionalTypes2.ts, 162, 39)) +>E : Symbol(E, Decl(conditionalTypes2.ts, 162, 39)) + +function oops(arg: MyElement): MyElement { +>oops : Symbol(oops, Decl(conditionalTypes2.ts, 162, 56)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 163, 14)) +>B : Symbol(B, Decl(conditionalTypes2.ts, 163, 16)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 163, 14)) +>arg : Symbol(arg, Decl(conditionalTypes2.ts, 163, 30)) +>MyElement : Symbol(MyElement, Decl(conditionalTypes2.ts, 158, 45)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 163, 14)) +>MyElement : Symbol(MyElement, Decl(conditionalTypes2.ts, 158, 45)) +>B : Symbol(B, Decl(conditionalTypes2.ts, 163, 16)) + + return arg; // Unsound, should be error +>arg : Symbol(arg, Decl(conditionalTypes2.ts, 163, 30)) +} + +type MyAcceptor = [A] extends [[infer E]] ? (arg: E) => void : never; +>MyAcceptor : Symbol(MyAcceptor, Decl(conditionalTypes2.ts, 165, 1)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 167, 16)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 167, 16)) +>E : Symbol(E, Decl(conditionalTypes2.ts, 167, 40)) +>arg : Symbol(arg, Decl(conditionalTypes2.ts, 167, 48)) +>E : Symbol(E, Decl(conditionalTypes2.ts, 167, 40)) + +function oops2(arg: MyAcceptor): MyAcceptor { +>oops2 : Symbol(oops2, Decl(conditionalTypes2.ts, 167, 72)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 168, 15)) +>B : Symbol(B, Decl(conditionalTypes2.ts, 168, 17)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 168, 15)) +>arg : Symbol(arg, Decl(conditionalTypes2.ts, 168, 31)) +>MyAcceptor : Symbol(MyAcceptor, Decl(conditionalTypes2.ts, 165, 1)) +>B : Symbol(B, Decl(conditionalTypes2.ts, 168, 17)) +>MyAcceptor : Symbol(MyAcceptor, Decl(conditionalTypes2.ts, 165, 1)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 168, 15)) + + return arg; // Unsound, should be error +>arg : Symbol(arg, Decl(conditionalTypes2.ts, 168, 31)) +} + +type Dist = T extends number ? number : string; +>Dist : Symbol(Dist, Decl(conditionalTypes2.ts, 170, 1)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 172, 10)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 172, 10)) + +type Aux = A["a"] extends number ? number : string; +>Aux : Symbol(Aux, Decl(conditionalTypes2.ts, 172, 50)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 173, 9)) +>a : Symbol(a, Decl(conditionalTypes2.ts, 173, 20)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 173, 9)) + +type Nondist = Aux<{a: T}>; +>Nondist : Symbol(Nondist, Decl(conditionalTypes2.ts, 173, 77)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 174, 13)) +>Aux : Symbol(Aux, Decl(conditionalTypes2.ts, 172, 50)) +>a : Symbol(a, Decl(conditionalTypes2.ts, 174, 23)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 174, 13)) + +function oops3(arg: Dist): Nondist { +>oops3 : Symbol(oops3, Decl(conditionalTypes2.ts, 174, 30)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 175, 15)) +>arg : Symbol(arg, Decl(conditionalTypes2.ts, 175, 18)) +>Dist : Symbol(Dist, Decl(conditionalTypes2.ts, 170, 1)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 175, 15)) +>Nondist : Symbol(Nondist, Decl(conditionalTypes2.ts, 173, 77)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 175, 15)) + + return arg; // Unsound, should be error +>arg : Symbol(arg, Decl(conditionalTypes2.ts, 175, 18)) +} diff --git a/tests/baselines/reference/conditionalTypes2.types b/tests/baselines/reference/conditionalTypes2.types index aac6ba47475..3cffe6ab48e 100644 --- a/tests/baselines/reference/conditionalTypes2.types +++ b/tests/baselines/reference/conditionalTypes2.types @@ -1,4 +1,6 @@ === tests/cases/conformance/types/conditional/conditionalTypes2.ts === +// #27118: Conditional types are now invariant in the check type. + interface Covariant { foo: T extends string ? T : number; >foo : T extends string ? T : number @@ -19,7 +21,7 @@ function f1(a: Covariant, b: Covariant) { >a : Covariant >b : Covariant - a = b; + a = b; // Error >a = b : Covariant >a : Covariant >b : Covariant @@ -40,7 +42,7 @@ function f2(a: Contravariant, b: Contravariant) { >a : Contravariant >b : Contravariant - b = a; + b = a; // Error >b = a : Contravariant >b : Contravariant >a : Contravariant @@ -207,71 +209,6 @@ function f21(x: Extract, Bar>, y: Extract, z: E >z : Extract2 } -// Repros from #22860 - -class Opt { ->Opt : Opt - - toVector(): Vector { ->toVector : () => Vector - - return undefined; ->undefined : any ->undefined : undefined - } -} - -interface Seq { - tail(): Opt>; ->tail : () => Opt> -} - -class Vector implements Seq { ->Vector : Vector - - tail(): Opt> { ->tail : () => Opt> - - return undefined; ->undefined : any ->undefined : undefined - } - partition2(predicate:(v:T)=>v is U): [Vector,Vector>]; ->partition2 : { (predicate: (v: T) => v is U): [Vector, Vector>]; (predicate: (x: T) => boolean): [Vector, Vector]; } ->predicate : (v: T) => v is U ->v : T - - partition2(predicate:(x:T)=>boolean): [Vector,Vector]; ->partition2 : { (predicate: (v: T) => v is U): [Vector, Vector>]; (predicate: (x: T) => boolean): [Vector, Vector]; } ->predicate : (x: T) => boolean ->x : T - - partition2(predicate:(v:T)=>boolean): [Vector,Vector] { ->partition2 : { (predicate: (v: T) => v is U): [Vector, Vector>]; (predicate: (x: T) => boolean): [Vector, Vector]; } ->predicate : (v: T) => boolean ->v : T - - return undefined; ->undefined : any ->undefined : undefined - } -} - -interface A1 { - bat: B1>; ->bat : B1> -} - -interface B1 extends A1 { - bat: B1>; ->bat : B1> - - boom: T extends any ? true : true ->boom : T extends any ? true : true ->true : true ->true : true -} - // Repro from #22899 declare function toString1(value: object | Function): string ; @@ -431,3 +368,47 @@ type PCCA = ProductComplementComplement['a']; type PCCB = ProductComplementComplement['b']; >PCCB : Product<"b", 1> +// Repros from #27118 + +type MyElement = [A] extends [[infer E]] ? E : never; +>MyElement : MyElement + +function oops(arg: MyElement): MyElement { +>oops : (arg: MyElement) => MyElement +>arg : MyElement + + return arg; // Unsound, should be error +>arg : MyElement +} + +type MyAcceptor = [A] extends [[infer E]] ? (arg: E) => void : never; +>MyAcceptor : MyAcceptor +>arg : E + +function oops2(arg: MyAcceptor): MyAcceptor { +>oops2 : (arg: MyAcceptor) => MyAcceptor +>arg : MyAcceptor + + return arg; // Unsound, should be error +>arg : MyAcceptor +} + +type Dist = T extends number ? number : string; +>Dist : Dist + +type Aux = A["a"] extends number ? number : string; +>Aux : Aux +>a : unknown + +type Nondist = Aux<{a: T}>; +>Nondist : Aux<{ a: T; }> +>a : T + +function oops3(arg: Dist): Nondist { +>oops3 : (arg: Dist) => Aux<{ a: T; }> +>arg : Dist + + return arg; // Unsound, should be error +>arg : Dist +} + diff --git a/tests/cases/conformance/types/conditional/conditionalTypes2.ts b/tests/cases/conformance/types/conditional/conditionalTypes2.ts index 4b65b5ddeb2..5d73c58fe7f 100644 --- a/tests/cases/conformance/types/conditional/conditionalTypes2.ts +++ b/tests/cases/conformance/types/conditional/conditionalTypes2.ts @@ -1,6 +1,8 @@ // @strict: true // @declaration: true +// #27118: Conditional types are now invariant in the check type. + interface Covariant { foo: T extends string ? T : number; } @@ -14,13 +16,13 @@ interface Invariant { } function f1(a: Covariant, b: Covariant) { - a = b; + a = b; // Error b = a; // Error } function f2(a: Contravariant, b: Contravariant) { a = b; // Error - b = a; + b = a; // Error } function f3(a: Invariant, b: Invariant) { @@ -78,38 +80,6 @@ function f21(x: Extract, Bar>, y: Extract, z: E fooBat(z); // Error } -// Repros from #22860 - -class Opt { - toVector(): Vector { - return undefined; - } -} - -interface Seq { - tail(): Opt>; -} - -class Vector implements Seq { - tail(): Opt> { - return undefined; - } - partition2(predicate:(v:T)=>v is U): [Vector,Vector>]; - partition2(predicate:(x:T)=>boolean): [Vector,Vector]; - partition2(predicate:(v:T)=>boolean): [Vector,Vector] { - return undefined; - } -} - -interface A1 { - bat: B1>; -} - -interface B1 extends A1 { - bat: B1>; - boom: T extends any ? true : true -} - // Repro from #22899 declare function toString1(value: object | Function): string ; @@ -190,3 +160,22 @@ type ProductComplementComplement = { }; type PCCA = ProductComplementComplement['a']; type PCCB = ProductComplementComplement['b']; + +// Repros from #27118 + +type MyElement = [A] extends [[infer E]] ? E : never; +function oops(arg: MyElement): MyElement { + return arg; // Unsound, should be error +} + +type MyAcceptor = [A] extends [[infer E]] ? (arg: E) => void : never; +function oops2(arg: MyAcceptor): MyAcceptor { + return arg; // Unsound, should be error +} + +type Dist = T extends number ? number : string; +type Aux = A["a"] extends number ? number : string; +type Nondist = Aux<{a: T}>; +function oops3(arg: Dist): Nondist { + return arg; // Unsound, should be error +} From 9a0a838d1270d46212848ca0e7cafa435a65112d Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sun, 10 Feb 2019 07:48:22 -0800 Subject: [PATCH 18/34] Use getIndexedAccess to compute type for contextual rest parameters --- src/compiler/checker.ts | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f7cc72c534d..354d6af67be 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -21550,13 +21550,8 @@ namespace ts { } if (signature.hasRestParameter) { const restType = getTypeOfSymbol(signature.parameters[paramCount]); - if (isTupleType(restType)) { - if (pos - paramCount < getLengthOfTupleType(restType)) { - return restType.typeArguments![pos - paramCount]; - } - return getRestTypeOfTupleType(restType); - } - return getIndexTypeOfType(restType, IndexKind.Number); + const indexType = getLiteralType(pos - paramCount); + return getIndexedAccessType(restType, indexType); } return undefined; } @@ -21564,18 +21559,22 @@ namespace ts { function getRestTypeAtPosition(source: Signature, pos: number): Type { const paramCount = getParameterCount(source); const restType = getEffectiveRestType(source); - if (restType && pos === paramCount - 1) { + const nonRestCount = paramCount - (restType ? 1 : 0); + if (restType && pos === nonRestCount) { return restType; } - const start = restType ? Math.min(pos, paramCount - 1) : pos; const types = []; const names = []; - for (let i = start; i < paramCount; i++) { + for (let i = pos; i < nonRestCount; i++) { types.push(getTypeAtPosition(source, i)); names.push(getParameterNameAtPosition(source, i)); } + if (restType) { + types.push(getIndexedAccessType(restType, numberType)); + names.push(getParameterNameAtPosition(source, nonRestCount)); + } const minArgumentCount = getMinArgumentCount(source); - const minLength = minArgumentCount < start ? 0 : minArgumentCount - start; + const minLength = minArgumentCount < pos ? 0 : minArgumentCount - pos; return createTupleType(types, minLength, !!restType, /*readonly*/ false, names); } From 1f3213981181d6ff68e6f6e478032cb02d962961 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sun, 10 Feb 2019 15:07:01 -0800 Subject: [PATCH 19/34] Make inferences to union types containing multiple naked type variables --- src/compiler/checker.ts | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f7cc72c534d..9dc9efdf514 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14472,26 +14472,15 @@ namespace ts { inferFromTypes(source, getUnionType([getTrueTypeFromConditionalType(target), getFalseTypeFromConditionalType(target)])); } else if (target.flags & TypeFlags.UnionOrIntersection) { - const targetTypes = (target).types; - let typeVariableCount = 0; - let typeVariable: TypeParameter | IndexedAccessType | undefined; - // First infer to each type in union or intersection that isn't a type variable - for (const t of targetTypes) { - if (getInferenceInfoForType(t)) { - typeVariable = t; - typeVariableCount++; - } - else { - inferFromTypes(source, t); - } - } - // Next, if target containings a single naked type variable, make a secondary inference to that type - // variable. This gives meaningful results for union types in co-variant positions and intersection - // types in contra-variant positions (such as callback parameters). - if (typeVariableCount === 1) { + for (const t of (target).types) { const savePriority = priority; - priority |= InferencePriority.NakedTypeVariable; - inferFromTypes(source, typeVariable!); + // Inferences directly to naked type variables are given lower priority as they are + // less specific. For example, when inferring from Promise to T | Promise, + // we want to infer string for T, not Promise | string. + if (getInferenceInfoForType(t)) { + priority |= InferencePriority.NakedTypeVariable; + } + inferFromTypes(source, t); priority = savePriority; } } From 3ffb15fd7045c82393034ae4315ddd3633280db0 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sun, 10 Feb 2019 15:16:32 -0800 Subject: [PATCH 20/34] Accept new baselines --- .../conditionalTypeDoesntSpinForever.types | 16 ++++++++-------- tests/baselines/reference/objectSpread.types | 2 +- .../baselines/reference/restTupleElements1.types | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/baselines/reference/conditionalTypeDoesntSpinForever.types b/tests/baselines/reference/conditionalTypeDoesntSpinForever.types index d4fe4bf4826..1f4b4a62cd2 100644 --- a/tests/baselines/reference/conditionalTypeDoesntSpinForever.types +++ b/tests/baselines/reference/conditionalTypeDoesntSpinForever.types @@ -120,9 +120,9 @@ export enum PubSubRecordIsStoredInRedisAsA { buildPubSubRecordType(Object.assign({}, soFar, {storedAs: PubSubRecordIsStoredInRedisAsA.jsonEncodedRedisString})) as >buildPubSubRecordType(Object.assign({}, soFar, {storedAs: PubSubRecordIsStoredInRedisAsA.jsonEncodedRedisString})) as BuildPubSubRecordType : BuildPubSubRecordType ->buildPubSubRecordType(Object.assign({}, soFar, {storedAs: PubSubRecordIsStoredInRedisAsA.jsonEncodedRedisString})) : BuildPubSubRecordType +>buildPubSubRecordType(Object.assign({}, soFar, {storedAs: PubSubRecordIsStoredInRedisAsA.jsonEncodedRedisString})) : BuildPubSubRecordType >buildPubSubRecordType : (soFar: SO_FAR) => BuildPubSubRecordType ->Object.assign({}, soFar, {storedAs: PubSubRecordIsStoredInRedisAsA.jsonEncodedRedisString}) : SO_FAR & { storedAs: PubSubRecordIsStoredInRedisAsA; } +>Object.assign({}, soFar, {storedAs: PubSubRecordIsStoredInRedisAsA.jsonEncodedRedisString}) : SO_FAR & { storedAs: PubSubRecordIsStoredInRedisAsA.jsonEncodedRedisString; } >Object.assign : { (target: T, source: U): T & U; (target: T, source1: U, source2: V): T & U & V; (target: T, source1: U, source2: V, source3: W): T & U & V & W; (target: object, ...sources: any[]): any; } >Object : ObjectConstructor >assign : { (target: T, source: U): T & U; (target: T, source1: U, source2: V): T & U & V; (target: T, source1: U, source2: V, source3: W): T & U & V & W; (target: object, ...sources: any[]): any; } @@ -144,9 +144,9 @@ export enum PubSubRecordIsStoredInRedisAsA { buildPubSubRecordType(Object.assign({}, soFar, {storedAs: PubSubRecordIsStoredInRedisAsA.redisHash})) as >buildPubSubRecordType(Object.assign({}, soFar, {storedAs: PubSubRecordIsStoredInRedisAsA.redisHash})) as BuildPubSubRecordType : BuildPubSubRecordType ->buildPubSubRecordType(Object.assign({}, soFar, {storedAs: PubSubRecordIsStoredInRedisAsA.redisHash})) : BuildPubSubRecordType +>buildPubSubRecordType(Object.assign({}, soFar, {storedAs: PubSubRecordIsStoredInRedisAsA.redisHash})) : BuildPubSubRecordType >buildPubSubRecordType : (soFar: SO_FAR) => BuildPubSubRecordType ->Object.assign({}, soFar, {storedAs: PubSubRecordIsStoredInRedisAsA.redisHash}) : SO_FAR & { storedAs: PubSubRecordIsStoredInRedisAsA; } +>Object.assign({}, soFar, {storedAs: PubSubRecordIsStoredInRedisAsA.redisHash}) : SO_FAR & { storedAs: PubSubRecordIsStoredInRedisAsA.redisHash; } >Object.assign : { (target: T, source: U): T & U; (target: T, source1: U, source2: V): T & U & V; (target: T, source1: U, source2: V, source3: W): T & U & V & W; (target: object, ...sources: any[]): any; } >Object : ObjectConstructor >assign : { (target: T, source: U): T & U; (target: T, source1: U, source2: V): T & U & V; (target: T, source1: U, source2: V, source3: W): T & U & V & W; (target: object, ...sources: any[]): any; } @@ -337,16 +337,16 @@ export enum PubSubRecordIsStoredInRedisAsA { buildPubSubRecordType(Object.assign({}, soFar, {maxMsToWaitBeforePublishing: 0})) as BuildPubSubRecordType, >buildPubSubRecordType(Object.assign({}, soFar, {maxMsToWaitBeforePublishing: 0})) as BuildPubSubRecordType : BuildPubSubRecordType ->buildPubSubRecordType(Object.assign({}, soFar, {maxMsToWaitBeforePublishing: 0})) : BuildPubSubRecordType +>buildPubSubRecordType(Object.assign({}, soFar, {maxMsToWaitBeforePublishing: 0})) : BuildPubSubRecordType >buildPubSubRecordType : (soFar: SO_FAR) => BuildPubSubRecordType ->Object.assign({}, soFar, {maxMsToWaitBeforePublishing: 0}) : SO_FAR & { maxMsToWaitBeforePublishing: number; } +>Object.assign({}, soFar, {maxMsToWaitBeforePublishing: 0}) : SO_FAR & { maxMsToWaitBeforePublishing: 0; } >Object.assign : { (target: T, source: U): T & U; (target: T, source1: U, source2: V): T & U & V; (target: T, source1: U, source2: V, source3: W): T & U & V & W; (target: object, ...sources: any[]): any; } >Object : ObjectConstructor >assign : { (target: T, source: U): T & U; (target: T, source1: U, source2: V): T & U & V; (target: T, source1: U, source2: V, source3: W): T & U & V & W; (target: object, ...sources: any[]): any; } >{} : {} >soFar : SO_FAR ->{maxMsToWaitBeforePublishing: 0} : { maxMsToWaitBeforePublishing: number; } ->maxMsToWaitBeforePublishing : number +>{maxMsToWaitBeforePublishing: 0} : { maxMsToWaitBeforePublishing: 0; } +>maxMsToWaitBeforePublishing : 0 >0 : 0 >maxMsToWaitBeforePublishing : 0 } diff --git a/tests/baselines/reference/objectSpread.types b/tests/baselines/reference/objectSpread.types index 0ffd5dd20b7..e095a4e03bb 100644 --- a/tests/baselines/reference/objectSpread.types +++ b/tests/baselines/reference/objectSpread.types @@ -602,7 +602,7 @@ let exclusive: { id: string, a: number, b: string, c: string, d: boolean } = >d : boolean f({ a: 1, b: 'yes' }, { c: 'no', d: false }) ->f({ a: 1, b: 'yes' }, { c: 'no', d: false }) : { a: number; b: string; } & { c: string; d: boolean; } & { id: string; } +>f({ a: 1, b: 'yes' }, { c: 'no', d: false }) : { a: number; b: string; } & { c: string; d: false; } & { id: string; } >f : (t: T, u: U) => T & U & { id: string; } >{ a: 1, b: 'yes' } : { a: number; b: string; } >a : number diff --git a/tests/baselines/reference/restTupleElements1.types b/tests/baselines/reference/restTupleElements1.types index 9a8b3aaeb7e..ffa20bf503e 100644 --- a/tests/baselines/reference/restTupleElements1.types +++ b/tests/baselines/reference/restTupleElements1.types @@ -173,7 +173,7 @@ f0([]); // Error >[] : never[] f0([1]); ->f0([1]) : [number, {}] +>f0([1]) : [number, number] >f0 : (x: [T, ...U[]]) => [T, U] >[1] : [number] >1 : 1 From 15610faa9de4b06ecc24eec6f3c83948b4dd77cd Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sun, 10 Feb 2019 15:18:45 -0800 Subject: [PATCH 21/34] Update test --- tests/cases/compiler/jqueryInference.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/cases/compiler/jqueryInference.ts b/tests/cases/compiler/jqueryInference.ts index 60165916257..5784638e453 100644 --- a/tests/cases/compiler/jqueryInference.ts +++ b/tests/cases/compiler/jqueryInference.ts @@ -10,4 +10,4 @@ declare function shouldBeIdentity(p: DoNothingAlias): MyPromise; var p2 = shouldBeIdentity(p1); -var p2: MyPromise; +var p2: MyPromise; From 62e270c04d014d58d5bde60d026d91ea5e022c3e Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sun, 10 Feb 2019 15:18:51 -0800 Subject: [PATCH 22/34] Accept new baselines --- tests/baselines/reference/jqueryInference.js | 2 +- tests/baselines/reference/jqueryInference.symbols | 2 +- tests/baselines/reference/jqueryInference.types | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/baselines/reference/jqueryInference.js b/tests/baselines/reference/jqueryInference.js index 05664a889de..cea70bc4391 100644 --- a/tests/baselines/reference/jqueryInference.js +++ b/tests/baselines/reference/jqueryInference.js @@ -11,7 +11,7 @@ declare function shouldBeIdentity(p: DoNothingAlias): MyPromise; var p2 = shouldBeIdentity(p1); -var p2: MyPromise; +var p2: MyPromise; //// [jqueryInference.js] diff --git a/tests/baselines/reference/jqueryInference.symbols b/tests/baselines/reference/jqueryInference.symbols index ce3836aacd4..3d6c4f2f960 100644 --- a/tests/baselines/reference/jqueryInference.symbols +++ b/tests/baselines/reference/jqueryInference.symbols @@ -48,7 +48,7 @@ var p2 = shouldBeIdentity(p1); >shouldBeIdentity : Symbol(shouldBeIdentity, Decl(jqueryInference.ts, 6, 58)) >p1 : Symbol(p1, Decl(jqueryInference.ts, 10, 13)) -var p2: MyPromise; +var p2: MyPromise; >p2 : Symbol(p2, Decl(jqueryInference.ts, 11, 3), Decl(jqueryInference.ts, 12, 3)) >MyPromise : Symbol(MyPromise, Decl(jqueryInference.ts, 0, 0)) diff --git a/tests/baselines/reference/jqueryInference.types b/tests/baselines/reference/jqueryInference.types index 5f055fe16b2..558b0f53df3 100644 --- a/tests/baselines/reference/jqueryInference.types +++ b/tests/baselines/reference/jqueryInference.types @@ -22,11 +22,11 @@ declare const p1: MyPromise; >p1 : MyPromise var p2 = shouldBeIdentity(p1); ->p2 : MyPromise ->shouldBeIdentity(p1) : MyPromise +>p2 : MyPromise +>shouldBeIdentity(p1) : MyPromise >shouldBeIdentity : (p: DoNothingAlias) => MyPromise >p1 : MyPromise -var p2: MyPromise; ->p2 : MyPromise +var p2: MyPromise; +>p2 : MyPromise From 35cf397ae3083536884304a27d9494be0a758b38 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sun, 10 Feb 2019 15:29:14 -0800 Subject: [PATCH 23/34] Add regression tests --- .../unionAndIntersectionInference1.ts | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/cases/conformance/types/typeRelationships/typeInference/unionAndIntersectionInference1.ts b/tests/cases/conformance/types/typeRelationships/typeInference/unionAndIntersectionInference1.ts index 7066c3e6790..d4c7d25615e 100644 --- a/tests/cases/conformance/types/typeRelationships/typeInference/unionAndIntersectionInference1.ts +++ b/tests/cases/conformance/types/typeRelationships/typeInference/unionAndIntersectionInference1.ts @@ -1,3 +1,5 @@ +// @target: es2015 + // Repro from #2264 interface Y { 'i am a very certain type': Y } @@ -70,3 +72,21 @@ declare var mbp: Man & Bear; pigify(mbp).oinks; // OK, mbp is treated as Pig pigify(mbp).walks; // Ok, mbp is treated as Man + +// Repros from #29815 + +interface ITest { + name: 'test' +} + +const createTestAsync = (): Promise => Promise.resolve().then(() => ({ name: 'test' })) + +const createTest = (): ITest => { + return { name: 'test' } +} + +declare function f1(x: T | U): T | U; +declare function f2(x: T & U): T & U; + +let x1: string = f1('a'); +let x2: string = f2('a'); From 1c9fe44726535ad15ca742a6521eea8a0eec3475 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sun, 10 Feb 2019 15:29:22 -0800 Subject: [PATCH 24/34] Accept new baselines --- .../unionAndIntersectionInference1.js | 28 ++++++++- .../unionAndIntersectionInference1.symbols | 58 ++++++++++++++++++- .../unionAndIntersectionInference1.types | 53 +++++++++++++++++ 3 files changed, 136 insertions(+), 3 deletions(-) diff --git a/tests/baselines/reference/unionAndIntersectionInference1.js b/tests/baselines/reference/unionAndIntersectionInference1.js index 235eb23ebf8..ca9e527d99e 100644 --- a/tests/baselines/reference/unionAndIntersectionInference1.js +++ b/tests/baselines/reference/unionAndIntersectionInference1.js @@ -71,6 +71,24 @@ declare var mbp: Man & Bear; pigify(mbp).oinks; // OK, mbp is treated as Pig pigify(mbp).walks; // Ok, mbp is treated as Man + +// Repros from #29815 + +interface ITest { + name: 'test' +} + +const createTestAsync = (): Promise => Promise.resolve().then(() => ({ name: 'test' })) + +const createTest = (): ITest => { + return { name: 'test' } +} + +declare function f1(x: T | U): T | U; +declare function f2(x: T & U): T & U; + +let x1: string = f1('a'); +let x2: string = f2('a'); //// [unionAndIntersectionInference1.js] @@ -80,7 +98,7 @@ function destructure(something, haveValue, haveY) { return something === y ? haveY(y) : haveValue(something); } var value = Math.random() > 0.5 ? 'hey!' : undefined; -var result = destructure(value, function (text) { return 'string'; }, function (y) { return 'other one'; }); // text: string, y: Y +var result = destructure(value, text => 'string', y => 'other one'); // text: string, y: Y // Repro from #4212 function isVoid(value) { return undefined; @@ -107,7 +125,13 @@ function baz1(value) { function get(x) { return null; // just an example } -var foo; +let foo; get(foo).toUpperCase(); // Ok pigify(mbp).oinks; // OK, mbp is treated as Pig pigify(mbp).walks; // Ok, mbp is treated as Man +const createTestAsync = () => Promise.resolve().then(() => ({ name: 'test' })); +const createTest = () => { + return { name: 'test' }; +}; +let x1 = f1('a'); +let x2 = f2('a'); diff --git a/tests/baselines/reference/unionAndIntersectionInference1.symbols b/tests/baselines/reference/unionAndIntersectionInference1.symbols index 38bcd416dff..e866f19daa4 100644 --- a/tests/baselines/reference/unionAndIntersectionInference1.symbols +++ b/tests/baselines/reference/unionAndIntersectionInference1.symbols @@ -50,7 +50,7 @@ function destructure( var value = Math.random() > 0.5 ? 'hey!' : undefined; >value : Symbol(value, Decl(unionAndIntersectionInference1.ts, 12, 3)) >Math.random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) ->Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) >random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) >Y : Symbol(Y, Decl(unionAndIntersectionInference1.ts, 0, 0)) >undefined : Symbol(undefined) @@ -201,3 +201,59 @@ pigify(mbp).walks; // Ok, mbp is treated as Man >mbp : Symbol(mbp, Decl(unionAndIntersectionInference1.ts, 68, 11)) >walks : Symbol(Man.walks, Decl(unionAndIntersectionInference1.ts, 55, 15)) +// Repros from #29815 + +interface ITest { +>ITest : Symbol(ITest, Decl(unionAndIntersectionInference1.ts, 71, 18)) + + name: 'test' +>name : Symbol(ITest.name, Decl(unionAndIntersectionInference1.ts, 75, 17)) +} + +const createTestAsync = (): Promise => Promise.resolve().then(() => ({ name: 'test' })) +>createTestAsync : Symbol(createTestAsync, Decl(unionAndIntersectionInference1.ts, 79, 5)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) +>ITest : Symbol(ITest, Decl(unionAndIntersectionInference1.ts, 71, 18)) +>Promise.resolve().then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>name : Symbol(name, Decl(unionAndIntersectionInference1.ts, 79, 77)) + +const createTest = (): ITest => { +>createTest : Symbol(createTest, Decl(unionAndIntersectionInference1.ts, 81, 5)) +>ITest : Symbol(ITest, Decl(unionAndIntersectionInference1.ts, 71, 18)) + + return { name: 'test' } +>name : Symbol(name, Decl(unionAndIntersectionInference1.ts, 82, 10)) +} + +declare function f1(x: T | U): T | U; +>f1 : Symbol(f1, Decl(unionAndIntersectionInference1.ts, 83, 1)) +>T : Symbol(T, Decl(unionAndIntersectionInference1.ts, 85, 20)) +>U : Symbol(U, Decl(unionAndIntersectionInference1.ts, 85, 22)) +>x : Symbol(x, Decl(unionAndIntersectionInference1.ts, 85, 26)) +>T : Symbol(T, Decl(unionAndIntersectionInference1.ts, 85, 20)) +>U : Symbol(U, Decl(unionAndIntersectionInference1.ts, 85, 22)) +>T : Symbol(T, Decl(unionAndIntersectionInference1.ts, 85, 20)) +>U : Symbol(U, Decl(unionAndIntersectionInference1.ts, 85, 22)) + +declare function f2(x: T & U): T & U; +>f2 : Symbol(f2, Decl(unionAndIntersectionInference1.ts, 85, 43)) +>T : Symbol(T, Decl(unionAndIntersectionInference1.ts, 86, 20)) +>U : Symbol(U, Decl(unionAndIntersectionInference1.ts, 86, 22)) +>x : Symbol(x, Decl(unionAndIntersectionInference1.ts, 86, 26)) +>T : Symbol(T, Decl(unionAndIntersectionInference1.ts, 86, 20)) +>U : Symbol(U, Decl(unionAndIntersectionInference1.ts, 86, 22)) +>T : Symbol(T, Decl(unionAndIntersectionInference1.ts, 86, 20)) +>U : Symbol(U, Decl(unionAndIntersectionInference1.ts, 86, 22)) + +let x1: string = f1('a'); +>x1 : Symbol(x1, Decl(unionAndIntersectionInference1.ts, 88, 3)) +>f1 : Symbol(f1, Decl(unionAndIntersectionInference1.ts, 83, 1)) + +let x2: string = f2('a'); +>x2 : Symbol(x2, Decl(unionAndIntersectionInference1.ts, 89, 3)) +>f2 : Symbol(f2, Decl(unionAndIntersectionInference1.ts, 85, 43)) + diff --git a/tests/baselines/reference/unionAndIntersectionInference1.types b/tests/baselines/reference/unionAndIntersectionInference1.types index 7b2515c6b58..4dddcb8bd0f 100644 --- a/tests/baselines/reference/unionAndIntersectionInference1.types +++ b/tests/baselines/reference/unionAndIntersectionInference1.types @@ -179,3 +179,56 @@ pigify(mbp).walks; // Ok, mbp is treated as Man >mbp : Man & Bear >walks : boolean +// Repros from #29815 + +interface ITest { + name: 'test' +>name : "test" +} + +const createTestAsync = (): Promise => Promise.resolve().then(() => ({ name: 'test' })) +>createTestAsync : () => Promise +>(): Promise => Promise.resolve().then(() => ({ name: 'test' })) : () => Promise +>Promise.resolve().then(() => ({ name: 'test' })) : Promise +>Promise.resolve().then : (onfulfilled?: (value: void) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>Promise.resolve() : Promise +>Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise : PromiseConstructor +>resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>then : (onfulfilled?: (value: void) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => ({ name: 'test' }) : () => { name: "test"; } +>({ name: 'test' }) : { name: "test"; } +>{ name: 'test' } : { name: "test"; } +>name : "test" +>'test' : "test" + +const createTest = (): ITest => { +>createTest : () => ITest +>(): ITest => { return { name: 'test' }} : () => ITest + + return { name: 'test' } +>{ name: 'test' } : { name: "test"; } +>name : "test" +>'test' : "test" +} + +declare function f1(x: T | U): T | U; +>f1 : (x: T | U) => T | U +>x : T | U + +declare function f2(x: T & U): T & U; +>f2 : (x: T & U) => T & U +>x : T & U + +let x1: string = f1('a'); +>x1 : string +>f1('a') : "a" +>f1 : (x: T | U) => T | U +>'a' : "a" + +let x2: string = f2('a'); +>x2 : string +>f2('a') : "a" +>f2 : (x: T & U) => T & U +>'a' : "a" + From 17d16d1bbb943e4c5ead1dfb50d0da53cc499693 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Mon, 11 Feb 2019 08:36:35 -0800 Subject: [PATCH 25/34] Disable checkJS survey (#29830) * Disable checkJS survey * Completely remove survey infrastructure * Re-instate the protocol part of SurveyReady --- src/server/editorServices.ts | 32 ----- src/server/project.ts | 2 - src/server/session.ts | 4 - src/testRunner/tsconfig.json | 1 - .../unittests/tsserver/events/surveyReady.ts | 111 ------------------ .../reference/api/tsserverlibrary.d.ts | 11 +- .../TypeScript-Node-Starter | 2 +- tests/cases/user/prettier/prettier | 2 +- tests/cases/user/webpack/webpack | 2 +- 9 files changed, 4 insertions(+), 163 deletions(-) delete mode 100644 src/testRunner/unittests/tsserver/events/surveyReady.ts diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 6dccc08c4b5..e9d97f6e03c 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -7,7 +7,6 @@ namespace ts.server { export const ProjectsUpdatedInBackgroundEvent = "projectsUpdatedInBackground"; export const ProjectLoadingStartEvent = "projectLoadingStart"; export const ProjectLoadingFinishEvent = "projectLoadingFinish"; - export const SurveyReady = "surveyReady"; export const LargeFileReferencedEvent = "largeFileReferenced"; export const ConfigFileDiagEvent = "configFileDiag"; export const ProjectLanguageServiceStateEvent = "projectLanguageServiceState"; @@ -30,11 +29,6 @@ namespace ts.server { data: { project: Project; }; } - export interface SurveyReady { - eventName: typeof SurveyReady; - data: { surveyId: string; }; - } - export interface LargeFileReferencedEvent { eventName: typeof LargeFileReferencedEvent; data: { file: string; fileSize: number; maxFileSize: number; }; @@ -146,7 +140,6 @@ namespace ts.server { } export type ProjectServiceEvent = LargeFileReferencedEvent | - SurveyReady | ProjectsUpdatedInBackgroundEvent | ProjectLoadingStartEvent | ProjectLoadingFinishEvent | @@ -518,9 +511,6 @@ namespace ts.server { /** Tracks projects that we have already sent telemetry for. */ private readonly seenProjects = createMap(); - /** Tracks projects that we have already sent survey events for. */ - private readonly seenSurveyProjects = createMap(); - /*@internal*/ readonly watchFactory: WatchFactory; @@ -722,14 +712,6 @@ namespace ts.server { this.eventHandler(event); } - /* @internal */ - sendSurveyReadyEvent(surveyId: string) { - if (!this.eventHandler) { - return; - } - this.eventHandler({ eventName: SurveyReady, data: { surveyId } }); - } - /* @internal */ sendLargeFileReferencedEvent(file: string, fileSize: number) { if (!this.eventHandler) { @@ -1611,20 +1593,6 @@ namespace ts.server { return project; } - /*@internal*/ - sendSurveyReady(project: ExternalProject | ConfiguredProject): void { - if (this.seenSurveyProjects.has(project.projectName)) { - return; - } - - if (project.getCompilerOptions().checkJs !== undefined) { - const name = "checkJs"; - this.logger.info(`Survey ${name} is ready`); - this.sendSurveyReadyEvent(name); - this.seenSurveyProjects.set(project.projectName, true); - } - } - /*@internal*/ sendProjectTelemetry(project: ExternalProject | ConfiguredProject): void { if (this.seenProjects.has(project.projectName)) { diff --git a/src/server/project.ts b/src/server/project.ts index b296668e6ae..280cedb424d 100644 --- a/src/server/project.ts +++ b/src/server/project.ts @@ -1431,7 +1431,6 @@ namespace ts.server { } this.projectService.sendProjectLoadingFinishEvent(this); this.projectService.sendProjectTelemetry(this); - this.projectService.sendSurveyReady(this); return result; } @@ -1627,7 +1626,6 @@ namespace ts.server { updateGraph() { const result = super.updateGraph(); this.projectService.sendProjectTelemetry(this); - this.projectService.sendSurveyReady(this); return result; } diff --git a/src/server/session.ts b/src/server/session.ts index e5b128c984e..b47dfe6b716 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -610,10 +610,6 @@ namespace ts.server { diagnostics: bakedDiags }, ConfigFileDiagEvent); break; - case SurveyReady: - const { surveyId } = event.data; - this.event({ surveyId }, SurveyReady); - break; case ProjectLanguageServiceStateEvent: { const eventName: protocol.ProjectLanguageServiceStateEventName = ProjectLanguageServiceStateEvent; this.event({ diff --git a/src/testRunner/tsconfig.json b/src/testRunner/tsconfig.json index 7e75c0105a2..137e4d8af58 100644 --- a/src/testRunner/tsconfig.json +++ b/src/testRunner/tsconfig.json @@ -109,7 +109,6 @@ "unittests/tsserver/events/projectLanguageServiceState.ts", "unittests/tsserver/events/projectLoading.ts", "unittests/tsserver/events/projectUpdatedInBackground.ts", - "unittests/tsserver/events/surveyReady.ts", "unittests/tsserver/externalProjects.ts", "unittests/tsserver/forceConsistentCasingInFileNames.ts", "unittests/tsserver/formatSettings.ts", diff --git a/src/testRunner/unittests/tsserver/events/surveyReady.ts b/src/testRunner/unittests/tsserver/events/surveyReady.ts deleted file mode 100644 index b04746800d0..00000000000 --- a/src/testRunner/unittests/tsserver/events/surveyReady.ts +++ /dev/null @@ -1,111 +0,0 @@ -namespace ts.projectSystem { - describe("unittests:: tsserver:: events:: SurveyReady", () => { - function createSessionWithEventHandler(host: TestServerHost) { - const { session, events: surveyEvents } = createSessionWithEventTracking(host, server.SurveyReady); - - return { session, verifySurveyReadyEvent }; - - function verifySurveyReadyEvent(numberOfEvents: number) { - assert.equal(surveyEvents.length, numberOfEvents); - const expectedEvents = numberOfEvents === 0 ? [] : [{ - eventName: server.SurveyReady, - data: { surveyId: "checkJs" } - }]; - assert.deepEqual(surveyEvents, expectedEvents); - } - } - - it("doesn't log an event when checkJs isn't set", () => { - const projectRoot = "/user/username/projects/project"; - const file: File = { - path: `${projectRoot}/src/file.ts`, - content: "export var y = 10;" - }; - const tsconfig: File = { - path: `${projectRoot}/tsconfig.json`, - content: JSON.stringify({ compilerOptions: {} }), - }; - const host = createServerHost([file, tsconfig]); - const { session, verifySurveyReadyEvent } = createSessionWithEventHandler(host); - const service = session.getProjectService(); - openFilesForSession([file], session); - checkNumberOfProjects(service, { configuredProjects: 1 }); - const project = service.configuredProjects.get(tsconfig.path)!; - checkProjectActualFiles(project, [file.path, tsconfig.path]); - - verifySurveyReadyEvent(0); - }); - - it("logs an event when checkJs is set", () => { - const projectRoot = "/user/username/projects/project"; - const file: File = { - path: `${projectRoot}/src/file.ts`, - content: "export var y = 10;" - }; - const tsconfig: File = { - path: `${projectRoot}/tsconfig.json`, - content: JSON.stringify({ compilerOptions: { checkJs: true } }), - }; - const host = createServerHost([file, tsconfig]); - const { session, verifySurveyReadyEvent } = createSessionWithEventHandler(host); - openFilesForSession([file], session); - - verifySurveyReadyEvent(1); - }); - - it("logs an event when checkJs is set, only the first time", () => { - const projectRoot = "/user/username/projects/project"; - const file: File = { - path: `${projectRoot}/src/file.ts`, - content: "export var y = 10;" - }; - const rando: File = { - path: `/rando/calrissian.ts`, - content: "export function f() { }" - }; - const tsconfig: File = { - path: `${projectRoot}/tsconfig.json`, - content: JSON.stringify({ compilerOptions: { checkJs: true } }), - }; - const host = createServerHost([file, tsconfig]); - const { session, verifySurveyReadyEvent } = createSessionWithEventHandler(host); - openFilesForSession([file], session); - - verifySurveyReadyEvent(1); - - closeFilesForSession([file], session); - openFilesForSession([rando], session); - openFilesForSession([file], session); - - verifySurveyReadyEvent(1); - }); - - it("logs an event when checkJs is set after closing and reopening", () => { - const projectRoot = "/user/username/projects/project"; - const file: File = { - path: `${projectRoot}/src/file.ts`, - content: "export var y = 10;" - }; - const rando: File = { - path: `/rando/calrissian.ts`, - content: "export function f() { }" - }; - const tsconfig: File = { - path: `${projectRoot}/tsconfig.json`, - content: JSON.stringify({}), - }; - const host = createServerHost([file, tsconfig]); - const { session, verifySurveyReadyEvent } = createSessionWithEventHandler(host); - openFilesForSession([file], session); - - verifySurveyReadyEvent(0); - - closeFilesForSession([file], session); - openFilesForSession([rando], session); - host.writeFile(tsconfig.path, JSON.stringify({ compilerOptions: { checkJs: true } })); - openFilesForSession([file], session); - - verifySurveyReadyEvent(1); - }); - }); -} diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 025880dc09e..36c246c999f 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -8357,7 +8357,6 @@ declare namespace ts.server { const ProjectsUpdatedInBackgroundEvent = "projectsUpdatedInBackground"; const ProjectLoadingStartEvent = "projectLoadingStart"; const ProjectLoadingFinishEvent = "projectLoadingFinish"; - const SurveyReady = "surveyReady"; const LargeFileReferencedEvent = "largeFileReferenced"; const ConfigFileDiagEvent = "configFileDiag"; const ProjectLanguageServiceStateEvent = "projectLanguageServiceState"; @@ -8382,12 +8381,6 @@ declare namespace ts.server { project: Project; }; } - interface SurveyReady { - eventName: typeof SurveyReady; - data: { - surveyId: string; - }; - } interface LargeFileReferencedEvent { eventName: typeof LargeFileReferencedEvent; data: { @@ -8472,7 +8465,7 @@ declare namespace ts.server { interface OpenFileInfo { readonly checkJs: boolean; } - type ProjectServiceEvent = LargeFileReferencedEvent | SurveyReady | ProjectsUpdatedInBackgroundEvent | ProjectLoadingStartEvent | ProjectLoadingFinishEvent | ConfigFileDiagEvent | ProjectLanguageServiceStateEvent | ProjectInfoTelemetryEvent | OpenFileInfoTelemetryEvent; + type ProjectServiceEvent = LargeFileReferencedEvent | ProjectsUpdatedInBackgroundEvent | ProjectLoadingStartEvent | ProjectLoadingFinishEvent | ConfigFileDiagEvent | ProjectLanguageServiceStateEvent | ProjectInfoTelemetryEvent | OpenFileInfoTelemetryEvent; type ProjectServiceEventHandler = (event: ProjectServiceEvent) => void; interface SafeList { [name: string]: { @@ -8589,8 +8582,6 @@ declare namespace ts.server { readonly syntaxOnly?: boolean; /** Tracks projects that we have already sent telemetry for. */ private readonly seenProjects; - /** Tracks projects that we have already sent survey events for. */ - private readonly seenSurveyProjects; constructor(opts: ProjectServiceOptions); toPath(fileName: string): Path; private loadTypesMap; diff --git a/tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter b/tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter index 40bdb4eadab..6b9706810b5 160000 --- a/tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter +++ b/tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter @@ -1 +1 @@ -Subproject commit 40bdb4eadabc9fbed7d83e3f26817a931c0763b6 +Subproject commit 6b9706810b55af326a93b9aa59cb17815a30bb32 diff --git a/tests/cases/user/prettier/prettier b/tests/cases/user/prettier/prettier index 67f1c4877ee..6e0de081223 160000 --- a/tests/cases/user/prettier/prettier +++ b/tests/cases/user/prettier/prettier @@ -1 +1 @@ -Subproject commit 67f1c4877ee1090b66d468a847caccca411a6f82 +Subproject commit 6e0de0812231c3a48387d398d092418749aa39f1 diff --git a/tests/cases/user/webpack/webpack b/tests/cases/user/webpack/webpack index 10282ea2064..a28f44f6132 160000 --- a/tests/cases/user/webpack/webpack +++ b/tests/cases/user/webpack/webpack @@ -1 +1 @@ -Subproject commit 10282ea20648b465caec6448849f24fc34e1ba3e +Subproject commit a28f44f613276446fb764dec7fab38b7cff8a07c From 36be6c8b6859ea5b8a18e375609133311fd0cce3 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 11 Feb 2019 09:41:38 -0800 Subject: [PATCH 26/34] Accept new baselines --- .../restTuplesFromContextualTypes.errors.txt | 12 ++++++------ .../reference/restTuplesFromContextualTypes.types | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/baselines/reference/restTuplesFromContextualTypes.errors.txt b/tests/baselines/reference/restTuplesFromContextualTypes.errors.txt index d2246fbfd84..7af71017a71 100644 --- a/tests/baselines/reference/restTuplesFromContextualTypes.errors.txt +++ b/tests/baselines/reference/restTuplesFromContextualTypes.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/types/rest/restTuplesFromContextualTypes.ts(56,7): error TS2345: Argument of type '(a: number, b: any, ...x: any[]) => void' is not assignable to parameter of type '(x: number, ...args: T) => void'. +tests/cases/conformance/types/rest/restTuplesFromContextualTypes.ts(56,7): error TS2345: Argument of type '(a: number, b: T[0], ...x: T[number][]) => void' is not assignable to parameter of type '(x: number, ...args: T) => void'. Types of parameters 'b' and 'args' are incompatible. - Type 'T' is not assignable to type '[any, ...any[]]'. - Property '0' is missing in type 'any[]' but required in type '[any, ...any[]]'. + Type 'T' is not assignable to type '[T[0], ...T[number][]]'. + Property '0' is missing in type 'any[]' but required in type '[T[0], ...T[number][]]'. ==== tests/cases/conformance/types/rest/restTuplesFromContextualTypes.ts (1 errors) ==== @@ -62,10 +62,10 @@ tests/cases/conformance/types/rest/restTuplesFromContextualTypes.ts(56,7): error f((a, ...x) => {}); f((a, b, ...x) => {}); ~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '(a: number, b: any, ...x: any[]) => void' is not assignable to parameter of type '(x: number, ...args: T) => void'. +!!! error TS2345: Argument of type '(a: number, b: T[0], ...x: T[number][]) => void' is not assignable to parameter of type '(x: number, ...args: T) => void'. !!! error TS2345: Types of parameters 'b' and 'args' are incompatible. -!!! error TS2345: Type 'T' is not assignable to type '[any, ...any[]]'. -!!! error TS2345: Property '0' is missing in type 'any[]' but required in type '[any, ...any[]]'. +!!! error TS2345: Type 'T' is not assignable to type '[T[0], ...T[number][]]'. +!!! error TS2345: Property '0' is missing in type 'any[]' but required in type '[T[0], ...T[number][]]'. } // Repro from #25288 diff --git a/tests/baselines/reference/restTuplesFromContextualTypes.types b/tests/baselines/reference/restTuplesFromContextualTypes.types index ee63057b9eb..ad5a4788426 100644 --- a/tests/baselines/reference/restTuplesFromContextualTypes.types +++ b/tests/baselines/reference/restTuplesFromContextualTypes.types @@ -332,8 +332,8 @@ function f4(t: T) { f((...x) => {}); >f((...x) => {}) : void >f : (cb: (x: number, ...args: T) => void) => void ->(...x) => {} : (x: number, ...args: any[]) => void ->x : [number, ...any[]] +>(...x) => {} : (x: number, ...args: T[number][]) => void +>x : [number, ...T[number][]] f((a, ...x) => {}); >f((a, ...x) => {}) : void @@ -345,10 +345,10 @@ function f4(t: T) { f((a, b, ...x) => {}); >f((a, b, ...x) => {}) : void >f : (cb: (x: number, ...args: T) => void) => void ->(a, b, ...x) => {} : (a: number, b: any, ...x: any[]) => void +>(a, b, ...x) => {} : (a: number, b: T[0], ...x: T[number][]) => void >a : number ->b : any ->x : any[] +>b : T[0] +>x : T[number][] } // Repro from #25288 From 710826e37e9fc2627e1c4ea2746645d1befb7b89 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 11 Feb 2019 09:46:02 -0800 Subject: [PATCH 27/34] Add regression test --- .../types/rest/restTuplesFromContextualTypes.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/cases/conformance/types/rest/restTuplesFromContextualTypes.ts b/tests/cases/conformance/types/rest/restTuplesFromContextualTypes.ts index 84bf81195b0..d5623a000a2 100644 --- a/tests/cases/conformance/types/rest/restTuplesFromContextualTypes.ts +++ b/tests/cases/conformance/types/rest/restTuplesFromContextualTypes.ts @@ -70,3 +70,17 @@ declare function take(cb: (a: number, b: string) => void): void; (function foo(...rest){}(1, '')); take(function(...rest){}); + +// Repro from #29833 + +type ArgsUnion = [number, string] | [number, Error]; +type TupleUnionFunc = (...params: ArgsUnion) => number; + +const funcUnionTupleNoRest: TupleUnionFunc = (num, strOrErr) => { + return num; +}; + +const funcUnionTupleRest: TupleUnionFunc = (...params) => { + const [num, strOrErr] = params; + return num; +}; From f33c740b8c29d5b2b07ec6d01422ccd16e7a0d63 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 11 Feb 2019 09:46:10 -0800 Subject: [PATCH 28/34] Accept new baselines --- .../restTuplesFromContextualTypes.errors.txt | 14 +++++++ .../restTuplesFromContextualTypes.js | 29 +++++++++++++++ .../restTuplesFromContextualTypes.symbols | 37 +++++++++++++++++++ .../restTuplesFromContextualTypes.types | 35 ++++++++++++++++++ 4 files changed, 115 insertions(+) diff --git a/tests/baselines/reference/restTuplesFromContextualTypes.errors.txt b/tests/baselines/reference/restTuplesFromContextualTypes.errors.txt index 7af71017a71..2b94b57f462 100644 --- a/tests/baselines/reference/restTuplesFromContextualTypes.errors.txt +++ b/tests/baselines/reference/restTuplesFromContextualTypes.errors.txt @@ -79,4 +79,18 @@ tests/cases/conformance/types/rest/restTuplesFromContextualTypes.ts(56,7): error (function foo(...rest){}(1, '')); take(function(...rest){}); + + // Repro from #29833 + + type ArgsUnion = [number, string] | [number, Error]; + type TupleUnionFunc = (...params: ArgsUnion) => number; + + const funcUnionTupleNoRest: TupleUnionFunc = (num, strOrErr) => { + return num; + }; + + const funcUnionTupleRest: TupleUnionFunc = (...params) => { + const [num, strOrErr] = params; + return num; + }; \ No newline at end of file diff --git a/tests/baselines/reference/restTuplesFromContextualTypes.js b/tests/baselines/reference/restTuplesFromContextualTypes.js index 3db6c53f384..34e75fcea6e 100644 --- a/tests/baselines/reference/restTuplesFromContextualTypes.js +++ b/tests/baselines/reference/restTuplesFromContextualTypes.js @@ -68,6 +68,20 @@ declare function take(cb: (a: number, b: string) => void): void; (function foo(...rest){}(1, '')); take(function(...rest){}); + +// Repro from #29833 + +type ArgsUnion = [number, string] | [number, Error]; +type TupleUnionFunc = (...params: ArgsUnion) => number; + +const funcUnionTupleNoRest: TupleUnionFunc = (num, strOrErr) => { + return num; +}; + +const funcUnionTupleRest: TupleUnionFunc = (...params) => { + const [num, strOrErr] = params; + return num; +}; //// [restTuplesFromContextualTypes.js] @@ -274,6 +288,17 @@ take(function () { rest[_i] = arguments[_i]; } }); +var funcUnionTupleNoRest = function (num, strOrErr) { + return num; +}; +var funcUnionTupleRest = function () { + var params = []; + for (var _i = 0; _i < arguments.length; _i++) { + params[_i] = arguments[_i]; + } + var num = params[0], strOrErr = params[1]; + return num; +}; //// [restTuplesFromContextualTypes.d.ts] @@ -286,3 +311,7 @@ declare function f3(cb: (x: number, ...args: typeof t3) => void): void; declare function f4(t: T): void; declare var tuple: [number, string]; declare function take(cb: (a: number, b: string) => void): void; +declare type ArgsUnion = [number, string] | [number, Error]; +declare type TupleUnionFunc = (...params: ArgsUnion) => number; +declare const funcUnionTupleNoRest: TupleUnionFunc; +declare const funcUnionTupleRest: TupleUnionFunc; diff --git a/tests/baselines/reference/restTuplesFromContextualTypes.symbols b/tests/baselines/reference/restTuplesFromContextualTypes.symbols index d9b2310b5e2..c58e8cabcae 100644 --- a/tests/baselines/reference/restTuplesFromContextualTypes.symbols +++ b/tests/baselines/reference/restTuplesFromContextualTypes.symbols @@ -265,3 +265,40 @@ take(function(...rest){}); >take : Symbol(take, Decl(restTuplesFromContextualTypes.ts, 61, 33)) >rest : Symbol(rest, Decl(restTuplesFromContextualTypes.ts, 68, 14)) +// Repro from #29833 + +type ArgsUnion = [number, string] | [number, Error]; +>ArgsUnion : Symbol(ArgsUnion, Decl(restTuplesFromContextualTypes.ts, 68, 26)) +>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + +type TupleUnionFunc = (...params: ArgsUnion) => number; +>TupleUnionFunc : Symbol(TupleUnionFunc, Decl(restTuplesFromContextualTypes.ts, 72, 52)) +>params : Symbol(params, Decl(restTuplesFromContextualTypes.ts, 73, 23)) +>ArgsUnion : Symbol(ArgsUnion, Decl(restTuplesFromContextualTypes.ts, 68, 26)) + +const funcUnionTupleNoRest: TupleUnionFunc = (num, strOrErr) => { +>funcUnionTupleNoRest : Symbol(funcUnionTupleNoRest, Decl(restTuplesFromContextualTypes.ts, 75, 5)) +>TupleUnionFunc : Symbol(TupleUnionFunc, Decl(restTuplesFromContextualTypes.ts, 72, 52)) +>num : Symbol(num, Decl(restTuplesFromContextualTypes.ts, 75, 46)) +>strOrErr : Symbol(strOrErr, Decl(restTuplesFromContextualTypes.ts, 75, 50)) + + return num; +>num : Symbol(num, Decl(restTuplesFromContextualTypes.ts, 75, 46)) + +}; + +const funcUnionTupleRest: TupleUnionFunc = (...params) => { +>funcUnionTupleRest : Symbol(funcUnionTupleRest, Decl(restTuplesFromContextualTypes.ts, 79, 5)) +>TupleUnionFunc : Symbol(TupleUnionFunc, Decl(restTuplesFromContextualTypes.ts, 72, 52)) +>params : Symbol(params, Decl(restTuplesFromContextualTypes.ts, 79, 44)) + + const [num, strOrErr] = params; +>num : Symbol(num, Decl(restTuplesFromContextualTypes.ts, 80, 9)) +>strOrErr : Symbol(strOrErr, Decl(restTuplesFromContextualTypes.ts, 80, 13)) +>params : Symbol(params, Decl(restTuplesFromContextualTypes.ts, 79, 44)) + + return num; +>num : Symbol(num, Decl(restTuplesFromContextualTypes.ts, 80, 9)) + +}; + diff --git a/tests/baselines/reference/restTuplesFromContextualTypes.types b/tests/baselines/reference/restTuplesFromContextualTypes.types index ad5a4788426..c282dbbae31 100644 --- a/tests/baselines/reference/restTuplesFromContextualTypes.types +++ b/tests/baselines/reference/restTuplesFromContextualTypes.types @@ -389,3 +389,38 @@ take(function(...rest){}); >function(...rest){} : (a: number, b: string) => void >rest : [number, string] +// Repro from #29833 + +type ArgsUnion = [number, string] | [number, Error]; +>ArgsUnion : ArgsUnion + +type TupleUnionFunc = (...params: ArgsUnion) => number; +>TupleUnionFunc : TupleUnionFunc +>params : ArgsUnion + +const funcUnionTupleNoRest: TupleUnionFunc = (num, strOrErr) => { +>funcUnionTupleNoRest : TupleUnionFunc +>(num, strOrErr) => { return num;} : (num: number, strOrErr: string | Error) => number +>num : number +>strOrErr : string | Error + + return num; +>num : number + +}; + +const funcUnionTupleRest: TupleUnionFunc = (...params) => { +>funcUnionTupleRest : TupleUnionFunc +>(...params) => { const [num, strOrErr] = params; return num;} : (...params: ArgsUnion) => number +>params : ArgsUnion + + const [num, strOrErr] = params; +>num : number +>strOrErr : string | Error +>params : ArgsUnion + + return num; +>num : number + +}; + From 1f10e74abc0aad67c1064abd51a77bcc2808e8e6 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Mon, 11 Feb 2019 11:18:29 -0800 Subject: [PATCH 29/34] Enable no-eval rule --- src/harness/evaluator.ts | 1 + src/harness/fourslash.ts | 1 + src/harness/harness.ts | 1 + tslint.json | 2 +- 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/harness/evaluator.ts b/src/harness/evaluator.ts index 168fda1d767..a22bdb958bc 100644 --- a/src/harness/evaluator.ts +++ b/src/harness/evaluator.ts @@ -56,6 +56,7 @@ namespace evaluator { } const evaluateText = `(function (module, exports, require, __dirname, __filename, ${globalNames.join(", ")}) { ${output.text} })`; + // tslint:disable-next-line:no-eval const evaluateThunk = eval(evaluateText) as (module: any, exports: any, require: (id: string) => any, dirname: string, filename: string, ...globalArgs: any[]) => void; const module: { exports: any; } = { exports: {} }; evaluateThunk.call(globals, module, module.exports, noRequire, vpath.dirname(output.file), output.file, FakeSymbol, ...globalArgs); diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index b0bb35d5db3..f3a7197e777 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -3159,6 +3159,7 @@ ${code} const debug = new FourSlashInterface.Debug(state); const format = new FourSlashInterface.Format(state); const cancellation = new FourSlashInterface.Cancellation(state); + // tslint:disable-next-line:no-eval const f = eval(wrappedCode); f(test, goTo, plugins, verify, edit, debug, format, cancellation, FourSlashInterface.Classification, FourSlashInterface.Completion, verifyOperationIsCancelled); } diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 13ef2adbf90..a78a04c3ecb 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -77,6 +77,7 @@ namespace Utils { const environment = getExecutionEnvironment(); switch (environment) { case ExecutionEnvironment.Browser: + // tslint:disable-next-line:no-eval eval(fileContents); break; case ExecutionEnvironment.Node: diff --git a/tslint.json b/tslint.json index a3ca10e75ed..488c6a8d003 100644 --- a/tslint.json +++ b/tslint.json @@ -34,6 +34,7 @@ ], "no-bom": true, "no-double-space": true, + "no-eval": true, "no-in-operator": true, "no-increment-decrement": true, "no-inferrable-types": true, @@ -100,7 +101,6 @@ "no-console": false, "no-debugger": false, "no-empty-interface": false, - "no-eval": false, "no-object-literal-type-assertion": false, "no-shadowed-variable": false, "no-submodule-imports": false, From 02a5ef6a179c9a08a410b6d042c45a47ec13cb42 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Mon, 11 Feb 2019 11:26:19 -0800 Subject: [PATCH 30/34] Add setInterval/setTimeout --- src/harness/harnessLanguageService.ts | 1 + src/testRunner/parallel/host.ts | 2 ++ src/tsserver/server.ts | 1 + tslint.json | 5 +++++ 4 files changed, 9 insertions(+) diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index a78ef88e5b7..b70afecb791 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -766,6 +766,7 @@ namespace Harness.LanguageService { } setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): any { + // tslint:disable-next-line:ban return setTimeout(callback, ms, args); } diff --git a/src/testRunner/parallel/host.ts b/src/testRunner/parallel/host.ts index 376896a4697..9adf9e7e850 100644 --- a/src/testRunner/parallel/host.ts +++ b/src/testRunner/parallel/host.ts @@ -302,6 +302,7 @@ namespace Harness.Parallel.Host { worker.timer = undefined; } else { + // tslint:disable-next-line:ban worker.timer = setTimeout(killChild, data.payload.duration, data.payload); } break; @@ -623,6 +624,7 @@ namespace Harness.Parallel.Host { shimNoopTestInterface(global); } + // tslint:disable-next-line:ban setTimeout(() => startDelayed(perfData, totalCost), 0); // Do real startup on next tick, so all unit tests have been collected } } diff --git a/src/tsserver/server.ts b/src/tsserver/server.ts index 21146958748..0dc57ca520a 100644 --- a/src/tsserver/server.ts +++ b/src/tsserver/server.ts @@ -705,6 +705,7 @@ namespace ts.server { // stat due to inconsistencies of fs.watch // and efficiency of stat on modern filesystems function startWatchTimer() { + // tslint:disable-next-line:ban setInterval(() => { let count = 0; let nextToCheck = nextFileToCheck; diff --git a/tslint.json b/tslint.json index 488c6a8d003..5952c770c5e 100644 --- a/tslint.json +++ b/tslint.json @@ -5,6 +5,11 @@ "no-unnecessary-type-assertion": true, "array-type": [true, "array"], + "ban": [ + true, + "setInterval", + "setTimeout" + ], "ban-types": { "options": [ ["Object", "Avoid using the `Object` type. Did you mean `object`?"], From 6d2b738bd844ac73b57b6577912b146f1e4f3ef5 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Tue, 12 Feb 2019 17:55:19 -0800 Subject: [PATCH 31/34] Use built local on CI and not LKG (#29886) * Use built local on CI and not LKG * Adjust function to remove need for assertions * Accept baseline diff to go back to local based baseline * Remove comment --- Jakefile.js | 2 +- src/compiler/core.ts | 7 ++++--- tests/baselines/reference/api/tsserverlibrary.d.ts | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Jakefile.js b/Jakefile.js index c6b1cde9d4e..18f4aa56f8d 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -24,7 +24,7 @@ const host = process.env.TYPESCRIPT_HOST || process.env.host || "node"; const defaultTestTimeout = 40000; const useBuilt = - process.env.USE_BUILT === "true" ? true : + (process.env.USE_BUILT === "true" || process.env.CI === "true") ? true : process.env.LKG === "true" ? false : false; diff --git a/src/compiler/core.ts b/src/compiler/core.ts index c5505ec3736..4bd4801ce8f 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -1396,9 +1396,10 @@ namespace ts { export function assign(t: T, ...args: (T | undefined)[]) { for (const arg of args) { - for (const p in arg!) { - if (hasProperty(arg!, p)) { - t![p] = arg![p]; // TODO: GH#23368 + if (arg === undefined) continue; + for (const p in arg) { + if (hasProperty(arg, p)) { + t[p] = arg[p]; } } } diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 36c246c999f..70fccdf87c1 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -8347,7 +8347,7 @@ declare namespace ts.server { excludedFiles: ReadonlyArray; private typeAcquisition; updateGraph(): boolean; - getExcludedFiles(): ReadonlyArray; + getExcludedFiles(): readonly NormalizedPath[]; getTypeAcquisition(): TypeAcquisition; setTypeAcquisition(newTypeAcquisition: TypeAcquisition): void; } From ad7702f15a89d7056459375898fa7bfa5f96e5ef Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Wed, 13 Feb 2019 12:57:35 -0800 Subject: [PATCH 32/34] Disable node 6 (#29832) * Disable node 6 It exits LTS in a couple of months, and doesn't support async/await, meaning that it blocks us from switching Travis to use gulp instead of jake. * Swap in node 8 for node 6 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 0f720b7375e..b35dabcbb5f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ language: node_js node_js: - 'node' - '10' - - '6' + - '8' sudo: false From 5ec35c1ee80a621cec8066bdd53a000b4b4a633f Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Wed, 13 Feb 2019 17:27:28 -0800 Subject: [PATCH 33/34] Readd configure-insiders task to Gulpfile (#29907) It's identical to configure-nightly but with the flag changed from dev to insiders. We use it to manually publish an insiders build via pipeline, and went missing when we copied functionality from the jakefile. --- Gulpfile.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Gulpfile.js b/Gulpfile.js index 68a2b79f222..7d31e0a6137 100644 --- a/Gulpfile.js +++ b/Gulpfile.js @@ -618,6 +618,10 @@ const configureNightly = () => exec(process.execPath, ["scripts/configurePrerele task("configure-nightly", series(buildScripts, configureNightly)); task("configure-nightly").description = "Runs scripts/configurePrerelease.ts to prepare a build for nightly publishing"; +const configureInsiders = () => exec(process.execPath, ["scripts/configurePrerelease.js", "insiders", "package.json", "src/compiler/core.ts"]) +task("configure-insiders", series(buildScripts, configureInsiders)); +task("configure-insiders").description = "Runs scripts/configurePrerelease.ts to prepare a build for insiders publishing"; + const publishNightly = () => exec("npm", ["publish", "--tag", "next"]); task("publish-nightly", series(task("clean"), task("LKG"), task("clean"), task("runtests-parallel"), publishNightly)); task("publish-nightly").description = "Runs `npm publish --tag next` to create a new nightly build on npm"; From 84076a55351684296f7b3f1d2715690acbe8039f Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Wed, 13 Feb 2019 22:54:33 -0800 Subject: [PATCH 34/34] Add diagnostic context for expando property declarations (#29905) --- src/compiler/transformers/declarations.ts | 2 ++ .../transformers/declarations/diagnostics.ts | 10 +++--- ...nEmitExpandoPropertyPrivateName.errors.txt | 14 +++++++++ ...clarationEmitExpandoPropertyPrivateName.js | 31 +++++++++++++++++++ ...tionEmitExpandoPropertyPrivateName.symbols | 22 +++++++++++++ ...rationEmitExpandoPropertyPrivateName.types | 22 +++++++++++++ ...clarationEmitExpandoPropertyPrivateName.ts | 9 ++++++ .../TypeScript-Node-Starter | 2 +- tests/cases/user/prettier/prettier | 2 +- tests/cases/user/webpack/webpack | 2 +- 10 files changed, 109 insertions(+), 7 deletions(-) create mode 100644 tests/baselines/reference/declarationEmitExpandoPropertyPrivateName.errors.txt create mode 100644 tests/baselines/reference/declarationEmitExpandoPropertyPrivateName.js create mode 100644 tests/baselines/reference/declarationEmitExpandoPropertyPrivateName.symbols create mode 100644 tests/baselines/reference/declarationEmitExpandoPropertyPrivateName.types create mode 100644 tests/cases/compiler/declarationEmitExpandoPropertyPrivateName.ts diff --git a/src/compiler/transformers/declarations.ts b/src/compiler/transformers/declarations.ts index 42bb5d77931..63c340d81dc 100644 --- a/src/compiler/transformers/declarations.ts +++ b/src/compiler/transformers/declarations.ts @@ -1006,7 +1006,9 @@ namespace ts { if (!isPropertyAccessExpression(p.valueDeclaration)) { return undefined; } + getSymbolAccessibilityDiagnostic = createGetSymbolAccessibilityDiagnosticForNode(p.valueDeclaration); const type = resolver.createTypeOfDeclaration(p.valueDeclaration, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker); + getSymbolAccessibilityDiagnostic = oldDiag; const varDecl = createVariableDeclaration(unescapeLeadingUnderscores(p.escapedName), type, /*initializer*/ undefined); return createVariableStatement(/*modifiers*/ undefined, createVariableDeclarationList([varDecl])); }); diff --git a/src/compiler/transformers/declarations/diagnostics.ts b/src/compiler/transformers/declarations/diagnostics.ts index b4c72c79012..9a9aed99e47 100644 --- a/src/compiler/transformers/declarations/diagnostics.ts +++ b/src/compiler/transformers/declarations/diagnostics.ts @@ -26,7 +26,8 @@ namespace ts { | ImportEqualsDeclaration | TypeAliasDeclaration | ConstructorDeclaration - | IndexSignatureDeclaration; + | IndexSignatureDeclaration + | PropertyAccessExpression; export function canProduceDiagnostics(node: Node): node is DeclarationDiagnosticProducing { return isVariableDeclaration(node) || @@ -46,7 +47,8 @@ namespace ts { isImportEqualsDeclaration(node) || isTypeAliasDeclaration(node) || isConstructorDeclaration(node) || - isIndexSignatureDeclaration(node); + isIndexSignatureDeclaration(node) || + isPropertyAccessExpression(node); } export function createGetSymbolAccessibilityDiagnosticForNodeName(node: DeclarationDiagnosticProducing) { @@ -123,7 +125,7 @@ namespace ts { } export function createGetSymbolAccessibilityDiagnosticForNode(node: DeclarationDiagnosticProducing): (symbolAccessibilityResult: SymbolAccessibilityResult) => SymbolAccessibilityDiagnostic | undefined { - if (isVariableDeclaration(node) || isPropertyDeclaration(node) || isPropertySignature(node) || isBindingElement(node) || isConstructorDeclaration(node)) { + if (isVariableDeclaration(node) || isPropertyDeclaration(node) || isPropertySignature(node) || isPropertyAccessExpression(node) || isBindingElement(node) || isConstructorDeclaration(node)) { return getVariableDeclarationTypeVisibilityError; } else if (isSetAccessor(node) || isGetAccessor(node)) { @@ -164,7 +166,7 @@ namespace ts { } // This check is to ensure we don't report error on constructor parameter property as that error would be reported during parameter emit // The only exception here is if the constructor was marked as private. we are not emitting the constructor parameters at all. - else if (node.kind === SyntaxKind.PropertyDeclaration || node.kind === SyntaxKind.PropertySignature || + else if (node.kind === SyntaxKind.PropertyDeclaration || node.kind === SyntaxKind.PropertyAccessExpression || node.kind === SyntaxKind.PropertySignature || (node.kind === SyntaxKind.Parameter && hasModifier(node.parent, ModifierFlags.Private))) { // TODO(jfreeman): Deal with computed properties in error reporting. if (hasModifier(node, ModifierFlags.Static)) { diff --git a/tests/baselines/reference/declarationEmitExpandoPropertyPrivateName.errors.txt b/tests/baselines/reference/declarationEmitExpandoPropertyPrivateName.errors.txt new file mode 100644 index 00000000000..343a3a5351a --- /dev/null +++ b/tests/baselines/reference/declarationEmitExpandoPropertyPrivateName.errors.txt @@ -0,0 +1,14 @@ +tests/cases/compiler/b.ts(4,1): error TS4032: Property 'val' of exported interface has or is using name 'I' from private module '"tests/cases/compiler/a"'. + + +==== tests/cases/compiler/a.ts (0 errors) ==== + interface I {} + export function f(): I { return null as I; } +==== tests/cases/compiler/b.ts (1 errors) ==== + import {f} from "./a"; + + export function q() {} + q.val = f(); + ~~~~~ +!!! error TS4032: Property 'val' of exported interface has or is using name 'I' from private module '"tests/cases/compiler/a"'. + \ No newline at end of file diff --git a/tests/baselines/reference/declarationEmitExpandoPropertyPrivateName.js b/tests/baselines/reference/declarationEmitExpandoPropertyPrivateName.js new file mode 100644 index 00000000000..a40fb252760 --- /dev/null +++ b/tests/baselines/reference/declarationEmitExpandoPropertyPrivateName.js @@ -0,0 +1,31 @@ +//// [tests/cases/compiler/declarationEmitExpandoPropertyPrivateName.ts] //// + +//// [a.ts] +interface I {} +export function f(): I { return null as I; } +//// [b.ts] +import {f} from "./a"; + +export function q() {} +q.val = f(); + + +//// [a.js] +"use strict"; +exports.__esModule = true; +function f() { return null; } +exports.f = f; +//// [b.js] +"use strict"; +exports.__esModule = true; +var a_1 = require("./a"); +function q() { } +exports.q = q; +q.val = a_1.f(); + + +//// [a.d.ts] +interface I { +} +export declare function f(): I; +export {}; diff --git a/tests/baselines/reference/declarationEmitExpandoPropertyPrivateName.symbols b/tests/baselines/reference/declarationEmitExpandoPropertyPrivateName.symbols new file mode 100644 index 00000000000..841620f0361 --- /dev/null +++ b/tests/baselines/reference/declarationEmitExpandoPropertyPrivateName.symbols @@ -0,0 +1,22 @@ +=== tests/cases/compiler/a.ts === +interface I {} +>I : Symbol(I, Decl(a.ts, 0, 0)) + +export function f(): I { return null as I; } +>f : Symbol(f, Decl(a.ts, 0, 14)) +>I : Symbol(I, Decl(a.ts, 0, 0)) +>I : Symbol(I, Decl(a.ts, 0, 0)) + +=== tests/cases/compiler/b.ts === +import {f} from "./a"; +>f : Symbol(f, Decl(b.ts, 0, 8)) + +export function q() {} +>q : Symbol(q, Decl(b.ts, 0, 22), Decl(b.ts, 2, 22)) + +q.val = f(); +>q.val : Symbol(q.val, Decl(b.ts, 2, 22)) +>q : Symbol(q, Decl(b.ts, 0, 22), Decl(b.ts, 2, 22)) +>val : Symbol(q.val, Decl(b.ts, 2, 22)) +>f : Symbol(f, Decl(b.ts, 0, 8)) + diff --git a/tests/baselines/reference/declarationEmitExpandoPropertyPrivateName.types b/tests/baselines/reference/declarationEmitExpandoPropertyPrivateName.types new file mode 100644 index 00000000000..7418b414029 --- /dev/null +++ b/tests/baselines/reference/declarationEmitExpandoPropertyPrivateName.types @@ -0,0 +1,22 @@ +=== tests/cases/compiler/a.ts === +interface I {} +export function f(): I { return null as I; } +>f : () => I +>null as I : I +>null : null + +=== tests/cases/compiler/b.ts === +import {f} from "./a"; +>f : () => I + +export function q() {} +>q : typeof q + +q.val = f(); +>q.val = f() : I +>q.val : I +>q : typeof q +>val : I +>f() : I +>f : () => I + diff --git a/tests/cases/compiler/declarationEmitExpandoPropertyPrivateName.ts b/tests/cases/compiler/declarationEmitExpandoPropertyPrivateName.ts new file mode 100644 index 00000000000..09be2a08ff8 --- /dev/null +++ b/tests/cases/compiler/declarationEmitExpandoPropertyPrivateName.ts @@ -0,0 +1,9 @@ +// @declaration: true +// @filename: a.ts +interface I {} +export function f(): I { return null as I; } +// @filename: b.ts +import {f} from "./a"; + +export function q() {} +q.val = f(); diff --git a/tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter b/tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter index 6b9706810b5..40bdb4eadab 160000 --- a/tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter +++ b/tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter @@ -1 +1 @@ -Subproject commit 6b9706810b55af326a93b9aa59cb17815a30bb32 +Subproject commit 40bdb4eadabc9fbed7d83e3f26817a931c0763b6 diff --git a/tests/cases/user/prettier/prettier b/tests/cases/user/prettier/prettier index 6e0de081223..67f1c4877ee 160000 --- a/tests/cases/user/prettier/prettier +++ b/tests/cases/user/prettier/prettier @@ -1 +1 @@ -Subproject commit 6e0de0812231c3a48387d398d092418749aa39f1 +Subproject commit 67f1c4877ee1090b66d468a847caccca411a6f82 diff --git a/tests/cases/user/webpack/webpack b/tests/cases/user/webpack/webpack index a28f44f6132..10282ea2064 160000 --- a/tests/cases/user/webpack/webpack +++ b/tests/cases/user/webpack/webpack @@ -1 +1 @@ -Subproject commit a28f44f613276446fb764dec7fab38b7cff8a07c +Subproject commit 10282ea20648b465caec6448849f24fc34e1ba3e