diff --git a/Gulpfile.js b/Gulpfile.js index b31462755ad..704fbba4447 100644 --- a/Gulpfile.js +++ b/Gulpfile.js @@ -24,10 +24,9 @@ const baselineAccept = require("./scripts/build/baselineAccept"); const cmdLineOptions = require("./scripts/build/options"); const exec = require("./scripts/build/exec"); const browserify = require("./scripts/build/browserify"); -const debounce = require("./scripts/build/debounce"); const prepend = require("./scripts/build/prepend"); const { removeSourceMaps } = require("./scripts/build/sourcemaps"); -const { CancelSource, CancelError } = require("./scripts/build/cancellation"); +const { CancellationTokenSource, CancelError, delay, Semaphore } = require("prex"); const { libraryTargets, generateLibs } = require("./scripts/build/lib"); const { runConsoleTests, cleanTestDirs, writeTestConfigFile, refBaseline, localBaseline, refRwcBaseline, localRwcBaseline } = require("./scripts/build/tests"); @@ -534,57 +533,80 @@ gulp.task( ["watch-diagnostics", "watch-lib"].concat(useCompilerDeps), () => project.watch(tsserverProject, { typescript: useCompiler })); -gulp.task( - "watch-local", - /*help*/ false, - ["watch-lib", "watch-tsc", "watch-services", "watch-server"]); - gulp.task( "watch-runner", /*help*/ false, useCompilerDeps, () => project.watch(testRunnerProject, { typescript: useCompiler })); -const watchPatterns = [ - runJs, - typescriptDts, - tsserverlibraryDts -]; +gulp.task( + "watch-local", + "Watches for changes to projects in src/ (but does not execute tests).", + ["watch-lib", "watch-tsc", "watch-services", "watch-server", "watch-runner", "watch-lssl"]); gulp.task( "watch", - "Watches for changes to the build inputs for built/local/run.js, then executes runtests-parallel.", + "Watches for changes to the build inputs for built/local/run.js, then runs tests.", ["build-rules", "watch-runner", "watch-services", "watch-lssl"], () => { - /** @type {CancelSource | undefined} */ - let runTestsSource; + const sem = new Semaphore(1); - const fn = debounce(() => { - runTests().catch(error => { - if (error instanceof CancelError) { - log.warn("Operation was canceled"); - } - else { - log.error(error); - } - }); - }, /*timeout*/ 100, { max: 500 }); - - gulp.watch(watchPatterns, () => project.wait().then(fn)); + gulp.watch([runJs, typescriptDts, tsserverlibraryDts], () => { + runTests(); + }); // NOTE: gulp.watch is far too slow when watching tests/cases/**/* as it first enumerates *every* file const testFilePattern = /(\.ts|[\\/]tsconfig\.json)$/; fs.watch("tests/cases", { recursive: true }, (_, file) => { - if (testFilePattern.test(file)) project.wait().then(fn); + if (testFilePattern.test(file)) runTests(); }); - function runTests() { - if (runTestsSource) runTestsSource.cancel(); - runTestsSource = new CancelSource(); - return cmdLineOptions.tests || cmdLineOptions.failed - ? runConsoleTests(runJs, "mocha-fivemat-progress-reporter", /*runInParallel*/ false, /*watchMode*/ true, runTestsSource.token) - : runConsoleTests(runJs, "min", /*runInParallel*/ true, /*watchMode*/ true, runTestsSource.token); - } + async function runTests() { + try { + // Ensure only one instance of the test runner is running at any given time. + if (sem.count > 0) { + await sem.wait(); + try { + // Wait for any concurrent recompilations to complete... + try { + await delay(100); + while (project.hasRemainingWork()) { + await project.waitForWorkToComplete(); + await delay(500); + } + } + catch (e) { + if (e instanceof CancelError) return; + throw e; + } + + // cancel any pending or active test run if a new recompilation is triggered + const source = new CancellationTokenSource(); + project.waitForWorkToStart().then(() => { + source.cancel(); + }); + + if (cmdLineOptions.tests || cmdLineOptions.failed) { + await runConsoleTests(runJs, "mocha-fivemat-progress-reporter", /*runInParallel*/ false, /*watchMode*/ true, source.token); + } + else { + await runConsoleTests(runJs, "min", /*runInParallel*/ true, /*watchMode*/ true, source.token); + } + } + finally { + sem.release(); + } + } + } + catch (e) { + if (e instanceof CancelError) { + log.warn("Operation was canceled"); + } + else { + log.error(e); + } + } + }; }); gulp.task("clean-built", /*help*/ false, [`clean:${diagnosticInformationMapTs}`], () => del(["built"])); diff --git a/package.json b/package.json index 510d3aab53b..55acc40268d 100644 --- a/package.json +++ b/package.json @@ -81,6 +81,7 @@ "mocha": "latest", "mocha-fivemat-progress-reporter": "latest", "plugin-error": "latest", + "prex": "^0.4.3", "q": "latest", "remove-internal": "^2.9.2", "run-sequence": "latest", diff --git a/scripts/build/cancellation.js b/scripts/build/cancellation.js deleted file mode 100644 index 793aaf19d86..00000000000 --- a/scripts/build/cancellation.js +++ /dev/null @@ -1,71 +0,0 @@ -// @ts-check -const symSource = Symbol("CancelToken.source"); -const symToken = Symbol("CancelSource.token"); -const symCancellationRequested = Symbol("CancelSource.cancellationRequested"); -const symCancellationCallbacks = Symbol("CancelSource.cancellationCallbacks"); - -class CancelSource { - constructor() { - this[symCancellationRequested] = false; - this[symCancellationCallbacks] = []; - } - - /** @type {CancelToken} */ - get token() { - return this[symToken] || (this[symToken] = new CancelToken(this)); - } - - cancel() { - if (!this[symCancellationRequested]) { - this[symCancellationRequested] = true; - for (const callback of this[symCancellationCallbacks]) { - callback(); - } - } - } -} -exports.CancelSource = CancelSource; - -class CancelToken { - /** - * @param {CancelSource} source - */ - constructor(source) { - if (source[symToken]) return source[symToken]; - this[symSource] = source; - } - - /** @type {boolean} */ - get cancellationRequested() { - return this[symSource][symCancellationRequested]; - } - - /** - * @param {() => void} callback - */ - subscribe(callback) { - const source = this[symSource]; - if (source[symCancellationRequested]) { - callback(); - return; - } - - source[symCancellationCallbacks].push(callback); - - return { - unsubscribe() { - const index = source[symCancellationCallbacks].indexOf(callback); - if (index !== -1) source[symCancellationCallbacks].splice(index, 1); - } - }; - } -} -exports.CancelToken = CancelToken; - -class CancelError extends Error { - constructor(message = "Operation was canceled") { - super(message); - this.name = "CancelError"; - } -} -exports.CancelError = CancelError; \ No newline at end of file diff --git a/scripts/build/exec.js b/scripts/build/exec.js index 04336321dd4..8e0a058fed0 100644 --- a/scripts/build/exec.js +++ b/scripts/build/exec.js @@ -3,7 +3,7 @@ const cp = require("child_process"); const log = require("fancy-log"); // was `require("gulp-util").log (see https://github.com/gulpjs/gulp-util) const isWin = /^win/.test(process.platform); const chalk = require("./chalk"); -const { CancelToken, CancelError } = require("./cancellation"); +const { CancellationToken, CancelError } = require("prex"); module.exports = exec; @@ -15,31 +15,36 @@ module.exports = exec; * * @typedef ExecOptions * @property {boolean} [ignoreExitCode] - * @property {CancelToken} [cancelToken] + * @property {import("prex").CancellationToken} [cancelToken] */ function exec(cmd, args, options = {}) { return /**@type {Promise<{exitCode: number}>}*/(new Promise((resolve, reject) => { - log(`> ${chalk.green(cmd)} ${args.join(" ")}`); + const { ignoreExitCode, cancelToken = CancellationToken.none } = options; + cancelToken.throwIfCancellationRequested(); + // TODO (weswig): Update child_process types to add windowsVerbatimArguments to the type definition const subshellFlag = isWin ? "/c" : "-c"; const command = isWin ? [possiblyQuote(cmd), ...args] : [`${cmd} ${args.join(" ")}`]; - const ex = cp.spawn(isWin ? "cmd" : "/bin/sh", [subshellFlag, ...command], { stdio: "inherit", windowsVerbatimArguments: true }); - const subscription = options.cancelToken && options.cancelToken.subscribe(() => { - ex.kill("SIGINT"); - ex.kill("SIGTERM"); + + log(`> ${chalk.green(cmd)} ${args.join(" ")}`); + const proc = cp.spawn(isWin ? "cmd" : "/bin/sh", [subshellFlag, ...command], { stdio: "inherit", windowsVerbatimArguments: true }); + const registration = cancelToken.register(() => { + log(`${chalk.red("killing")} '${chalk.green(cmd)} ${args.join(" ")}'...`); + proc.kill("SIGINT"); + proc.kill("SIGTERM"); reject(new CancelError()); }); - ex.on("exit", exitCode => { - subscription && subscription.unsubscribe(); - if (exitCode === 0 || options.ignoreExitCode) { + proc.on("exit", exitCode => { + registration.unregister(); + if (exitCode === 0 || ignoreExitCode) { resolve({ exitCode }); } else { reject(new Error(`Process exited with code: ${exitCode}`)); } }); - ex.on("error", error => { - subscription && subscription.unsubscribe(); + proc.on("error", error => { + registration.unregister(); reject(error); }); })); diff --git a/scripts/build/project.js b/scripts/build/project.js index 933f7c44c65..0375faa2820 100644 --- a/scripts/build/project.js +++ b/scripts/build/project.js @@ -3,6 +3,8 @@ const path = require("path"); const fs = require("fs"); const gulp = require("./gulp"); const gulpif = require("gulp-if"); +const log = require("fancy-log"); // was `require("gulp-util").log (see https://github.com/gulpjs/gulp-util) +const chalk = require("./chalk"); const sourcemaps = require("gulp-sourcemaps"); const merge2 = require("merge2"); const tsc = require("gulp-typescript"); @@ -12,7 +14,12 @@ const ts = require("../../lib/typescript"); const del = require("del"); const needsUpdate = require("./needsUpdate"); const mkdirp = require("./mkdirp"); +const prettyTime = require("pretty-hrtime"); const { reportDiagnostics } = require("./diagnostics"); +const { CountdownEvent, ManualResetEvent } = require("prex"); + +const workStartedEvent = new ManualResetEvent(); +const countdown = new CountdownEvent(0); class CompilationGulp extends gulp.Gulp { /** @@ -20,15 +27,39 @@ class CompilationGulp extends gulp.Gulp { */ fork(verbose) { const child = new ForkedGulp(this.tasks); - if (verbose) { - child.on("task_start", e => gulp.emit("task_start", e)); - child.on("task_stop", e => gulp.emit("task_stop", e)); - child.on("task_err", e => gulp.emit("task_err", e)); - child.on("task_not_found", e => gulp.emit("task_not_found", e)); - child.on("task_recursion", e => gulp.emit("task_recursion", e)); - } + child.on("task_start", e => { + if (countdown.remainingCount === 0) { + countdown.reset(1); + workStartedEvent.set(); + workStartedEvent.reset(); + } + else { + countdown.add(); + } + if (verbose) { + log('Starting', `'${chalk.cyan(e.task)}' ${chalk.gray(`(${countdown.remainingCount} remaining)`)}...`); + } + }); + child.on("task_stop", e => { + countdown.signal(); + if (verbose) { + log('Finished', `'${chalk.cyan(e.task)}' after ${chalk.magenta(prettyTime(/** @type {*}*/(e).hrDuration))} ${chalk.gray(`(${countdown.remainingCount} remaining)`)}`); + } + }); + child.on("task_err", e => { + countdown.signal(); + if (verbose) { + log(`'${chalk.cyan(e.task)}' ${chalk.red("errored after")} ${chalk.magenta(prettyTime(/** @type {*}*/(e).hrDuration))} ${chalk.gray(`(${countdown.remainingCount} remaining)`)}`); + log(e.err ? e.err.stack : e.message); + } + }); return child; } + + // @ts-ignore + start() { + throw new Error("Not supported, use fork."); + } } class ForkedGulp extends gulp.Gulp { @@ -211,24 +242,26 @@ exports.flatten = flatten; /** * Returns a Promise that resolves when all pending build tasks have completed + * @param {import("prex").CancellationToken} [token] */ -function wait() { - return new Promise(resolve => { - if (compilationGulp.allDone()) { - resolve(); - } - else { - const onDone = () => { - compilationGulp.removeListener("onDone", onDone); - compilationGulp.removeListener("err", onDone); - resolve(); - }; - compilationGulp.on("stop", onDone); - compilationGulp.on("err", onDone); - } - }); +function waitForWorkToComplete(token) { + return countdown.wait(token); } -exports.wait = wait; +exports.waitForWorkToComplete = waitForWorkToComplete; + +/** + * Returns a Promise that resolves when all pending build tasks have completed + * @param {import("prex").CancellationToken} [token] + */ +function waitForWorkToStart(token) { + return workStartedEvent.wait(token); +} +exports.waitForWorkToStart = waitForWorkToStart; + +function getRemainingWork() { + return countdown.remainingCount > 0; +} +exports.hasRemainingWork = getRemainingWork; /** * Resolve a TypeScript specifier into a fully-qualified module specifier and any requisite dependencies. diff --git a/scripts/build/tests.js b/scripts/build/tests.js index d631f1e35ac..5bc619e3823 100644 --- a/scripts/build/tests.js +++ b/scripts/build/tests.js @@ -8,6 +8,7 @@ const mkdirP = require("./mkdirp"); const cmdLineOptions = require("./options"); const exec = require("./exec"); const log = require("fancy-log"); // was `require("gulp-util").log (see https://github.com/gulpjs/gulp-util) +const { CancellationToken } = require("prex"); const mochaJs = require.resolve("mocha/bin/_mocha"); exports.localBaseline = "tests/baselines/local/"; @@ -21,9 +22,9 @@ exports.localTest262Baseline = "internal/baselines/test262/local"; * @param {string} defaultReporter * @param {boolean} runInParallel * @param {boolean} watchMode - * @param {InstanceType} [cancelToken] + * @param {import("prex").CancellationToken} [cancelToken] */ -async function runConsoleTests(runJs, defaultReporter, runInParallel, watchMode, cancelToken) { +async function runConsoleTests(runJs, defaultReporter, runInParallel, watchMode, cancelToken = CancellationToken.none) { let testTimeout = cmdLineOptions.timeout; let tests = cmdLineOptions.tests; const lintFlag = cmdLineOptions.lint; @@ -37,6 +38,7 @@ async function runConsoleTests(runJs, defaultReporter, runInParallel, watchMode, const keepFailed = cmdLineOptions.keepFailed; if (!cmdLineOptions.dirty) { await cleanTestDirs(); + cancelToken.throwIfCancellationRequested(); } if (fs.existsSync(testConfigFile)) { diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 44e6487c7c4..bab6ca7b360 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -236,8 +236,9 @@ namespace ts { if (symbolFlags & SymbolFlags.Value) { const { valueDeclaration } = symbol; if (!valueDeclaration || + (isAssignmentDeclaration(valueDeclaration) && !isAssignmentDeclaration(node)) || (valueDeclaration.kind !== node.kind && isEffectiveModuleDeclaration(valueDeclaration))) { - // other kinds of value declarations take precedence over modules + // other kinds of value declarations take precedence over modules and assignment declarations symbol.valueDeclaration = node; } } @@ -373,7 +374,8 @@ namespace ts { // prototype symbols like methods. symbolTable.set(name, symbol = createSymbol(SymbolFlags.None, name)); } - else { + else if (!(includes & SymbolFlags.Variable && symbol.flags & SymbolFlags.JSContainer)) { + // JSContainers are allowed to merge with variables, no matter what other flags they have. if (isNamedDeclaration(node)) { node.name.parent = node; } @@ -2537,12 +2539,10 @@ namespace ts { (namespaceSymbol.members || (namespaceSymbol.members = createSymbolTable())) : (namespaceSymbol.exports || (namespaceSymbol.exports = createSymbolTable())); - // Declare the method/property - const jsContainerFlag = isToplevelNamespaceableInitializer ? SymbolFlags.JSContainer : 0; const isMethod = isFunctionLikeDeclaration(getAssignedJavascriptInitializer(propertyAccess)!); - const symbolFlags = (isMethod ? SymbolFlags.Method : SymbolFlags.Property) | jsContainerFlag; - const symbolExcludes = (isMethod ? SymbolFlags.MethodExcludes : SymbolFlags.PropertyExcludes) & ~jsContainerFlag; - declareSymbol(symbolTable, namespaceSymbol, propertyAccess, symbolFlags, symbolExcludes); + const includes = isMethod ? SymbolFlags.Method : SymbolFlags.Property; + const excludes = isMethod ? SymbolFlags.MethodExcludes : SymbolFlags.PropertyExcludes; + declareSymbol(symbolTable, namespaceSymbol, propertyAccess, includes | SymbolFlags.JSContainer, excludes & ~SymbolFlags.JSContainer); } /** diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 44c7eba605d..ebd849a7844 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -837,8 +837,9 @@ namespace ts { target.flags |= source.flags; if (source.valueDeclaration && (!target.valueDeclaration || + isAssignmentDeclaration(target.valueDeclaration) || isEffectiveModuleDeclaration(target.valueDeclaration) && !isEffectiveModuleDeclaration(source.valueDeclaration))) { - // other kinds of value declarations take precedence over modules + // other kinds of value declarations take precedence over modules and assignment declarations target.valueDeclaration = source.valueDeclaration; } addRange(target.declarations, source.declarations); @@ -1212,7 +1213,7 @@ namespace ts { } if (meaning & SymbolFlags.Value && result.flags & SymbolFlags.Variable) { // expression inside parameter will lookup as normal variable scope when targeting es2015+ - if (compilerOptions.target && compilerOptions.target >= ScriptTarget.ES2015 && isParameter(lastLocation) && !isParameterPropertyDeclaration(lastLocation) && result.valueDeclaration !== lastLocation) { + if (compilerOptions.target && compilerOptions.target >= ScriptTarget.ES2015 && isParameter(lastLocation) && !isParameterPropertyDeclaration(lastLocation) && result.valueDeclaration.pos > lastLocation.end) { useResult = false; } else if (result.flags & SymbolFlags.FunctionScopedVariable) { @@ -3933,7 +3934,7 @@ namespace ts { // specifier preference const { moduleResolverHost } = context.tracker; const specifierCompilerOptions = isBundle ? { ...compilerOptions, baseUrl: moduleResolverHost.getCommonSourceDirectory() } : compilerOptions; - specifier = first(first(moduleSpecifiers.getModuleSpecifiers( + specifier = first(moduleSpecifiers.getModuleSpecifiers( symbol, specifierCompilerOptions, contextFile, @@ -3941,7 +3942,7 @@ namespace ts { host.getSourceFiles(), { importModuleSpecifierPreference: isBundle ? "non-relative" : "relative" }, host.redirectTargetsMap, - ))); + )); links.specifierCache = links.specifierCache || createMap(); links.specifierCache.set(contextFile.path, specifier); } @@ -10527,9 +10528,13 @@ namespace ts { * attempt to issue more specific errors on, for example, specific object literal properties or tuple members. */ function checkTypeAssignableToAndOptionallyElaborate(source: Type, target: Type, errorNode: Node | undefined, expr: Expression | undefined, headMessage?: DiagnosticMessage, containingMessageChain?: () => DiagnosticMessageChain | undefined): boolean { - if (isTypeAssignableTo(source, target)) return true; - if (!elaborateError(expr, source, target)) { - return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage, containingMessageChain); + return checkTypeRelatedToAndOptionallyElaborate(source, target, assignableRelation, errorNode, expr, headMessage, containingMessageChain); + } + + function checkTypeRelatedToAndOptionallyElaborate(source: Type, target: Type, relation: Map, errorNode: Node | undefined, expr: Expression | undefined, headMessage?: DiagnosticMessage, containingMessageChain?: () => DiagnosticMessageChain | undefined): boolean { + if (isTypeRelatedTo(source, target, relation)) return true; + if (!errorNode || !elaborateError(expr, source, target)) { + return checkTypeRelatedTo(source, target, relation, errorNode, headMessage, containingMessageChain); } return false; } @@ -11320,7 +11325,7 @@ namespace ts { return hasExcessProperties(source, discriminant, /*discriminant*/ undefined, reportErrors); } for (const prop of getPropertiesOfObjectType(source)) { - if (!isKnownProperty(target, prop.escapedName, isComparingJsxAttributes)) { + if (!isPropertyFromSpread(prop, source.symbol) && !isKnownProperty(target, prop.escapedName, isComparingJsxAttributes)) { if (reportErrors) { // We know *exactly* where things went wrong when comparing the types. // Use this property as the error node as this will be more helpful in @@ -11364,6 +11369,10 @@ namespace ts { return false; } + function isPropertyFromSpread(prop: Symbol, container: Symbol) { + return prop.valueDeclaration && container.valueDeclaration && prop.valueDeclaration.parent !== container.valueDeclaration; + } + function eachTypeRelatedToSomeType(source: UnionOrIntersectionType, target: UnionOrIntersectionType): Ternary { let result = Ternary.True; const sourceTypes = source.types; @@ -13658,7 +13667,7 @@ namespace ts { return inference.priority! & InferencePriority.PriorityImpliesCombination ? getIntersectionType(inference.contraCandidates!) : getCommonSubtype(inference.contraCandidates!); } - function getCovariantInference(inference: InferenceInfo, context: InferenceContext, signature: Signature) { + function getCovariantInference(inference: InferenceInfo, signature: Signature) { // Extract all object literal types and replace them with a single widened and normalized type. const candidates = widenObjectLiteralCandidates(inference.candidates!); // We widen inferred literal types if @@ -13671,10 +13680,9 @@ namespace ts { const baseCandidates = primitiveConstraint ? sameMap(candidates, getRegularTypeOfLiteralType) : widenLiteralTypes ? sameMap(candidates, getWidenedLiteralType) : candidates; - // If all inferences were made from contravariant positions, infer a common subtype. Otherwise, if - // union types were requested or if all inferences were made from the return type position, infer a - // union type. Otherwise, infer a common supertype. - const unwidenedType = context.flags & InferenceFlags.InferUnionTypes || inference.priority! & InferencePriority.PriorityImpliesCombination ? + // If all inferences were made from a position that implies a combined result, infer a union type. + // Otherwise, infer a common supertype. + const unwidenedType = inference.priority! & InferencePriority.PriorityImpliesCombination ? getUnionType(baseCandidates, UnionReduction.Subtype) : getCommonSupertype(baseCandidates); return getWidenedType(unwidenedType); @@ -13694,7 +13702,7 @@ namespace ts { inference.contraCandidates = undefined; } if (inference.candidates) { - inferredType = getCovariantInference(inference, context, signature); + inferredType = getCovariantInference(inference, signature); } else if (context.flags & InferenceFlags.NoDefault) { // We use silentNeverType as the wildcard that signals no inferences. @@ -16140,6 +16148,16 @@ namespace ts { return true; } case SpecialPropertyAssignmentKind.ThisProperty: + if (!binaryExpression.symbol || + binaryExpression.symbol.valueDeclaration && !!getJSDocTypeTag(binaryExpression.symbol.valueDeclaration)) { + return true; + } + const thisAccess = binaryExpression.left as PropertyAccessExpression; + if (!isObjectLiteralMethod(getThisContainer(thisAccess.expression, /*includeArrowFunctions*/ false))) { + return false; + } + const thisType = checkThisExpression(thisAccess.expression); + return thisType && !!getPropertyOfType(thisType, thisAccess.name.escapedText); case SpecialPropertyAssignmentKind.ModuleExports: return !binaryExpression.symbol || binaryExpression.symbol.valueDeclaration && !!getJSDocTypeTag(binaryExpression.symbol.valueDeclaration); default: @@ -18633,7 +18651,7 @@ namespace ts { // Instantiate a generic signature in the context of a non-generic signature (section 3.8.5 in TypeScript spec) function instantiateSignatureInContextOf(signature: Signature, contextualSignature: Signature, contextualMapper?: TypeMapper, compareTypes?: TypeComparer): Signature { - const context = createInferenceContext(signature.typeParameters!, signature, InferenceFlags.InferUnionTypes, compareTypes); + const context = createInferenceContext(signature.typeParameters!, signature, InferenceFlags.None, compareTypes); const sourceSignature = contextualMapper ? instantiateSignature(contextualSignature, contextualMapper) : contextualSignature; forEachMatchingParameterType(sourceSignature, signature, (source, target) => { // Type parameters from outer context referenced by source type are fixed by instantiation of the source type @@ -18859,7 +18877,7 @@ namespace ts { // we obtain the regular type of any object literal arguments because we may not have inferred complete // parameter types yet and therefore excess property checks may yield false positives (see #17041). const checkArgType = excludeArgument ? getRegularTypeOfObjectLiteral(argType) : argType; - if (!checkTypeRelatedTo(checkArgType, paramType, relation, reportErrors ? arg : undefined, headMessage)) { + if (!checkTypeRelatedToAndOptionallyElaborate(checkArgType, paramType, relation, reportErrors ? arg : undefined, arg, headMessage)) { return false; } } @@ -26347,7 +26365,7 @@ namespace ts { function checkExportSpecifier(node: ExportSpecifier) { checkAliasSymbol(node); - if (compilerOptions.declaration) { + if (getEmitDeclarations(compilerOptions)) { collectLinkedAliases(node.propertyName || node.name, /*setVisibility*/ true); } if (!node.parent.parent.moduleSpecifier) { @@ -26388,7 +26406,7 @@ namespace ts { if (node.expression.kind === SyntaxKind.Identifier) { markExportAsReferenced(node); - if (compilerOptions.declaration) { + if (getEmitDeclarations(compilerOptions)) { collectLinkedAliases(node.expression as Identifier, /*setVisibility*/ true); } } @@ -27335,12 +27353,10 @@ namespace ts { } if (isPartOfTypeNode(node)) { - let typeFromTypeNode = getTypeFromTypeNode(node); + const typeFromTypeNode = getTypeFromTypeNode(node); if (isExpressionWithTypeArgumentsInClassImplementsClause(node)) { - const containingClass = getContainingClass(node)!; - const classType = getTypeOfNode(containingClass) as InterfaceType; - typeFromTypeNode = getTypeWithThisArgument(typeFromTypeNode, classType.thisType); + return getTypeWithThisArgument(typeFromTypeNode, getTypeOfClassContainingHeritageClause(node).thisType); } return typeFromTypeNode; @@ -27353,8 +27369,7 @@ namespace ts { if (isExpressionWithTypeArgumentsInClassExtendsClause(node)) { // A SyntaxKind.ExpressionWithTypeArguments is considered a type node, except when it occurs in the // extends clause of a class. We handle that case here. - const classNode = getContainingClass(node)!; - const classType = getDeclaredTypeOfSymbol(getSymbolOfNode(classNode)) as InterfaceType; + const classType = getTypeOfClassContainingHeritageClause(node); const baseType = firstOrUndefined(getBaseTypes(classType)); return baseType ? getTypeWithThisArgument(baseType, classType.thisType) : errorType; } @@ -27396,6 +27411,10 @@ namespace ts { return errorType; } + function getTypeOfClassContainingHeritageClause(node: ExpressionWithTypeArguments): InterfaceType { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node.parent.parent)); + } + // Gets the type of object literal or array literal of destructuring assignment. // { a } from // for ( { a } of elems) { diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index f1dd4093956..e4c4edcb4db 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -62,9 +62,7 @@ namespace ts { /* @internal */ export const libMap = createMapFromEntries(libEntries); - /* @internal */ - export const optionDeclarations: CommandLineOption[] = [ - // CommandLine only options + const commonOptionsWithBuild: CommandLineOption[] = [ { name: "help", shortName: "h", @@ -78,6 +76,27 @@ namespace ts { shortName: "?", type: "boolean" }, + { + name: "preserveWatchOutput", + type: "boolean", + showInSimplifiedHelpView: false, + category: Diagnostics.Command_line_Options, + description: Diagnostics.Whether_to_keep_outdated_console_output_in_watch_mode_instead_of_clearing_the_screen, + }, + { + name: "watch", + shortName: "w", + type: "boolean", + showInSimplifiedHelpView: true, + category: Diagnostics.Command_line_Options, + description: Diagnostics.Watch_input_files, + }, + ]; + + /* @internal */ + export const optionDeclarations: CommandLineOption[] = [ + // CommandLine only options + ...commonOptionsWithBuild, { name: "all", type: "boolean", @@ -125,21 +144,6 @@ namespace ts { category: Diagnostics.Command_line_Options, description: Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental }, - { - name: "preserveWatchOutput", - type: "boolean", - showInSimplifiedHelpView: false, - category: Diagnostics.Command_line_Options, - description: Diagnostics.Whether_to_keep_outdated_console_output_in_watch_mode_instead_of_clearing_the_screen, - }, - { - name: "watch", - shortName: "w", - type: "boolean", - showInSimplifiedHelpView: true, - category: Diagnostics.Command_line_Options, - description: Diagnostics.Watch_input_files, - }, // Basic { @@ -754,6 +758,38 @@ namespace ts { } ]; + /* @internal */ + export const buildOpts: CommandLineOption[] = [ + ...commonOptionsWithBuild, + { + name: "verbose", + shortName: "v", + category: Diagnostics.Command_line_Options, + description: Diagnostics.Enable_verbose_logging, + type: "boolean" + }, + { + name: "dry", + shortName: "d", + category: Diagnostics.Command_line_Options, + description: Diagnostics.Show_what_would_be_built_or_deleted_if_specified_with_clean, + type: "boolean" + }, + { + name: "force", + shortName: "f", + category: Diagnostics.Command_line_Options, + description: Diagnostics.Build_all_projects_including_those_that_appear_to_be_up_to_date, + type: "boolean" + }, + { + name: "clean", + category: Diagnostics.Command_line_Options, + description: Diagnostics.Delete_the_outputs_of_all_projects, + type: "boolean" + } + ]; + /* @internal */ export const typeAcquisitionDeclarations: CommandLineOption[] = [ { @@ -997,6 +1033,58 @@ namespace ts { return optionNameMap.get(optionName); } + /*@internal*/ + export interface ParsedBuildCommand { + buildOptions: BuildOptions; + projects: string[]; + errors: ReadonlyArray; + } + + /*@internal*/ + export function parseBuildCommand(args: string[]): ParsedBuildCommand { + let buildOptionNameMap: OptionNameMap | undefined; + const returnBuildOptionNameMap = () => (buildOptionNameMap || (buildOptionNameMap = createOptionNameMap(buildOpts))); + + const buildOptions: BuildOptions = {}; + const projects: string[] = []; + let errors: Diagnostic[] | undefined; + for (const arg of args) { + if (arg.charCodeAt(0) === CharacterCodes.minus) { + const opt = getOptionDeclarationFromName(returnBuildOptionNameMap, arg.slice(arg.charCodeAt(1) === CharacterCodes.minus ? 2 : 1), /*allowShort*/ true); + if (opt) { + buildOptions[opt.name as keyof BuildOptions] = true; + } + else { + (errors || (errors = [])).push(createCompilerDiagnostic(Diagnostics.Unknown_build_option_0, arg)); + } + } + else { + // Not a flag, parse as filename + projects.push(arg); + } + } + + if (projects.length === 0) { + // tsc -b invoked with no extra arguments; act as if invoked with "tsc -b ." + projects.push("."); + } + + // Nonsensical combinations + if (buildOptions.clean && buildOptions.force) { + (errors || (errors = [])).push(createCompilerDiagnostic(Diagnostics.Options_0_and_1_cannot_be_combined, "clean", "force")); + } + if (buildOptions.clean && buildOptions.verbose) { + (errors || (errors = [])).push(createCompilerDiagnostic(Diagnostics.Options_0_and_1_cannot_be_combined, "clean", "verbose")); + } + if (buildOptions.clean && buildOptions.watch) { + (errors || (errors = [])).push(createCompilerDiagnostic(Diagnostics.Options_0_and_1_cannot_be_combined, "clean", "watch")); + } + if (buildOptions.watch && buildOptions.dry) { + (errors || (errors = [])).push(createCompilerDiagnostic(Diagnostics.Options_0_and_1_cannot_be_combined, "watch", "dry")); + } + + return { buildOptions, projects, errors: errors || emptyArray }; + } function getDiagnosticText(_message: DiagnosticMessage, ..._args: any[]): string { const diagnostic = createCompilerDiagnostic.apply(undefined, arguments); diff --git a/src/compiler/moduleSpecifiers.ts b/src/compiler/moduleSpecifiers.ts index b34471a107a..eda480d032c 100644 --- a/src/compiler/moduleSpecifiers.ts +++ b/src/compiler/moduleSpecifiers.ts @@ -75,10 +75,10 @@ namespace ts.moduleSpecifiers { const info = getInfo(importingSourceFileName, host); const modulePaths = getAllModulePaths(files, importingSourceFileName, toFileName, info.getCanonicalFileName, host, redirectTargetsMap); return firstDefined(modulePaths, moduleFileName => tryGetModuleNameAsNodeModule(moduleFileName, info, host, compilerOptions)) || - first(getLocalModuleSpecifiers(toFileName, info, compilerOptions, preferences)); + getLocalModuleSpecifier(toFileName, info, compilerOptions, preferences); } - // For each symlink/original for a module, returns a list of ways to import that file. + // Returns an import for each symlink and for the realpath. export function getModuleSpecifiers( moduleSymbol: Symbol, compilerOptions: CompilerOptions, @@ -87,9 +87,9 @@ namespace ts.moduleSpecifiers { files: ReadonlyArray, userPreferences: UserPreferences, redirectTargetsMap: RedirectTargetsMap, - ): ReadonlyArray> { + ): ReadonlyArray { const ambient = tryGetModuleNameFromAmbientModule(moduleSymbol); - if (ambient) return [[ambient]]; + if (ambient) return [ambient]; const info = getInfo(importingSourceFile.path, host); const moduleSourceFile = getSourceFileOfNode(moduleSymbol.valueDeclaration || getNonAugmentationDeclaration(moduleSymbol)); @@ -97,8 +97,7 @@ namespace ts.moduleSpecifiers { const preferences = getPreferences(userPreferences, compilerOptions, importingSourceFile); const global = mapDefined(modulePaths, moduleFileName => tryGetModuleNameAsNodeModule(moduleFileName, info, host, compilerOptions)); - return global.length ? global.map(g => [g]) : modulePaths.map(moduleFileName => - getLocalModuleSpecifiers(moduleFileName, info, compilerOptions, preferences)); + return global.length ? global : modulePaths.map(moduleFileName => getLocalModuleSpecifier(moduleFileName, info, compilerOptions, preferences)); } interface Info { @@ -112,68 +111,40 @@ namespace ts.moduleSpecifiers { return { getCanonicalFileName, sourceDirectory }; } - function getLocalModuleSpecifiers(moduleFileName: string, { getCanonicalFileName, sourceDirectory }: Info, compilerOptions: CompilerOptions, { ending, relativePreference }: Preferences): ReadonlyArray { + function getLocalModuleSpecifier(moduleFileName: string, { getCanonicalFileName, sourceDirectory }: Info, compilerOptions: CompilerOptions, { ending, relativePreference }: Preferences): string { const { baseUrl, paths, rootDirs } = compilerOptions; const relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName) || removeExtensionAndIndexPostFix(ensurePathIsNonModuleName(getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), ending, compilerOptions); if (!baseUrl || relativePreference === RelativePreference.Relative) { - return [relativePath]; + return relativePath; } const relativeToBaseUrl = getRelativePathIfInDirectory(moduleFileName, baseUrl, getCanonicalFileName); if (!relativeToBaseUrl) { - return [relativePath]; + return relativePath; } const importRelativeToBaseUrl = removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions); - if (paths) { - const fromPaths = tryGetModuleNameFromPaths(removeFileExtension(relativeToBaseUrl), importRelativeToBaseUrl, paths); - if (fromPaths) { - return [fromPaths]; - } - } + const fromPaths = paths && tryGetModuleNameFromPaths(removeFileExtension(relativeToBaseUrl), importRelativeToBaseUrl, paths); + const nonRelative = fromPaths === undefined ? importRelativeToBaseUrl : fromPaths; if (relativePreference === RelativePreference.NonRelative) { - return [importRelativeToBaseUrl]; + return nonRelative; } if (relativePreference !== RelativePreference.Auto) Debug.assertNever(relativePreference); - if (isPathRelativeToParent(relativeToBaseUrl)) { - return [relativePath]; + // Prefer a relative import over a baseUrl import if it has fewer components. + return isPathRelativeToParent(nonRelative) || countPathComponents(relativePath) < countPathComponents(nonRelative) ? relativePath : nonRelative; + } + + function countPathComponents(path: string): number { + let count = 0; + for (let i = startsWith(path, "./") ? 2 : 0; i < path.length; i++) { + if (path.charCodeAt(i) === CharacterCodes.slash) count++; } - - /* - Prefer a relative import over a baseUrl import if it doesn't traverse up to baseUrl. - - Suppose we have: - baseUrl = /base - sourceDirectory = /base/a/b - moduleFileName = /base/foo/bar - Then: - relativePath = ../../foo/bar - getRelativePathNParents(relativePath) = 2 - pathFromSourceToBaseUrl = ../../ - getRelativePathNParents(pathFromSourceToBaseUrl) = 2 - 2 < 2 = false - In this case we should prefer using the baseUrl path "/a/b" instead of the relative path "../../foo/bar". - - Suppose we have: - baseUrl = /base - sourceDirectory = /base/foo/a - moduleFileName = /base/foo/bar - Then: - relativePath = ../a - getRelativePathNParents(relativePath) = 1 - pathFromSourceToBaseUrl = ../../ - getRelativePathNParents(pathFromSourceToBaseUrl) = 2 - 1 < 2 = true - In this case we should prefer using the relative path "../a" instead of the baseUrl path "foo/a". - */ - const pathFromSourceToBaseUrl = ensurePathIsNonModuleName(getRelativePathFromDirectory(sourceDirectory, baseUrl, getCanonicalFileName)); - const relativeFirst = getRelativePathNParents(relativePath) < getRelativePathNParents(pathFromSourceToBaseUrl); - return relativeFirst ? [relativePath, importRelativeToBaseUrl] : [importRelativeToBaseUrl, relativePath]; + return count; } function usesJsExtensionOnImports({ imports }: SourceFile): boolean { @@ -245,15 +216,6 @@ namespace ts.moduleSpecifiers { return result; } - function getRelativePathNParents(relativePath: string): number { - const components = getPathComponents(relativePath); - if (components[0] || components.length === 1) return 0; - for (let i = 1; i < components.length; i++) { - if (components[i] !== "..") return i - 1; - } - return components.length - 1; - } - function tryGetModuleNameFromAmbientModule(moduleSymbol: Symbol): string | undefined { const decl = find(moduleSymbol.declarations, d => isNonGlobalAmbientModule(d) && (!isExternalModuleAugmentation(d) || !isExternalModuleNameRelative(getTextOfIdentifierOrLiteral(d.name))) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index e9eb953d22a..b40648033de 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -6856,7 +6856,7 @@ namespace ts { function parseTypedefTag(atToken: AtToken, tagName: Identifier, indent: number): JSDocTypedefTag { const typeExpression = tryParseTypeExpression(); - skipWhitespace(); + skipWhitespaceOrAsterisk(); const typedefTag = createNode(SyntaxKind.JSDocTypedefTag, atToken.pos); typedefTag.atToken = atToken; diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 56300a03f67..2bbf17e6098 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -1259,8 +1259,6 @@ namespace ts { } function getProjectReferences() { - if (!resolvedProjectReferences) return; - return resolvedProjectReferences; } diff --git a/src/compiler/tsbuild.ts b/src/compiler/tsbuild.ts index e52c743bb36..95beb65e28e 100644 --- a/src/compiler/tsbuild.ts +++ b/src/compiler/tsbuild.ts @@ -429,6 +429,7 @@ namespace ts { projectPendingBuild.removeKey(proj); if (!projectPendingBuild.getSize()) { invalidatedProjectQueue.length = 0; + nextIndex = 0; } return proj; } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 54e19154376..56bad9c86e3 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3441,8 +3441,8 @@ namespace ts { Enum = RegularEnum | ConstEnum, Variable = FunctionScopedVariable | BlockScopedVariable, - Value = Variable | Property | EnumMember | Function | Class | Enum | ValueModule | Method | GetAccessor | SetAccessor | JSContainer, - Type = Class | Interface | Enum | EnumMember | TypeLiteral | ObjectLiteral | TypeParameter | TypeAlias | JSContainer, + Value = Variable | Property | EnumMember | ObjectLiteral | Function | Class | Enum | ValueModule | Method | GetAccessor | SetAccessor | JSContainer, + Type = Class | Interface | Enum | EnumMember | TypeLiteral | TypeParameter | TypeAlias | JSContainer, Namespace = ValueModule | NamespaceModule | Enum, Module = ValueModule | NamespaceModule, Accessor = GetAccessor | SetAccessor, @@ -3463,7 +3463,7 @@ namespace ts { InterfaceExcludes = Type & ~(Interface | Class), RegularEnumExcludes = (Value | Type) & ~(RegularEnum | ValueModule), // regular enums merge only with regular enums and modules ConstEnumExcludes = (Value | Type) & ~ConstEnum, // const enums merge only with const enums - ValueModuleExcludes = Value & ~(Function | Class | RegularEnum | ValueModule), + ValueModuleExcludes = Value & ~(Function | Class | RegularEnum | ValueModule | JSContainer), NamespaceModuleExcludes = 0, MethodExcludes = Value & ~Method, GetAccessorExcludes = Value & ~SetAccessor, @@ -4175,9 +4175,8 @@ namespace ts { /* @internal */ export const enum InferenceFlags { None = 0, // No special inference behaviors - InferUnionTypes = 1 << 0, // Infer union types for disjoint candidates (otherwise unknownType) - NoDefault = 1 << 1, // Infer unknownType for no inferences (otherwise anyType or emptyObjectType) - AnyDefault = 1 << 2, // Infer anyType for no inferences (otherwise emptyObjectType) + NoDefault = 1 << 0, // Infer unknownType for no inferences (otherwise anyType or emptyObjectType) + AnyDefault = 1 << 1, // Infer anyType for no inferences (otherwise emptyObjectType) } /** diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 0e92bad7f55..da13fcb4391 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1762,6 +1762,10 @@ namespace ts { return decl; } + export function isAssignmentDeclaration(decl: Declaration) { + return isBinaryExpression(decl) || isPropertyAccessExpression(decl) || isIdentifier(decl); + } + /** Get the initializer, taking into account defaulted Javascript initializers */ export function getEffectiveInitializer(node: HasExpressionInitializer) { if (isInJavaScriptFile(node) && node.initializer && @@ -3743,7 +3747,7 @@ namespace ts { return false; } - export function isExpressionWithTypeArgumentsInClassExtendsClause(node: Node): boolean { + export function isExpressionWithTypeArgumentsInClassExtendsClause(node: Node): node is ExpressionWithTypeArguments { return tryGetClassExtendingExpressionWithTypeArguments(node) !== undefined; } diff --git a/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl index dc8079b6a53..cf26e2044e7 100644 --- a/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -588,7 +588,7 @@ - + diff --git a/src/services/codefixes/importFixes.ts b/src/services/codefixes/importFixes.ts index 7ff5d30c954..963d1cd64f2 100644 --- a/src/services/codefixes/importFixes.ts +++ b/src/services/codefixes/importFixes.ts @@ -283,14 +283,13 @@ namespace ts.codefix { preferences: UserPreferences, ): ReadonlyArray { const isJs = isSourceFileJavaScript(sourceFile); - const choicesForEachExportingModule = flatMap>(moduleSymbols, ({ moduleSymbol, importKind, exportedSymbolIsTypeOnly }) => { - const modulePathsGroups = moduleSpecifiers.getModuleSpecifiers(moduleSymbol, program.getCompilerOptions(), sourceFile, host, program.getSourceFiles(), preferences, program.redirectTargetsMap); - return modulePathsGroups.map(group => group.map((moduleSpecifier): FixAddNewImport | FixUseImportType => + const choicesForEachExportingModule = flatMap(moduleSymbols, ({ moduleSymbol, importKind, exportedSymbolIsTypeOnly }) => + moduleSpecifiers.getModuleSpecifiers(moduleSymbol, program.getCompilerOptions(), sourceFile, host, program.getSourceFiles(), preferences, program.redirectTargetsMap) + .map((moduleSpecifier): FixAddNewImport | FixUseImportType => // `position` should only be undefined at a missing jsx namespace, in which case we shouldn't be looking for pure types. exportedSymbolIsTypeOnly && isJs ? { kind: ImportFixKind.ImportType, moduleSpecifier, position: Debug.assertDefined(position) } : { kind: ImportFixKind.AddNew, moduleSpecifier, importKind })); - }); - // Sort to keep the shortest paths first, but keep [relativePath, importRelativeToBaseUrl] groups together - return flatten(choicesForEachExportingModule.sort((a, b) => first(a).moduleSpecifier.length - first(b).moduleSpecifier.length)); + // Sort to keep the shortest paths first + return choicesForEachExportingModule.sort((a, b) => a.moduleSpecifier.length - b.moduleSpecifier.length); } function getFixesForAddImport( diff --git a/src/services/completions.ts b/src/services/completions.ts index a82c4e02882..1e74ea3bbf1 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -264,6 +264,9 @@ namespace ts.Completions { } function quote(text: string, preferences: UserPreferences): string { + if (/^\d+$/.test(text)) { + return text; + } const quoted = JSON.stringify(text); switch (preferences.quotePreference) { case undefined: diff --git a/src/testRunner/unittests/commandLineParsing.ts b/src/testRunner/unittests/commandLineParsing.ts index 7145b9e5ec4..7ac9504f1f8 100644 --- a/src/testRunner/unittests/commandLineParsing.ts +++ b/src/testRunner/unittests/commandLineParsing.ts @@ -366,4 +366,120 @@ namespace ts { }); }); }); + + describe("parseBuildOptions", () => { + function assertParseResult(commandLine: string[], expectedParsedBuildCommand: ParsedBuildCommand) { + const parsed = parseBuildCommand(commandLine); + const parsedBuildOptions = JSON.stringify(parsed.buildOptions); + const expectedBuildOptions = JSON.stringify(expectedParsedBuildCommand.buildOptions); + assert.equal(parsedBuildOptions, expectedBuildOptions); + + const parsedErrors = parsed.errors; + const expectedErrors = expectedParsedBuildCommand.errors; + assert.isTrue(parsedErrors.length === expectedErrors.length, `Expected error: ${JSON.stringify(expectedErrors)}. Actual error: ${JSON.stringify(parsedErrors)}.`); + for (let i = 0; i < parsedErrors.length; i++) { + const parsedError = parsedErrors[i]; + const expectedError = expectedErrors[i]; + assert.equal(parsedError.code, expectedError.code); + assert.equal(parsedError.category, expectedError.category); + assert.equal(parsedError.messageText, expectedError.messageText); + } + + const parsedProjects = parsed.projects; + const expectedProjects = expectedParsedBuildCommand.projects; + assert.deepEqual(parsedProjects, expectedProjects, `Expected projects: [${JSON.stringify(expectedProjects)}]. Actual projects: [${JSON.stringify(parsedProjects)}].`); + } + it("parse build without any options ", () => { + // --lib es6 0.ts + assertParseResult([], + { + errors: [], + projects: ["."], + buildOptions: {} + }); + }); + + it("Parse multiple options", () => { + // --lib es5,es2015.symbol.wellknown 0.ts + assertParseResult(["--verbose", "--force", "tests"], + { + errors: [], + projects: ["tests"], + buildOptions: { verbose: true, force: true } + }); + }); + + it("Parse option with invalid option ", () => { + // --lib es5,invalidOption 0.ts + assertParseResult(["--verbose", "--invalidOption"], + { + errors: [{ + messageText: "Unknown build option '--invalidOption'.", + category: Diagnostics.Unknown_build_option_0.category, + code: Diagnostics.Unknown_build_option_0.code, + file: undefined, + start: undefined, + length: undefined, + }], + projects: ["."], + buildOptions: { verbose: true } + }); + }); + + it("Parse multiple flags with input projects at the end", () => { + // --lib es5,es2015.symbol.wellknown --target es5 0.ts + assertParseResult(["--force", "--verbose", "src", "tests"], + { + errors: [], + projects: ["src", "tests"], + buildOptions: { force: true, verbose: true } + }); + }); + + it("Parse multiple flags with input projects in the middle", () => { + // --module commonjs --target es5 0.ts --lib es5,es2015.symbol.wellknown + assertParseResult(["--force", "src", "tests", "--verbose"], + { + errors: [], + projects: ["src", "tests"], + buildOptions: { force: true, verbose: true } + }); + }); + + it("Parse multiple flags with input projects in the beginning", () => { + // --module commonjs --target es5 0.ts --lib es5,es2015.symbol.wellknown + assertParseResult(["src", "tests", "--force", "--verbose"], + { + errors: [], + projects: ["src", "tests"], + buildOptions: { force: true, verbose: true } + }); + }); + + describe("Combining options that make no sense together", () => { + function verifyInvalidCombination(flag1: keyof BuildOptions, flag2: keyof BuildOptions) { + it(`--${flag1} and --${flag2} together is invalid`, () => { + // --module commonjs --target es5 0.ts --lib es5,es2015.symbol.wellknown + assertParseResult([`--${flag1}`, `--${flag2}`], + { + errors: [{ + messageText: `Options '${flag1}' and '${flag2}' cannot be combined.`, + category: Diagnostics.Options_0_and_1_cannot_be_combined.category, + code: Diagnostics.Options_0_and_1_cannot_be_combined.code, + file: undefined, + start: undefined, + length: undefined, + }], + projects: ["."], + buildOptions: { [flag1]: true, [flag2]: true } + }); + }); + } + + verifyInvalidCombination("clean", "force"); + verifyInvalidCombination("clean", "verbose"); + verifyInvalidCombination("clean", "watch"); + verifyInvalidCombination("watch", "dry"); + }); + }); } diff --git a/src/testRunner/unittests/tsbuildWatchMode.ts b/src/testRunner/unittests/tsbuildWatchMode.ts index d1405fa9e2c..b7884350061 100644 --- a/src/testRunner/unittests/tsbuildWatchMode.ts +++ b/src/testRunner/unittests/tsbuildWatchMode.ts @@ -98,34 +98,42 @@ namespace ts.tscWatch { for (const stamp of outputFileStamps) { assert.isDefined(stamp[1], `${stamp[0]} expected to be present`); } - return { host, outputFileStamps }; + return host; } it("creates solution in watch mode", () => { createSolutionInWatchMode(); }); it("change builds changes and reports found errors message", () => { - const { host, outputFileStamps } = createSolutionInWatchMode(); - host.writeFile(core[1].path, `${core[1].content} + const host = createSolutionInWatchMode(); + verifyChange(`${core[1].content} export class someClass { }`); - host.checkTimeoutQueueLengthAndRun(1); // Builds core - const changedCore = getOutputFileStamps(host); - verifyChangedFiles(changedCore, outputFileStamps, [ - ...getOutputFileNames(SubProject.core, "anotherModule"), // This should not be written really - ...getOutputFileNames(SubProject.core, "index") - ]); - host.checkTimeoutQueueLengthAndRun(1); // Builds tests - const changedTests = getOutputFileStamps(host); - verifyChangedFiles(changedTests, changedCore, [ - ...getOutputFileNames(SubProject.tests, "index") // Again these need not be written - ]); - host.checkTimeoutQueueLengthAndRun(1); // Builds logic - const changedLogic = getOutputFileStamps(host); - verifyChangedFiles(changedLogic, changedTests, [ - ...getOutputFileNames(SubProject.logic, "index") // Again these need not be written - ]); - host.checkTimeoutQueueLength(0); - checkOutputErrorsIncremental(host, emptyArray); + + // Another change requeues and builds it + verifyChange(core[1].content); + + function verifyChange(coreContent: string) { + const outputFileStamps = getOutputFileStamps(host); + host.writeFile(core[1].path, coreContent); + host.checkTimeoutQueueLengthAndRun(1); // Builds core + const changedCore = getOutputFileStamps(host); + verifyChangedFiles(changedCore, outputFileStamps, [ + ...getOutputFileNames(SubProject.core, "anotherModule"), // This should not be written really + ...getOutputFileNames(SubProject.core, "index") + ]); + host.checkTimeoutQueueLengthAndRun(1); // Builds tests + const changedTests = getOutputFileStamps(host); + verifyChangedFiles(changedTests, changedCore, [ + ...getOutputFileNames(SubProject.tests, "index") // Again these need not be written + ]); + host.checkTimeoutQueueLengthAndRun(1); // Builds logic + const changedLogic = getOutputFileStamps(host); + verifyChangedFiles(changedLogic, changedTests, [ + ...getOutputFileNames(SubProject.logic, "index") // Again these need not be written + ]); + host.checkTimeoutQueueLength(0); + checkOutputErrorsIncremental(host, emptyArray); + } }); // TODO: write tests reporting errors but that will have more involved work since file diff --git a/src/tsc/tsc.ts b/src/tsc/tsc.ts index 1685dfc3449..d3966071265 100644 --- a/src/tsc/tsc.ts +++ b/src/tsc/tsc.ts @@ -165,79 +165,10 @@ namespace ts { } function performBuild(args: string[]): number | undefined { - const buildOpts: CommandLineOption[] = [ - { - name: "help", - shortName: "h", - type: "boolean", - showInSimplifiedHelpView: true, - category: Diagnostics.Command_line_Options, - description: Diagnostics.Print_this_message, - }, - { - name: "help", - shortName: "?", - type: "boolean" - }, - { - name: "verbose", - shortName: "v", - category: Diagnostics.Command_line_Options, - description: Diagnostics.Enable_verbose_logging, - type: "boolean" - }, - { - name: "dry", - shortName: "d", - category: Diagnostics.Command_line_Options, - description: Diagnostics.Show_what_would_be_built_or_deleted_if_specified_with_clean, - type: "boolean" - }, - { - name: "force", - shortName: "f", - category: Diagnostics.Command_line_Options, - description: Diagnostics.Build_all_projects_including_those_that_appear_to_be_up_to_date, - type: "boolean" - }, - { - name: "clean", - category: Diagnostics.Command_line_Options, - description: Diagnostics.Delete_the_outputs_of_all_projects, - type: "boolean" - }, - { - name: "watch", - category: Diagnostics.Command_line_Options, - description: Diagnostics.Watch_input_files, - type: "boolean" - }, - { - name: "preserveWatchOutput", - type: "boolean", - category: Diagnostics.Command_line_Options, - description: Diagnostics.Whether_to_keep_outdated_console_output_in_watch_mode_instead_of_clearing_the_screen, - }, - ]; - let buildOptionNameMap: OptionNameMap | undefined; - const returnBuildOptionNameMap = () => (buildOptionNameMap || (buildOptionNameMap = createOptionNameMap(buildOpts))); - - const buildOptions: BuildOptions = {}; - const projects: string[] = []; - for (const arg of args) { - if (arg.charCodeAt(0) === CharacterCodes.minus) { - const opt = getOptionDeclarationFromName(returnBuildOptionNameMap, arg.slice(arg.charCodeAt(1) === CharacterCodes.minus ? 2 : 1), /*allowShort*/ true); - if (opt) { - buildOptions[opt.name as keyof BuildOptions] = true; - } - else { - reportDiagnostic(createCompilerDiagnostic(Diagnostics.Unknown_build_option_0, arg)); - } - } - else { - // Not a flag, parse as filename - addProject(arg); - } + const { buildOptions, projects: buildProjects, errors } = parseBuildCommand(args); + if (errors.length > 0) { + errors.forEach(reportDiagnostic); + return ExitStatus.DiagnosticsPresent_OutputsSkipped; } if (buildOptions.help) { @@ -248,6 +179,21 @@ namespace ts { // Update to pretty if host supports it updateReportDiagnostic(); + const projects = mapDefined(buildProjects, project => { + const fileName = resolvePath(sys.getCurrentDirectory(), project); + const refPath = resolveProjectReferencePath(sys, { path: fileName }); + if (!sys.fileExists(refPath)) { + reportDiagnostic(createCompilerDiagnostic(Diagnostics.File_0_does_not_exist, fileName)); + return undefined; + } + return refPath; + }); + + if (projects.length === 0) { + printVersion(); + printHelp(buildOpts, "--build "); + return ExitStatus.Success; + } if (!sys.getModifiedTime || !sys.setModifiedTime || (buildOptions.clean && !sys.deleteFile)) { reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--build")); @@ -257,29 +203,6 @@ namespace ts { reportWatchModeWithoutSysSupport(); } - // Nonsensical combinations - if (buildOptions.clean && buildOptions.force) { - reportDiagnostic(createCompilerDiagnostic(Diagnostics.Options_0_and_1_cannot_be_combined, "clean", "force")); - return ExitStatus.DiagnosticsPresent_OutputsSkipped; - } - if (buildOptions.clean && buildOptions.verbose) { - reportDiagnostic(createCompilerDiagnostic(Diagnostics.Options_0_and_1_cannot_be_combined, "clean", "verbose")); - return ExitStatus.DiagnosticsPresent_OutputsSkipped; - } - if (buildOptions.clean && buildOptions.watch) { - reportDiagnostic(createCompilerDiagnostic(Diagnostics.Options_0_and_1_cannot_be_combined, "clean", "watch")); - return ExitStatus.DiagnosticsPresent_OutputsSkipped; - } - if (buildOptions.watch && buildOptions.dry) { - reportDiagnostic(createCompilerDiagnostic(Diagnostics.Options_0_and_1_cannot_be_combined, "watch", "dry")); - return ExitStatus.DiagnosticsPresent_OutputsSkipped; - } - - if (projects.length === 0) { - // tsc -b invoked with no extra arguments; act as if invoked with "tsc -b ." - addProject("."); - } - // TODO: change this to host if watch => watchHost otherwiue without wathc const builder = createSolutionBuilder(createSolutionBuilderWithWatchHost(sys, reportDiagnostic, createBuilderStatusReporter(sys, shouldBePretty()), createWatchStatusReporter()), projects, buildOptions); if (buildOptions.clean) { @@ -293,15 +216,6 @@ namespace ts { } return builder.buildAllProjects(); - - function addProject(projectSpecification: string) { - const fileName = resolvePath(sys.getCurrentDirectory(), projectSpecification); - const refPath = resolveProjectReferencePath(sys, { path: fileName }); - if (!sys.fileExists(refPath)) { - return reportDiagnostic(createCompilerDiagnostic(Diagnostics.File_0_does_not_exist, fileName)); - } - projects.push(refPath); - } } function performCompilation(rootNames: string[], projectReferences: ReadonlyArray | undefined, options: CompilerOptions, configFileParsingDiagnostics?: ReadonlyArray) { diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 911fd328f3b..fd291c5387f 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -2060,28 +2060,28 @@ declare namespace ts { ModuleExports = 134217728, Enum = 384, Variable = 3, - Value = 67216319, - Type = 67901928, + Value = 67220415, + Type = 67897832, Namespace = 1920, Module = 1536, Accessor = 98304, - FunctionScopedVariableExcludes = 67216318, - BlockScopedVariableExcludes = 67216319, - ParameterExcludes = 67216319, + FunctionScopedVariableExcludes = 67220414, + BlockScopedVariableExcludes = 67220415, + ParameterExcludes = 67220415, PropertyExcludes = 0, EnumMemberExcludes = 68008959, - FunctionExcludes = 67215791, + FunctionExcludes = 67219887, ClassExcludes = 68008383, - InterfaceExcludes = 67901832, + InterfaceExcludes = 67897736, RegularEnumExcludes = 68008191, ConstEnumExcludes = 68008831, - ValueModuleExcludes = 67215503, + ValueModuleExcludes = 110735, NamespaceModuleExcludes = 0, - MethodExcludes = 67208127, - GetAccessorExcludes = 67150783, - SetAccessorExcludes = 67183551, - TypeParameterExcludes = 67639784, - TypeAliasExcludes = 67901928, + MethodExcludes = 67212223, + GetAccessorExcludes = 67154879, + SetAccessorExcludes = 67187647, + TypeParameterExcludes = 67635688, + TypeAliasExcludes = 67897832, AliasExcludes = 2097152, ModuleMember = 2623475, ExportHasLocal = 944, diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index c12d797bea8..852ca173b33 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -2060,28 +2060,28 @@ declare namespace ts { ModuleExports = 134217728, Enum = 384, Variable = 3, - Value = 67216319, - Type = 67901928, + Value = 67220415, + Type = 67897832, Namespace = 1920, Module = 1536, Accessor = 98304, - FunctionScopedVariableExcludes = 67216318, - BlockScopedVariableExcludes = 67216319, - ParameterExcludes = 67216319, + FunctionScopedVariableExcludes = 67220414, + BlockScopedVariableExcludes = 67220415, + ParameterExcludes = 67220415, PropertyExcludes = 0, EnumMemberExcludes = 68008959, - FunctionExcludes = 67215791, + FunctionExcludes = 67219887, ClassExcludes = 68008383, - InterfaceExcludes = 67901832, + InterfaceExcludes = 67897736, RegularEnumExcludes = 68008191, ConstEnumExcludes = 68008831, - ValueModuleExcludes = 67215503, + ValueModuleExcludes = 110735, NamespaceModuleExcludes = 0, - MethodExcludes = 67208127, - GetAccessorExcludes = 67150783, - SetAccessorExcludes = 67183551, - TypeParameterExcludes = 67639784, - TypeAliasExcludes = 67901928, + MethodExcludes = 67212223, + GetAccessorExcludes = 67154879, + SetAccessorExcludes = 67187647, + TypeParameterExcludes = 67635688, + TypeAliasExcludes = 67897832, AliasExcludes = 2097152, ModuleMember = 2623475, ExportHasLocal = 944, diff --git a/tests/baselines/reference/assignmentCompatFunctionsWithOptionalArgs.errors.txt b/tests/baselines/reference/assignmentCompatFunctionsWithOptionalArgs.errors.txt index 2316320f480..6686167cf1e 100644 --- a/tests/baselines/reference/assignmentCompatFunctionsWithOptionalArgs.errors.txt +++ b/tests/baselines/reference/assignmentCompatFunctionsWithOptionalArgs.errors.txt @@ -1,7 +1,5 @@ tests/cases/compiler/assignmentCompatFunctionsWithOptionalArgs.ts(1,10): error TS2391: Function implementation is missing or not immediately following the declaration. -tests/cases/compiler/assignmentCompatFunctionsWithOptionalArgs.ts(4,5): error TS2345: Argument of type '{ id: number; name: boolean; }' is not assignable to parameter of type '{ id: number; name?: string; }'. - Types of property 'name' are incompatible. - Type 'boolean' is not assignable to type 'string'. +tests/cases/compiler/assignmentCompatFunctionsWithOptionalArgs.ts(4,17): error TS2322: Type 'false' is not assignable to type 'string'. tests/cases/compiler/assignmentCompatFunctionsWithOptionalArgs.ts(5,5): error TS2345: Argument of type '{ name: string; }' is not assignable to parameter of type '{ id: number; name?: string; }'. Property 'id' is missing in type '{ name: string; }'. @@ -13,10 +11,9 @@ tests/cases/compiler/assignmentCompatFunctionsWithOptionalArgs.ts(5,5): error TS foo({ id: 1234 }); // Ok foo({ id: 1234, name: "hello" }); // Ok foo({ id: 1234, name: false }); // Error, name of wrong type - ~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ id: number; name: boolean; }' is not assignable to parameter of type '{ id: number; name?: string; }'. -!!! error TS2345: Types of property 'name' are incompatible. -!!! error TS2345: Type 'boolean' is not assignable to type 'string'. + ~~~~ +!!! error TS2322: Type 'false' is not assignable to type 'string'. +!!! related TS6500 tests/cases/compiler/assignmentCompatFunctionsWithOptionalArgs.ts:1:31: The expected type comes from property 'name' which is declared here on type '{ id: number; name?: string; }' foo({ name: "hello" }); // Error, id required but missing ~~~~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '{ name: string; }' is not assignable to parameter of type '{ id: number; name?: string; }'. diff --git a/tests/baselines/reference/assignmentCompatWithCallSignatures3.errors.txt b/tests/baselines/reference/assignmentCompatWithCallSignatures3.errors.txt index 28fe7c738a6..441810033d2 100644 --- a/tests/baselines/reference/assignmentCompatWithCallSignatures3.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithCallSignatures3.errors.txt @@ -45,6 +45,11 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme Property 'baz' is missing in type 'Base'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures3.ts(83,1): error TS2322: Type '(x: Base[], y: Derived[]) => Derived[]' is not assignable to type '(x: Base[], y: T) => T'. Type 'Derived[]' is not assignable to type 'T'. +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures3.ts(85,1): error TS2322: Type '(x: { a: T; b: T; }) => T' is not assignable to type '(x: { a: string; b: number; }) => Object'. + Types of parameters 'x' and 'x' are incompatible. + Type '{ a: string; b: number; }' is not assignable to type '{ a: string; b: string; }'. + Types of property 'b' are incompatible. + Type 'number' is not assignable to type 'string'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures3.ts(86,1): error TS2322: Type '(x: { a: string; b: number; }) => Object' is not assignable to type '(x: { a: T; b: T; }) => T'. Types of parameters 'x' and 'x' are incompatible. Type '{ a: T; b: T; }' is not assignable to type '{ a: string; b: number; }'. @@ -52,7 +57,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme Type 'T' is not assignable to type 'string'. -==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures3.ts (14 errors) ==== +==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures3.ts (15 errors) ==== // these are all permitted with the current rules, since we do not do contextual signature instantiation class Base { foo: string; } @@ -198,6 +203,12 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type 'Derived[]' is not assignable to type 'T'. var b14: (x: { a: T; b: T }) => T; a14 = b14; // ok + ~~~ +!!! error TS2322: Type '(x: { a: T; b: T; }) => T' is not assignable to type '(x: { a: string; b: number; }) => Object'. +!!! error TS2322: Types of parameters 'x' and 'x' are incompatible. +!!! error TS2322: Type '{ a: string; b: number; }' is not assignable to type '{ a: string; b: string; }'. +!!! error TS2322: Types of property 'b' are incompatible. +!!! error TS2322: Type 'number' is not assignable to type 'string'. b14 = a14; // ok ~~~ !!! error TS2322: Type '(x: { a: string; b: number; }) => Object' is not assignable to type '(x: { a: T; b: T; }) => T'. diff --git a/tests/baselines/reference/assignmentCompatWithCallSignatures4.errors.txt b/tests/baselines/reference/assignmentCompatWithCallSignatures4.errors.txt index 39d3a2a3593..0a2ae478989 100644 --- a/tests/baselines/reference/assignmentCompatWithCallSignatures4.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithCallSignatures4.errors.txt @@ -22,8 +22,10 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures4.ts(66,9): error TS2322: Type '(x: Base[], y: Derived2[]) => Derived[]' is not assignable to type '(x: Base[], y: Base[]) => T'. Type 'Derived[]' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures4.ts(69,9): error TS2322: Type '(x: { a: T; b: T; }) => T' is not assignable to type '(x: { a: string; b: number; }) => number'. - Type 'string | number' is not assignable to type 'number'. - Type 'string' is not assignable to type 'number'. + Types of parameters 'x' and 'x' are incompatible. + Type '{ a: string; b: number; }' is not assignable to type '{ a: string; b: string; }'. + Types of property 'b' are incompatible. + Type 'number' is not assignable to type 'string'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures4.ts(70,9): error TS2322: Type '(x: { a: string; b: number; }) => number' is not assignable to type '(x: { a: T; b: T; }) => T'. Types of parameters 'x' and 'x' are incompatible. Type '{ a: T; b: T; }' is not assignable to type '{ a: string; b: number; }'. @@ -156,8 +158,10 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme a15 = b15; ~~~ !!! error TS2322: Type '(x: { a: T; b: T; }) => T' is not assignable to type '(x: { a: string; b: number; }) => number'. -!!! error TS2322: Type 'string | number' is not assignable to type 'number'. -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: Types of parameters 'x' and 'x' are incompatible. +!!! error TS2322: Type '{ a: string; b: number; }' is not assignable to type '{ a: string; b: string; }'. +!!! error TS2322: Types of property 'b' are incompatible. +!!! error TS2322: Type 'number' is not assignable to type 'string'. b15 = a15; ~~~ !!! error TS2322: Type '(x: { a: string; b: number; }) => number' is not assignable to type '(x: { a: T; b: T; }) => T'. diff --git a/tests/baselines/reference/assignmentCompatWithCallSignatures5.errors.txt b/tests/baselines/reference/assignmentCompatWithCallSignatures5.errors.txt index ba8f5304aa2..57944ae9863 100644 --- a/tests/baselines/reference/assignmentCompatWithCallSignatures5.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithCallSignatures5.errors.txt @@ -1,9 +1,15 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures5.ts(40,1): error TS2322: Type '(x: T) => void' is not assignable to type '(x: T) => T'. Type 'void' is not assignable to type 'T'. +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures5.ts(52,1): error TS2322: Type '(x: { foo: T; }, y: { foo: T; bar: T; }) => Base' is not assignable to type '(x: { foo: T; }, y: { foo: U; bar: U; }) => Base'. + Types of parameters 'y' and 'y' are incompatible. + Type '{ foo: U; bar: U; }' is not assignable to type '{ foo: T; bar: T; }'. + Types of property 'foo' are incompatible. + Type 'U' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures5.ts(55,1): error TS2322: Type '(x: { a: T; b: T; }) => T[]' is not assignable to type '(x: { a: U; b: V; }) => U[]'. - Type '(U | V)[]' is not assignable to type 'U[]'. - Type 'U | V' is not assignable to type 'U'. - Type 'V' is not assignable to type 'U'. + Types of parameters 'x' and 'x' are incompatible. + Type '{ a: U; b: V; }' is not assignable to type '{ a: U; b: U; }'. + Types of property 'b' are incompatible. + Type 'V' is not assignable to type 'U'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures5.ts(58,1): error TS2322: Type '(x: { a: T; b: T; }) => T[]' is not assignable to type '(x: { a: U; b: V; }) => U[]'. Types of parameters 'x' and 'x' are incompatible. Type '{ a: U; b: V; }' is not assignable to type '{ a: Base; b: Base; }'. @@ -11,7 +17,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme Type 'U' is not assignable to type 'Base'. -==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures5.ts (3 errors) ==== +==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures5.ts (4 errors) ==== // checking assignment compat for function types. No errors in this file class Base { foo: string; } @@ -67,14 +73,21 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme var b11: (x: { foo: T }, y: { foo: U; bar: U }) => Base; a11 = b11; // ok b11 = a11; // ok + ~~~ +!!! error TS2322: Type '(x: { foo: T; }, y: { foo: T; bar: T; }) => Base' is not assignable to type '(x: { foo: T; }, y: { foo: U; bar: U; }) => Base'. +!!! error TS2322: Types of parameters 'y' and 'y' are incompatible. +!!! error TS2322: Type '{ foo: U; bar: U; }' is not assignable to type '{ foo: T; bar: T; }'. +!!! error TS2322: Types of property 'foo' are incompatible. +!!! error TS2322: Type 'U' is not assignable to type 'T'. var b15: (x: { a: U; b: V; }) => U[]; a15 = b15; // ok, T = U, T = V b15 = a15; // ok ~~~ !!! error TS2322: Type '(x: { a: T; b: T; }) => T[]' is not assignable to type '(x: { a: U; b: V; }) => U[]'. -!!! error TS2322: Type '(U | V)[]' is not assignable to type 'U[]'. -!!! error TS2322: Type 'U | V' is not assignable to type 'U'. -!!! error TS2322: Type 'V' is not assignable to type 'U'. +!!! error TS2322: Types of parameters 'x' and 'x' are incompatible. +!!! error TS2322: Type '{ a: U; b: V; }' is not assignable to type '{ a: U; b: U; }'. +!!! error TS2322: Types of property 'b' are incompatible. +!!! error TS2322: Type 'V' is not assignable to type 'U'. var b16: (x: { a: T; b: T }) => T[]; a15 = b16; // ok b15 = a16; // ok diff --git a/tests/baselines/reference/assignmentCompatWithCallSignatures6.errors.txt b/tests/baselines/reference/assignmentCompatWithCallSignatures6.errors.txt index b8399a1855b..e3d7fda7ba3 100644 --- a/tests/baselines/reference/assignmentCompatWithCallSignatures6.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithCallSignatures6.errors.txt @@ -1,5 +1,10 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures6.ts(30,1): error TS2322: Type '(x: T) => void' is not assignable to type '(x: T) => T'. Type 'void' is not assignable to type 'T'. +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures6.ts(39,1): error TS2322: Type '(x: { foo: T; }, y: { foo: T; bar: T; }) => Base' is not assignable to type '(x: { foo: T; }, y: { foo: U; bar: U; }) => Base'. + Types of parameters 'y' and 'y' are incompatible. + Type '{ foo: U; bar: U; }' is not assignable to type '{ foo: T; bar: T; }'. + Types of property 'foo' are incompatible. + Type 'U' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures6.ts(42,1): error TS2322: Type '(x: { a: T; b: T; }) => T[]' is not assignable to type '(x: { a: T; b: T; }) => T[]'. Types of parameters 'x' and 'x' are incompatible. Type '{ a: T; b: T; }' is not assignable to type '{ a: Base; b: Base; }'. @@ -7,7 +12,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme Type 'T' is not assignable to type 'Base'. -==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures6.ts (2 errors) ==== +==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures6.ts (3 errors) ==== // checking assignment compatibility relations for function types. All valid class Base { foo: string; } @@ -50,6 +55,12 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme var b11: (x: { foo: T }, y: { foo: U; bar: U }) => Base; x.a11 = b11; b11 = x.a11; + ~~~ +!!! error TS2322: Type '(x: { foo: T; }, y: { foo: T; bar: T; }) => Base' is not assignable to type '(x: { foo: T; }, y: { foo: U; bar: U; }) => Base'. +!!! error TS2322: Types of parameters 'y' and 'y' are incompatible. +!!! error TS2322: Type '{ foo: U; bar: U; }' is not assignable to type '{ foo: T; bar: T; }'. +!!! error TS2322: Types of property 'foo' are incompatible. +!!! error TS2322: Type 'U' is not assignable to type 'T'. var b16: (x: { a: T; b: T }) => T[]; x.a16 = b16; b16 = x.a16; diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures3.errors.txt b/tests/baselines/reference/assignmentCompatWithConstructSignatures3.errors.txt index f9a5be732c9..3bce93635d0 100644 --- a/tests/baselines/reference/assignmentCompatWithConstructSignatures3.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithConstructSignatures3.errors.txt @@ -45,6 +45,11 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme Property 'baz' is missing in type 'Base'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures3.ts(83,1): error TS2322: Type 'new (x: Base[], y: Derived[]) => Derived[]' is not assignable to type 'new (x: Base[], y: T) => T'. Type 'Derived[]' is not assignable to type 'T'. +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures3.ts(85,1): error TS2322: Type 'new (x: { a: T; b: T; }) => T' is not assignable to type 'new (x: { a: string; b: number; }) => Object'. + Types of parameters 'x' and 'x' are incompatible. + Type '{ a: string; b: number; }' is not assignable to type '{ a: string; b: string; }'. + Types of property 'b' are incompatible. + Type 'number' is not assignable to type 'string'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures3.ts(86,1): error TS2322: Type 'new (x: { a: string; b: number; }) => Object' is not assignable to type 'new (x: { a: T; b: T; }) => T'. Types of parameters 'x' and 'x' are incompatible. Type '{ a: T; b: T; }' is not assignable to type '{ a: string; b: number; }'. @@ -52,7 +57,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme Type 'T' is not assignable to type 'string'. -==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures3.ts (14 errors) ==== +==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures3.ts (15 errors) ==== // checking assignment compatibility relations for function types. All of these are valid. class Base { foo: string; } @@ -198,6 +203,12 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type 'Derived[]' is not assignable to type 'T'. var b14: new (x: { a: T; b: T }) => T; a14 = b14; // ok + ~~~ +!!! error TS2322: Type 'new (x: { a: T; b: T; }) => T' is not assignable to type 'new (x: { a: string; b: number; }) => Object'. +!!! error TS2322: Types of parameters 'x' and 'x' are incompatible. +!!! error TS2322: Type '{ a: string; b: number; }' is not assignable to type '{ a: string; b: string; }'. +!!! error TS2322: Types of property 'b' are incompatible. +!!! error TS2322: Type 'number' is not assignable to type 'string'. b14 = a14; // ok ~~~ !!! error TS2322: Type 'new (x: { a: string; b: number; }) => Object' is not assignable to type 'new (x: { a: T; b: T; }) => T'. diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures4.errors.txt b/tests/baselines/reference/assignmentCompatWithConstructSignatures4.errors.txt index 8679b1d85f1..620e83e1603 100644 --- a/tests/baselines/reference/assignmentCompatWithConstructSignatures4.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithConstructSignatures4.errors.txt @@ -22,8 +22,10 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures4.ts(66,9): error TS2322: Type 'new (x: Base[], y: Derived2[]) => Derived[]' is not assignable to type 'new (x: Base[], y: Base[]) => T'. Type 'Derived[]' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures4.ts(69,9): error TS2322: Type 'new (x: { a: T; b: T; }) => T' is not assignable to type 'new (x: { a: string; b: number; }) => number'. - Type 'string | number' is not assignable to type 'number'. - Type 'string' is not assignable to type 'number'. + Types of parameters 'x' and 'x' are incompatible. + Type '{ a: string; b: number; }' is not assignable to type '{ a: string; b: string; }'. + Types of property 'b' are incompatible. + Type 'number' is not assignable to type 'string'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures4.ts(70,9): error TS2322: Type 'new (x: { a: string; b: number; }) => number' is not assignable to type 'new (x: { a: T; b: T; }) => T'. Types of parameters 'x' and 'x' are incompatible. Type '{ a: T; b: T; }' is not assignable to type '{ a: string; b: number; }'. @@ -172,8 +174,10 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme a15 = b15; // ok ~~~ !!! error TS2322: Type 'new (x: { a: T; b: T; }) => T' is not assignable to type 'new (x: { a: string; b: number; }) => number'. -!!! error TS2322: Type 'string | number' is not assignable to type 'number'. -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: Types of parameters 'x' and 'x' are incompatible. +!!! error TS2322: Type '{ a: string; b: number; }' is not assignable to type '{ a: string; b: string; }'. +!!! error TS2322: Types of property 'b' are incompatible. +!!! error TS2322: Type 'number' is not assignable to type 'string'. b15 = a15; // ok ~~~ !!! error TS2322: Type 'new (x: { a: string; b: number; }) => number' is not assignable to type 'new (x: { a: T; b: T; }) => T'. diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures5.errors.txt b/tests/baselines/reference/assignmentCompatWithConstructSignatures5.errors.txt index 23e0c682fdc..5445d9ee35a 100644 --- a/tests/baselines/reference/assignmentCompatWithConstructSignatures5.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithConstructSignatures5.errors.txt @@ -1,9 +1,15 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures5.ts(40,1): error TS2322: Type 'new (x: T) => void' is not assignable to type 'new (x: T) => T'. Type 'void' is not assignable to type 'T'. +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures5.ts(52,1): error TS2322: Type 'new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base' is not assignable to type 'new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base'. + Types of parameters 'y' and 'y' are incompatible. + Type '{ foo: U; bar: U; }' is not assignable to type '{ foo: T; bar: T; }'. + Types of property 'foo' are incompatible. + Type 'U' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures5.ts(55,1): error TS2322: Type 'new (x: { a: T; b: T; }) => T[]' is not assignable to type 'new (x: { a: U; b: V; }) => U[]'. - Type '(U | V)[]' is not assignable to type 'U[]'. - Type 'U | V' is not assignable to type 'U'. - Type 'V' is not assignable to type 'U'. + Types of parameters 'x' and 'x' are incompatible. + Type '{ a: U; b: V; }' is not assignable to type '{ a: U; b: U; }'. + Types of property 'b' are incompatible. + Type 'V' is not assignable to type 'U'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures5.ts(58,1): error TS2322: Type 'new (x: { a: T; b: T; }) => T[]' is not assignable to type 'new (x: { a: U; b: V; }) => U[]'. Types of parameters 'x' and 'x' are incompatible. Type '{ a: U; b: V; }' is not assignable to type '{ a: Base; b: Base; }'. @@ -11,7 +17,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme Type 'U' is not assignable to type 'Base'. -==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures5.ts (3 errors) ==== +==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures5.ts (4 errors) ==== // checking assignment compat for function types. All valid class Base { foo: string; } @@ -67,14 +73,21 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme var b11: new (x: { foo: T }, y: { foo: U; bar: U }) => Base; a11 = b11; // ok b11 = a11; // ok + ~~~ +!!! error TS2322: Type 'new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base' is not assignable to type 'new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base'. +!!! error TS2322: Types of parameters 'y' and 'y' are incompatible. +!!! error TS2322: Type '{ foo: U; bar: U; }' is not assignable to type '{ foo: T; bar: T; }'. +!!! error TS2322: Types of property 'foo' are incompatible. +!!! error TS2322: Type 'U' is not assignable to type 'T'. var b15: new (x: { a: U; b: V; }) => U[]; a15 = b15; // ok b15 = a15; // ok ~~~ !!! error TS2322: Type 'new (x: { a: T; b: T; }) => T[]' is not assignable to type 'new (x: { a: U; b: V; }) => U[]'. -!!! error TS2322: Type '(U | V)[]' is not assignable to type 'U[]'. -!!! error TS2322: Type 'U | V' is not assignable to type 'U'. -!!! error TS2322: Type 'V' is not assignable to type 'U'. +!!! error TS2322: Types of parameters 'x' and 'x' are incompatible. +!!! error TS2322: Type '{ a: U; b: V; }' is not assignable to type '{ a: U; b: U; }'. +!!! error TS2322: Types of property 'b' are incompatible. +!!! error TS2322: Type 'V' is not assignable to type 'U'. var b16: new (x: { a: T; b: T }) => T[]; a15 = b16; // ok b15 = a16; // ok diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures6.errors.txt b/tests/baselines/reference/assignmentCompatWithConstructSignatures6.errors.txt index f89db500202..399a56e4136 100644 --- a/tests/baselines/reference/assignmentCompatWithConstructSignatures6.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithConstructSignatures6.errors.txt @@ -1,5 +1,10 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures6.ts(30,1): error TS2322: Type 'new (x: T) => void' is not assignable to type 'new (x: T) => T'. Type 'void' is not assignable to type 'T'. +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures6.ts(39,1): error TS2322: Type 'new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base' is not assignable to type 'new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base'. + Types of parameters 'y' and 'y' are incompatible. + Type '{ foo: U; bar: U; }' is not assignable to type '{ foo: T; bar: T; }'. + Types of property 'foo' are incompatible. + Type 'U' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures6.ts(42,1): error TS2322: Type 'new (x: { a: T; b: T; }) => T[]' is not assignable to type 'new (x: { a: T; b: T; }) => T[]'. Types of parameters 'x' and 'x' are incompatible. Type '{ a: T; b: T; }' is not assignable to type '{ a: Base; b: Base; }'. @@ -7,7 +12,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme Type 'T' is not assignable to type 'Base'. -==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures6.ts (2 errors) ==== +==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures6.ts (3 errors) ==== // checking assignment compatibility relations for function types. All valid. class Base { foo: string; } @@ -50,6 +55,12 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme var b11: new (x: { foo: T }, y: { foo: U; bar: U }) => Base; x.a11 = b11; b11 = x.a11; + ~~~ +!!! error TS2322: Type 'new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base' is not assignable to type 'new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base'. +!!! error TS2322: Types of parameters 'y' and 'y' are incompatible. +!!! error TS2322: Type '{ foo: U; bar: U; }' is not assignable to type '{ foo: T; bar: T; }'. +!!! error TS2322: Types of property 'foo' are incompatible. +!!! error TS2322: Type 'U' is not assignable to type 'T'. var b16: new (x: { a: T; b: T }) => T[]; x.a16 = b16; b16 = x.a16; diff --git a/tests/baselines/reference/assignmentCompatWithGenericCallSignatures2.errors.txt b/tests/baselines/reference/assignmentCompatWithGenericCallSignatures2.errors.txt index 7e39c3305a3..38f03ca68c4 100644 --- a/tests/baselines/reference/assignmentCompatWithGenericCallSignatures2.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithGenericCallSignatures2.errors.txt @@ -1,9 +1,12 @@ +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignatures2.ts(15,1): error TS2322: Type 'B' is not assignable to type 'A'. + Types of parameters 'y' and 'y' are incompatible. + Type 'T[]' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignatures2.ts(16,1): error TS2322: Type 'A' is not assignable to type 'B'. Types of parameters 'y' and 'y' are incompatible. Type 'S' is not assignable to type 'S[]'. -==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignatures2.ts (1 errors) ==== +==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignatures2.ts (2 errors) ==== // some complex cases of assignment compat of generic signatures. No contextual signature instantiation interface A { @@ -17,8 +20,12 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme var a: A; var b: B; - // Both ok + // Both errors a = b; + ~ +!!! error TS2322: Type 'B' is not assignable to type 'A'. +!!! error TS2322: Types of parameters 'y' and 'y' are incompatible. +!!! error TS2322: Type 'T[]' is not assignable to type 'T'. b = a; ~ !!! error TS2322: Type 'A' is not assignable to type 'B'. diff --git a/tests/baselines/reference/assignmentCompatWithGenericCallSignatures2.js b/tests/baselines/reference/assignmentCompatWithGenericCallSignatures2.js index dd9b553791d..057cbebb382 100644 --- a/tests/baselines/reference/assignmentCompatWithGenericCallSignatures2.js +++ b/tests/baselines/reference/assignmentCompatWithGenericCallSignatures2.js @@ -12,7 +12,7 @@ interface B { var a: A; var b: B; -// Both ok +// Both errors a = b; b = a; @@ -21,6 +21,6 @@ b = a; // some complex cases of assignment compat of generic signatures. No contextual signature instantiation var a; var b; -// Both ok +// Both errors a = b; b = a; diff --git a/tests/baselines/reference/assignmentCompatWithGenericCallSignatures2.symbols b/tests/baselines/reference/assignmentCompatWithGenericCallSignatures2.symbols index 73991a789a2..9a37bebd6e2 100644 --- a/tests/baselines/reference/assignmentCompatWithGenericCallSignatures2.symbols +++ b/tests/baselines/reference/assignmentCompatWithGenericCallSignatures2.symbols @@ -31,7 +31,7 @@ var b: B; >b : Symbol(b, Decl(assignmentCompatWithGenericCallSignatures2.ts, 11, 3)) >B : Symbol(B, Decl(assignmentCompatWithGenericCallSignatures2.ts, 4, 1)) -// Both ok +// Both errors a = b; >a : Symbol(a, Decl(assignmentCompatWithGenericCallSignatures2.ts, 10, 3)) >b : Symbol(b, Decl(assignmentCompatWithGenericCallSignatures2.ts, 11, 3)) diff --git a/tests/baselines/reference/assignmentCompatWithGenericCallSignatures2.types b/tests/baselines/reference/assignmentCompatWithGenericCallSignatures2.types index 31b075d5bce..ab5bc2d49e8 100644 --- a/tests/baselines/reference/assignmentCompatWithGenericCallSignatures2.types +++ b/tests/baselines/reference/assignmentCompatWithGenericCallSignatures2.types @@ -19,7 +19,7 @@ var a: A; var b: B; >b : B -// Both ok +// Both errors a = b; >a = b : B >a : A diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance2.js b/tests/baselines/reference/callSignatureAssignabilityInInheritance2.js index 6913975d757..fe8f9330a5f 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance2.js +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance2.js @@ -62,7 +62,7 @@ interface I extends A { a11: (x: T, y: T) => T; // ok a12: >(x: Array, y: T) => Array; // ok, less specific parameter type a13: >(x: Array, y: T) => T; // ok, T = Array, satisfies constraint, contextual signature instantiation succeeds - a14: (x: { a: T; b: T }) => T; // ok, best common type yields T = {} but that's satisfactory for this signature + a14: (x: { a: T; b: U }) => T; // ok a15: (x: T) => T[]; // ok a16: (x: T) => number[]; // ok a17: (x: (a: T) => T) => T[]; // ok diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance2.symbols b/tests/baselines/reference/callSignatureAssignabilityInInheritance2.symbols index 849bcb1cf60..14e25b4e9d9 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance2.symbols +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance2.symbols @@ -354,18 +354,19 @@ interface I extends A { >T : Symbol(T, Decl(callSignatureAssignabilityInInheritance2.ts, 62, 10)) >T : Symbol(T, Decl(callSignatureAssignabilityInInheritance2.ts, 62, 10)) - a14: (x: { a: T; b: T }) => T; // ok, best common type yields T = {} but that's satisfactory for this signature + a14: (x: { a: T; b: U }) => T; // ok >a14 : Symbol(I.a14, Decl(callSignatureAssignabilityInInheritance2.ts, 62, 63)) >T : Symbol(T, Decl(callSignatureAssignabilityInInheritance2.ts, 63, 10)) ->x : Symbol(x, Decl(callSignatureAssignabilityInInheritance2.ts, 63, 13)) ->a : Symbol(a, Decl(callSignatureAssignabilityInInheritance2.ts, 63, 17)) ->T : Symbol(T, Decl(callSignatureAssignabilityInInheritance2.ts, 63, 10)) ->b : Symbol(b, Decl(callSignatureAssignabilityInInheritance2.ts, 63, 23)) +>U : Symbol(U, Decl(callSignatureAssignabilityInInheritance2.ts, 63, 12)) +>x : Symbol(x, Decl(callSignatureAssignabilityInInheritance2.ts, 63, 16)) +>a : Symbol(a, Decl(callSignatureAssignabilityInInheritance2.ts, 63, 20)) >T : Symbol(T, Decl(callSignatureAssignabilityInInheritance2.ts, 63, 10)) +>b : Symbol(b, Decl(callSignatureAssignabilityInInheritance2.ts, 63, 26)) +>U : Symbol(U, Decl(callSignatureAssignabilityInInheritance2.ts, 63, 12)) >T : Symbol(T, Decl(callSignatureAssignabilityInInheritance2.ts, 63, 10)) a15: (x: T) => T[]; // ok ->a15 : Symbol(I.a15, Decl(callSignatureAssignabilityInInheritance2.ts, 63, 37)) +>a15 : Symbol(I.a15, Decl(callSignatureAssignabilityInInheritance2.ts, 63, 40)) >T : Symbol(T, Decl(callSignatureAssignabilityInInheritance2.ts, 64, 10)) >x : Symbol(x, Decl(callSignatureAssignabilityInInheritance2.ts, 64, 13)) >T : Symbol(T, Decl(callSignatureAssignabilityInInheritance2.ts, 64, 10)) diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance2.types b/tests/baselines/reference/callSignatureAssignabilityInInheritance2.types index ab6daaf8b5b..065d0027ed3 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance2.types +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance2.types @@ -230,11 +230,11 @@ interface I extends A { >x : Base[] >y : T - a14: (x: { a: T; b: T }) => T; // ok, best common type yields T = {} but that's satisfactory for this signature ->a14 : (x: { a: T; b: T; }) => T ->x : { a: T; b: T; } + a14: (x: { a: T; b: U }) => T; // ok +>a14 : (x: { a: T; b: U; }) => T +>x : { a: T; b: U; } >a : T ->b : T +>b : U a15: (x: T) => T[]; // ok >a15 : (x: T) => T[] diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance3.errors.txt b/tests/baselines/reference/callSignatureAssignabilityInInheritance3.errors.txt index 5bf725b06e3..33af0d9f4bf 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance3.errors.txt +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance3.errors.txt @@ -14,8 +14,10 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSign tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance3.ts(76,19): error TS2430: Interface 'I6' incorrectly extends interface 'A'. Types of property 'a15' are incompatible. Type '(x: { a: T; b: T; }) => T' is not assignable to type '(x: { a: string; b: number; }) => number'. - Type 'string | number' is not assignable to type 'number'. - Type 'string' is not assignable to type 'number'. + Types of parameters 'x' and 'x' are incompatible. + Type '{ a: string; b: number; }' is not assignable to type '{ a: string; b: string; }'. + Types of property 'b' are incompatible. + Type 'number' is not assignable to type 'string'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance3.ts(80,19): error TS2430: Interface 'I7' incorrectly extends interface 'A'. Types of property 'a15' are incompatible. Type '(x: { a: T; b: T; }) => number' is not assignable to type '(x: { a: string; b: number; }) => number'. @@ -131,8 +133,10 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSign !!! error TS2430: Interface 'I6' incorrectly extends interface 'A'. !!! error TS2430: Types of property 'a15' are incompatible. !!! error TS2430: Type '(x: { a: T; b: T; }) => T' is not assignable to type '(x: { a: string; b: number; }) => number'. -!!! error TS2430: Type 'string | number' is not assignable to type 'number'. -!!! error TS2430: Type 'string' is not assignable to type 'number'. +!!! error TS2430: Types of parameters 'x' and 'x' are incompatible. +!!! error TS2430: Type '{ a: string; b: number; }' is not assignable to type '{ a: string; b: string; }'. +!!! error TS2430: Types of property 'b' are incompatible. +!!! error TS2430: Type 'number' is not assignable to type 'string'. a15: (x: { a: T; b: T }) => T; // error, T is {} which isn't an acceptable return type } diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance5.js b/tests/baselines/reference/callSignatureAssignabilityInInheritance5.js index c04d5bcb2ab..9d7dbc9eab6 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance5.js +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance5.js @@ -45,7 +45,7 @@ interface I extends B { a11: (x: T, y: T) => T; // ok a12: >(x: Array, y: T) => Array; // ok, less specific parameter type a13: >(x: Array, y: T) => T; // ok, T = Array, satisfies constraint, contextual signature instantiation succeeds - a14: (x: { a: T; b: T }) => T; // ok, best common type yields T = {} but that's satisfactory for this signature + a14: (x: { a: T; b: U }) => T; // ok } //// [callSignatureAssignabilityInInheritance5.js] diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance5.symbols b/tests/baselines/reference/callSignatureAssignabilityInInheritance5.symbols index 4a9030e443b..de3bdf742d0 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance5.symbols +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance5.symbols @@ -302,13 +302,14 @@ interface I extends B { >T : Symbol(T, Decl(callSignatureAssignabilityInInheritance5.ts, 45, 10)) >T : Symbol(T, Decl(callSignatureAssignabilityInInheritance5.ts, 45, 10)) - a14: (x: { a: T; b: T }) => T; // ok, best common type yields T = {} but that's satisfactory for this signature + a14: (x: { a: T; b: U }) => T; // ok >a14 : Symbol(I.a14, Decl(callSignatureAssignabilityInInheritance5.ts, 45, 63)) >T : Symbol(T, Decl(callSignatureAssignabilityInInheritance5.ts, 46, 10)) ->x : Symbol(x, Decl(callSignatureAssignabilityInInheritance5.ts, 46, 13)) ->a : Symbol(a, Decl(callSignatureAssignabilityInInheritance5.ts, 46, 17)) ->T : Symbol(T, Decl(callSignatureAssignabilityInInheritance5.ts, 46, 10)) ->b : Symbol(b, Decl(callSignatureAssignabilityInInheritance5.ts, 46, 23)) +>U : Symbol(U, Decl(callSignatureAssignabilityInInheritance5.ts, 46, 12)) +>x : Symbol(x, Decl(callSignatureAssignabilityInInheritance5.ts, 46, 16)) +>a : Symbol(a, Decl(callSignatureAssignabilityInInheritance5.ts, 46, 20)) >T : Symbol(T, Decl(callSignatureAssignabilityInInheritance5.ts, 46, 10)) +>b : Symbol(b, Decl(callSignatureAssignabilityInInheritance5.ts, 46, 26)) +>U : Symbol(U, Decl(callSignatureAssignabilityInInheritance5.ts, 46, 12)) >T : Symbol(T, Decl(callSignatureAssignabilityInInheritance5.ts, 46, 10)) } diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance5.types b/tests/baselines/reference/callSignatureAssignabilityInInheritance5.types index 2d133bc6d65..3f892ff0b17 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance5.types +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance5.types @@ -180,9 +180,9 @@ interface I extends B { >x : Base[] >y : T - a14: (x: { a: T; b: T }) => T; // ok, best common type yields T = {} but that's satisfactory for this signature ->a14 : (x: { a: T; b: T; }) => T ->x : { a: T; b: T; } + a14: (x: { a: T; b: U }) => T; // ok +>a14 : (x: { a: T; b: U; }) => T +>x : { a: T; b: U; } >a : T ->b : T +>b : U } diff --git a/tests/baselines/reference/constructSignatureAssignabilityInInheritance2.js b/tests/baselines/reference/constructSignatureAssignabilityInInheritance2.js index 0c4b5c62380..a85f64f95a1 100644 --- a/tests/baselines/reference/constructSignatureAssignabilityInInheritance2.js +++ b/tests/baselines/reference/constructSignatureAssignabilityInInheritance2.js @@ -62,7 +62,7 @@ interface I extends A { a11: new (x: T, y: T) => T; // ok a12: new >(x: Array, y: T) => Array; // ok, less specific parameter type a13: new >(x: Array, y: T) => T; // ok, T = Array, satisfies constraint, contextual signature instantiation succeeds - a14: new (x: { a: T; b: T }) => T; // ok, best common type yields T = {} but that's satisfactory for this signature + a14: new (x: { a: T; b: U }) => T; // ok a15: new (x: T) => T[]; // ok a16: new (x: T) => number[]; // ok a17: new (x: new (a: T) => T) => T[]; // ok diff --git a/tests/baselines/reference/constructSignatureAssignabilityInInheritance2.symbols b/tests/baselines/reference/constructSignatureAssignabilityInInheritance2.symbols index 1ad1c3707c5..2aaa5eda84f 100644 --- a/tests/baselines/reference/constructSignatureAssignabilityInInheritance2.symbols +++ b/tests/baselines/reference/constructSignatureAssignabilityInInheritance2.symbols @@ -354,18 +354,19 @@ interface I extends A { >T : Symbol(T, Decl(constructSignatureAssignabilityInInheritance2.ts, 62, 14)) >T : Symbol(T, Decl(constructSignatureAssignabilityInInheritance2.ts, 62, 14)) - a14: new (x: { a: T; b: T }) => T; // ok, best common type yields T = {} but that's satisfactory for this signature + a14: new (x: { a: T; b: U }) => T; // ok >a14 : Symbol(I.a14, Decl(constructSignatureAssignabilityInInheritance2.ts, 62, 67)) >T : Symbol(T, Decl(constructSignatureAssignabilityInInheritance2.ts, 63, 14)) ->x : Symbol(x, Decl(constructSignatureAssignabilityInInheritance2.ts, 63, 17)) ->a : Symbol(a, Decl(constructSignatureAssignabilityInInheritance2.ts, 63, 21)) ->T : Symbol(T, Decl(constructSignatureAssignabilityInInheritance2.ts, 63, 14)) ->b : Symbol(b, Decl(constructSignatureAssignabilityInInheritance2.ts, 63, 27)) +>U : Symbol(U, Decl(constructSignatureAssignabilityInInheritance2.ts, 63, 16)) +>x : Symbol(x, Decl(constructSignatureAssignabilityInInheritance2.ts, 63, 20)) +>a : Symbol(a, Decl(constructSignatureAssignabilityInInheritance2.ts, 63, 24)) >T : Symbol(T, Decl(constructSignatureAssignabilityInInheritance2.ts, 63, 14)) +>b : Symbol(b, Decl(constructSignatureAssignabilityInInheritance2.ts, 63, 30)) +>U : Symbol(U, Decl(constructSignatureAssignabilityInInheritance2.ts, 63, 16)) >T : Symbol(T, Decl(constructSignatureAssignabilityInInheritance2.ts, 63, 14)) a15: new (x: T) => T[]; // ok ->a15 : Symbol(I.a15, Decl(constructSignatureAssignabilityInInheritance2.ts, 63, 41)) +>a15 : Symbol(I.a15, Decl(constructSignatureAssignabilityInInheritance2.ts, 63, 44)) >T : Symbol(T, Decl(constructSignatureAssignabilityInInheritance2.ts, 64, 14)) >x : Symbol(x, Decl(constructSignatureAssignabilityInInheritance2.ts, 64, 17)) >T : Symbol(T, Decl(constructSignatureAssignabilityInInheritance2.ts, 64, 14)) diff --git a/tests/baselines/reference/constructSignatureAssignabilityInInheritance2.types b/tests/baselines/reference/constructSignatureAssignabilityInInheritance2.types index 01941d5219b..08a687d8867 100644 --- a/tests/baselines/reference/constructSignatureAssignabilityInInheritance2.types +++ b/tests/baselines/reference/constructSignatureAssignabilityInInheritance2.types @@ -230,11 +230,11 @@ interface I extends A { >x : Base[] >y : T - a14: new (x: { a: T; b: T }) => T; // ok, best common type yields T = {} but that's satisfactory for this signature ->a14 : new (x: { a: T; b: T; }) => T ->x : { a: T; b: T; } + a14: new (x: { a: T; b: U }) => T; // ok +>a14 : new (x: { a: T; b: U; }) => T +>x : { a: T; b: U; } >a : T ->b : T +>b : U a15: new (x: T) => T[]; // ok >a15 : new (x: T) => T[] diff --git a/tests/baselines/reference/constructSignatureAssignabilityInInheritance3.errors.txt b/tests/baselines/reference/constructSignatureAssignabilityInInheritance3.errors.txt index 9646acd071f..1a9edc159af 100644 --- a/tests/baselines/reference/constructSignatureAssignabilityInInheritance3.errors.txt +++ b/tests/baselines/reference/constructSignatureAssignabilityInInheritance3.errors.txt @@ -14,8 +14,10 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/construc tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance3.ts(66,19): error TS2430: Interface 'I6' incorrectly extends interface 'A'. Types of property 'a15' are incompatible. Type 'new (x: { a: T; b: T; }) => T' is not assignable to type 'new (x: { a: string; b: number; }) => number'. - Type 'string | number' is not assignable to type 'number'. - Type 'string' is not assignable to type 'number'. + Types of parameters 'x' and 'x' are incompatible. + Type '{ a: string; b: number; }' is not assignable to type '{ a: string; b: string; }'. + Types of property 'b' are incompatible. + Type 'number' is not assignable to type 'string'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance3.ts(70,19): error TS2430: Interface 'I7' incorrectly extends interface 'A'. Types of property 'a15' are incompatible. Type 'new (x: { a: T; b: T; }) => number' is not assignable to type 'new (x: { a: string; b: number; }) => number'. @@ -121,8 +123,10 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/construc !!! error TS2430: Interface 'I6' incorrectly extends interface 'A'. !!! error TS2430: Types of property 'a15' are incompatible. !!! error TS2430: Type 'new (x: { a: T; b: T; }) => T' is not assignable to type 'new (x: { a: string; b: number; }) => number'. -!!! error TS2430: Type 'string | number' is not assignable to type 'number'. -!!! error TS2430: Type 'string' is not assignable to type 'number'. +!!! error TS2430: Types of parameters 'x' and 'x' are incompatible. +!!! error TS2430: Type '{ a: string; b: number; }' is not assignable to type '{ a: string; b: string; }'. +!!! error TS2430: Types of property 'b' are incompatible. +!!! error TS2430: Type 'number' is not assignable to type 'string'. a15: new (x: { a: T; b: T }) => T; // error, T is {} which isn't an acceptable return type } diff --git a/tests/baselines/reference/constructSignatureAssignabilityInInheritance5.js b/tests/baselines/reference/constructSignatureAssignabilityInInheritance5.js index d81722fc950..8431b225440 100644 --- a/tests/baselines/reference/constructSignatureAssignabilityInInheritance5.js +++ b/tests/baselines/reference/constructSignatureAssignabilityInInheritance5.js @@ -45,7 +45,7 @@ interface I extends B { a11: new (x: T, y: T) => T; // ok a12: new >(x: Array, y: T) => Array; // ok, less specific parameter type a13: new >(x: Array, y: T) => T; // ok, T = Array, satisfies constraint, contextual signature instantiation succeeds - a14: new (x: { a: T; b: T }) => T; // ok, best common type yields T = {} but that's satisfactory for this signature + a14: new (x: { a: T; b: U }) => T; // ok } //// [constructSignatureAssignabilityInInheritance5.js] diff --git a/tests/baselines/reference/constructSignatureAssignabilityInInheritance5.symbols b/tests/baselines/reference/constructSignatureAssignabilityInInheritance5.symbols index e1991673f98..c08d7537f65 100644 --- a/tests/baselines/reference/constructSignatureAssignabilityInInheritance5.symbols +++ b/tests/baselines/reference/constructSignatureAssignabilityInInheritance5.symbols @@ -302,13 +302,14 @@ interface I extends B { >T : Symbol(T, Decl(constructSignatureAssignabilityInInheritance5.ts, 45, 14)) >T : Symbol(T, Decl(constructSignatureAssignabilityInInheritance5.ts, 45, 14)) - a14: new (x: { a: T; b: T }) => T; // ok, best common type yields T = {} but that's satisfactory for this signature + a14: new (x: { a: T; b: U }) => T; // ok >a14 : Symbol(I.a14, Decl(constructSignatureAssignabilityInInheritance5.ts, 45, 67)) >T : Symbol(T, Decl(constructSignatureAssignabilityInInheritance5.ts, 46, 14)) ->x : Symbol(x, Decl(constructSignatureAssignabilityInInheritance5.ts, 46, 17)) ->a : Symbol(a, Decl(constructSignatureAssignabilityInInheritance5.ts, 46, 21)) ->T : Symbol(T, Decl(constructSignatureAssignabilityInInheritance5.ts, 46, 14)) ->b : Symbol(b, Decl(constructSignatureAssignabilityInInheritance5.ts, 46, 27)) +>U : Symbol(U, Decl(constructSignatureAssignabilityInInheritance5.ts, 46, 16)) +>x : Symbol(x, Decl(constructSignatureAssignabilityInInheritance5.ts, 46, 20)) +>a : Symbol(a, Decl(constructSignatureAssignabilityInInheritance5.ts, 46, 24)) >T : Symbol(T, Decl(constructSignatureAssignabilityInInheritance5.ts, 46, 14)) +>b : Symbol(b, Decl(constructSignatureAssignabilityInInheritance5.ts, 46, 30)) +>U : Symbol(U, Decl(constructSignatureAssignabilityInInheritance5.ts, 46, 16)) >T : Symbol(T, Decl(constructSignatureAssignabilityInInheritance5.ts, 46, 14)) } diff --git a/tests/baselines/reference/constructSignatureAssignabilityInInheritance5.types b/tests/baselines/reference/constructSignatureAssignabilityInInheritance5.types index 0397a78f678..9296ce8295d 100644 --- a/tests/baselines/reference/constructSignatureAssignabilityInInheritance5.types +++ b/tests/baselines/reference/constructSignatureAssignabilityInInheritance5.types @@ -180,9 +180,9 @@ interface I extends B { >x : Base[] >y : T - a14: new (x: { a: T; b: T }) => T; // ok, best common type yields T = {} but that's satisfactory for this signature ->a14 : new (x: { a: T; b: T; }) => T ->x : { a: T; b: T; } + a14: new (x: { a: T; b: U }) => T; // ok +>a14 : new (x: { a: T; b: U; }) => T +>x : { a: T; b: U; } >a : T ->b : T +>b : U } diff --git a/tests/baselines/reference/contextualSignatureInstantiation.errors.txt b/tests/baselines/reference/contextualSignatureInstantiation.errors.txt new file mode 100644 index 00000000000..6c14ad3c150 --- /dev/null +++ b/tests/baselines/reference/contextualSignatureInstantiation.errors.txt @@ -0,0 +1,53 @@ +tests/cases/conformance/types/typeRelationships/typeInference/contextualSignatureInstantiation.ts(19,13): error TS2345: Argument of type '(x: T, y: T) => T' is not assignable to parameter of type '(x: number, y: string) => number'. + Types of parameters 'y' and 'y' are incompatible. + Type 'string' is not assignable to type 'number'. +tests/cases/conformance/types/typeRelationships/typeInference/contextualSignatureInstantiation.ts(20,23): error TS2345: Argument of type '(x: T, y: T) => T' is not assignable to parameter of type '(x: number, y: string) => number'. + Types of parameters 'y' and 'y' are incompatible. + Type 'string' is not assignable to type 'number'. +tests/cases/conformance/types/typeRelationships/typeInference/contextualSignatureInstantiation.ts(21,23): error TS2345: Argument of type '(x: T, y: T) => T' is not assignable to parameter of type '(x: string, y: number) => string'. + Types of parameters 'y' and 'y' are incompatible. + Type 'number' is not assignable to type 'string'. + + +==== tests/cases/conformance/types/typeRelationships/typeInference/contextualSignatureInstantiation.ts (3 errors) ==== + // TypeScript Spec, section 4.12.2: + // If e is an expression of a function type that contains exactly one generic call signature and no other members, + // and T is a function type with exactly one non - generic call signature and no other members, then any inferences + // made for type parameters referenced by the parameters of T's call signature are fixed, and e's type is changed + // to a function type with e's call signature instantiated in the context of T's call signature (section 3.8.5). + + declare function foo(cb: (x: number, y: string) => T): T; + declare function bar(x: T, y: U, cb: (x: T, y: U) => V): V; + declare function baz(x: T, y: T, cb: (x: T, y: T) => U): U; + + declare function g(x: T, y: T): T; + declare function h(x: T, y: U): T[] | U[]; + + var a: number; + var a = bar(1, 1, g); // Should be number + var a = baz(1, 1, g); // Should be number + + var b: number | string; + var b = foo(g); // Error, number and string are disjoint types + ~ +!!! error TS2345: Argument of type '(x: T, y: T) => T' is not assignable to parameter of type '(x: number, y: string) => number'. +!!! error TS2345: Types of parameters 'y' and 'y' are incompatible. +!!! error TS2345: Type 'string' is not assignable to type 'number'. + var b = bar(1, "one", g); // Error, number and string are disjoint types + ~ +!!! error TS2345: Argument of type '(x: T, y: T) => T' is not assignable to parameter of type '(x: number, y: string) => number'. +!!! error TS2345: Types of parameters 'y' and 'y' are incompatible. +!!! error TS2345: Type 'string' is not assignable to type 'number'. + var b = bar("one", 1, g); // Error, number and string are disjoint types + ~ +!!! error TS2345: Argument of type '(x: T, y: T) => T' is not assignable to parameter of type '(x: string, y: number) => string'. +!!! error TS2345: Types of parameters 'y' and 'y' are incompatible. +!!! error TS2345: Type 'number' is not assignable to type 'string'. + var b = baz(b, b, g); // Should be number | string + + var d: number[] | string[]; + var d = foo(h); // Should be number[] | string[] + var d = bar(1, "one", h); // Should be number[] | string[] + var d = bar("one", 1, h); // Should be number[] | string[] + var d = baz(d, d, g); // Should be number[] | string[] + \ No newline at end of file diff --git a/tests/baselines/reference/contextualSignatureInstantiation.js b/tests/baselines/reference/contextualSignatureInstantiation.js index 11e19b3262e..d945592bbda 100644 --- a/tests/baselines/reference/contextualSignatureInstantiation.js +++ b/tests/baselines/reference/contextualSignatureInstantiation.js @@ -17,9 +17,9 @@ var a = bar(1, 1, g); // Should be number var a = baz(1, 1, g); // Should be number var b: number | string; -var b = foo(g); // Should be number | string -var b = bar(1, "one", g); // Should be number | string -var b = bar("one", 1, g); // Should be number | string +var b = foo(g); // Error, number and string are disjoint types +var b = bar(1, "one", g); // Error, number and string are disjoint types +var b = bar("one", 1, g); // Error, number and string are disjoint types var b = baz(b, b, g); // Should be number | string var d: number[] | string[]; @@ -39,9 +39,9 @@ var a; var a = bar(1, 1, g); // Should be number var a = baz(1, 1, g); // Should be number var b; -var b = foo(g); // Should be number | string -var b = bar(1, "one", g); // Should be number | string -var b = bar("one", 1, g); // Should be number | string +var b = foo(g); // Error, number and string are disjoint types +var b = bar(1, "one", g); // Error, number and string are disjoint types +var b = bar("one", 1, g); // Error, number and string are disjoint types var b = baz(b, b, g); // Should be number | string var d; var d = foo(h); // Should be number[] | string[] diff --git a/tests/baselines/reference/contextualSignatureInstantiation.symbols b/tests/baselines/reference/contextualSignatureInstantiation.symbols index c16ffed84b7..742ae58905c 100644 --- a/tests/baselines/reference/contextualSignatureInstantiation.symbols +++ b/tests/baselines/reference/contextualSignatureInstantiation.symbols @@ -83,17 +83,17 @@ var a = baz(1, 1, g); // Should be number var b: number | string; >b : Symbol(b, Decl(contextualSignatureInstantiation.ts, 17, 3), Decl(contextualSignatureInstantiation.ts, 18, 3), Decl(contextualSignatureInstantiation.ts, 19, 3), Decl(contextualSignatureInstantiation.ts, 20, 3), Decl(contextualSignatureInstantiation.ts, 21, 3)) -var b = foo(g); // Should be number | string +var b = foo(g); // Error, number and string are disjoint types >b : Symbol(b, Decl(contextualSignatureInstantiation.ts, 17, 3), Decl(contextualSignatureInstantiation.ts, 18, 3), Decl(contextualSignatureInstantiation.ts, 19, 3), Decl(contextualSignatureInstantiation.ts, 20, 3), Decl(contextualSignatureInstantiation.ts, 21, 3)) >foo : Symbol(foo, Decl(contextualSignatureInstantiation.ts, 0, 0)) >g : Symbol(g, Decl(contextualSignatureInstantiation.ts, 8, 65)) -var b = bar(1, "one", g); // Should be number | string +var b = bar(1, "one", g); // Error, number and string are disjoint types >b : Symbol(b, Decl(contextualSignatureInstantiation.ts, 17, 3), Decl(contextualSignatureInstantiation.ts, 18, 3), Decl(contextualSignatureInstantiation.ts, 19, 3), Decl(contextualSignatureInstantiation.ts, 20, 3), Decl(contextualSignatureInstantiation.ts, 21, 3)) >bar : Symbol(bar, Decl(contextualSignatureInstantiation.ts, 6, 60)) >g : Symbol(g, Decl(contextualSignatureInstantiation.ts, 8, 65)) -var b = bar("one", 1, g); // Should be number | string +var b = bar("one", 1, g); // Error, number and string are disjoint types >b : Symbol(b, Decl(contextualSignatureInstantiation.ts, 17, 3), Decl(contextualSignatureInstantiation.ts, 18, 3), Decl(contextualSignatureInstantiation.ts, 19, 3), Decl(contextualSignatureInstantiation.ts, 20, 3), Decl(contextualSignatureInstantiation.ts, 21, 3)) >bar : Symbol(bar, Decl(contextualSignatureInstantiation.ts, 6, 60)) >g : Symbol(g, Decl(contextualSignatureInstantiation.ts, 8, 65)) diff --git a/tests/baselines/reference/contextualSignatureInstantiation.types b/tests/baselines/reference/contextualSignatureInstantiation.types index 0f8c1ed49ba..ae5a4000537 100644 --- a/tests/baselines/reference/contextualSignatureInstantiation.types +++ b/tests/baselines/reference/contextualSignatureInstantiation.types @@ -59,23 +59,23 @@ var a = baz(1, 1, g); // Should be number var b: number | string; >b : string | number -var b = foo(g); // Should be number | string +var b = foo(g); // Error, number and string are disjoint types >b : string | number ->foo(g) : string | number +>foo(g) : any >foo : (cb: (x: number, y: string) => T) => T >g : (x: T, y: T) => T -var b = bar(1, "one", g); // Should be number | string +var b = bar(1, "one", g); // Error, number and string are disjoint types >b : string | number ->bar(1, "one", g) : string | number +>bar(1, "one", g) : any >bar : (x: T, y: U, cb: (x: T, y: U) => V) => V >1 : 1 >"one" : "one" >g : (x: T, y: T) => T -var b = bar("one", 1, g); // Should be number | string +var b = bar("one", 1, g); // Error, number and string are disjoint types >b : string | number ->bar("one", 1, g) : string | number +>bar("one", 1, g) : any >bar : (x: T, y: U, cb: (x: T, y: U) => V) => V >"one" : "one" >1 : 1 diff --git a/tests/baselines/reference/contextualSignatureInstatiationContravariance.errors.txt b/tests/baselines/reference/contextualSignatureInstatiationContravariance.errors.txt new file mode 100644 index 00000000000..fe9c6cf3f14 --- /dev/null +++ b/tests/baselines/reference/contextualSignatureInstatiationContravariance.errors.txt @@ -0,0 +1,23 @@ +tests/cases/compiler/contextualSignatureInstatiationContravariance.ts(8,1): error TS2322: Type '(x: T, y: T) => void' is not assignable to type '(g: Giraffe, e: Elephant) => void'. + Types of parameters 'y' and 'e' are incompatible. + Type 'Elephant' is not assignable to type 'Giraffe'. + Property 'y' is missing in type 'Elephant'. + + +==== tests/cases/compiler/contextualSignatureInstatiationContravariance.ts (1 errors) ==== + interface Animal { x } + interface Giraffe extends Animal { y } + interface Elephant extends Animal { y2 } + + var f2: (x: T, y: T) => void; + + var g2: (g: Giraffe, e: Elephant) => void; + g2 = f2; // error because Giraffe and Elephant are disjoint types + ~~ +!!! error TS2322: Type '(x: T, y: T) => void' is not assignable to type '(g: Giraffe, e: Elephant) => void'. +!!! error TS2322: Types of parameters 'y' and 'e' are incompatible. +!!! error TS2322: Type 'Elephant' is not assignable to type 'Giraffe'. +!!! error TS2322: Property 'y' is missing in type 'Elephant'. + + var h2: (g1: Giraffe, g2: Giraffe) => void; + h2 = f2; // valid because Giraffe satisfies the constraint. It is safe in the traditional contravariant fashion. \ No newline at end of file diff --git a/tests/baselines/reference/contextualSignatureInstatiationContravariance.js b/tests/baselines/reference/contextualSignatureInstatiationContravariance.js index 6e731d61713..6e2de5d2907 100644 --- a/tests/baselines/reference/contextualSignatureInstatiationContravariance.js +++ b/tests/baselines/reference/contextualSignatureInstatiationContravariance.js @@ -6,7 +6,7 @@ interface Elephant extends Animal { y2 } var f2: (x: T, y: T) => void; var g2: (g: Giraffe, e: Elephant) => void; -g2 = f2; // valid because both Giraffe and Elephant satisfy the constraint. T is Animal +g2 = f2; // error because Giraffe and Elephant are disjoint types var h2: (g1: Giraffe, g2: Giraffe) => void; h2 = f2; // valid because Giraffe satisfies the constraint. It is safe in the traditional contravariant fashion. @@ -14,6 +14,6 @@ h2 = f2; // valid because Giraffe satisfies the constraint. It is safe in the tr //// [contextualSignatureInstatiationContravariance.js] var f2; var g2; -g2 = f2; // valid because both Giraffe and Elephant satisfy the constraint. T is Animal +g2 = f2; // error because Giraffe and Elephant are disjoint types var h2; h2 = f2; // valid because Giraffe satisfies the constraint. It is safe in the traditional contravariant fashion. diff --git a/tests/baselines/reference/contextualSignatureInstatiationContravariance.symbols b/tests/baselines/reference/contextualSignatureInstatiationContravariance.symbols index 37a0c4adb02..fc11cca8aa6 100644 --- a/tests/baselines/reference/contextualSignatureInstatiationContravariance.symbols +++ b/tests/baselines/reference/contextualSignatureInstatiationContravariance.symbols @@ -29,7 +29,7 @@ var g2: (g: Giraffe, e: Elephant) => void; >e : Symbol(e, Decl(contextualSignatureInstatiationContravariance.ts, 6, 20)) >Elephant : Symbol(Elephant, Decl(contextualSignatureInstatiationContravariance.ts, 1, 38)) -g2 = f2; // valid because both Giraffe and Elephant satisfy the constraint. T is Animal +g2 = f2; // error because Giraffe and Elephant are disjoint types >g2 : Symbol(g2, Decl(contextualSignatureInstatiationContravariance.ts, 6, 3)) >f2 : Symbol(f2, Decl(contextualSignatureInstatiationContravariance.ts, 4, 3)) diff --git a/tests/baselines/reference/contextualSignatureInstatiationContravariance.types b/tests/baselines/reference/contextualSignatureInstatiationContravariance.types index d0d281b7d49..0ca89f7016c 100644 --- a/tests/baselines/reference/contextualSignatureInstatiationContravariance.types +++ b/tests/baselines/reference/contextualSignatureInstatiationContravariance.types @@ -18,7 +18,7 @@ var g2: (g: Giraffe, e: Elephant) => void; >g : Giraffe >e : Elephant -g2 = f2; // valid because both Giraffe and Elephant satisfy the constraint. T is Animal +g2 = f2; // error because Giraffe and Elephant are disjoint types >g2 = f2 : (x: T, y: T) => void >g2 : (g: Giraffe, e: Elephant) => void >f2 : (x: T, y: T) => void diff --git a/tests/baselines/reference/declarationEmitWithComposite.js b/tests/baselines/reference/declarationEmitWithComposite.js new file mode 100644 index 00000000000..3ccdf5c1ea1 --- /dev/null +++ b/tests/baselines/reference/declarationEmitWithComposite.js @@ -0,0 +1,17 @@ +//// [test.ts] +interface Foo { + x: number; +} +export default Foo; + + +//// [/foo/out/test.js] +"use strict"; +exports.__esModule = true; + + +//// [/foo/out/test.d.ts] +interface Foo { + x: number; +} +export default Foo; diff --git a/tests/baselines/reference/declarationEmitWithComposite.symbols b/tests/baselines/reference/declarationEmitWithComposite.symbols new file mode 100644 index 00000000000..74f9fba394b --- /dev/null +++ b/tests/baselines/reference/declarationEmitWithComposite.symbols @@ -0,0 +1,10 @@ +=== /foo/test.ts === +interface Foo { +>Foo : Symbol(Foo, Decl(test.ts, 0, 0)) + + x: number; +>x : Symbol(Foo.x, Decl(test.ts, 0, 15)) +} +export default Foo; +>Foo : Symbol(Foo, Decl(test.ts, 0, 0)) + diff --git a/tests/baselines/reference/declarationEmitWithComposite.types b/tests/baselines/reference/declarationEmitWithComposite.types new file mode 100644 index 00000000000..489a84bb9f1 --- /dev/null +++ b/tests/baselines/reference/declarationEmitWithComposite.types @@ -0,0 +1,8 @@ +=== /foo/test.ts === +interface Foo { + x: number; +>x : number +} +export default Foo; +>Foo : Foo + diff --git a/tests/baselines/reference/declarationsAndAssignments.errors.txt b/tests/baselines/reference/declarationsAndAssignments.errors.txt index 920f995ef32..930d5f0c5b9 100644 --- a/tests/baselines/reference/declarationsAndAssignments.errors.txt +++ b/tests/baselines/reference/declarationsAndAssignments.errors.txt @@ -17,10 +17,8 @@ tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(73,11): tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(73,14): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(74,11): error TS2459: Type 'undefined[]' has no property 'a' and no string index signature. tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(74,14): error TS2459: Type 'undefined[]' has no property 'b' and no string index signature. -tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(106,5): error TS2345: Argument of type '[number, [string, { y: false; }]]' is not assignable to parameter of type '[number, [string, { x: any; y?: boolean; }]]'. - Type '[string, { y: false; }]' is not assignable to type '[string, { x: any; y?: boolean; }]'. - Type '{ y: false; }' is not assignable to type '{ x: any; y?: boolean; }'. - Property 'x' is missing in type '{ y: false; }'. +tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(106,17): error TS2322: Type '{ y: boolean; }' is not assignable to type '{ x: any; y?: boolean; }'. + Property 'x' is missing in type '{ y: boolean; }'. tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(138,6): error TS2322: Type 'string' is not assignable to type 'number'. tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(138,9): error TS2322: Type 'number' is not assignable to type 'string'. @@ -170,11 +168,9 @@ tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(138,9): f14([2, ["abc", { x: 0, y: true }]]); f14([2, ["abc", { x: 0 }]]); f14([2, ["abc", { y: false }]]); // Error, no x - ~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '[number, [string, { y: false; }]]' is not assignable to parameter of type '[number, [string, { x: any; y?: boolean; }]]'. -!!! error TS2345: Type '[string, { y: false; }]' is not assignable to type '[string, { x: any; y?: boolean; }]'. -!!! error TS2345: Type '{ y: false; }' is not assignable to type '{ x: any; y?: boolean; }'. -!!! error TS2345: Property 'x' is missing in type '{ y: false; }'. + ~~~~~~~~~~~~ +!!! error TS2322: Type '{ y: boolean; }' is not assignable to type '{ x: any; y?: boolean; }'. +!!! error TS2322: Property 'x' is missing in type '{ y: boolean; }'. module M { export var [a, b] = [1, 2]; diff --git a/tests/baselines/reference/destructuringParameterDeclaration2.errors.txt b/tests/baselines/reference/destructuringParameterDeclaration2.errors.txt index 6e4b3f1ad08..a3ca44020c2 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration2.errors.txt +++ b/tests/baselines/reference/destructuringParameterDeclaration2.errors.txt @@ -1,38 +1,21 @@ -tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(7,4): error TS2345: Argument of type '[number, string, string[][]]' is not assignable to parameter of type '[number, number, string[][]]'. - Type 'string' is not assignable to type 'number'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(7,8): error TS2322: Type 'string' is not assignable to type 'number'. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(7,29): error TS1005: ',' expected. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(8,4): error TS2345: Argument of type '[number, number, string[][], string]' is not assignable to parameter of type '[number, number, string[][]]'. Types of property 'length' are incompatible. Type '4' is not assignable to type '3'. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(16,8): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(16,16): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. -tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(23,14): error TS2345: Argument of type '{ x: string; y: boolean; }' is not assignable to parameter of type '{ x: number; y: any; }'. - Types of property 'x' are incompatible. - Type 'string' is not assignable to type 'number'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(23,16): error TS2322: Type 'string' is not assignable to type 'number'. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(30,14): error TS2300: Duplicate identifier 'z'. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(30,18): error TS2300: Duplicate identifier 'z'. -tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(34,4): error TS2345: Argument of type '{ z: number; }' is not assignable to parameter of type '{ z: { x: any; y: { j: any; }; }; }'. - Types of property 'z' are incompatible. - Type 'number' is not assignable to type '{ x: any; y: { j: any; }; }'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(34,6): error TS2322: Type 'number' is not assignable to type '{ x: any; y: { j: any; }; }'. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(35,4): error TS2345: Argument of type '{}' is not assignable to parameter of type '{ z: number; }'. Property 'z' is missing in type '{}'. -tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(36,4): error TS2345: Argument of type '{ z: boolean; }' is not assignable to parameter of type '{ z: number; }'. - Types of property 'z' are incompatible. - Type 'boolean' is not assignable to type 'number'. -tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(37,4): error TS2345: Argument of type '{ z: boolean; }' is not assignable to parameter of type '{ z?: number; }'. - Types of property 'z' are incompatible. - Type 'boolean' is not assignable to type 'number'. -tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(38,4): error TS2345: Argument of type '{ b: boolean; }' is not assignable to parameter of type '{ b: string | number; }'. - Types of property 'b' are incompatible. - Type 'boolean' is not assignable to type 'string | number'. -tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(39,4): error TS2345: Argument of type '[number, number, boolean, boolean]' is not assignable to parameter of type '[any, any, [[any]]]'. - Types of property '2' are incompatible. - Type 'boolean' is not assignable to type '[[any]]'. -tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(40,4): error TS2345: Argument of type '[number, number, [[string]]]' is not assignable to parameter of type '[any, any, [[number?]]]'. - Type '[[string]]' is not assignable to type '[[number?]]'. - Type '[string]' is not assignable to type '[number?]'. - Types of property '0' are incompatible. - Type 'string' is not assignable to type 'number'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(36,6): error TS2322: Type 'true' is not assignable to type 'number'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(37,6): error TS2322: Type 'false' is not assignable to type 'number'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(38,6): error TS2322: Type 'true' is not assignable to type 'string | number'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(39,11): error TS2322: Type 'false' is not assignable to type '[[any]]'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(40,13): error TS2322: Type 'string' is not assignable to type 'number'. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(46,13): error TS2463: A binding pattern parameter cannot be optional in an implementation signature. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(47,13): error TS2463: A binding pattern parameter cannot be optional in an implementation signature. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(56,8): error TS2463: A binding pattern parameter cannot be optional in an implementation signature. @@ -54,9 +37,8 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts( // If the declaration includes a type annotation, the parameter is of that type function a0([a, b, [[c]]]: [number, number, string[][]]) { } a0([1, "string", [["world"]]); // Error - ~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '[number, string, string[][]]' is not assignable to parameter of type '[number, number, string[][]]'. -!!! error TS2345: Type 'string' is not assignable to type 'number'. + ~~~~~~~~ +!!! error TS2322: Type 'string' is not assignable to type 'number'. ~ !!! error TS1005: ',' expected. a0([1, 2, [["world"]], "string"]); // Error @@ -83,10 +65,9 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts( function b3([[a], b, [[c, d]]] = [[undefined], undefined, [[undefined, undefined]]]) { } b1("string", { x: "string", y: true }); // Error - ~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ x: string; y: boolean; }' is not assignable to parameter of type '{ x: number; y: any; }'. -!!! error TS2345: Types of property 'x' are incompatible. -!!! error TS2345: Type 'string' is not assignable to type 'number'. + ~ +!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! related TS6500 tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts:19:29: The expected type comes from property 'x' which is declared here on type '{ x: number; y: any; }' // If the declaration specifies a binding pattern, the parameter type is the implied type of that binding pattern (section 5.1.3) function c0({z: {x, y: {j}}}) { } @@ -102,41 +83,29 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts( function c6([a, b, [[c = 1]]]) { } c0({ z: 1 }); // Error, implied type is { z: {x: any, y: {j: any}} } - ~~~~~~~~ -!!! error TS2345: Argument of type '{ z: number; }' is not assignable to parameter of type '{ z: { x: any; y: { j: any; }; }; }'. -!!! error TS2345: Types of property 'z' are incompatible. -!!! error TS2345: Type 'number' is not assignable to type '{ x: any; y: { j: any; }; }'. + ~ +!!! error TS2322: Type 'number' is not assignable to type '{ x: any; y: { j: any; }; }'. c1({}); // Error, implied type is {z:number}? ~~ !!! error TS2345: Argument of type '{}' is not assignable to parameter of type '{ z: number; }'. !!! error TS2345: Property 'z' is missing in type '{}'. c1({ z: true }); // Error, implied type is {z:number}? - ~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ z: boolean; }' is not assignable to parameter of type '{ z: number; }'. -!!! error TS2345: Types of property 'z' are incompatible. -!!! error TS2345: Type 'boolean' is not assignable to type 'number'. + ~ +!!! error TS2322: Type 'true' is not assignable to type 'number'. +!!! related TS6500 tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts:27:21: The expected type comes from property 'z' which is declared here on type '{ z: number; }' c2({ z: false }); // Error, implied type is {z?: number} - ~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ z: boolean; }' is not assignable to parameter of type '{ z?: number; }'. -!!! error TS2345: Types of property 'z' are incompatible. -!!! error TS2345: Type 'boolean' is not assignable to type 'number'. + ~ +!!! error TS2322: Type 'false' is not assignable to type 'number'. c3({ b: true }); // Error, implied type is { b: number|string }. - ~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ b: boolean; }' is not assignable to parameter of type '{ b: string | number; }'. -!!! error TS2345: Types of property 'b' are incompatible. -!!! error TS2345: Type 'boolean' is not assignable to type 'string | number'. + ~ +!!! error TS2322: Type 'true' is not assignable to type 'string | number'. +!!! related TS6500 tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts:29:20: The expected type comes from property 'b' which is declared here on type '{ b: string | number; }' c5([1, 2, false, true]); // Error, implied type is [any, any, [[any]]] - ~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '[number, number, boolean, boolean]' is not assignable to parameter of type '[any, any, [[any]]]'. -!!! error TS2345: Types of property '2' are incompatible. -!!! error TS2345: Type 'boolean' is not assignable to type '[[any]]'. + ~~~~~ +!!! error TS2322: Type 'false' is not assignable to type '[[any]]'. c6([1, 2, [["string"]]]); // Error, implied type is [any, any, [[number]]] // Use initializer - ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '[number, number, [[string]]]' is not assignable to parameter of type '[any, any, [[number?]]]'. -!!! error TS2345: Type '[[string]]' is not assignable to type '[[number?]]'. -!!! error TS2345: Type '[string]' is not assignable to type '[number?]'. -!!! error TS2345: Types of property '0' are incompatible. -!!! error TS2345: Type 'string' is not assignable to type 'number'. + ~~~~~~~~ +!!! error TS2322: Type 'string' is not assignable to type 'number'. // A parameter can be marked optional by following its name or binding pattern with a question mark (?) // or by including an initializer. Initializers (including binding property or element initializers) are diff --git a/tests/baselines/reference/destructuringParameterDeclaration3ES5.errors.txt b/tests/baselines/reference/destructuringParameterDeclaration3ES5.errors.txt index d3d7cc97b51..89c0cad0d3a 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration3ES5.errors.txt +++ b/tests/baselines/reference/destructuringParameterDeclaration3ES5.errors.txt @@ -1,9 +1,7 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration3ES5.ts(26,4): error TS2345: Argument of type '[number, number, [[string]], boolean, boolean]' is not assignable to parameter of type '[any, any, [[any]]]'. Types of property 'length' are incompatible. Type '5' is not assignable to type '3'. -tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration3ES5.ts(29,5): error TS2345: Argument of type '[number, number, number, boolean, boolean]' is not assignable to parameter of type '[any, any, [[any]], ...any[]]'. - Types of property '2' are incompatible. - Type 'number' is not assignable to type '[[any]]'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration3ES5.ts(29,12): error TS2322: Type 'number' is not assignable to type '[[any]]'. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration3ES5.ts(30,5): error TS2345: Argument of type '[number, number]' is not assignable to parameter of type '[any, any, [[any]], ...any[]]'. Property '2' is missing in type '[number, number]'. @@ -42,10 +40,8 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration3ES5. a10([1, 2, [["string"]], false, true]); // Parameter type is any[] a10([1, 2, 3, false, true]); // Parameter type is any[] - ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '[number, number, number, boolean, boolean]' is not assignable to parameter of type '[any, any, [[any]], ...any[]]'. -!!! error TS2345: Types of property '2' are incompatible. -!!! error TS2345: Type 'number' is not assignable to type '[[any]]'. + ~ +!!! error TS2322: Type 'number' is not assignable to type '[[any]]'. a10([1, 2]); // Parameter type is any[] ~~~~~~ !!! error TS2345: Argument of type '[number, number]' is not assignable to parameter of type '[any, any, [[any]], ...any[]]'. diff --git a/tests/baselines/reference/destructuringParameterDeclaration3ES5iterable.errors.txt b/tests/baselines/reference/destructuringParameterDeclaration3ES5iterable.errors.txt index fa08518279e..047ee9e191c 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration3ES5iterable.errors.txt +++ b/tests/baselines/reference/destructuringParameterDeclaration3ES5iterable.errors.txt @@ -1,9 +1,7 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration3ES5iterable.ts(26,4): error TS2345: Argument of type '[number, number, [[string]], boolean, boolean]' is not assignable to parameter of type '[any, any, [[any]]]'. Types of property 'length' are incompatible. Type '5' is not assignable to type '3'. -tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration3ES5iterable.ts(29,5): error TS2345: Argument of type '[number, number, number, boolean, boolean]' is not assignable to parameter of type '[any, any, [[any]], ...any[]]'. - Types of property '2' are incompatible. - Type 'number' is not assignable to type '[[any]]'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration3ES5iterable.ts(29,12): error TS2322: Type 'number' is not assignable to type '[[any]]'. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration3ES5iterable.ts(30,5): error TS2345: Argument of type '[number, number]' is not assignable to parameter of type '[any, any, [[any]], ...any[]]'. Property '2' is missing in type '[number, number]'. @@ -42,10 +40,8 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration3ES5i a10([1, 2, [["string"]], false, true]); // Parameter type is any[] a10([1, 2, 3, false, true]); // Parameter type is any[] - ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '[number, number, number, boolean, boolean]' is not assignable to parameter of type '[any, any, [[any]], ...any[]]'. -!!! error TS2345: Types of property '2' are incompatible. -!!! error TS2345: Type 'number' is not assignable to type '[[any]]'. + ~ +!!! error TS2322: Type 'number' is not assignable to type '[[any]]'. a10([1, 2]); // Parameter type is any[] ~~~~~~ !!! error TS2345: Argument of type '[number, number]' is not assignable to parameter of type '[any, any, [[any]], ...any[]]'. diff --git a/tests/baselines/reference/destructuringParameterDeclaration3ES6.errors.txt b/tests/baselines/reference/destructuringParameterDeclaration3ES6.errors.txt index 238e155e954..38b56187a28 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration3ES6.errors.txt +++ b/tests/baselines/reference/destructuringParameterDeclaration3ES6.errors.txt @@ -1,9 +1,7 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration3ES6.ts(26,4): error TS2345: Argument of type '[number, number, [[string]], boolean, boolean]' is not assignable to parameter of type '[any, any, [[any]]]'. Types of property 'length' are incompatible. Type '5' is not assignable to type '3'. -tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration3ES6.ts(29,5): error TS2345: Argument of type '[number, number, number, boolean, boolean]' is not assignable to parameter of type '[any, any, [[any]], ...any[]]'. - Types of property '2' are incompatible. - Type 'number' is not assignable to type '[[any]]'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration3ES6.ts(29,12): error TS2322: Type 'number' is not assignable to type '[[any]]'. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration3ES6.ts(30,5): error TS2345: Argument of type '[number, number]' is not assignable to parameter of type '[any, any, [[any]], ...any[]]'. Property '2' is missing in type '[number, number]'. @@ -42,10 +40,8 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration3ES6. a10([1, 2, [["string"]], false, true]); // Parameter type is any[] a10([1, 2, 3, false, true]); // Parameter type is any[] - ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '[number, number, number, boolean, boolean]' is not assignable to parameter of type '[any, any, [[any]], ...any[]]'. -!!! error TS2345: Types of property '2' are incompatible. -!!! error TS2345: Type 'number' is not assignable to type '[[any]]'. + ~ +!!! error TS2322: Type 'number' is not assignable to type '[[any]]'. a10([1, 2]); // Parameter type is any[] ~~~~~~ !!! error TS2345: Argument of type '[number, number]' is not assignable to parameter of type '[any, any, [[any]], ...any[]]'. diff --git a/tests/baselines/reference/destructuringParameterDeclaration4.errors.txt b/tests/baselines/reference/destructuringParameterDeclaration4.errors.txt index 2af931d352d..46e4f597c21 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration4.errors.txt +++ b/tests/baselines/reference/destructuringParameterDeclaration4.errors.txt @@ -2,9 +2,7 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts( tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(15,16): error TS1048: A rest parameter cannot have an initializer. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(20,19): error TS2345: Argument of type 'true' is not assignable to parameter of type 'string | number'. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(21,7): error TS2552: Cannot find name 'array2'. Did you mean 'Array'? -tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(22,4): error TS2345: Argument of type '[number, number, string, boolean, boolean]' is not assignable to parameter of type '[any, any, [[any]]]'. - Types of property '2' are incompatible. - Type 'string' is not assignable to type '[[any]]'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(22,11): error TS2322: Type 'string' is not assignable to type '[[any]]'. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(23,4): error TS2345: Argument of type '[number, number]' is not assignable to parameter of type '[any, any, [[any]]]'. Property '2' is missing in type '[number, number]'. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(24,4): error TS2345: Argument of type '(string | number)[]' is not assignable to parameter of type 'number[]'. @@ -47,10 +45,8 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts( !!! error TS2552: Cannot find name 'array2'. Did you mean 'Array'? !!! related TS2728 /.ts/lib.es5.d.ts:1298:15: 'Array' is declared here. a5([1, 2, "string", false, true]); // Error, parameter type is [any, any, [[any]]] - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '[number, number, string, boolean, boolean]' is not assignable to parameter of type '[any, any, [[any]]]'. -!!! error TS2345: Types of property '2' are incompatible. -!!! error TS2345: Type 'string' is not assignable to type '[[any]]'. + ~~~~~~~~ +!!! error TS2322: Type 'string' is not assignable to type '[[any]]'. a5([1, 2]); // Error, parameter type is [any, any, [[any]]] ~~~~~~ !!! error TS2345: Argument of type '[number, number]' is not assignable to parameter of type '[any, any, [[any]]]'. diff --git a/tests/baselines/reference/destructuringParameterDeclaration5.errors.txt b/tests/baselines/reference/destructuringParameterDeclaration5.errors.txt index 2afb25502c7..be65d7c37aa 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration5.errors.txt +++ b/tests/baselines/reference/destructuringParameterDeclaration5.errors.txt @@ -1,15 +1,9 @@ -tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration5.ts(47,4): error TS2345: Argument of type '{ y: Class; }' is not assignable to parameter of type '{ y: D; }'. - Types of property 'y' are incompatible. - Type 'Class' is not assignable to type 'D'. - Property 'foo' is missing in type 'Class'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration5.ts(47,6): error TS2322: Type 'Class' is not assignable to type 'D'. + Property 'foo' is missing in type 'Class'. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration5.ts(48,4): error TS2345: Argument of type '{}' is not assignable to parameter of type '{ y: D; }'. Property 'y' is missing in type '{}'. -tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration5.ts(49,4): error TS2345: Argument of type '{ y: number; }' is not assignable to parameter of type '{ y: D; }'. - Types of property 'y' are incompatible. - Type 'number' is not assignable to type 'D'. -tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration5.ts(50,4): error TS2345: Argument of type '{ y: string; }' is not assignable to parameter of type '{ y: D; }'. - Types of property 'y' are incompatible. - Type 'string' is not assignable to type 'D'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration5.ts(49,6): error TS2322: Type 'number' is not assignable to type 'D'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration5.ts(50,6): error TS2322: Type 'string' is not assignable to type 'D'. ==== tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration5.ts (4 errors) ==== @@ -60,22 +54,19 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration5.ts( d3({ y: new SubClass() }); // Error d3({ y: new Class() }); - ~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ y: Class; }' is not assignable to parameter of type '{ y: D; }'. -!!! error TS2345: Types of property 'y' are incompatible. -!!! error TS2345: Type 'Class' is not assignable to type 'D'. -!!! error TS2345: Property 'foo' is missing in type 'Class'. + ~ +!!! error TS2322: Type 'Class' is not assignable to type 'D'. +!!! error TS2322: Property 'foo' is missing in type 'Class'. +!!! related TS6500 tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration5.ts:29:33: The expected type comes from property 'y' which is declared here on type '{ y: D; }' d3({}); ~~ !!! error TS2345: Argument of type '{}' is not assignable to parameter of type '{ y: D; }'. !!! error TS2345: Property 'y' is missing in type '{}'. d3({ y: 1 }); - ~~~~~~~~ -!!! error TS2345: Argument of type '{ y: number; }' is not assignable to parameter of type '{ y: D; }'. -!!! error TS2345: Types of property 'y' are incompatible. -!!! error TS2345: Type 'number' is not assignable to type 'D'. + ~ +!!! error TS2322: Type 'number' is not assignable to type 'D'. +!!! related TS6500 tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration5.ts:29:33: The expected type comes from property 'y' which is declared here on type '{ y: D; }' d3({ y: "world" }); - ~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ y: string; }' is not assignable to parameter of type '{ y: D; }'. -!!! error TS2345: Types of property 'y' are incompatible. -!!! error TS2345: Type 'string' is not assignable to type 'D'. \ No newline at end of file + ~ +!!! error TS2322: Type 'string' is not assignable to type 'D'. +!!! related TS6500 tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration5.ts:29:33: The expected type comes from property 'y' which is declared here on type '{ y: D; }' \ No newline at end of file diff --git a/tests/baselines/reference/destructuringParameterDeclaration8.errors.txt b/tests/baselines/reference/destructuringParameterDeclaration8.errors.txt index 0b333efe901..bb6b1686fc2 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration8.errors.txt +++ b/tests/baselines/reference/destructuringParameterDeclaration8.errors.txt @@ -1,11 +1,7 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration8.ts(4,5): error TS2322: Type '"z"' is not assignable to type '"x" | "y"'. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration8.ts(5,15): error TS2322: Type '"c"' is not assignable to type '"a" | "b"'. -tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration8.ts(17,6): error TS2345: Argument of type '{ method: "z"; nested: { p: "b"; }; }' is not assignable to parameter of type '{ method?: "x" | "y"; nested?: { p: "a" | "b"; }; }'. - Types of property 'method' are incompatible. - Type '"z"' is not assignable to type '"x" | "y"'. -tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration8.ts(18,6): error TS2345: Argument of type '{ method: "one"; nested: { p: "a"; }; }' is not assignable to parameter of type '{ method?: "x" | "y"; nested?: { p: "a" | "b"; }; }'. - Types of property 'method' are incompatible. - Type '"one"' is not assignable to type '"x" | "y"'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration8.ts(17,8): error TS2322: Type '"z"' is not assignable to type '"x" | "y"'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration8.ts(18,8): error TS2322: Type '"one"' is not assignable to type '"x" | "y"'. ==== tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration8.ts (4 errors) ==== @@ -30,13 +26,11 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration8.ts( test({}); test({ method: 'x', nested: { p: 'a' } }) test({ method: 'z', nested: { p: 'b' } }) - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ method: "z"; nested: { p: "b"; }; }' is not assignable to parameter of type '{ method?: "x" | "y"; nested?: { p: "a" | "b"; }; }'. -!!! error TS2345: Types of property 'method' are incompatible. -!!! error TS2345: Type '"z"' is not assignable to type '"x" | "y"'. + ~~~~~~ +!!! error TS2322: Type '"z"' is not assignable to type '"x" | "y"'. +!!! related TS6500 tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration8.ts:7:5: The expected type comes from property 'method' which is declared here on type '{ method?: "x" | "y"; nested?: { p: "a" | "b"; }; }' test({ method: 'one', nested: { p: 'a' } }) - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ method: "one"; nested: { p: "a"; }; }' is not assignable to parameter of type '{ method?: "x" | "y"; nested?: { p: "a" | "b"; }; }'. -!!! error TS2345: Types of property 'method' are incompatible. -!!! error TS2345: Type '"one"' is not assignable to type '"x" | "y"'. + ~~~~~~ +!!! error TS2322: Type '"one"' is not assignable to type '"x" | "y"'. +!!! related TS6500 tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration8.ts:7:5: The expected type comes from property 'method' which is declared here on type '{ method?: "x" | "y"; nested?: { p: "a" | "b"; }; }' \ No newline at end of file diff --git a/tests/baselines/reference/destructuringParameterProperties2.errors.txt b/tests/baselines/reference/destructuringParameterProperties2.errors.txt index deb039aa67d..da8ecee52b6 100644 --- a/tests/baselines/reference/destructuringParameterProperties2.errors.txt +++ b/tests/baselines/reference/destructuringParameterProperties2.errors.txt @@ -5,8 +5,7 @@ tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(4 tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(9,21): error TS2339: Property 'a' does not exist on type 'C1'. tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(13,21): error TS2339: Property 'b' does not exist on type 'C1'. tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(17,21): error TS2339: Property 'c' does not exist on type 'C1'. -tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(21,27): error TS2345: Argument of type '[number, undefined, string]' is not assignable to parameter of type '[number, string, boolean]'. - Type 'string' is not assignable to type 'boolean'. +tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(21,42): error TS2322: Type 'string' is not assignable to type 'boolean'. ==== tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts (8 errors) ==== @@ -45,9 +44,8 @@ tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(2 } var x = new C1(undefined, [0, undefined, ""]); - ~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '[number, undefined, string]' is not assignable to parameter of type '[number, string, boolean]'. -!!! error TS2345: Type 'string' is not assignable to type 'boolean'. + ~~ +!!! error TS2322: Type 'string' is not assignable to type 'boolean'. var [x_a, x_b, x_c] = [x.getA(), x.getB(), x.getC()]; var y = new C1(10, [0, "", true]); diff --git a/tests/baselines/reference/destructuringParameterProperties5.errors.txt b/tests/baselines/reference/destructuringParameterProperties5.errors.txt index e0540240b61..44e013fad0b 100644 --- a/tests/baselines/reference/destructuringParameterProperties5.errors.txt +++ b/tests/baselines/reference/destructuringParameterProperties5.errors.txt @@ -7,12 +7,13 @@ tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(7 tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(7,51): error TS2339: Property 'x3' does not exist on type 'C1'. tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(7,62): error TS2339: Property 'y' does not exist on type 'C1'. tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(7,72): error TS2339: Property 'z' does not exist on type 'C1'. -tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(11,19): error TS2345: Argument of type '[{ x1: number; x2: string; x3: boolean; }, string, boolean]' is not assignable to parameter of type '[ObjType1, number, string]'. - Type '{ x1: number; x2: string; x3: boolean; }' is not assignable to type 'ObjType1'. - Object literal may only specify known properties, and 'x1' does not exist in type 'ObjType1'. +tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(11,19): error TS2322: Type '{ x1: number; x2: string; x3: boolean; }' is not assignable to type 'ObjType1'. + Object literal may only specify known properties, and 'x1' does not exist in type 'ObjType1'. +tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(11,47): error TS2322: Type 'string' is not assignable to type 'number'. +tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(11,51): error TS2322: Type 'false' is not assignable to type 'string'. -==== tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts (10 errors) ==== +==== tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts (12 errors) ==== type ObjType1 = { x: number; y: string; z: boolean } type TupleType1 = [ObjType1, number, string] @@ -43,7 +44,10 @@ tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(1 var a = new C1([{ x1: 10, x2: "", x3: true }, "", false]); ~~~~~~ -!!! error TS2345: Argument of type '[{ x1: number; x2: string; x3: boolean; }, string, boolean]' is not assignable to parameter of type '[ObjType1, number, string]'. -!!! error TS2345: Type '{ x1: number; x2: string; x3: boolean; }' is not assignable to type 'ObjType1'. -!!! error TS2345: Object literal may only specify known properties, and 'x1' does not exist in type 'ObjType1'. +!!! error TS2322: Type '{ x1: number; x2: string; x3: boolean; }' is not assignable to type 'ObjType1'. +!!! error TS2322: Object literal may only specify known properties, and 'x1' does not exist in type 'ObjType1'. + ~~ +!!! error TS2322: Type 'string' is not assignable to type 'number'. + ~~~~~ +!!! error TS2322: Type 'false' is not assignable to type 'string'. var [a_x1, a_x2, a_x3, a_y, a_z] = [a.x1, a.x2, a.x3, a.y, a.z]; \ No newline at end of file diff --git a/tests/baselines/reference/genericCallWithFunctionTypedArguments5.errors.txt b/tests/baselines/reference/genericCallWithFunctionTypedArguments5.errors.txt index 75ae76b1dbc..ee15ac0597c 100644 --- a/tests/baselines/reference/genericCallWithFunctionTypedArguments5.errors.txt +++ b/tests/baselines/reference/genericCallWithFunctionTypedArguments5.errors.txt @@ -1,9 +1,5 @@ -tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments5.ts(10,14): error TS2345: Argument of type '{ cb: (x: T, y: T) => string; }' is not assignable to parameter of type '{ cb: (t: {}) => string; }'. - Types of property 'cb' are incompatible. - Type '(x: T, y: T) => string' is not assignable to type '(t: {}) => string'. -tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments5.ts(11,14): error TS2345: Argument of type '{ cb: (x: string, y: number) => string; }' is not assignable to parameter of type '{ cb: (t: string) => string; }'. - Types of property 'cb' are incompatible. - Type '(x: string, y: number) => string' is not assignable to type '(t: string) => string'. +tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments5.ts(10,16): error TS2322: Type '(x: T, y: T) => string' is not assignable to type '(t: {}) => string'. +tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments5.ts(11,16): error TS2322: Type '(x: string, y: number) => string' is not assignable to type '(t: string) => string'. ==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments5.ts (2 errors) ==== @@ -17,15 +13,13 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFun var r = foo(arg); // {} // more args not allowed var r2 = foo({ cb: (x: T, y: T) => '' }); // error - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ cb: (x: T, y: T) => string; }' is not assignable to parameter of type '{ cb: (t: {}) => string; }'. -!!! error TS2345: Types of property 'cb' are incompatible. -!!! error TS2345: Type '(x: T, y: T) => string' is not assignable to type '(t: {}) => string'. + ~~ +!!! error TS2322: Type '(x: T, y: T) => string' is not assignable to type '(t: {}) => string'. +!!! related TS6500 tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments5.ts:3:27: The expected type comes from property 'cb' which is declared here on type '{ cb: (t: {}) => string; }' var r3 = foo({ cb: (x: string, y: number) => '' }); // error - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ cb: (x: string, y: number) => string; }' is not assignable to parameter of type '{ cb: (t: string) => string; }'. -!!! error TS2345: Types of property 'cb' are incompatible. -!!! error TS2345: Type '(x: string, y: number) => string' is not assignable to type '(t: string) => string'. + ~~ +!!! error TS2322: Type '(x: string, y: number) => string' is not assignable to type '(t: string) => string'. +!!! related TS6500 tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments5.ts:3:27: The expected type comes from property 'cb' which is declared here on type '{ cb: (t: string) => string; }' function foo2(arg: { cb: (t: T, t2: T) => U }) { return arg.cb(null, null); diff --git a/tests/baselines/reference/genericCallWithObjectLiteralArgs.errors.txt b/tests/baselines/reference/genericCallWithObjectLiteralArgs.errors.txt index c1724a8f698..22e19e10d80 100644 --- a/tests/baselines/reference/genericCallWithObjectLiteralArgs.errors.txt +++ b/tests/baselines/reference/genericCallWithObjectLiteralArgs.errors.txt @@ -1,6 +1,4 @@ -tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectLiteralArgs.ts(5,13): error TS2345: Argument of type '{ bar: number; baz: string; }' is not assignable to parameter of type '{ bar: number; baz: number; }'. - Types of property 'baz' are incompatible. - Type 'string' is not assignable to type 'number'. +tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectLiteralArgs.ts(5,23): error TS2322: Type 'string' is not assignable to type 'number'. ==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectLiteralArgs.ts (1 errors) ==== @@ -9,10 +7,9 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObj } var r = foo({ bar: 1, baz: '' }); // error - ~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ bar: number; baz: string; }' is not assignable to parameter of type '{ bar: number; baz: number; }'. -!!! error TS2345: Types of property 'baz' are incompatible. -!!! error TS2345: Type 'string' is not assignable to type 'number'. + ~~~ +!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! related TS6500 tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectLiteralArgs.ts:1:30: The expected type comes from property 'baz' which is declared here on type '{ bar: number; baz: number; }' var r2 = foo({ bar: 1, baz: 1 }); // T = number var r3 = foo({ bar: foo, baz: foo }); // T = typeof foo var r4 = foo({ bar: 1, baz: '' }); // T = Object \ No newline at end of file diff --git a/tests/baselines/reference/genericCallWithObjectLiteralArguments1.errors.txt b/tests/baselines/reference/genericCallWithObjectLiteralArguments1.errors.txt index cbc57364155..3537744ad39 100644 --- a/tests/baselines/reference/genericCallWithObjectLiteralArguments1.errors.txt +++ b/tests/baselines/reference/genericCallWithObjectLiteralArguments1.errors.txt @@ -1,45 +1,30 @@ -tests/cases/compiler/genericCallWithObjectLiteralArguments1.ts(3,13): error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type '{ x: number; y: number; }'. - Types of property 'y' are incompatible. - Type 'string' is not assignable to type 'number'. -tests/cases/compiler/genericCallWithObjectLiteralArguments1.ts(4,22): error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type '{ x: number; y: number; }'. - Types of property 'y' are incompatible. - Type 'string' is not assignable to type 'number'. -tests/cases/compiler/genericCallWithObjectLiteralArguments1.ts(5,22): error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type '{ x: string; y: string; }'. - Types of property 'x' are incompatible. - Type 'number' is not assignable to type 'string'. -tests/cases/compiler/genericCallWithObjectLiteralArguments1.ts(6,22): error TS2345: Argument of type '{ x: string; y: number; }' is not assignable to parameter of type '{ x: number; y: number; }'. - Types of property 'x' are incompatible. - Type 'string' is not assignable to type 'number'. -tests/cases/compiler/genericCallWithObjectLiteralArguments1.ts(7,22): error TS2345: Argument of type '{ x: string; y: number; }' is not assignable to parameter of type '{ x: string; y: string; }'. - Types of property 'y' are incompatible. - Type 'number' is not assignable to type 'string'. +tests/cases/compiler/genericCallWithObjectLiteralArguments1.ts(3,21): error TS2322: Type 'string' is not assignable to type 'number'. +tests/cases/compiler/genericCallWithObjectLiteralArguments1.ts(4,30): error TS2322: Type 'string' is not assignable to type 'number'. +tests/cases/compiler/genericCallWithObjectLiteralArguments1.ts(5,24): error TS2322: Type 'number' is not assignable to type 'string'. +tests/cases/compiler/genericCallWithObjectLiteralArguments1.ts(6,24): error TS2322: Type 'string' is not assignable to type 'number'. +tests/cases/compiler/genericCallWithObjectLiteralArguments1.ts(7,31): error TS2322: Type 'number' is not assignable to type 'string'. ==== tests/cases/compiler/genericCallWithObjectLiteralArguments1.ts (5 errors) ==== function foo(n: { x: T; y: T }, m: T) { return m; } // these are all errors var x = foo({ x: 3, y: "" }, 4); - ~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type '{ x: number; y: number; }'. -!!! error TS2345: Types of property 'y' are incompatible. -!!! error TS2345: Type 'string' is not assignable to type 'number'. + ~ +!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! related TS6500 tests/cases/compiler/genericCallWithObjectLiteralArguments1.ts:1:28: The expected type comes from property 'y' which is declared here on type '{ x: number; y: number; }' var x2 = foo({ x: 3, y: "" }, 4); - ~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type '{ x: number; y: number; }'. -!!! error TS2345: Types of property 'y' are incompatible. -!!! error TS2345: Type 'string' is not assignable to type 'number'. + ~ +!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! related TS6500 tests/cases/compiler/genericCallWithObjectLiteralArguments1.ts:1:28: The expected type comes from property 'y' which is declared here on type '{ x: number; y: number; }' var x3 = foo({ x: 3, y: "" }, 4); - ~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type '{ x: string; y: string; }'. -!!! error TS2345: Types of property 'x' are incompatible. -!!! error TS2345: Type 'number' is not assignable to type 'string'. + ~ +!!! error TS2322: Type 'number' is not assignable to type 'string'. +!!! related TS6500 tests/cases/compiler/genericCallWithObjectLiteralArguments1.ts:1:22: The expected type comes from property 'x' which is declared here on type '{ x: string; y: string; }' var x4 = foo({ x: "", y: 4 }, ""); - ~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ x: string; y: number; }' is not assignable to parameter of type '{ x: number; y: number; }'. -!!! error TS2345: Types of property 'x' are incompatible. -!!! error TS2345: Type 'string' is not assignable to type 'number'. + ~ +!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! related TS6500 tests/cases/compiler/genericCallWithObjectLiteralArguments1.ts:1:22: The expected type comes from property 'x' which is declared here on type '{ x: number; y: number; }' var x5 = foo({ x: "", y: 4 }, ""); - ~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ x: string; y: number; }' is not assignable to parameter of type '{ x: string; y: string; }'. -!!! error TS2345: Types of property 'y' are incompatible. -!!! error TS2345: Type 'number' is not assignable to type 'string'. \ No newline at end of file + ~ +!!! error TS2322: Type 'number' is not assignable to type 'string'. +!!! related TS6500 tests/cases/compiler/genericCallWithObjectLiteralArguments1.ts:1:28: The expected type comes from property 'y' which is declared here on type '{ x: string; y: string; }' \ No newline at end of file diff --git a/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints3.errors.txt b/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints3.errors.txt index ad07374b810..d6cbc5d17b7 100644 --- a/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints3.errors.txt +++ b/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints3.errors.txt @@ -1,7 +1,5 @@ -tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndConstraints3.ts(18,12): error TS2345: Argument of type '{ x: Derived; y: Derived2; }' is not assignable to parameter of type '{ x: Derived; y: Derived; }'. - Types of property 'y' are incompatible. - Type 'Derived2' is not assignable to type 'Derived'. - Property 'y' is missing in type 'Derived2'. +tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndConstraints3.ts(18,32): error TS2322: Type 'Derived2' is not assignable to type 'Derived'. + Property 'y' is missing in type 'Derived2'. ==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndConstraints3.ts (1 errors) ==== @@ -23,11 +21,10 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObj } var r1 = f({ x: new Derived(), y: new Derived2() }); // error because neither is supertype of the other - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ x: Derived; y: Derived2; }' is not assignable to parameter of type '{ x: Derived; y: Derived; }'. -!!! error TS2345: Types of property 'y' are incompatible. -!!! error TS2345: Type 'Derived2' is not assignable to type 'Derived'. -!!! error TS2345: Property 'y' is missing in type 'Derived2'. + ~ +!!! error TS2322: Type 'Derived2' is not assignable to type 'Derived'. +!!! error TS2322: Property 'y' is missing in type 'Derived2'. +!!! related TS6500 tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndConstraints3.ts:13:39: The expected type comes from property 'y' which is declared here on type '{ x: Derived; y: Derived; }' function f2(a: U) { var r: T; diff --git a/tests/baselines/reference/genericConstraintSatisfaction1.errors.txt b/tests/baselines/reference/genericConstraintSatisfaction1.errors.txt index ade053d9344..735900e3ef3 100644 --- a/tests/baselines/reference/genericConstraintSatisfaction1.errors.txt +++ b/tests/baselines/reference/genericConstraintSatisfaction1.errors.txt @@ -1,6 +1,4 @@ -tests/cases/compiler/genericConstraintSatisfaction1.ts(6,5): error TS2345: Argument of type '{ s: number; }' is not assignable to parameter of type '{ s: string; }'. - Types of property 's' are incompatible. - Type 'number' is not assignable to type 'string'. +tests/cases/compiler/genericConstraintSatisfaction1.ts(6,6): error TS2322: Type 'number' is not assignable to type 'string'. ==== tests/cases/compiler/genericConstraintSatisfaction1.ts (1 errors) ==== @@ -10,8 +8,7 @@ tests/cases/compiler/genericConstraintSatisfaction1.ts(6,5): error TS2345: Argum var x: I<{s: string}> x.f({s: 1}) - ~~~~~~ -!!! error TS2345: Argument of type '{ s: number; }' is not assignable to parameter of type '{ s: string; }'. -!!! error TS2345: Types of property 's' are incompatible. -!!! error TS2345: Type 'number' is not assignable to type 'string'. + ~ +!!! error TS2322: Type 'number' is not assignable to type 'string'. +!!! related TS6500 tests/cases/compiler/genericConstraintSatisfaction1.ts:5:11: The expected type comes from property 's' which is declared here on type '{ s: string; }' \ No newline at end of file diff --git a/tests/baselines/reference/indexedAccessRelation.errors.txt b/tests/baselines/reference/indexedAccessRelation.errors.txt index 84e65df856d..14dbee4d4c1 100644 --- a/tests/baselines/reference/indexedAccessRelation.errors.txt +++ b/tests/baselines/reference/indexedAccessRelation.errors.txt @@ -1,10 +1,8 @@ -tests/cases/compiler/indexedAccessRelation.ts(16,23): error TS2345: Argument of type '{ a: T; }' is not assignable to parameter of type 'Pick, "a">'. - Types of property 'a' are incompatible. - Type 'T' is not assignable to type 'S["a"] & T'. - Type 'Foo' is not assignable to type 'S["a"] & T'. +tests/cases/compiler/indexedAccessRelation.ts(16,25): error TS2322: Type 'T' is not assignable to type 'S["a"] & T'. + Type 'Foo' is not assignable to type 'S["a"] & T'. + Type 'Foo' is not assignable to type 'S["a"]'. + Type 'T' is not assignable to type 'S["a"]'. Type 'Foo' is not assignable to type 'S["a"]'. - Type 'T' is not assignable to type 'S["a"]'. - Type 'Foo' is not assignable to type 'S["a"]'. ==== tests/cases/compiler/indexedAccessRelation.ts (1 errors) ==== @@ -24,14 +22,13 @@ tests/cases/compiler/indexedAccessRelation.ts(16,23): error TS2345: Argument of { foo(a: T) { this.setState({ a: a }); - ~~~~~~~~ -!!! error TS2345: Argument of type '{ a: T; }' is not assignable to parameter of type 'Pick, "a">'. -!!! error TS2345: Types of property 'a' are incompatible. -!!! error TS2345: Type 'T' is not assignable to type 'S["a"] & T'. -!!! error TS2345: Type 'Foo' is not assignable to type 'S["a"] & T'. -!!! error TS2345: Type 'Foo' is not assignable to type 'S["a"]'. -!!! error TS2345: Type 'T' is not assignable to type 'S["a"]'. -!!! error TS2345: Type 'Foo' is not assignable to type 'S["a"]'. + ~ +!!! error TS2322: Type 'T' is not assignable to type 'S["a"] & T'. +!!! error TS2322: Type 'Foo' is not assignable to type 'S["a"] & T'. +!!! error TS2322: Type 'Foo' is not assignable to type 'S["a"]'. +!!! error TS2322: Type 'T' is not assignable to type 'S["a"]'. +!!! error TS2322: Type 'Foo' is not assignable to type 'S["a"]'. +!!! related TS6500 tests/cases/compiler/indexedAccessRelation.ts:8:5: The expected type comes from property 'a' which is declared here on type 'Pick, "a">' } } \ No newline at end of file diff --git a/tests/baselines/reference/infiniteConstraints.errors.txt b/tests/baselines/reference/infiniteConstraints.errors.txt index 7cc00a98a9e..cc420675872 100644 --- a/tests/baselines/reference/infiniteConstraints.errors.txt +++ b/tests/baselines/reference/infiniteConstraints.errors.txt @@ -55,10 +55,12 @@ tests/cases/compiler/infiniteConstraints.ts(36,71): error TS2536: Type '"foo"' c !!! error TS2345: Type 'Record<"val", "test">' is not assignable to type 'never'. const shouldBeError = ensureNoDuplicates({main: value("dup"), alternate: value("dup")}); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ main: Record<"val", "dup">; alternate: Record<"val", "dup">; }' is not assignable to parameter of type '{ main: never; alternate: never; }'. -!!! error TS2345: Types of property 'main' are incompatible. -!!! error TS2345: Type 'Record<"val", "dup">' is not assignable to type 'never'. + ~~~~ +!!! error TS2322: Type 'Record<"val", "dup">' is not assignable to type 'never'. +!!! related TS6500 tests/cases/compiler/infiniteConstraints.ts:31:43: The expected type comes from property 'main' which is declared here on type '{ main: never; alternate: never; }' + ~~~~~~~~~ +!!! error TS2322: Type 'Record<"val", "dup">' is not assignable to type 'never'. +!!! related TS6500 tests/cases/compiler/infiniteConstraints.ts:31:63: The expected type comes from property 'alternate' which is declared here on type '{ main: never; alternate: never; }' // Repro from #26448 diff --git a/tests/baselines/reference/invariantGenericErrorElaboration.errors.txt b/tests/baselines/reference/invariantGenericErrorElaboration.errors.txt index 5142b665d71..bf9c8065cea 100644 --- a/tests/baselines/reference/invariantGenericErrorElaboration.errors.txt +++ b/tests/baselines/reference/invariantGenericErrorElaboration.errors.txt @@ -8,9 +8,7 @@ tests/cases/compiler/invariantGenericErrorElaboration.ts(3,7): error TS2322: Typ Type 'Constraint>>' is not assignable to type 'Constraint>'. Types of property 'underlying' are incompatible. Type 'Constraint>' is not assignable to type 'Constraint'. -tests/cases/compiler/invariantGenericErrorElaboration.ts(4,17): error TS2345: Argument of type '{ foo: Num; }' is not assignable to parameter of type '{ [_: string]: Runtype; }'. - Property 'foo' is incompatible with index signature. - Type 'Num' is not assignable to type 'Runtype'. +tests/cases/compiler/invariantGenericErrorElaboration.ts(4,19): error TS2322: Type 'Num' is not assignable to type 'Runtype'. ==== tests/cases/compiler/invariantGenericErrorElaboration.ts (2 errors) ==== @@ -29,10 +27,9 @@ tests/cases/compiler/invariantGenericErrorElaboration.ts(4,17): error TS2345: Ar !!! error TS2322: Types of property 'underlying' are incompatible. !!! error TS2322: Type 'Constraint>' is not assignable to type 'Constraint'. const Foo = Obj({ foo: Num }) - ~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ foo: Num; }' is not assignable to parameter of type '{ [_: string]: Runtype; }'. -!!! error TS2345: Property 'foo' is incompatible with index signature. -!!! error TS2345: Type 'Num' is not assignable to type 'Runtype'. + ~~~ +!!! error TS2322: Type 'Num' is not assignable to type 'Runtype'. +!!! related TS6501 tests/cases/compiler/invariantGenericErrorElaboration.ts:17:34: The expected type comes from this index signature. interface Runtype { constraint: Constraint diff --git a/tests/baselines/reference/jsContainerMergeJsContainer.types b/tests/baselines/reference/jsContainerMergeJsContainer.types index 73e61aded0d..75d2152c571 100644 --- a/tests/baselines/reference/jsContainerMergeJsContainer.types +++ b/tests/baselines/reference/jsContainerMergeJsContainer.types @@ -6,18 +6,18 @@ const a = {}; a.d = function() {}; >a.d = function() {} : { (): void; prototype: {}; } ->a.d : { (): void; prototype: {}; } +>a.d : typeof a.d >a : typeof a ->d : { (): void; prototype: {}; } +>d : typeof a.d >function() {} : { (): void; prototype: {}; } === tests/cases/conformance/salsa/b.js === a.d.prototype = {}; >a.d.prototype = {} : {} >a.d.prototype : {} ->a.d : { (): void; prototype: {}; } +>a.d : typeof a.d >a : typeof a ->d : { (): void; prototype: {}; } +>d : typeof a.d >prototype : {} >{} : {} diff --git a/tests/baselines/reference/lastPropertyInLiteralWins.errors.txt b/tests/baselines/reference/lastPropertyInLiteralWins.errors.txt index 2b4a694975b..5e12521ad60 100644 --- a/tests/baselines/reference/lastPropertyInLiteralWins.errors.txt +++ b/tests/baselines/reference/lastPropertyInLiteralWins.errors.txt @@ -1,13 +1,12 @@ -tests/cases/compiler/lastPropertyInLiteralWins.ts(7,6): error TS2345: Argument of type '{ thunk: (num: number) => void; }' is not assignable to parameter of type 'Thing'. - Types of property 'thunk' are incompatible. - Type '(num: number) => void' is not assignable to type '(str: string) => void'. - Types of parameters 'num' and 'str' are incompatible. - Type 'string' is not assignable to type 'number'. +tests/cases/compiler/lastPropertyInLiteralWins.ts(8,5): error TS2322: Type '(num: number) => void' is not assignable to type '(str: string) => void'. + Types of parameters 'num' and 'str' are incompatible. + Type 'string' is not assignable to type 'number'. tests/cases/compiler/lastPropertyInLiteralWins.ts(9,5): error TS2300: Duplicate identifier 'thunk'. +tests/cases/compiler/lastPropertyInLiteralWins.ts(9,5): error TS2322: Type '(num: number) => void' is not assignable to type '(str: string) => void'. tests/cases/compiler/lastPropertyInLiteralWins.ts(14,5): error TS2300: Duplicate identifier 'thunk'. -==== tests/cases/compiler/lastPropertyInLiteralWins.ts (3 errors) ==== +==== tests/cases/compiler/lastPropertyInLiteralWins.ts (4 errors) ==== interface Thing { thunk: (str: string) => void; } @@ -15,20 +14,19 @@ tests/cases/compiler/lastPropertyInLiteralWins.ts(14,5): error TS2300: Duplicate thing.thunk("str"); } test({ // Should error, as last one wins, and is wrong type - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ thunk: (str: string) => {}, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~ +!!! error TS2322: Type '(num: number) => void' is not assignable to type '(str: string) => void'. +!!! error TS2322: Types of parameters 'num' and 'str' are incompatible. +!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! related TS6500 tests/cases/compiler/lastPropertyInLiteralWins.ts:2:5: The expected type comes from property 'thunk' which is declared here on type 'Thing' thunk: (num: number) => {} - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~ !!! error TS2300: Duplicate identifier 'thunk'. + ~~~~~ +!!! error TS2322: Type '(num: number) => void' is not assignable to type '(str: string) => void'. +!!! related TS6500 tests/cases/compiler/lastPropertyInLiteralWins.ts:2:5: The expected type comes from property 'thunk' which is declared here on type 'Thing' }); - ~ -!!! error TS2345: Argument of type '{ thunk: (num: number) => void; }' is not assignable to parameter of type 'Thing'. -!!! error TS2345: Types of property 'thunk' are incompatible. -!!! error TS2345: Type '(num: number) => void' is not assignable to type '(str: string) => void'. -!!! error TS2345: Types of parameters 'num' and 'str' are incompatible. -!!! error TS2345: Type 'string' is not assignable to type 'number'. test({ // Should be OK. Last 'thunk' is of correct type thunk: (num: number) => {}, diff --git a/tests/baselines/reference/mappedTypeErrors.errors.txt b/tests/baselines/reference/mappedTypeErrors.errors.txt index 99d8f9c7ad1..6d78b229fa4 100644 --- a/tests/baselines/reference/mappedTypeErrors.errors.txt +++ b/tests/baselines/reference/mappedTypeErrors.errors.txt @@ -27,14 +27,10 @@ tests/cases/conformance/types/mapped/mappedTypeErrors.ts(77,59): error TS2345: A Object literal may only specify known properties, and 'z' does not exist in type 'Readonly<{ x: number; y: number; }>'. tests/cases/conformance/types/mapped/mappedTypeErrors.ts(83,58): error TS2345: Argument of type '{ x: number; y: number; z: number; }' is not assignable to parameter of type 'Partial<{ x: number; y: number; }>'. Object literal may only specify known properties, and 'z' does not exist in type 'Partial<{ x: number; y: number; }>'. -tests/cases/conformance/types/mapped/mappedTypeErrors.ts(105,15): error TS2345: Argument of type '{ a: undefined; }' is not assignable to parameter of type 'Pick'. - Types of property 'a' are incompatible. - Type 'undefined' is not assignable to type 'string'. +tests/cases/conformance/types/mapped/mappedTypeErrors.ts(105,17): error TS2322: Type 'undefined' is not assignable to type 'string'. tests/cases/conformance/types/mapped/mappedTypeErrors.ts(106,17): error TS2345: Argument of type '{ c: boolean; }' is not assignable to parameter of type 'Pick'. Object literal may only specify known properties, and 'c' does not exist in type 'Pick'. -tests/cases/conformance/types/mapped/mappedTypeErrors.ts(123,12): error TS2345: Argument of type '{ a: undefined; }' is not assignable to parameter of type 'Pick'. - Types of property 'a' are incompatible. - Type 'undefined' is not assignable to type 'string'. +tests/cases/conformance/types/mapped/mappedTypeErrors.ts(123,14): error TS2322: Type 'undefined' is not assignable to type 'string'. tests/cases/conformance/types/mapped/mappedTypeErrors.ts(124,14): error TS2345: Argument of type '{ c: boolean; }' is not assignable to parameter of type 'Pick'. Object literal may only specify known properties, and 'c' does not exist in type 'Pick'. tests/cases/conformance/types/mapped/mappedTypeErrors.ts(128,16): error TS2322: Type 'string' is not assignable to type 'number | undefined'. @@ -196,10 +192,9 @@ tests/cases/conformance/types/mapped/mappedTypeErrors.ts(136,21): error TS2536: setState(foo, { }); setState(foo, foo); setState(foo, { a: undefined }); // Error - ~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ a: undefined; }' is not assignable to parameter of type 'Pick'. -!!! error TS2345: Types of property 'a' are incompatible. -!!! error TS2345: Type 'undefined' is not assignable to type 'string'. + ~ +!!! error TS2322: Type 'undefined' is not assignable to type 'string'. +!!! related TS6500 tests/cases/conformance/types/mapped/mappedTypeErrors.ts:89:5: The expected type comes from property 'a' which is declared here on type 'Pick' setState(foo, { c: true }); // Error ~~~~~~~ !!! error TS2345: Argument of type '{ c: boolean; }' is not assignable to parameter of type 'Pick'. @@ -221,10 +216,9 @@ tests/cases/conformance/types/mapped/mappedTypeErrors.ts(136,21): error TS2536: c.setState({ }); c.setState(foo); c.setState({ a: undefined }); // Error - ~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ a: undefined; }' is not assignable to parameter of type 'Pick'. -!!! error TS2345: Types of property 'a' are incompatible. -!!! error TS2345: Type 'undefined' is not assignable to type 'string'. + ~ +!!! error TS2322: Type 'undefined' is not assignable to type 'string'. +!!! related TS6500 tests/cases/conformance/types/mapped/mappedTypeErrors.ts:89:5: The expected type comes from property 'a' which is declared here on type 'Pick' c.setState({ c: true }); // Error ~~~~~~~ !!! error TS2345: Argument of type '{ c: boolean; }' is not assignable to parameter of type 'Pick'. diff --git a/tests/baselines/reference/mappedTypeInferenceErrors.errors.txt b/tests/baselines/reference/mappedTypeInferenceErrors.errors.txt index 28bc188f7b6..41edb0f6924 100644 --- a/tests/baselines/reference/mappedTypeInferenceErrors.errors.txt +++ b/tests/baselines/reference/mappedTypeInferenceErrors.errors.txt @@ -1,9 +1,4 @@ -tests/cases/conformance/types/mapped/mappedTypeInferenceErrors.ts(9,5): error TS2345: Argument of type '{ props: { x: number; y: number; }; computed: { bar(): number; baz: number; }; }' is not assignable to parameter of type '{ props: { x: number; y: number; }; computed: ComputedOf<{ bar: number; baz: {}; }>; } & ThisType<{ x: number; y: number; } & { bar: number; baz: {}; }>'. - Type '{ props: { x: number; y: number; }; computed: { bar(): number; baz: number; }; }' is not assignable to type '{ props: { x: number; y: number; }; computed: ComputedOf<{ bar: number; baz: {}; }>; }'. - Types of property 'computed' are incompatible. - Type '{ bar(): number; baz: number; }' is not assignable to type 'ComputedOf<{ bar: number; baz: {}; }>'. - Types of property 'baz' are incompatible. - Type 'number' is not assignable to type '() => {}'. +tests/cases/conformance/types/mapped/mappedTypeInferenceErrors.ts(16,9): error TS2322: Type 'number' is not assignable to type '() => {}'. ==== tests/cases/conformance/types/mapped/mappedTypeInferenceErrors.ts (1 errors) ==== @@ -16,29 +11,16 @@ tests/cases/conformance/types/mapped/mappedTypeInferenceErrors.ts(9,5): error TS declare function foo(options: { props: P, computed: ComputedOf } & ThisType

): void; foo({ - ~ props: { x: 10, y: 20 }, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ computed: { - ~~~~~~~~~~~~~~~ bar(): number { - ~~~~~~~~~~~~~~~~~~~~~~~ let z = this.bar; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ return 42; - ~~~~~~~~~~~~~~~~~~~~~~ }, - ~~~~~~~~~~ baz: 42 - ~~~~~~~~~~~~~~~ + ~~~ +!!! error TS2322: Type 'number' is not assignable to type '() => {}'. +!!! related TS6500 tests/cases/conformance/types/mapped/mappedTypeInferenceErrors.ts:16:9: The expected type comes from property 'baz' which is declared here on type 'ComputedOf<{ bar: number; baz: {}; }>' } - ~~~~~ }); - ~ -!!! error TS2345: Argument of type '{ props: { x: number; y: number; }; computed: { bar(): number; baz: number; }; }' is not assignable to parameter of type '{ props: { x: number; y: number; }; computed: ComputedOf<{ bar: number; baz: {}; }>; } & ThisType<{ x: number; y: number; } & { bar: number; baz: {}; }>'. -!!! error TS2345: Type '{ props: { x: number; y: number; }; computed: { bar(): number; baz: number; }; }' is not assignable to type '{ props: { x: number; y: number; }; computed: ComputedOf<{ bar: number; baz: {}; }>; }'. -!!! error TS2345: Types of property 'computed' are incompatible. -!!! error TS2345: Type '{ bar(): number; baz: number; }' is not assignable to type 'ComputedOf<{ bar: number; baz: {}; }>'. -!!! error TS2345: Types of property 'baz' are incompatible. -!!! error TS2345: Type 'number' is not assignable to type '() => {}'. \ No newline at end of file diff --git a/tests/baselines/reference/objectLitTargetTypeCallSite.errors.txt b/tests/baselines/reference/objectLitTargetTypeCallSite.errors.txt index 0d064af3935..6ced1a767de 100644 --- a/tests/baselines/reference/objectLitTargetTypeCallSite.errors.txt +++ b/tests/baselines/reference/objectLitTargetTypeCallSite.errors.txt @@ -1,6 +1,4 @@ -tests/cases/compiler/objectLitTargetTypeCallSite.ts(5,9): error TS2345: Argument of type '{ a: boolean; b: string; }' is not assignable to parameter of type '{ a: number; b: string; }'. - Types of property 'a' are incompatible. - Type 'boolean' is not assignable to type 'number'. +tests/cases/compiler/objectLitTargetTypeCallSite.ts(5,10): error TS2322: Type 'true' is not assignable to type 'number'. ==== tests/cases/compiler/objectLitTargetTypeCallSite.ts (1 errors) ==== @@ -9,7 +7,6 @@ tests/cases/compiler/objectLitTargetTypeCallSite.ts(5,9): error TS2345: Argument } process({a:true,b:"y"}); - ~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ a: boolean; b: string; }' is not assignable to parameter of type '{ a: number; b: string; }'. -!!! error TS2345: Types of property 'a' are incompatible. -!!! error TS2345: Type 'boolean' is not assignable to type 'number'. \ No newline at end of file + ~ +!!! error TS2322: Type 'true' is not assignable to type 'number'. +!!! related TS6500 tests/cases/compiler/objectLitTargetTypeCallSite.ts:1:23: The expected type comes from property 'a' which is declared here on type '{ a: number; b: string; }' \ No newline at end of file diff --git a/tests/baselines/reference/objectLiteralFunctionArgContextualTyping2.errors.txt b/tests/baselines/reference/objectLiteralFunctionArgContextualTyping2.errors.txt index 0117d2c0c8c..9fa7176779f 100644 --- a/tests/baselines/reference/objectLiteralFunctionArgContextualTyping2.errors.txt +++ b/tests/baselines/reference/objectLiteralFunctionArgContextualTyping2.errors.txt @@ -4,12 +4,9 @@ tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts(9,4): error TS Property 'doStuff' is missing in type '{ value: string; }'. tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts(10,17): error TS2345: Argument of type '{ value: string; what: number; }' is not assignable to parameter of type 'I2'. Object literal may only specify known properties, and 'what' does not exist in type 'I2'. -tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts(11,6): error TS2345: Argument of type '{ toString: (s: any) => any; }' is not assignable to parameter of type 'I2'. - Object literal may only specify known properties, and 'toString' does not exist in type 'I2'. -tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts(12,6): error TS2345: Argument of type '{ toString: (s: string) => string; }' is not assignable to parameter of type 'I2'. - Object literal may only specify known properties, and 'toString' does not exist in type 'I2'. -tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts(13,17): error TS2345: Argument of type '{ value: string; toString: (s: any) => any; }' is not assignable to parameter of type 'I2'. - Object literal may only specify known properties, and 'toString' does not exist in type 'I2'. +tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts(11,6): error TS2322: Type '(s: any) => any' is not assignable to type '() => string'. +tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts(12,6): error TS2322: Type '(s: string) => string' is not assignable to type '() => string'. +tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts(13,17): error TS2322: Type '(s: any) => any' is not assignable to type '() => string'. ==== tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts (6 errors) ==== @@ -33,14 +30,14 @@ tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts(13,17): error !!! error TS2345: Argument of type '{ value: string; what: number; }' is not assignable to parameter of type 'I2'. !!! error TS2345: Object literal may only specify known properties, and 'what' does not exist in type 'I2'. f2({ toString: (s) => s }) - ~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ toString: (s: any) => any; }' is not assignable to parameter of type 'I2'. -!!! error TS2345: Object literal may only specify known properties, and 'toString' does not exist in type 'I2'. + ~~~~~~~~ +!!! error TS2322: Type '(s: any) => any' is not assignable to type '() => string'. +!!! related TS6500 /.ts/lib.es5.d.ts:125:5: The expected type comes from property 'toString' which is declared here on type 'I2' f2({ toString: (s: string) => s }) - ~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ toString: (s: string) => string; }' is not assignable to parameter of type 'I2'. -!!! error TS2345: Object literal may only specify known properties, and 'toString' does not exist in type 'I2'. + ~~~~~~~~ +!!! error TS2322: Type '(s: string) => string' is not assignable to type '() => string'. +!!! related TS6500 /.ts/lib.es5.d.ts:125:5: The expected type comes from property 'toString' which is declared here on type 'I2' f2({ value: '', toString: (s) => s.uhhh }) - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ value: string; toString: (s: any) => any; }' is not assignable to parameter of type 'I2'. -!!! error TS2345: Object literal may only specify known properties, and 'toString' does not exist in type 'I2'. \ No newline at end of file + ~~~~~~~~ +!!! error TS2322: Type '(s: any) => any' is not assignable to type '() => string'. +!!! related TS6500 /.ts/lib.es5.d.ts:125:5: The expected type comes from property 'toString' which is declared here on type 'I2' \ No newline at end of file diff --git a/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentError.errors.txt b/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentError.errors.txt index e36842e4f69..7a425857bd6 100644 --- a/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentError.errors.txt +++ b/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentError.errors.txt @@ -2,9 +2,7 @@ tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPr Object literal may only specify known properties, and 'name' does not exist in type '{ b: string; id: number; }'. tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts(6,81): error TS2322: Type 'string' is not assignable to type 'number'. tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts(6,87): error TS2322: Type 'number' is not assignable to type 'string'. -tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts(8,5): error TS2345: Argument of type '{ name: string; id: number; }' is not assignable to parameter of type '{ name: string; id: boolean; }'. - Types of property 'id' are incompatible. - Type 'number' is not assignable to type 'boolean'. +tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts(8,13): error TS2322: Type 'number' is not assignable to type 'boolean'. ==== tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts (4 errors) ==== @@ -25,9 +23,8 @@ tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPr !!! related TS6500 tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts:6:43: The expected type comes from property 'id' which is declared here on type '{ id: string; name: number; }' function bar(obj: { name: string; id: boolean }) { } bar({ name, id }); // error - ~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ name: string; id: number; }' is not assignable to parameter of type '{ name: string; id: boolean; }'. -!!! error TS2345: Types of property 'id' are incompatible. -!!! error TS2345: Type 'number' is not assignable to type 'boolean'. + ~~ +!!! error TS2322: Type 'number' is not assignable to type 'boolean'. +!!! related TS6500 tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts:7:35: The expected type comes from property 'id' which is declared here on type '{ name: string; id: boolean; }' \ No newline at end of file diff --git a/tests/baselines/reference/objectSpreadNegative.errors.txt b/tests/baselines/reference/objectSpreadNegative.errors.txt index 92225755c71..1af05906873 100644 --- a/tests/baselines/reference/objectSpreadNegative.errors.txt +++ b/tests/baselines/reference/objectSpreadNegative.errors.txt @@ -18,15 +18,9 @@ tests/cases/conformance/types/spread/objectSpreadNegative.ts(53,9): error TS2339 tests/cases/conformance/types/spread/objectSpreadNegative.ts(58,11): error TS2339: Property 'a' does not exist on type '{}'. tests/cases/conformance/types/spread/objectSpreadNegative.ts(62,14): error TS2698: Spread types may only be created from object types. tests/cases/conformance/types/spread/objectSpreadNegative.ts(65,14): error TS2698: Spread types may only be created from object types. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(79,37): error TS2322: Type '{ a: string; b: string; extra: string; }' is not assignable to type 'A'. - Object literal may only specify known properties, and 'extra' does not exist in type 'A'. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(82,7): error TS2322: Type '{ a: string; b: string; extra: string; }' is not assignable to type 'A'. - Object literal may only specify known properties, and 'extra' does not exist in type 'A'. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(84,7): error TS2322: Type '{ a: string; b: string; extra: string; }' is not assignable to type 'A'. - Object literal may only specify known properties, and 'extra' does not exist in type 'A'. -==== tests/cases/conformance/types/spread/objectSpreadNegative.ts (20 errors) ==== +==== tests/cases/conformance/types/spread/objectSpreadNegative.ts (17 errors) ==== let o = { a: 1, b: 'no' } /// private propagates @@ -138,23 +132,4 @@ tests/cases/conformance/types/spread/objectSpreadNegative.ts(84,7): error TS2322 f({ a: 1 }, { a: 'mismatch' }) let overwriteId: { id: string, a: number, c: number, d: string } = f({ a: 1, id: true }, { c: 1, d: 'no' }) - - // excess property checks - type A = { a: string, b: string }; - type Extra = { a: string, b: string, extra: string }; - const extra1: A = { a: "a", b: "b", extra: "extra" }; - ~~~~~~~~~~~~~~ -!!! error TS2322: Type '{ a: string; b: string; extra: string; }' is not assignable to type 'A'. -!!! error TS2322: Object literal may only specify known properties, and 'extra' does not exist in type 'A'. - const extra2 = { a: "a", b: "b", extra: "extra" }; - const a1: A = { ...extra1 }; // error spans should be here - const a2: A = { ...extra2 }; // not on the symbol declarations above - ~~ -!!! error TS2322: Type '{ a: string; b: string; extra: string; }' is not assignable to type 'A'. -!!! error TS2322: Object literal may only specify known properties, and 'extra' does not exist in type 'A'. - const extra3: Extra = { a: "a", b: "b", extra: "extra" }; - const a3: A = { ...extra3 }; // same here - ~~ -!!! error TS2322: Type '{ a: string; b: string; extra: string; }' is not assignable to type 'A'. -!!! error TS2322: Object literal may only specify known properties, and 'extra' does not exist in type 'A'. \ No newline at end of file diff --git a/tests/baselines/reference/objectSpreadNegative.js b/tests/baselines/reference/objectSpreadNegative.js index 63ae8914385..35d8cdf9830 100644 --- a/tests/baselines/reference/objectSpreadNegative.js +++ b/tests/baselines/reference/objectSpreadNegative.js @@ -73,16 +73,6 @@ let overlapConflict: { id:string, a: string } = f({ a: 1 }, { a: 'mismatch' }) let overwriteId: { id: string, a: number, c: number, d: string } = f({ a: 1, id: true }, { c: 1, d: 'no' }) - -// excess property checks -type A = { a: string, b: string }; -type Extra = { a: string, b: string, extra: string }; -const extra1: A = { a: "a", b: "b", extra: "extra" }; -const extra2 = { a: "a", b: "b", extra: "extra" }; -const a1: A = { ...extra1 }; // error spans should be here -const a2: A = { ...extra2 }; // not on the symbol declarations above -const extra3: Extra = { a: "a", b: "b", extra: "extra" }; -const a3: A = { ...extra3 }; // same here //// [objectSpreadNegative.js] @@ -167,9 +157,3 @@ var exclusive = f({ a: 1, b: 'yes' }, { c: 'no', d: false }); var overlap = f({ a: 1 }, { a: 2, b: 'extra' }); var overlapConflict = f({ a: 1 }, { a: 'mismatch' }); var overwriteId = f({ a: 1, id: true }, { c: 1, d: 'no' }); -var extra1 = { a: "a", b: "b", extra: "extra" }; -var extra2 = { a: "a", b: "b", extra: "extra" }; -var a1 = __assign({}, extra1); // error spans should be here -var a2 = __assign({}, extra2); // not on the symbol declarations above -var extra3 = { a: "a", b: "b", extra: "extra" }; -var a3 = __assign({}, extra3); // same here diff --git a/tests/baselines/reference/objectSpreadNegative.symbols b/tests/baselines/reference/objectSpreadNegative.symbols index 21af20facbb..4bff16d9be6 100644 --- a/tests/baselines/reference/objectSpreadNegative.symbols +++ b/tests/baselines/reference/objectSpreadNegative.symbols @@ -243,50 +243,3 @@ let overwriteId: { id: string, a: number, c: number, d: string } = >c : Symbol(c, Decl(objectSpreadNegative.ts, 73, 27)) >d : Symbol(d, Decl(objectSpreadNegative.ts, 73, 33)) -// excess property checks -type A = { a: string, b: string }; ->A : Symbol(A, Decl(objectSpreadNegative.ts, 73, 44)) ->a : Symbol(a, Decl(objectSpreadNegative.ts, 76, 10)) ->b : Symbol(b, Decl(objectSpreadNegative.ts, 76, 21)) - -type Extra = { a: string, b: string, extra: string }; ->Extra : Symbol(Extra, Decl(objectSpreadNegative.ts, 76, 34)) ->a : Symbol(a, Decl(objectSpreadNegative.ts, 77, 14)) ->b : Symbol(b, Decl(objectSpreadNegative.ts, 77, 25)) ->extra : Symbol(extra, Decl(objectSpreadNegative.ts, 77, 36)) - -const extra1: A = { a: "a", b: "b", extra: "extra" }; ->extra1 : Symbol(extra1, Decl(objectSpreadNegative.ts, 78, 5)) ->A : Symbol(A, Decl(objectSpreadNegative.ts, 73, 44)) ->a : Symbol(a, Decl(objectSpreadNegative.ts, 78, 19)) ->b : Symbol(b, Decl(objectSpreadNegative.ts, 78, 27)) ->extra : Symbol(extra, Decl(objectSpreadNegative.ts, 78, 35)) - -const extra2 = { a: "a", b: "b", extra: "extra" }; ->extra2 : Symbol(extra2, Decl(objectSpreadNegative.ts, 79, 5)) ->a : Symbol(a, Decl(objectSpreadNegative.ts, 79, 16)) ->b : Symbol(b, Decl(objectSpreadNegative.ts, 79, 24)) ->extra : Symbol(extra, Decl(objectSpreadNegative.ts, 79, 32)) - -const a1: A = { ...extra1 }; // error spans should be here ->a1 : Symbol(a1, Decl(objectSpreadNegative.ts, 80, 5)) ->A : Symbol(A, Decl(objectSpreadNegative.ts, 73, 44)) ->extra1 : Symbol(extra1, Decl(objectSpreadNegative.ts, 78, 5)) - -const a2: A = { ...extra2 }; // not on the symbol declarations above ->a2 : Symbol(a2, Decl(objectSpreadNegative.ts, 81, 5)) ->A : Symbol(A, Decl(objectSpreadNegative.ts, 73, 44)) ->extra2 : Symbol(extra2, Decl(objectSpreadNegative.ts, 79, 5)) - -const extra3: Extra = { a: "a", b: "b", extra: "extra" }; ->extra3 : Symbol(extra3, Decl(objectSpreadNegative.ts, 82, 5)) ->Extra : Symbol(Extra, Decl(objectSpreadNegative.ts, 76, 34)) ->a : Symbol(a, Decl(objectSpreadNegative.ts, 82, 23)) ->b : Symbol(b, Decl(objectSpreadNegative.ts, 82, 31)) ->extra : Symbol(extra, Decl(objectSpreadNegative.ts, 82, 39)) - -const a3: A = { ...extra3 }; // same here ->a3 : Symbol(a3, Decl(objectSpreadNegative.ts, 83, 5)) ->A : Symbol(A, Decl(objectSpreadNegative.ts, 73, 44)) ->extra3 : Symbol(extra3, Decl(objectSpreadNegative.ts, 82, 5)) - diff --git a/tests/baselines/reference/objectSpreadNegative.types b/tests/baselines/reference/objectSpreadNegative.types index 0d0eab1c35d..26fd5642d23 100644 --- a/tests/baselines/reference/objectSpreadNegative.types +++ b/tests/baselines/reference/objectSpreadNegative.types @@ -325,60 +325,3 @@ let overwriteId: { id: string, a: number, c: number, d: string } = >d : string >'no' : "no" -// excess property checks -type A = { a: string, b: string }; ->A : A ->a : string ->b : string - -type Extra = { a: string, b: string, extra: string }; ->Extra : Extra ->a : string ->b : string ->extra : string - -const extra1: A = { a: "a", b: "b", extra: "extra" }; ->extra1 : A ->{ a: "a", b: "b", extra: "extra" } : { a: string; b: string; extra: string; } ->a : string ->"a" : "a" ->b : string ->"b" : "b" ->extra : string ->"extra" : "extra" - -const extra2 = { a: "a", b: "b", extra: "extra" }; ->extra2 : { a: string; b: string; extra: string; } ->{ a: "a", b: "b", extra: "extra" } : { a: string; b: string; extra: string; } ->a : string ->"a" : "a" ->b : string ->"b" : "b" ->extra : string ->"extra" : "extra" - -const a1: A = { ...extra1 }; // error spans should be here ->a1 : A ->{ ...extra1 } : { a: string; b: string; } ->extra1 : A - -const a2: A = { ...extra2 }; // not on the symbol declarations above ->a2 : A ->{ ...extra2 } : { a: string; b: string; extra: string; } ->extra2 : { a: string; b: string; extra: string; } - -const extra3: Extra = { a: "a", b: "b", extra: "extra" }; ->extra3 : Extra ->{ a: "a", b: "b", extra: "extra" } : { a: string; b: string; extra: string; } ->a : string ->"a" : "a" ->b : string ->"b" : "b" ->extra : string ->"extra" : "extra" - -const a3: A = { ...extra3 }; // same here ->a3 : A ->{ ...extra3 } : { a: string; b: string; extra: string; } ->extra3 : Extra - diff --git a/tests/baselines/reference/optionalBindingParameters1.errors.txt b/tests/baselines/reference/optionalBindingParameters1.errors.txt index f78f691d6eb..9ecf802f043 100644 --- a/tests/baselines/reference/optionalBindingParameters1.errors.txt +++ b/tests/baselines/reference/optionalBindingParameters1.errors.txt @@ -1,9 +1,9 @@ tests/cases/conformance/es6/destructuring/optionalBindingParameters1.ts(1,14): error TS2463: A binding pattern parameter cannot be optional in an implementation signature. -tests/cases/conformance/es6/destructuring/optionalBindingParameters1.ts(7,5): error TS2345: Argument of type '[boolean, number, string]' is not assignable to parameter of type '[string, number, boolean]'. - Type 'boolean' is not assignable to type 'string'. +tests/cases/conformance/es6/destructuring/optionalBindingParameters1.ts(7,6): error TS2322: Type 'false' is not assignable to type 'string'. +tests/cases/conformance/es6/destructuring/optionalBindingParameters1.ts(7,16): error TS2322: Type 'string' is not assignable to type 'boolean'. -==== tests/cases/conformance/es6/destructuring/optionalBindingParameters1.ts (2 errors) ==== +==== tests/cases/conformance/es6/destructuring/optionalBindingParameters1.ts (3 errors) ==== function foo([x,y,z]?: [string, number, boolean]) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2463: A binding pattern parameter cannot be optional in an implementation signature. @@ -13,6 +13,7 @@ tests/cases/conformance/es6/destructuring/optionalBindingParameters1.ts(7,5): er foo(["", 0, false]); foo([false, 0, ""]); - ~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '[boolean, number, string]' is not assignable to parameter of type '[string, number, boolean]'. -!!! error TS2345: Type 'boolean' is not assignable to type 'string'. \ No newline at end of file + ~~~~~ +!!! error TS2322: Type 'false' is not assignable to type 'string'. + ~~ +!!! error TS2322: Type 'string' is not assignable to type 'boolean'. \ No newline at end of file diff --git a/tests/baselines/reference/optionalBindingParameters2.errors.txt b/tests/baselines/reference/optionalBindingParameters2.errors.txt index f8b1aa73b2a..80f93ca8b64 100644 --- a/tests/baselines/reference/optionalBindingParameters2.errors.txt +++ b/tests/baselines/reference/optionalBindingParameters2.errors.txt @@ -1,10 +1,9 @@ tests/cases/conformance/es6/destructuring/optionalBindingParameters2.ts(1,14): error TS2463: A binding pattern parameter cannot be optional in an implementation signature. -tests/cases/conformance/es6/destructuring/optionalBindingParameters2.ts(7,5): error TS2345: Argument of type '{ x: boolean; y: number; z: string; }' is not assignable to parameter of type '{ x: string; y: number; z: boolean; }'. - Types of property 'x' are incompatible. - Type 'boolean' is not assignable to type 'string'. +tests/cases/conformance/es6/destructuring/optionalBindingParameters2.ts(7,7): error TS2322: Type 'false' is not assignable to type 'string'. +tests/cases/conformance/es6/destructuring/optionalBindingParameters2.ts(7,23): error TS2322: Type 'string' is not assignable to type 'boolean'. -==== tests/cases/conformance/es6/destructuring/optionalBindingParameters2.ts (2 errors) ==== +==== tests/cases/conformance/es6/destructuring/optionalBindingParameters2.ts (3 errors) ==== function foo({ x, y, z }?: { x: string; y: number; z: boolean }) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2463: A binding pattern parameter cannot be optional in an implementation signature. @@ -14,7 +13,9 @@ tests/cases/conformance/es6/destructuring/optionalBindingParameters2.ts(7,5): er foo({ x: "", y: 0, z: false }); foo({ x: false, y: 0, z: "" }); - ~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ x: boolean; y: number; z: string; }' is not assignable to parameter of type '{ x: string; y: number; z: boolean; }'. -!!! error TS2345: Types of property 'x' are incompatible. -!!! error TS2345: Type 'boolean' is not assignable to type 'string'. \ No newline at end of file + ~ +!!! error TS2322: Type 'false' is not assignable to type 'string'. +!!! related TS6500 tests/cases/conformance/es6/destructuring/optionalBindingParameters2.ts:1:30: The expected type comes from property 'x' which is declared here on type '{ x: string; y: number; z: boolean; }' + ~ +!!! error TS2322: Type 'string' is not assignable to type 'boolean'. +!!! related TS6500 tests/cases/conformance/es6/destructuring/optionalBindingParameters2.ts:1:52: The expected type comes from property 'z' which is declared here on type '{ x: string; y: number; z: boolean; }' \ No newline at end of file diff --git a/tests/baselines/reference/optionalBindingParametersInOverloads1.errors.txt b/tests/baselines/reference/optionalBindingParametersInOverloads1.errors.txt index d8e1c3c4aa6..5401ef79f2b 100644 --- a/tests/baselines/reference/optionalBindingParametersInOverloads1.errors.txt +++ b/tests/baselines/reference/optionalBindingParametersInOverloads1.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads1.ts(8,5): error TS2345: Argument of type '[boolean, number, string]' is not assignable to parameter of type '[string, number, boolean]'. - Type 'boolean' is not assignable to type 'string'. +tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads1.ts(8,6): error TS2322: Type 'false' is not assignable to type 'string'. +tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads1.ts(8,16): error TS2322: Type 'string' is not assignable to type 'boolean'. -==== tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads1.ts (1 errors) ==== +==== tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads1.ts (2 errors) ==== function foo([x, y, z] ?: [string, number, boolean]); function foo(...rest: any[]) { @@ -11,6 +11,7 @@ tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads1. foo(["", 0, false]); foo([false, 0, ""]); - ~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '[boolean, number, string]' is not assignable to parameter of type '[string, number, boolean]'. -!!! error TS2345: Type 'boolean' is not assignable to type 'string'. \ No newline at end of file + ~~~~~ +!!! error TS2322: Type 'false' is not assignable to type 'string'. + ~~ +!!! error TS2322: Type 'string' is not assignable to type 'boolean'. \ No newline at end of file diff --git a/tests/baselines/reference/optionalBindingParametersInOverloads2.errors.txt b/tests/baselines/reference/optionalBindingParametersInOverloads2.errors.txt index acc5c3721bb..86913394da6 100644 --- a/tests/baselines/reference/optionalBindingParametersInOverloads2.errors.txt +++ b/tests/baselines/reference/optionalBindingParametersInOverloads2.errors.txt @@ -1,9 +1,8 @@ -tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads2.ts(8,5): error TS2345: Argument of type '{ x: boolean; y: number; z: string; }' is not assignable to parameter of type '{ x: string; y: number; z: boolean; }'. - Types of property 'x' are incompatible. - Type 'boolean' is not assignable to type 'string'. +tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads2.ts(8,7): error TS2322: Type 'false' is not assignable to type 'string'. +tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads2.ts(8,23): error TS2322: Type 'string' is not assignable to type 'boolean'. -==== tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads2.ts (1 errors) ==== +==== tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads2.ts (2 errors) ==== function foo({ x, y, z }?: { x: string; y: number; z: boolean }); function foo(...rest: any[]) { @@ -12,7 +11,9 @@ tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads2. foo({ x: "", y: 0, z: false }); foo({ x: false, y: 0, z: "" }); - ~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ x: boolean; y: number; z: string; }' is not assignable to parameter of type '{ x: string; y: number; z: boolean; }'. -!!! error TS2345: Types of property 'x' are incompatible. -!!! error TS2345: Type 'boolean' is not assignable to type 'string'. \ No newline at end of file + ~ +!!! error TS2322: Type 'false' is not assignable to type 'string'. +!!! related TS6500 tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads2.ts:1:30: The expected type comes from property 'x' which is declared here on type '{ x: string; y: number; z: boolean; }' + ~ +!!! error TS2322: Type 'string' is not assignable to type 'boolean'. +!!! related TS6500 tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads2.ts:1:52: The expected type comes from property 'z' which is declared here on type '{ x: string; y: number; z: boolean; }' \ No newline at end of file diff --git a/tests/baselines/reference/overloadResolutionTest1.errors.txt b/tests/baselines/reference/overloadResolutionTest1.errors.txt index b36684db501..53ee7873472 100644 --- a/tests/baselines/reference/overloadResolutionTest1.errors.txt +++ b/tests/baselines/reference/overloadResolutionTest1.errors.txt @@ -2,12 +2,8 @@ tests/cases/compiler/overloadResolutionTest1.ts(7,16): error TS2345: Argument of Type '{ a: string; }' is not assignable to type '{ a: boolean; }'. Types of property 'a' are incompatible. Type 'string' is not assignable to type 'boolean'. -tests/cases/compiler/overloadResolutionTest1.ts(18,15): error TS2345: Argument of type '{ a: string; }' is not assignable to parameter of type '{ a: boolean; }'. - Types of property 'a' are incompatible. - Type 'string' is not assignable to type 'boolean'. -tests/cases/compiler/overloadResolutionTest1.ts(24,14): error TS2345: Argument of type '{ a: boolean; }' is not assignable to parameter of type '{ a: string; }'. - Types of property 'a' are incompatible. - Type 'boolean' is not assignable to type 'string'. +tests/cases/compiler/overloadResolutionTest1.ts(18,16): error TS2322: Type 'string' is not assignable to type 'boolean'. +tests/cases/compiler/overloadResolutionTest1.ts(24,15): error TS2322: Type 'true' is not assignable to type 'string'. ==== tests/cases/compiler/overloadResolutionTest1.ts (3 errors) ==== @@ -34,17 +30,15 @@ tests/cases/compiler/overloadResolutionTest1.ts(24,14): error TS2345: Argument o var x2 = foo2({a:0}); // works var x3 = foo2({a:true}); // works var x4 = foo2({a:"s"}); // error - ~~~~~~~ -!!! error TS2345: Argument of type '{ a: string; }' is not assignable to parameter of type '{ a: boolean; }'. -!!! error TS2345: Types of property 'a' are incompatible. -!!! error TS2345: Type 'string' is not assignable to type 'boolean'. + ~ +!!! error TS2322: Type 'string' is not assignable to type 'boolean'. +!!! related TS6500 tests/cases/compiler/overloadResolutionTest1.ts:13:20: The expected type comes from property 'a' which is declared here on type '{ a: boolean; }' function foo4(bar:{a:number;}):number; function foo4(bar:{a:string;}):string; function foo4(bar:{a:any;}):any{ return bar }; var x = foo4({a:true}); // error - ~~~~~~~~ -!!! error TS2345: Argument of type '{ a: boolean; }' is not assignable to parameter of type '{ a: string; }'. -!!! error TS2345: Types of property 'a' are incompatible. -!!! error TS2345: Type 'boolean' is not assignable to type 'string'. \ No newline at end of file + ~ +!!! error TS2322: Type 'true' is not assignable to type 'string'. +!!! related TS6500 tests/cases/compiler/overloadResolutionTest1.ts:22:20: The expected type comes from property 'a' which is declared here on type '{ a: string; }' \ No newline at end of file diff --git a/tests/baselines/reference/parameterInitializersForwardReferencing1.errors.txt b/tests/baselines/reference/parameterInitializersForwardReferencing1.errors.txt index 94f4175f5e5..73f4f27d08b 100644 --- a/tests/baselines/reference/parameterInitializersForwardReferencing1.errors.txt +++ b/tests/baselines/reference/parameterInitializersForwardReferencing1.errors.txt @@ -55,4 +55,6 @@ tests/cases/conformance/functions/parameterInitializersForwardReferencing1.ts(29 class Foo { constructor(public x = 12, public y = x) {} } + + function f8(foo1: string, bar = foo1) { } \ No newline at end of file diff --git a/tests/baselines/reference/parameterInitializersForwardReferencing1.js b/tests/baselines/reference/parameterInitializersForwardReferencing1.js index bb3a4c87e69..bd2b62e4216 100644 --- a/tests/baselines/reference/parameterInitializersForwardReferencing1.js +++ b/tests/baselines/reference/parameterInitializersForwardReferencing1.js @@ -34,6 +34,8 @@ function f7({[foo]: bar}: any[]) { class Foo { constructor(public x = 12, public y = x) {} } + +function f8(foo1: string, bar = foo1) { } //// [parameterInitializersForwardReferencing1.js] @@ -81,3 +83,6 @@ var Foo = /** @class */ (function () { } return Foo; }()); +function f8(foo1, bar) { + if (bar === void 0) { bar = foo1; } +} diff --git a/tests/baselines/reference/parameterInitializersForwardReferencing1.symbols b/tests/baselines/reference/parameterInitializersForwardReferencing1.symbols index 10f94a2bd64..74b00fe04b8 100644 --- a/tests/baselines/reference/parameterInitializersForwardReferencing1.symbols +++ b/tests/baselines/reference/parameterInitializersForwardReferencing1.symbols @@ -84,3 +84,9 @@ class Foo { >x : Symbol(x, Decl(parameterInitializersForwardReferencing1.ts, 33, 16)) } +function f8(foo1: string, bar = foo1) { } +>f8 : Symbol(f8, Decl(parameterInitializersForwardReferencing1.ts, 34, 1)) +>foo1 : Symbol(foo1, Decl(parameterInitializersForwardReferencing1.ts, 36, 12)) +>bar : Symbol(bar, Decl(parameterInitializersForwardReferencing1.ts, 36, 25)) +>foo1 : Symbol(foo1, Decl(parameterInitializersForwardReferencing1.ts, 36, 12)) + diff --git a/tests/baselines/reference/parameterInitializersForwardReferencing1.types b/tests/baselines/reference/parameterInitializersForwardReferencing1.types index d6eee6a9c30..2b80bfe87e0 100644 --- a/tests/baselines/reference/parameterInitializersForwardReferencing1.types +++ b/tests/baselines/reference/parameterInitializersForwardReferencing1.types @@ -92,3 +92,9 @@ class Foo { >x : number } +function f8(foo1: string, bar = foo1) { } +>f8 : (foo1: string, bar?: string) => void +>foo1 : string +>bar : string +>foo1 : string + diff --git a/tests/baselines/reference/parameterInitializersForwardReferencing1_es6.errors.txt b/tests/baselines/reference/parameterInitializersForwardReferencing1_es6.errors.txt index d84519e406e..90390fbe3a4 100644 --- a/tests/baselines/reference/parameterInitializersForwardReferencing1_es6.errors.txt +++ b/tests/baselines/reference/parameterInitializersForwardReferencing1_es6.errors.txt @@ -42,4 +42,6 @@ tests/cases/conformance/functions/parameterInitializersForwardReferencing1_es6.t class Foo { constructor(public x = 12, public y = x) {} } + + function f8(foo1: string, bar = foo1) { } \ No newline at end of file diff --git a/tests/baselines/reference/parameterInitializersForwardReferencing1_es6.js b/tests/baselines/reference/parameterInitializersForwardReferencing1_es6.js index a5b00cfeb44..ecabb8ceba9 100644 --- a/tests/baselines/reference/parameterInitializersForwardReferencing1_es6.js +++ b/tests/baselines/reference/parameterInitializersForwardReferencing1_es6.js @@ -34,6 +34,8 @@ function f7({[foo]: bar}: any[]) { class Foo { constructor(public x = 12, public y = x) {} } + +function f8(foo1: string, bar = foo1) { } //// [parameterInitializersForwardReferencing1_es6.js] @@ -67,3 +69,4 @@ class Foo { this.y = y; } } +function f8(foo1, bar = foo1) { } diff --git a/tests/baselines/reference/parameterInitializersForwardReferencing1_es6.symbols b/tests/baselines/reference/parameterInitializersForwardReferencing1_es6.symbols index 3d678a021ba..c0d42ab8b11 100644 --- a/tests/baselines/reference/parameterInitializersForwardReferencing1_es6.symbols +++ b/tests/baselines/reference/parameterInitializersForwardReferencing1_es6.symbols @@ -42,7 +42,7 @@ function f4 (foo, bar = foo) { >f4 : Symbol(f4, Decl(parameterInitializersForwardReferencing1_es6.ts, 14, 1)) >foo : Symbol(foo, Decl(parameterInitializersForwardReferencing1_es6.ts, 16, 13)) >bar : Symbol(bar, Decl(parameterInitializersForwardReferencing1_es6.ts, 16, 17)) ->foo : Symbol(foo, Decl(parameterInitializersForwardReferencing1_es6.ts, 0, 3)) +>foo : Symbol(foo, Decl(parameterInitializersForwardReferencing1_es6.ts, 16, 13)) return bar >bar : Symbol(bar, Decl(parameterInitializersForwardReferencing1_es6.ts, 16, 17)) @@ -84,3 +84,9 @@ class Foo { >x : Symbol(x, Decl(parameterInitializersForwardReferencing1_es6.ts, 33, 16)) } +function f8(foo1: string, bar = foo1) { } +>f8 : Symbol(f8, Decl(parameterInitializersForwardReferencing1_es6.ts, 34, 1)) +>foo1 : Symbol(foo1, Decl(parameterInitializersForwardReferencing1_es6.ts, 36, 12)) +>bar : Symbol(bar, Decl(parameterInitializersForwardReferencing1_es6.ts, 36, 25)) +>foo1 : Symbol(foo1, Decl(parameterInitializersForwardReferencing1_es6.ts, 36, 12)) + diff --git a/tests/baselines/reference/parameterInitializersForwardReferencing1_es6.types b/tests/baselines/reference/parameterInitializersForwardReferencing1_es6.types index ca8ae55557e..009ec47ddb8 100644 --- a/tests/baselines/reference/parameterInitializersForwardReferencing1_es6.types +++ b/tests/baselines/reference/parameterInitializersForwardReferencing1_es6.types @@ -45,13 +45,13 @@ function f3 (bar = foo, foo = 2) { // correct compiler error, error at runtime } function f4 (foo, bar = foo) { ->f4 : (foo: any, bar?: string) => string +>f4 : (foo: any, bar?: any) => any +>foo : any +>bar : any >foo : any ->bar : string ->foo : string return bar ->bar : string +>bar : any } function f5 (a = a) { @@ -92,3 +92,9 @@ class Foo { >x : number } +function f8(foo1: string, bar = foo1) { } +>f8 : (foo1: string, bar?: string) => void +>foo1 : string +>bar : string +>foo1 : string + diff --git a/tests/baselines/reference/spreadExcessProperty.js b/tests/baselines/reference/spreadExcessProperty.js new file mode 100644 index 00000000000..c5bf845224c --- /dev/null +++ b/tests/baselines/reference/spreadExcessProperty.js @@ -0,0 +1,20 @@ +//// [spreadExcessProperty.ts] +type A = { a: string, b: string }; +const extra1 = { a: "a", b: "b", extra: "extra" }; +const a1: A = { ...extra1 }; // spread should not give excess property errors + + +//// [spreadExcessProperty.js] +var __assign = (this && this.__assign) || function () { + __assign = Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); +}; +var extra1 = { a: "a", b: "b", extra: "extra" }; +var a1 = __assign({}, extra1); // spread should not give excess property errors diff --git a/tests/baselines/reference/spreadExcessProperty.symbols b/tests/baselines/reference/spreadExcessProperty.symbols new file mode 100644 index 00000000000..bc4ef206643 --- /dev/null +++ b/tests/baselines/reference/spreadExcessProperty.symbols @@ -0,0 +1,17 @@ +=== tests/cases/conformance/types/spread/spreadExcessProperty.ts === +type A = { a: string, b: string }; +>A : Symbol(A, Decl(spreadExcessProperty.ts, 0, 0)) +>a : Symbol(a, Decl(spreadExcessProperty.ts, 0, 10)) +>b : Symbol(b, Decl(spreadExcessProperty.ts, 0, 21)) + +const extra1 = { a: "a", b: "b", extra: "extra" }; +>extra1 : Symbol(extra1, Decl(spreadExcessProperty.ts, 1, 5)) +>a : Symbol(a, Decl(spreadExcessProperty.ts, 1, 16)) +>b : Symbol(b, Decl(spreadExcessProperty.ts, 1, 24)) +>extra : Symbol(extra, Decl(spreadExcessProperty.ts, 1, 32)) + +const a1: A = { ...extra1 }; // spread should not give excess property errors +>a1 : Symbol(a1, Decl(spreadExcessProperty.ts, 2, 5)) +>A : Symbol(A, Decl(spreadExcessProperty.ts, 0, 0)) +>extra1 : Symbol(extra1, Decl(spreadExcessProperty.ts, 1, 5)) + diff --git a/tests/baselines/reference/spreadExcessProperty.types b/tests/baselines/reference/spreadExcessProperty.types new file mode 100644 index 00000000000..015c7cc85aa --- /dev/null +++ b/tests/baselines/reference/spreadExcessProperty.types @@ -0,0 +1,21 @@ +=== tests/cases/conformance/types/spread/spreadExcessProperty.ts === +type A = { a: string, b: string }; +>A : A +>a : string +>b : string + +const extra1 = { a: "a", b: "b", extra: "extra" }; +>extra1 : { a: string; b: string; extra: string; } +>{ a: "a", b: "b", extra: "extra" } : { a: string; b: string; extra: string; } +>a : string +>"a" : "a" +>b : string +>"b" : "b" +>extra : string +>"extra" : "extra" + +const a1: A = { ...extra1 }; // spread should not give excess property errors +>a1 : A +>{ ...extra1 } : { a: string; b: string; extra: string; } +>extra1 : { a: string; b: string; extra: string; } + diff --git a/tests/baselines/reference/subtypingWithCallSignatures2.types b/tests/baselines/reference/subtypingWithCallSignatures2.types index 52b763cdaff..c8ac07429f3 100644 --- a/tests/baselines/reference/subtypingWithCallSignatures2.types +++ b/tests/baselines/reference/subtypingWithCallSignatures2.types @@ -737,20 +737,20 @@ var r14arg2 = (x: { a: string; b: number }) => null; >null : null var r14 = foo14(r14arg1); // any ->r14 : (x: { a: string; b: number; }) => Object ->foo14(r14arg1) : (x: { a: string; b: number; }) => Object +>r14 : any +>foo14(r14arg1) : any >foo14 : { (a: (x: { a: string; b: number; }) => Object): (x: { a: string; b: number; }) => Object; (a: any): any; } >r14arg1 : (x: { a: T; b: T; }) => T var r14a = [r14arg1, r14arg2]; ->r14a : ((x: { a: string; b: number; }) => Object)[] ->[r14arg1, r14arg2] : ((x: { a: string; b: number; }) => Object)[] +>r14a : (((x: { a: T; b: T; }) => T) | ((x: { a: string; b: number; }) => Object))[] +>[r14arg1, r14arg2] : (((x: { a: T; b: T; }) => T) | ((x: { a: string; b: number; }) => Object))[] >r14arg1 : (x: { a: T; b: T; }) => T >r14arg2 : (x: { a: string; b: number; }) => Object var r14b = [r14arg2, r14arg1]; ->r14b : ((x: { a: string; b: number; }) => Object)[] ->[r14arg2, r14arg1] : ((x: { a: string; b: number; }) => Object)[] +>r14b : (((x: { a: T; b: T; }) => T) | ((x: { a: string; b: number; }) => Object))[] +>[r14arg2, r14arg1] : (((x: { a: T; b: T; }) => T) | ((x: { a: string; b: number; }) => Object))[] >r14arg2 : (x: { a: string; b: number; }) => Object >r14arg1 : (x: { a: T; b: T; }) => T diff --git a/tests/baselines/reference/subtypingWithCallSignatures4.types b/tests/baselines/reference/subtypingWithCallSignatures4.types index e169885b87f..4a0b3416e56 100644 --- a/tests/baselines/reference/subtypingWithCallSignatures4.types +++ b/tests/baselines/reference/subtypingWithCallSignatures4.types @@ -381,14 +381,14 @@ var r11 = foo11(r11arg); >r11arg : (x: { foo: T; }, y: { foo: U; bar: U; }) => Base var r11a = [r11arg, r11arg2]; ->r11a : ((x: { foo: T; }, y: { foo: U; bar: U; }) => Base)[] ->[r11arg, r11arg2] : ((x: { foo: T; }, y: { foo: U; bar: U; }) => Base)[] +>r11a : ((x: { foo: T; }, y: { foo: T; bar: T; }) => Base)[] +>[r11arg, r11arg2] : ((x: { foo: T; }, y: { foo: T; bar: T; }) => Base)[] >r11arg : (x: { foo: T; }, y: { foo: U; bar: U; }) => Base >r11arg2 : (x: { foo: T; }, y: { foo: T; bar: T; }) => Base var r11b = [r11arg2, r11arg]; ->r11b : ((x: { foo: T; }, y: { foo: U; bar: U; }) => Base)[] ->[r11arg2, r11arg] : ((x: { foo: T; }, y: { foo: U; bar: U; }) => Base)[] +>r11b : ((x: { foo: T; }, y: { foo: T; bar: T; }) => Base)[] +>[r11arg2, r11arg] : ((x: { foo: T; }, y: { foo: T; bar: T; }) => Base)[] >r11arg2 : (x: { foo: T; }, y: { foo: T; bar: T; }) => Base >r11arg : (x: { foo: T; }, y: { foo: U; bar: U; }) => Base diff --git a/tests/baselines/reference/subtypingWithConstructSignatures2.types b/tests/baselines/reference/subtypingWithConstructSignatures2.types index 8021e2105fb..0d2ff802911 100644 --- a/tests/baselines/reference/subtypingWithConstructSignatures2.types +++ b/tests/baselines/reference/subtypingWithConstructSignatures2.types @@ -653,20 +653,20 @@ var r14arg2: new (x: { a: string; b: number }) => Object; >b : number var r14 = foo14(r14arg1); // any ->r14 : new (x: { a: string; b: number; }) => Object ->foo14(r14arg1) : new (x: { a: string; b: number; }) => Object +>r14 : any +>foo14(r14arg1) : any >foo14 : { (a: new (x: { a: string; b: number; }) => Object): new (x: { a: string; b: number; }) => Object; (a: any): any; } >r14arg1 : new (x: { a: T; b: T; }) => T var r14a = [r14arg1, r14arg2]; ->r14a : (new (x: { a: string; b: number; }) => Object)[] ->[r14arg1, r14arg2] : (new (x: { a: string; b: number; }) => Object)[] +>r14a : ((new (x: { a: T; b: T; }) => T) | (new (x: { a: string; b: number; }) => Object))[] +>[r14arg1, r14arg2] : ((new (x: { a: T; b: T; }) => T) | (new (x: { a: string; b: number; }) => Object))[] >r14arg1 : new (x: { a: T; b: T; }) => T >r14arg2 : new (x: { a: string; b: number; }) => Object var r14b = [r14arg2, r14arg1]; ->r14b : (new (x: { a: string; b: number; }) => Object)[] ->[r14arg2, r14arg1] : (new (x: { a: string; b: number; }) => Object)[] +>r14b : ((new (x: { a: T; b: T; }) => T) | (new (x: { a: string; b: number; }) => Object))[] +>[r14arg2, r14arg1] : ((new (x: { a: T; b: T; }) => T) | (new (x: { a: string; b: number; }) => Object))[] >r14arg2 : new (x: { a: string; b: number; }) => Object >r14arg1 : new (x: { a: T; b: T; }) => T diff --git a/tests/baselines/reference/subtypingWithConstructSignatures4.types b/tests/baselines/reference/subtypingWithConstructSignatures4.types index 412f7b2f73b..6c9881d1228 100644 --- a/tests/baselines/reference/subtypingWithConstructSignatures4.types +++ b/tests/baselines/reference/subtypingWithConstructSignatures4.types @@ -343,14 +343,14 @@ var r11 = foo11(r11arg); >r11arg : new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base var r11a = [r11arg, r11arg2]; ->r11a : (new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base)[] ->[r11arg, r11arg2] : (new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base)[] +>r11a : (new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base)[] +>[r11arg, r11arg2] : (new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base)[] >r11arg : new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base >r11arg2 : new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base var r11b = [r11arg2, r11arg]; ->r11b : (new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base)[] ->[r11arg2, r11arg] : (new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base)[] +>r11b : (new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base)[] +>[r11arg2, r11arg] : (new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base)[] >r11arg2 : new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base >r11arg : new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base diff --git a/tests/baselines/reference/subtypingWithConstructSignatures5.js b/tests/baselines/reference/subtypingWithConstructSignatures5.js index d3f47955ffc..de10469def0 100644 --- a/tests/baselines/reference/subtypingWithConstructSignatures5.js +++ b/tests/baselines/reference/subtypingWithConstructSignatures5.js @@ -45,7 +45,7 @@ interface I extends B { a11: new (x: T, y: T) => T; // ok a12: new >(x: Array, y: T) => Array; // ok, less specific parameter type a13: new >(x: Array, y: T) => T; // ok, T = Array, satisfies constraint, contextual signature instantiation succeeds - a14: new (x: { a: T; b: T }) => T; // ok, best common type yields T = {} but that's satisfactory for this signature + a14: new (x: { a: T; b: U }) => T; // ok } //// [subtypingWithConstructSignatures5.js] diff --git a/tests/baselines/reference/subtypingWithConstructSignatures5.symbols b/tests/baselines/reference/subtypingWithConstructSignatures5.symbols index cbb55d20155..2daf0631a09 100644 --- a/tests/baselines/reference/subtypingWithConstructSignatures5.symbols +++ b/tests/baselines/reference/subtypingWithConstructSignatures5.symbols @@ -302,13 +302,14 @@ interface I extends B { >T : Symbol(T, Decl(subtypingWithConstructSignatures5.ts, 45, 14)) >T : Symbol(T, Decl(subtypingWithConstructSignatures5.ts, 45, 14)) - a14: new (x: { a: T; b: T }) => T; // ok, best common type yields T = {} but that's satisfactory for this signature + a14: new (x: { a: T; b: U }) => T; // ok >a14 : Symbol(I.a14, Decl(subtypingWithConstructSignatures5.ts, 45, 67)) >T : Symbol(T, Decl(subtypingWithConstructSignatures5.ts, 46, 14)) ->x : Symbol(x, Decl(subtypingWithConstructSignatures5.ts, 46, 17)) ->a : Symbol(a, Decl(subtypingWithConstructSignatures5.ts, 46, 21)) ->T : Symbol(T, Decl(subtypingWithConstructSignatures5.ts, 46, 14)) ->b : Symbol(b, Decl(subtypingWithConstructSignatures5.ts, 46, 27)) +>U : Symbol(U, Decl(subtypingWithConstructSignatures5.ts, 46, 16)) +>x : Symbol(x, Decl(subtypingWithConstructSignatures5.ts, 46, 20)) +>a : Symbol(a, Decl(subtypingWithConstructSignatures5.ts, 46, 24)) >T : Symbol(T, Decl(subtypingWithConstructSignatures5.ts, 46, 14)) +>b : Symbol(b, Decl(subtypingWithConstructSignatures5.ts, 46, 30)) +>U : Symbol(U, Decl(subtypingWithConstructSignatures5.ts, 46, 16)) >T : Symbol(T, Decl(subtypingWithConstructSignatures5.ts, 46, 14)) } diff --git a/tests/baselines/reference/subtypingWithConstructSignatures5.types b/tests/baselines/reference/subtypingWithConstructSignatures5.types index a7adde7a480..d86cfe1c51d 100644 --- a/tests/baselines/reference/subtypingWithConstructSignatures5.types +++ b/tests/baselines/reference/subtypingWithConstructSignatures5.types @@ -180,9 +180,9 @@ interface I extends B { >x : Base[] >y : T - a14: new (x: { a: T; b: T }) => T; // ok, best common type yields T = {} but that's satisfactory for this signature ->a14 : new (x: { a: T; b: T; }) => T ->x : { a: T; b: T; } + a14: new (x: { a: T; b: U }) => T; // ok +>a14 : new (x: { a: T; b: U; }) => T +>x : { a: T; b: U; } >a : T ->b : T +>b : U } diff --git a/tests/baselines/reference/typeFromContextualThisType.symbols b/tests/baselines/reference/typeFromContextualThisType.symbols new file mode 100644 index 00000000000..c243123491d --- /dev/null +++ b/tests/baselines/reference/typeFromContextualThisType.symbols @@ -0,0 +1,40 @@ +=== tests/cases/conformance/salsa/bug25926.js === +/** @type {{ a(): void; b?(n: number): number; }} */ +const o1 = { +>o1 : Symbol(o1, Decl(bug25926.js, 1, 5)) + + a() { +>a : Symbol(a, Decl(bug25926.js, 1, 12)) + + this.b = n => n; +>this.b : Symbol(b, Decl(bug25926.js, 0, 23)) +>this : Symbol(__type, Decl(bug25926.js, 0, 11)) +>b : Symbol(b, Decl(bug25926.js, 2, 9)) +>n : Symbol(n, Decl(bug25926.js, 3, 16)) +>n : Symbol(n, Decl(bug25926.js, 3, 16)) + } +}; + +/** @type {{ d(): void; e?(n: number): number; f?(n: number): number; g?: number }} */ +const o2 = { +>o2 : Symbol(o2, Decl(bug25926.js, 8, 5)) + + d() { +>d : Symbol(d, Decl(bug25926.js, 8, 12)) + + this.e = this.f = m => this.g || m; +>this.e : Symbol(e, Decl(bug25926.js, 7, 23)) +>this : Symbol(__type, Decl(bug25926.js, 7, 11)) +>e : Symbol(e, Decl(bug25926.js, 9, 9)) +>this.f : Symbol(f, Decl(bug25926.js, 7, 46)) +>this : Symbol(__type, Decl(bug25926.js, 7, 11)) +>f : Symbol(f, Decl(bug25926.js, 10, 16)) +>m : Symbol(m, Decl(bug25926.js, 10, 25)) +>this.g : Symbol(g, Decl(bug25926.js, 7, 69)) +>this : Symbol(__type, Decl(bug25926.js, 7, 11)) +>g : Symbol(g, Decl(bug25926.js, 7, 69)) +>m : Symbol(m, Decl(bug25926.js, 10, 25)) + } +}; + + diff --git a/tests/baselines/reference/typeFromContextualThisType.types b/tests/baselines/reference/typeFromContextualThisType.types new file mode 100644 index 00000000000..fc6e3961800 --- /dev/null +++ b/tests/baselines/reference/typeFromContextualThisType.types @@ -0,0 +1,48 @@ +=== tests/cases/conformance/salsa/bug25926.js === +/** @type {{ a(): void; b?(n: number): number; }} */ +const o1 = { +>o1 : { a(): void; } +>{ a() { this.b = n => n; }} : { a(): void; } + + a() { +>a : () => void + + this.b = n => n; +>this.b = n => n : (n: number) => number +>this.b : ((n: number) => number) | undefined +>this : { a(): void; } +>b : ((n: number) => number) | undefined +>n => n : (n: number) => number +>n : number +>n : number + } +}; + +/** @type {{ d(): void; e?(n: number): number; f?(n: number): number; g?: number }} */ +const o2 = { +>o2 : { d(): void; g?: number | undefined; } +>{ d() { this.e = this.f = m => this.g || m; }} : { d(): void; } + + d() { +>d : () => void + + this.e = this.f = m => this.g || m; +>this.e = this.f = m => this.g || m : (m: number) => number +>this.e : ((n: number) => number) | undefined +>this : { d(): void; g?: number | undefined; } +>e : ((n: number) => number) | undefined +>this.f = m => this.g || m : (m: number) => number +>this.f : ((n: number) => number) | undefined +>this : { d(): void; g?: number | undefined; } +>f : ((n: number) => number) | undefined +>m => this.g || m : (m: number) => number +>m : number +>this.g || m : number +>this.g : number | undefined +>this : { d(): void; g?: number | undefined; } +>g : number | undefined +>m : number + } +}; + + diff --git a/tests/baselines/reference/typeFromPropertyAssignment31.errors.txt b/tests/baselines/reference/typeFromPropertyAssignment31.errors.txt new file mode 100644 index 00000000000..6055e89ffec --- /dev/null +++ b/tests/baselines/reference/typeFromPropertyAssignment31.errors.txt @@ -0,0 +1,36 @@ +tests/cases/conformance/salsa/typeFromPropertyAssignment31.ts(13,1): error TS2322: Type 'false' is not assignable to type 'number'. +tests/cases/conformance/salsa/typeFromPropertyAssignment31.ts(25,1): error TS2322: Type 'false' is not assignable to type 'number'. + + +==== tests/cases/conformance/salsa/typeFromPropertyAssignment31.ts (2 errors) ==== + function ExpandoMerge(n: number) { + return n; + } + ExpandoMerge.p1 = 111 + ExpandoMerge.m = function(n: number) { + return n + 1; + } + namespace ExpandoMerge { + export var p2 = 222; + } + ExpandoMerge.p4 = 44444; // ok + ExpandoMerge.p6 = 66666; // ok + ExpandoMerge.p8 = false; // type error + ~~~~~~~~~~~~~~~ +!!! error TS2322: Type 'false' is not assignable to type 'number'. + namespace ExpandoMerge { + export var p3 = 333; + export var p4 = 4; + export var p5 = 5; + export let p6 = 6; + export let p7 = 7; + export var p8 = 6; + export let p9 = 7; + } + ExpandoMerge.p5 = 555555; // ok + ExpandoMerge.p7 = 777777; // ok + ExpandoMerge.p9 = false; // type error + ~~~~~~~~~~~~~~~ +!!! error TS2322: Type 'false' is not assignable to type 'number'. + var n = ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 + ExpandoMerge.p7 + ExpandoMerge.p8 + ExpandoMerge.p9 + ExpandoMerge.m(12) + ExpandoMerge(1001); + \ No newline at end of file diff --git a/tests/baselines/reference/typeFromPropertyAssignment31.js b/tests/baselines/reference/typeFromPropertyAssignment31.js new file mode 100644 index 00000000000..e5c9bda9550 --- /dev/null +++ b/tests/baselines/reference/typeFromPropertyAssignment31.js @@ -0,0 +1,56 @@ +//// [typeFromPropertyAssignment31.ts] +function ExpandoMerge(n: number) { + return n; +} +ExpandoMerge.p1 = 111 +ExpandoMerge.m = function(n: number) { + return n + 1; +} +namespace ExpandoMerge { + export var p2 = 222; +} +ExpandoMerge.p4 = 44444; // ok +ExpandoMerge.p6 = 66666; // ok +ExpandoMerge.p8 = false; // type error +namespace ExpandoMerge { + export var p3 = 333; + export var p4 = 4; + export var p5 = 5; + export let p6 = 6; + export let p7 = 7; + export var p8 = 6; + export let p9 = 7; +} +ExpandoMerge.p5 = 555555; // ok +ExpandoMerge.p7 = 777777; // ok +ExpandoMerge.p9 = false; // type error +var n = ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 + ExpandoMerge.p7 + ExpandoMerge.p8 + ExpandoMerge.p9 + ExpandoMerge.m(12) + ExpandoMerge(1001); + + +//// [typeFromPropertyAssignment31.js] +function ExpandoMerge(n) { + return n; +} +ExpandoMerge.p1 = 111; +ExpandoMerge.m = function (n) { + return n + 1; +}; +(function (ExpandoMerge) { + ExpandoMerge.p2 = 222; +})(ExpandoMerge || (ExpandoMerge = {})); +ExpandoMerge.p4 = 44444; // ok +ExpandoMerge.p6 = 66666; // ok +ExpandoMerge.p8 = false; // type error +(function (ExpandoMerge) { + ExpandoMerge.p3 = 333; + ExpandoMerge.p4 = 4; + ExpandoMerge.p5 = 5; + ExpandoMerge.p6 = 6; + ExpandoMerge.p7 = 7; + ExpandoMerge.p8 = 6; + ExpandoMerge.p9 = 7; +})(ExpandoMerge || (ExpandoMerge = {})); +ExpandoMerge.p5 = 555555; // ok +ExpandoMerge.p7 = 777777; // ok +ExpandoMerge.p9 = false; // type error +var n = ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 + ExpandoMerge.p7 + ExpandoMerge.p8 + ExpandoMerge.p9 + ExpandoMerge.m(12) + ExpandoMerge(1001); diff --git a/tests/baselines/reference/typeFromPropertyAssignment31.symbols b/tests/baselines/reference/typeFromPropertyAssignment31.symbols new file mode 100644 index 00000000000..e5a6de9c82a --- /dev/null +++ b/tests/baselines/reference/typeFromPropertyAssignment31.symbols @@ -0,0 +1,116 @@ +=== tests/cases/conformance/salsa/typeFromPropertyAssignment31.ts === +function ExpandoMerge(n: number) { +>ExpandoMerge : Symbol(ExpandoMerge, Decl(typeFromPropertyAssignment31.ts, 0, 0), Decl(typeFromPropertyAssignment31.ts, 3, 21), Decl(typeFromPropertyAssignment31.ts, 6, 1), Decl(typeFromPropertyAssignment31.ts, 12, 24)) +>n : Symbol(n, Decl(typeFromPropertyAssignment31.ts, 0, 22)) + + return n; +>n : Symbol(n, Decl(typeFromPropertyAssignment31.ts, 0, 22)) +} +ExpandoMerge.p1 = 111 +>ExpandoMerge.p1 : Symbol(ExpandoMerge.p1, Decl(typeFromPropertyAssignment31.ts, 2, 1)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(typeFromPropertyAssignment31.ts, 0, 0), Decl(typeFromPropertyAssignment31.ts, 3, 21), Decl(typeFromPropertyAssignment31.ts, 6, 1), Decl(typeFromPropertyAssignment31.ts, 12, 24)) +>p1 : Symbol(ExpandoMerge.p1, Decl(typeFromPropertyAssignment31.ts, 2, 1)) + +ExpandoMerge.m = function(n: number) { +>ExpandoMerge.m : Symbol(ExpandoMerge.m, Decl(typeFromPropertyAssignment31.ts, 3, 21)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(typeFromPropertyAssignment31.ts, 0, 0), Decl(typeFromPropertyAssignment31.ts, 3, 21), Decl(typeFromPropertyAssignment31.ts, 6, 1), Decl(typeFromPropertyAssignment31.ts, 12, 24)) +>m : Symbol(ExpandoMerge.m, Decl(typeFromPropertyAssignment31.ts, 3, 21)) +>n : Symbol(n, Decl(typeFromPropertyAssignment31.ts, 4, 26)) + + return n + 1; +>n : Symbol(n, Decl(typeFromPropertyAssignment31.ts, 4, 26)) +} +namespace ExpandoMerge { +>ExpandoMerge : Symbol(ExpandoMerge, Decl(typeFromPropertyAssignment31.ts, 0, 0), Decl(typeFromPropertyAssignment31.ts, 3, 21), Decl(typeFromPropertyAssignment31.ts, 6, 1), Decl(typeFromPropertyAssignment31.ts, 12, 24)) + + export var p2 = 222; +>p2 : Symbol(p2, Decl(typeFromPropertyAssignment31.ts, 8, 14)) +} +ExpandoMerge.p4 = 44444; // ok +>ExpandoMerge.p4 : Symbol(ExpandoMerge.p4, Decl(typeFromPropertyAssignment31.ts, 9, 1), Decl(typeFromPropertyAssignment31.ts, 15, 14)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(typeFromPropertyAssignment31.ts, 0, 0), Decl(typeFromPropertyAssignment31.ts, 3, 21), Decl(typeFromPropertyAssignment31.ts, 6, 1), Decl(typeFromPropertyAssignment31.ts, 12, 24)) +>p4 : Symbol(ExpandoMerge.p4, Decl(typeFromPropertyAssignment31.ts, 9, 1), Decl(typeFromPropertyAssignment31.ts, 15, 14)) + +ExpandoMerge.p6 = 66666; // ok +>ExpandoMerge.p6 : Symbol(ExpandoMerge.p6, Decl(typeFromPropertyAssignment31.ts, 10, 24), Decl(typeFromPropertyAssignment31.ts, 17, 14)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(typeFromPropertyAssignment31.ts, 0, 0), Decl(typeFromPropertyAssignment31.ts, 3, 21), Decl(typeFromPropertyAssignment31.ts, 6, 1), Decl(typeFromPropertyAssignment31.ts, 12, 24)) +>p6 : Symbol(ExpandoMerge.p6, Decl(typeFromPropertyAssignment31.ts, 10, 24), Decl(typeFromPropertyAssignment31.ts, 17, 14)) + +ExpandoMerge.p8 = false; // type error +>ExpandoMerge.p8 : Symbol(ExpandoMerge.p8, Decl(typeFromPropertyAssignment31.ts, 11, 24), Decl(typeFromPropertyAssignment31.ts, 19, 14)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(typeFromPropertyAssignment31.ts, 0, 0), Decl(typeFromPropertyAssignment31.ts, 3, 21), Decl(typeFromPropertyAssignment31.ts, 6, 1), Decl(typeFromPropertyAssignment31.ts, 12, 24)) +>p8 : Symbol(ExpandoMerge.p8, Decl(typeFromPropertyAssignment31.ts, 11, 24), Decl(typeFromPropertyAssignment31.ts, 19, 14)) + +namespace ExpandoMerge { +>ExpandoMerge : Symbol(ExpandoMerge, Decl(typeFromPropertyAssignment31.ts, 0, 0), Decl(typeFromPropertyAssignment31.ts, 3, 21), Decl(typeFromPropertyAssignment31.ts, 6, 1), Decl(typeFromPropertyAssignment31.ts, 12, 24)) + + export var p3 = 333; +>p3 : Symbol(p3, Decl(typeFromPropertyAssignment31.ts, 14, 14)) + + export var p4 = 4; +>p4 : Symbol(p4, Decl(typeFromPropertyAssignment31.ts, 9, 1), Decl(typeFromPropertyAssignment31.ts, 15, 14)) + + export var p5 = 5; +>p5 : Symbol(p5, Decl(typeFromPropertyAssignment31.ts, 16, 14), Decl(typeFromPropertyAssignment31.ts, 21, 1)) + + export let p6 = 6; +>p6 : Symbol(p6, Decl(typeFromPropertyAssignment31.ts, 10, 24), Decl(typeFromPropertyAssignment31.ts, 17, 14)) + + export let p7 = 7; +>p7 : Symbol(p7, Decl(typeFromPropertyAssignment31.ts, 18, 14), Decl(typeFromPropertyAssignment31.ts, 22, 25)) + + export var p8 = 6; +>p8 : Symbol(p8, Decl(typeFromPropertyAssignment31.ts, 11, 24), Decl(typeFromPropertyAssignment31.ts, 19, 14)) + + export let p9 = 7; +>p9 : Symbol(p9, Decl(typeFromPropertyAssignment31.ts, 20, 14), Decl(typeFromPropertyAssignment31.ts, 23, 25)) +} +ExpandoMerge.p5 = 555555; // ok +>ExpandoMerge.p5 : Symbol(ExpandoMerge.p5, Decl(typeFromPropertyAssignment31.ts, 16, 14), Decl(typeFromPropertyAssignment31.ts, 21, 1)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(typeFromPropertyAssignment31.ts, 0, 0), Decl(typeFromPropertyAssignment31.ts, 3, 21), Decl(typeFromPropertyAssignment31.ts, 6, 1), Decl(typeFromPropertyAssignment31.ts, 12, 24)) +>p5 : Symbol(ExpandoMerge.p5, Decl(typeFromPropertyAssignment31.ts, 16, 14), Decl(typeFromPropertyAssignment31.ts, 21, 1)) + +ExpandoMerge.p7 = 777777; // ok +>ExpandoMerge.p7 : Symbol(ExpandoMerge.p7, Decl(typeFromPropertyAssignment31.ts, 18, 14), Decl(typeFromPropertyAssignment31.ts, 22, 25)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(typeFromPropertyAssignment31.ts, 0, 0), Decl(typeFromPropertyAssignment31.ts, 3, 21), Decl(typeFromPropertyAssignment31.ts, 6, 1), Decl(typeFromPropertyAssignment31.ts, 12, 24)) +>p7 : Symbol(ExpandoMerge.p7, Decl(typeFromPropertyAssignment31.ts, 18, 14), Decl(typeFromPropertyAssignment31.ts, 22, 25)) + +ExpandoMerge.p9 = false; // type error +>ExpandoMerge.p9 : Symbol(ExpandoMerge.p9, Decl(typeFromPropertyAssignment31.ts, 20, 14), Decl(typeFromPropertyAssignment31.ts, 23, 25)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(typeFromPropertyAssignment31.ts, 0, 0), Decl(typeFromPropertyAssignment31.ts, 3, 21), Decl(typeFromPropertyAssignment31.ts, 6, 1), Decl(typeFromPropertyAssignment31.ts, 12, 24)) +>p9 : Symbol(ExpandoMerge.p9, Decl(typeFromPropertyAssignment31.ts, 20, 14), Decl(typeFromPropertyAssignment31.ts, 23, 25)) + +var n = ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 + ExpandoMerge.p7 + ExpandoMerge.p8 + ExpandoMerge.p9 + ExpandoMerge.m(12) + ExpandoMerge(1001); +>n : Symbol(n, Decl(typeFromPropertyAssignment31.ts, 25, 3)) +>ExpandoMerge.p1 : Symbol(ExpandoMerge.p1, Decl(typeFromPropertyAssignment31.ts, 2, 1)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(typeFromPropertyAssignment31.ts, 0, 0), Decl(typeFromPropertyAssignment31.ts, 3, 21), Decl(typeFromPropertyAssignment31.ts, 6, 1), Decl(typeFromPropertyAssignment31.ts, 12, 24)) +>p1 : Symbol(ExpandoMerge.p1, Decl(typeFromPropertyAssignment31.ts, 2, 1)) +>ExpandoMerge.p2 : Symbol(ExpandoMerge.p2, Decl(typeFromPropertyAssignment31.ts, 8, 14)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(typeFromPropertyAssignment31.ts, 0, 0), Decl(typeFromPropertyAssignment31.ts, 3, 21), Decl(typeFromPropertyAssignment31.ts, 6, 1), Decl(typeFromPropertyAssignment31.ts, 12, 24)) +>p2 : Symbol(ExpandoMerge.p2, Decl(typeFromPropertyAssignment31.ts, 8, 14)) +>ExpandoMerge.p3 : Symbol(ExpandoMerge.p3, Decl(typeFromPropertyAssignment31.ts, 14, 14)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(typeFromPropertyAssignment31.ts, 0, 0), Decl(typeFromPropertyAssignment31.ts, 3, 21), Decl(typeFromPropertyAssignment31.ts, 6, 1), Decl(typeFromPropertyAssignment31.ts, 12, 24)) +>p3 : Symbol(ExpandoMerge.p3, Decl(typeFromPropertyAssignment31.ts, 14, 14)) +>ExpandoMerge.p4 : Symbol(ExpandoMerge.p4, Decl(typeFromPropertyAssignment31.ts, 9, 1), Decl(typeFromPropertyAssignment31.ts, 15, 14)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(typeFromPropertyAssignment31.ts, 0, 0), Decl(typeFromPropertyAssignment31.ts, 3, 21), Decl(typeFromPropertyAssignment31.ts, 6, 1), Decl(typeFromPropertyAssignment31.ts, 12, 24)) +>p4 : Symbol(ExpandoMerge.p4, Decl(typeFromPropertyAssignment31.ts, 9, 1), Decl(typeFromPropertyAssignment31.ts, 15, 14)) +>ExpandoMerge.p5 : Symbol(ExpandoMerge.p5, Decl(typeFromPropertyAssignment31.ts, 16, 14), Decl(typeFromPropertyAssignment31.ts, 21, 1)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(typeFromPropertyAssignment31.ts, 0, 0), Decl(typeFromPropertyAssignment31.ts, 3, 21), Decl(typeFromPropertyAssignment31.ts, 6, 1), Decl(typeFromPropertyAssignment31.ts, 12, 24)) +>p5 : Symbol(ExpandoMerge.p5, Decl(typeFromPropertyAssignment31.ts, 16, 14), Decl(typeFromPropertyAssignment31.ts, 21, 1)) +>ExpandoMerge.p6 : Symbol(ExpandoMerge.p6, Decl(typeFromPropertyAssignment31.ts, 10, 24), Decl(typeFromPropertyAssignment31.ts, 17, 14)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(typeFromPropertyAssignment31.ts, 0, 0), Decl(typeFromPropertyAssignment31.ts, 3, 21), Decl(typeFromPropertyAssignment31.ts, 6, 1), Decl(typeFromPropertyAssignment31.ts, 12, 24)) +>p6 : Symbol(ExpandoMerge.p6, Decl(typeFromPropertyAssignment31.ts, 10, 24), Decl(typeFromPropertyAssignment31.ts, 17, 14)) +>ExpandoMerge.p7 : Symbol(ExpandoMerge.p7, Decl(typeFromPropertyAssignment31.ts, 18, 14), Decl(typeFromPropertyAssignment31.ts, 22, 25)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(typeFromPropertyAssignment31.ts, 0, 0), Decl(typeFromPropertyAssignment31.ts, 3, 21), Decl(typeFromPropertyAssignment31.ts, 6, 1), Decl(typeFromPropertyAssignment31.ts, 12, 24)) +>p7 : Symbol(ExpandoMerge.p7, Decl(typeFromPropertyAssignment31.ts, 18, 14), Decl(typeFromPropertyAssignment31.ts, 22, 25)) +>ExpandoMerge.p8 : Symbol(ExpandoMerge.p8, Decl(typeFromPropertyAssignment31.ts, 11, 24), Decl(typeFromPropertyAssignment31.ts, 19, 14)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(typeFromPropertyAssignment31.ts, 0, 0), Decl(typeFromPropertyAssignment31.ts, 3, 21), Decl(typeFromPropertyAssignment31.ts, 6, 1), Decl(typeFromPropertyAssignment31.ts, 12, 24)) +>p8 : Symbol(ExpandoMerge.p8, Decl(typeFromPropertyAssignment31.ts, 11, 24), Decl(typeFromPropertyAssignment31.ts, 19, 14)) +>ExpandoMerge.p9 : Symbol(ExpandoMerge.p9, Decl(typeFromPropertyAssignment31.ts, 20, 14), Decl(typeFromPropertyAssignment31.ts, 23, 25)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(typeFromPropertyAssignment31.ts, 0, 0), Decl(typeFromPropertyAssignment31.ts, 3, 21), Decl(typeFromPropertyAssignment31.ts, 6, 1), Decl(typeFromPropertyAssignment31.ts, 12, 24)) +>p9 : Symbol(ExpandoMerge.p9, Decl(typeFromPropertyAssignment31.ts, 20, 14), Decl(typeFromPropertyAssignment31.ts, 23, 25)) +>ExpandoMerge.m : Symbol(ExpandoMerge.m, Decl(typeFromPropertyAssignment31.ts, 3, 21)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(typeFromPropertyAssignment31.ts, 0, 0), Decl(typeFromPropertyAssignment31.ts, 3, 21), Decl(typeFromPropertyAssignment31.ts, 6, 1), Decl(typeFromPropertyAssignment31.ts, 12, 24)) +>m : Symbol(ExpandoMerge.m, Decl(typeFromPropertyAssignment31.ts, 3, 21)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(typeFromPropertyAssignment31.ts, 0, 0), Decl(typeFromPropertyAssignment31.ts, 3, 21), Decl(typeFromPropertyAssignment31.ts, 6, 1), Decl(typeFromPropertyAssignment31.ts, 12, 24)) + diff --git a/tests/baselines/reference/typeFromPropertyAssignment31.types b/tests/baselines/reference/typeFromPropertyAssignment31.types new file mode 100644 index 00000000000..e302d58d507 --- /dev/null +++ b/tests/baselines/reference/typeFromPropertyAssignment31.types @@ -0,0 +1,156 @@ +=== tests/cases/conformance/salsa/typeFromPropertyAssignment31.ts === +function ExpandoMerge(n: number) { +>ExpandoMerge : typeof ExpandoMerge +>n : number + + return n; +>n : number +} +ExpandoMerge.p1 = 111 +>ExpandoMerge.p1 = 111 : 111 +>ExpandoMerge.p1 : number +>ExpandoMerge : typeof ExpandoMerge +>p1 : number +>111 : 111 + +ExpandoMerge.m = function(n: number) { +>ExpandoMerge.m = function(n: number) { return n + 1;} : (n: number) => number +>ExpandoMerge.m : (n: number) => number +>ExpandoMerge : typeof ExpandoMerge +>m : (n: number) => number +>function(n: number) { return n + 1;} : (n: number) => number +>n : number + + return n + 1; +>n + 1 : number +>n : number +>1 : 1 +} +namespace ExpandoMerge { +>ExpandoMerge : typeof ExpandoMerge + + export var p2 = 222; +>p2 : number +>222 : 222 +} +ExpandoMerge.p4 = 44444; // ok +>ExpandoMerge.p4 = 44444 : 44444 +>ExpandoMerge.p4 : number +>ExpandoMerge : typeof ExpandoMerge +>p4 : number +>44444 : 44444 + +ExpandoMerge.p6 = 66666; // ok +>ExpandoMerge.p6 = 66666 : 66666 +>ExpandoMerge.p6 : number +>ExpandoMerge : typeof ExpandoMerge +>p6 : number +>66666 : 66666 + +ExpandoMerge.p8 = false; // type error +>ExpandoMerge.p8 = false : false +>ExpandoMerge.p8 : number +>ExpandoMerge : typeof ExpandoMerge +>p8 : number +>false : false + +namespace ExpandoMerge { +>ExpandoMerge : typeof ExpandoMerge + + export var p3 = 333; +>p3 : number +>333 : 333 + + export var p4 = 4; +>p4 : number +>4 : 4 + + export var p5 = 5; +>p5 : number +>5 : 5 + + export let p6 = 6; +>p6 : number +>6 : 6 + + export let p7 = 7; +>p7 : number +>7 : 7 + + export var p8 = 6; +>p8 : number +>6 : 6 + + export let p9 = 7; +>p9 : number +>7 : 7 +} +ExpandoMerge.p5 = 555555; // ok +>ExpandoMerge.p5 = 555555 : 555555 +>ExpandoMerge.p5 : number +>ExpandoMerge : typeof ExpandoMerge +>p5 : number +>555555 : 555555 + +ExpandoMerge.p7 = 777777; // ok +>ExpandoMerge.p7 = 777777 : 777777 +>ExpandoMerge.p7 : number +>ExpandoMerge : typeof ExpandoMerge +>p7 : number +>777777 : 777777 + +ExpandoMerge.p9 = false; // type error +>ExpandoMerge.p9 = false : false +>ExpandoMerge.p9 : number +>ExpandoMerge : typeof ExpandoMerge +>p9 : number +>false : false + +var n = ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 + ExpandoMerge.p7 + ExpandoMerge.p8 + ExpandoMerge.p9 + ExpandoMerge.m(12) + ExpandoMerge(1001); +>n : number +>ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 + ExpandoMerge.p7 + ExpandoMerge.p8 + ExpandoMerge.p9 + ExpandoMerge.m(12) + ExpandoMerge(1001) : number +>ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 + ExpandoMerge.p7 + ExpandoMerge.p8 + ExpandoMerge.p9 + ExpandoMerge.m(12) : number +>ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 + ExpandoMerge.p7 + ExpandoMerge.p8 + ExpandoMerge.p9 : number +>ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 + ExpandoMerge.p7 + ExpandoMerge.p8 : number +>ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 + ExpandoMerge.p7 : number +>ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 : number +>ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 : number +>ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 : number +>ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 : number +>ExpandoMerge.p1 + ExpandoMerge.p2 : number +>ExpandoMerge.p1 : number +>ExpandoMerge : typeof ExpandoMerge +>p1 : number +>ExpandoMerge.p2 : number +>ExpandoMerge : typeof ExpandoMerge +>p2 : number +>ExpandoMerge.p3 : number +>ExpandoMerge : typeof ExpandoMerge +>p3 : number +>ExpandoMerge.p4 : number +>ExpandoMerge : typeof ExpandoMerge +>p4 : number +>ExpandoMerge.p5 : number +>ExpandoMerge : typeof ExpandoMerge +>p5 : number +>ExpandoMerge.p6 : number +>ExpandoMerge : typeof ExpandoMerge +>p6 : number +>ExpandoMerge.p7 : number +>ExpandoMerge : typeof ExpandoMerge +>p7 : number +>ExpandoMerge.p8 : number +>ExpandoMerge : typeof ExpandoMerge +>p8 : number +>ExpandoMerge.p9 : number +>ExpandoMerge : typeof ExpandoMerge +>p9 : number +>ExpandoMerge.m(12) : number +>ExpandoMerge.m : (n: number) => number +>ExpandoMerge : typeof ExpandoMerge +>m : (n: number) => number +>12 : 12 +>ExpandoMerge(1001) : number +>ExpandoMerge : typeof ExpandoMerge +>1001 : 1001 + diff --git a/tests/baselines/reference/typeFromPropertyAssignment32.errors.txt b/tests/baselines/reference/typeFromPropertyAssignment32.errors.txt new file mode 100644 index 00000000000..bd8d4b003d8 --- /dev/null +++ b/tests/baselines/reference/typeFromPropertyAssignment32.errors.txt @@ -0,0 +1,44 @@ +tests/cases/conformance/salsa/expando.ts(12,1): error TS2322: Type 'false' is not assignable to type 'number'. +tests/cases/conformance/salsa/expando.ts(13,1): error TS2322: Type 'false' is not assignable to type 'number'. +tests/cases/conformance/salsa/ns.ts(1,11): error TS2433: A namespace declaration cannot be in a different file from a class or function with which it is merged. +tests/cases/conformance/salsa/ns.ts(10,11): error TS2433: A namespace declaration cannot be in a different file from a class or function with which it is merged. + + +==== tests/cases/conformance/salsa/expando.ts (2 errors) ==== + function ExpandoMerge(n: number) { + return n; + } + ExpandoMerge.p1 = 111 + ExpandoMerge.m = function(n: number) { + return n + 1; + } + ExpandoMerge.p4 = 44444; + ExpandoMerge.p5 = 555555; + ExpandoMerge.p6 = 66666; + ExpandoMerge.p7 = 777777; + ExpandoMerge.p8 = false; // type error + ~~~~~~~~~~~~~~~ +!!! error TS2322: Type 'false' is not assignable to type 'number'. + ExpandoMerge.p9 = false; // type error + ~~~~~~~~~~~~~~~ +!!! error TS2322: Type 'false' is not assignable to type 'number'. + var n = ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 + ExpandoMerge.p7 + ExpandoMerge.p8 + ExpandoMerge.p9 + ExpandoMerge.m(12) + ExpandoMerge(1001); + +==== tests/cases/conformance/salsa/ns.ts (2 errors) ==== + namespace ExpandoMerge { + ~~~~~~~~~~~~ +!!! error TS2433: A namespace declaration cannot be in a different file from a class or function with which it is merged. + export var p3 = 333; + export var p4 = 4; + export var p5 = 5; + export let p6 = 6; + export let p7 = 7; + export var p8 = 6; + export let p9 = 7; + } + namespace ExpandoMerge { + ~~~~~~~~~~~~ +!!! error TS2433: A namespace declaration cannot be in a different file from a class or function with which it is merged. + export var p2 = 222; + } + \ No newline at end of file diff --git a/tests/baselines/reference/typeFromPropertyAssignment32.js b/tests/baselines/reference/typeFromPropertyAssignment32.js new file mode 100644 index 00000000000..d805f678358 --- /dev/null +++ b/tests/baselines/reference/typeFromPropertyAssignment32.js @@ -0,0 +1,62 @@ +//// [tests/cases/conformance/salsa/typeFromPropertyAssignment32.ts] //// + +//// [expando.ts] +function ExpandoMerge(n: number) { + return n; +} +ExpandoMerge.p1 = 111 +ExpandoMerge.m = function(n: number) { + return n + 1; +} +ExpandoMerge.p4 = 44444; +ExpandoMerge.p5 = 555555; +ExpandoMerge.p6 = 66666; +ExpandoMerge.p7 = 777777; +ExpandoMerge.p8 = false; // type error +ExpandoMerge.p9 = false; // type error +var n = ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 + ExpandoMerge.p7 + ExpandoMerge.p8 + ExpandoMerge.p9 + ExpandoMerge.m(12) + ExpandoMerge(1001); + +//// [ns.ts] +namespace ExpandoMerge { + export var p3 = 333; + export var p4 = 4; + export var p5 = 5; + export let p6 = 6; + export let p7 = 7; + export var p8 = 6; + export let p9 = 7; +} +namespace ExpandoMerge { + export var p2 = 222; +} + + +//// [expando.js] +function ExpandoMerge(n) { + return n; +} +ExpandoMerge.p1 = 111; +ExpandoMerge.m = function (n) { + return n + 1; +}; +ExpandoMerge.p4 = 44444; +ExpandoMerge.p5 = 555555; +ExpandoMerge.p6 = 66666; +ExpandoMerge.p7 = 777777; +ExpandoMerge.p8 = false; // type error +ExpandoMerge.p9 = false; // type error +var n = ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 + ExpandoMerge.p7 + ExpandoMerge.p8 + ExpandoMerge.p9 + ExpandoMerge.m(12) + ExpandoMerge(1001); +//// [ns.js] +var ExpandoMerge; +(function (ExpandoMerge) { + ExpandoMerge.p3 = 333; + ExpandoMerge.p4 = 4; + ExpandoMerge.p5 = 5; + ExpandoMerge.p6 = 6; + ExpandoMerge.p7 = 7; + ExpandoMerge.p8 = 6; + ExpandoMerge.p9 = 7; +})(ExpandoMerge || (ExpandoMerge = {})); +(function (ExpandoMerge) { + ExpandoMerge.p2 = 222; +})(ExpandoMerge || (ExpandoMerge = {})); diff --git a/tests/baselines/reference/typeFromPropertyAssignment32.symbols b/tests/baselines/reference/typeFromPropertyAssignment32.symbols new file mode 100644 index 00000000000..d730f4d7e11 --- /dev/null +++ b/tests/baselines/reference/typeFromPropertyAssignment32.symbols @@ -0,0 +1,118 @@ +=== tests/cases/conformance/salsa/expando.ts === +function ExpandoMerge(n: number) { +>ExpandoMerge : Symbol(ExpandoMerge, Decl(expando.ts, 0, 0), Decl(expando.ts, 3, 21), Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1)) +>n : Symbol(n, Decl(expando.ts, 0, 22)) + + return n; +>n : Symbol(n, Decl(expando.ts, 0, 22)) +} +ExpandoMerge.p1 = 111 +>ExpandoMerge.p1 : Symbol(ExpandoMerge.p1, Decl(expando.ts, 2, 1)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(expando.ts, 0, 0), Decl(expando.ts, 3, 21), Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1)) +>p1 : Symbol(ExpandoMerge.p1, Decl(expando.ts, 2, 1)) + +ExpandoMerge.m = function(n: number) { +>ExpandoMerge.m : Symbol(ExpandoMerge.m, Decl(expando.ts, 3, 21)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(expando.ts, 0, 0), Decl(expando.ts, 3, 21), Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1)) +>m : Symbol(ExpandoMerge.m, Decl(expando.ts, 3, 21)) +>n : Symbol(n, Decl(expando.ts, 4, 26)) + + return n + 1; +>n : Symbol(n, Decl(expando.ts, 4, 26)) +} +ExpandoMerge.p4 = 44444; +>ExpandoMerge.p4 : Symbol(ExpandoMerge.p4, Decl(expando.ts, 6, 1), Decl(ns.ts, 2, 14)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(expando.ts, 0, 0), Decl(expando.ts, 3, 21), Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1)) +>p4 : Symbol(ExpandoMerge.p4, Decl(expando.ts, 6, 1), Decl(ns.ts, 2, 14)) + +ExpandoMerge.p5 = 555555; +>ExpandoMerge.p5 : Symbol(ExpandoMerge.p5, Decl(expando.ts, 7, 24), Decl(ns.ts, 3, 14)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(expando.ts, 0, 0), Decl(expando.ts, 3, 21), Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1)) +>p5 : Symbol(ExpandoMerge.p5, Decl(expando.ts, 7, 24), Decl(ns.ts, 3, 14)) + +ExpandoMerge.p6 = 66666; +>ExpandoMerge.p6 : Symbol(ExpandoMerge.p6, Decl(expando.ts, 8, 25), Decl(ns.ts, 4, 14)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(expando.ts, 0, 0), Decl(expando.ts, 3, 21), Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1)) +>p6 : Symbol(ExpandoMerge.p6, Decl(expando.ts, 8, 25), Decl(ns.ts, 4, 14)) + +ExpandoMerge.p7 = 777777; +>ExpandoMerge.p7 : Symbol(ExpandoMerge.p7, Decl(expando.ts, 9, 24), Decl(ns.ts, 5, 14)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(expando.ts, 0, 0), Decl(expando.ts, 3, 21), Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1)) +>p7 : Symbol(ExpandoMerge.p7, Decl(expando.ts, 9, 24), Decl(ns.ts, 5, 14)) + +ExpandoMerge.p8 = false; // type error +>ExpandoMerge.p8 : Symbol(ExpandoMerge.p8, Decl(expando.ts, 10, 25), Decl(ns.ts, 6, 14)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(expando.ts, 0, 0), Decl(expando.ts, 3, 21), Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1)) +>p8 : Symbol(ExpandoMerge.p8, Decl(expando.ts, 10, 25), Decl(ns.ts, 6, 14)) + +ExpandoMerge.p9 = false; // type error +>ExpandoMerge.p9 : Symbol(ExpandoMerge.p9, Decl(expando.ts, 11, 24), Decl(ns.ts, 7, 14)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(expando.ts, 0, 0), Decl(expando.ts, 3, 21), Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1)) +>p9 : Symbol(ExpandoMerge.p9, Decl(expando.ts, 11, 24), Decl(ns.ts, 7, 14)) + +var n = ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 + ExpandoMerge.p7 + ExpandoMerge.p8 + ExpandoMerge.p9 + ExpandoMerge.m(12) + ExpandoMerge(1001); +>n : Symbol(n, Decl(expando.ts, 13, 3)) +>ExpandoMerge.p1 : Symbol(ExpandoMerge.p1, Decl(expando.ts, 2, 1)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(expando.ts, 0, 0), Decl(expando.ts, 3, 21), Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1)) +>p1 : Symbol(ExpandoMerge.p1, Decl(expando.ts, 2, 1)) +>ExpandoMerge.p2 : Symbol(ExpandoMerge.p2, Decl(ns.ts, 10, 14)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(expando.ts, 0, 0), Decl(expando.ts, 3, 21), Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1)) +>p2 : Symbol(ExpandoMerge.p2, Decl(ns.ts, 10, 14)) +>ExpandoMerge.p3 : Symbol(ExpandoMerge.p3, Decl(ns.ts, 1, 14)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(expando.ts, 0, 0), Decl(expando.ts, 3, 21), Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1)) +>p3 : Symbol(ExpandoMerge.p3, Decl(ns.ts, 1, 14)) +>ExpandoMerge.p4 : Symbol(ExpandoMerge.p4, Decl(expando.ts, 6, 1), Decl(ns.ts, 2, 14)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(expando.ts, 0, 0), Decl(expando.ts, 3, 21), Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1)) +>p4 : Symbol(ExpandoMerge.p4, Decl(expando.ts, 6, 1), Decl(ns.ts, 2, 14)) +>ExpandoMerge.p5 : Symbol(ExpandoMerge.p5, Decl(expando.ts, 7, 24), Decl(ns.ts, 3, 14)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(expando.ts, 0, 0), Decl(expando.ts, 3, 21), Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1)) +>p5 : Symbol(ExpandoMerge.p5, Decl(expando.ts, 7, 24), Decl(ns.ts, 3, 14)) +>ExpandoMerge.p6 : Symbol(ExpandoMerge.p6, Decl(expando.ts, 8, 25), Decl(ns.ts, 4, 14)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(expando.ts, 0, 0), Decl(expando.ts, 3, 21), Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1)) +>p6 : Symbol(ExpandoMerge.p6, Decl(expando.ts, 8, 25), Decl(ns.ts, 4, 14)) +>ExpandoMerge.p7 : Symbol(ExpandoMerge.p7, Decl(expando.ts, 9, 24), Decl(ns.ts, 5, 14)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(expando.ts, 0, 0), Decl(expando.ts, 3, 21), Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1)) +>p7 : Symbol(ExpandoMerge.p7, Decl(expando.ts, 9, 24), Decl(ns.ts, 5, 14)) +>ExpandoMerge.p8 : Symbol(ExpandoMerge.p8, Decl(expando.ts, 10, 25), Decl(ns.ts, 6, 14)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(expando.ts, 0, 0), Decl(expando.ts, 3, 21), Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1)) +>p8 : Symbol(ExpandoMerge.p8, Decl(expando.ts, 10, 25), Decl(ns.ts, 6, 14)) +>ExpandoMerge.p9 : Symbol(ExpandoMerge.p9, Decl(expando.ts, 11, 24), Decl(ns.ts, 7, 14)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(expando.ts, 0, 0), Decl(expando.ts, 3, 21), Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1)) +>p9 : Symbol(ExpandoMerge.p9, Decl(expando.ts, 11, 24), Decl(ns.ts, 7, 14)) +>ExpandoMerge.m : Symbol(ExpandoMerge.m, Decl(expando.ts, 3, 21)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(expando.ts, 0, 0), Decl(expando.ts, 3, 21), Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1)) +>m : Symbol(ExpandoMerge.m, Decl(expando.ts, 3, 21)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(expando.ts, 0, 0), Decl(expando.ts, 3, 21), Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1)) + +=== tests/cases/conformance/salsa/ns.ts === +namespace ExpandoMerge { +>ExpandoMerge : Symbol(ExpandoMerge, Decl(expando.ts, 0, 0), Decl(expando.ts, 3, 21), Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1)) + + export var p3 = 333; +>p3 : Symbol(p3, Decl(ns.ts, 1, 14)) + + export var p4 = 4; +>p4 : Symbol(p4, Decl(expando.ts, 6, 1), Decl(ns.ts, 2, 14)) + + export var p5 = 5; +>p5 : Symbol(p5, Decl(expando.ts, 7, 24), Decl(ns.ts, 3, 14)) + + export let p6 = 6; +>p6 : Symbol(p6, Decl(expando.ts, 8, 25), Decl(ns.ts, 4, 14)) + + export let p7 = 7; +>p7 : Symbol(p7, Decl(expando.ts, 9, 24), Decl(ns.ts, 5, 14)) + + export var p8 = 6; +>p8 : Symbol(p8, Decl(expando.ts, 10, 25), Decl(ns.ts, 6, 14)) + + export let p9 = 7; +>p9 : Symbol(p9, Decl(expando.ts, 11, 24), Decl(ns.ts, 7, 14)) +} +namespace ExpandoMerge { +>ExpandoMerge : Symbol(ExpandoMerge, Decl(expando.ts, 0, 0), Decl(expando.ts, 3, 21), Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1)) + + export var p2 = 222; +>p2 : Symbol(p2, Decl(ns.ts, 10, 14)) +} + diff --git a/tests/baselines/reference/typeFromPropertyAssignment32.types b/tests/baselines/reference/typeFromPropertyAssignment32.types new file mode 100644 index 00000000000..3ed7612d9c0 --- /dev/null +++ b/tests/baselines/reference/typeFromPropertyAssignment32.types @@ -0,0 +1,158 @@ +=== tests/cases/conformance/salsa/expando.ts === +function ExpandoMerge(n: number) { +>ExpandoMerge : typeof ExpandoMerge +>n : number + + return n; +>n : number +} +ExpandoMerge.p1 = 111 +>ExpandoMerge.p1 = 111 : 111 +>ExpandoMerge.p1 : number +>ExpandoMerge : typeof ExpandoMerge +>p1 : number +>111 : 111 + +ExpandoMerge.m = function(n: number) { +>ExpandoMerge.m = function(n: number) { return n + 1;} : (n: number) => number +>ExpandoMerge.m : (n: number) => number +>ExpandoMerge : typeof ExpandoMerge +>m : (n: number) => number +>function(n: number) { return n + 1;} : (n: number) => number +>n : number + + return n + 1; +>n + 1 : number +>n : number +>1 : 1 +} +ExpandoMerge.p4 = 44444; +>ExpandoMerge.p4 = 44444 : 44444 +>ExpandoMerge.p4 : number +>ExpandoMerge : typeof ExpandoMerge +>p4 : number +>44444 : 44444 + +ExpandoMerge.p5 = 555555; +>ExpandoMerge.p5 = 555555 : 555555 +>ExpandoMerge.p5 : number +>ExpandoMerge : typeof ExpandoMerge +>p5 : number +>555555 : 555555 + +ExpandoMerge.p6 = 66666; +>ExpandoMerge.p6 = 66666 : 66666 +>ExpandoMerge.p6 : number +>ExpandoMerge : typeof ExpandoMerge +>p6 : number +>66666 : 66666 + +ExpandoMerge.p7 = 777777; +>ExpandoMerge.p7 = 777777 : 777777 +>ExpandoMerge.p7 : number +>ExpandoMerge : typeof ExpandoMerge +>p7 : number +>777777 : 777777 + +ExpandoMerge.p8 = false; // type error +>ExpandoMerge.p8 = false : false +>ExpandoMerge.p8 : number +>ExpandoMerge : typeof ExpandoMerge +>p8 : number +>false : false + +ExpandoMerge.p9 = false; // type error +>ExpandoMerge.p9 = false : false +>ExpandoMerge.p9 : number +>ExpandoMerge : typeof ExpandoMerge +>p9 : number +>false : false + +var n = ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 + ExpandoMerge.p7 + ExpandoMerge.p8 + ExpandoMerge.p9 + ExpandoMerge.m(12) + ExpandoMerge(1001); +>n : number +>ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 + ExpandoMerge.p7 + ExpandoMerge.p8 + ExpandoMerge.p9 + ExpandoMerge.m(12) + ExpandoMerge(1001) : number +>ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 + ExpandoMerge.p7 + ExpandoMerge.p8 + ExpandoMerge.p9 + ExpandoMerge.m(12) : number +>ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 + ExpandoMerge.p7 + ExpandoMerge.p8 + ExpandoMerge.p9 : number +>ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 + ExpandoMerge.p7 + ExpandoMerge.p8 : number +>ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 + ExpandoMerge.p7 : number +>ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 : number +>ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 : number +>ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 : number +>ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 : number +>ExpandoMerge.p1 + ExpandoMerge.p2 : number +>ExpandoMerge.p1 : number +>ExpandoMerge : typeof ExpandoMerge +>p1 : number +>ExpandoMerge.p2 : number +>ExpandoMerge : typeof ExpandoMerge +>p2 : number +>ExpandoMerge.p3 : number +>ExpandoMerge : typeof ExpandoMerge +>p3 : number +>ExpandoMerge.p4 : number +>ExpandoMerge : typeof ExpandoMerge +>p4 : number +>ExpandoMerge.p5 : number +>ExpandoMerge : typeof ExpandoMerge +>p5 : number +>ExpandoMerge.p6 : number +>ExpandoMerge : typeof ExpandoMerge +>p6 : number +>ExpandoMerge.p7 : number +>ExpandoMerge : typeof ExpandoMerge +>p7 : number +>ExpandoMerge.p8 : number +>ExpandoMerge : typeof ExpandoMerge +>p8 : number +>ExpandoMerge.p9 : number +>ExpandoMerge : typeof ExpandoMerge +>p9 : number +>ExpandoMerge.m(12) : number +>ExpandoMerge.m : (n: number) => number +>ExpandoMerge : typeof ExpandoMerge +>m : (n: number) => number +>12 : 12 +>ExpandoMerge(1001) : number +>ExpandoMerge : typeof ExpandoMerge +>1001 : 1001 + +=== tests/cases/conformance/salsa/ns.ts === +namespace ExpandoMerge { +>ExpandoMerge : typeof ExpandoMerge + + export var p3 = 333; +>p3 : number +>333 : 333 + + export var p4 = 4; +>p4 : number +>4 : 4 + + export var p5 = 5; +>p5 : number +>5 : 5 + + export let p6 = 6; +>p6 : number +>6 : 6 + + export let p7 = 7; +>p7 : number +>7 : 7 + + export var p8 = 6; +>p8 : number +>6 : 6 + + export let p9 = 7; +>p9 : number +>7 : 7 +} +namespace ExpandoMerge { +>ExpandoMerge : typeof ExpandoMerge + + export var p2 = 222; +>p2 : number +>222 : 222 +} + diff --git a/tests/baselines/reference/typeFromPropertyAssignment33.errors.txt b/tests/baselines/reference/typeFromPropertyAssignment33.errors.txt new file mode 100644 index 00000000000..a4617c3d26a --- /dev/null +++ b/tests/baselines/reference/typeFromPropertyAssignment33.errors.txt @@ -0,0 +1,46 @@ +tests/cases/conformance/salsa/expando.ts(12,1): error TS2322: Type 'false' is not assignable to type 'number'. +tests/cases/conformance/salsa/expando.ts(13,1): error TS2322: Type 'false' is not assignable to type 'number'. +tests/cases/conformance/salsa/ns.ts(1,11): error TS2433: A namespace declaration cannot be in a different file from a class or function with which it is merged. +tests/cases/conformance/salsa/ns.ts(10,11): error TS2433: A namespace declaration cannot be in a different file from a class or function with which it is merged. + + +==== tests/cases/conformance/salsa/ns.ts (2 errors) ==== + namespace ExpandoMerge { + ~~~~~~~~~~~~ +!!! error TS2433: A namespace declaration cannot be in a different file from a class or function with which it is merged. + export var p3 = 333; + export var p4 = 4; + export var p5 = 5; + export let p6 = 6; + export let p7 = 7; + export var p8 = 6; + export let p9 = 7; + } + namespace ExpandoMerge { + ~~~~~~~~~~~~ +!!! error TS2433: A namespace declaration cannot be in a different file from a class or function with which it is merged. + export var p2 = 222; + } + + +==== tests/cases/conformance/salsa/expando.ts (2 errors) ==== + function ExpandoMerge(n: number) { + return n; + } + ExpandoMerge.p1 = 111 + ExpandoMerge.m = function(n: number) { + return n + 1; + } + ExpandoMerge.p4 = 44444; + ExpandoMerge.p5 = 555555; + ExpandoMerge.p6 = 66666; + ExpandoMerge.p7 = 777777; + ExpandoMerge.p8 = false; // type error + ~~~~~~~~~~~~~~~ +!!! error TS2322: Type 'false' is not assignable to type 'number'. + ExpandoMerge.p9 = false; // type error + ~~~~~~~~~~~~~~~ +!!! error TS2322: Type 'false' is not assignable to type 'number'. + var n = ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 + ExpandoMerge.p7 + ExpandoMerge.p8 + ExpandoMerge.p9 + ExpandoMerge.m(12) + ExpandoMerge(1001); + + \ No newline at end of file diff --git a/tests/baselines/reference/typeFromPropertyAssignment33.js b/tests/baselines/reference/typeFromPropertyAssignment33.js new file mode 100644 index 00000000000..fa431a0f273 --- /dev/null +++ b/tests/baselines/reference/typeFromPropertyAssignment33.js @@ -0,0 +1,64 @@ +//// [tests/cases/conformance/salsa/typeFromPropertyAssignment33.ts] //// + +//// [ns.ts] +namespace ExpandoMerge { + export var p3 = 333; + export var p4 = 4; + export var p5 = 5; + export let p6 = 6; + export let p7 = 7; + export var p8 = 6; + export let p9 = 7; +} +namespace ExpandoMerge { + export var p2 = 222; +} + + +//// [expando.ts] +function ExpandoMerge(n: number) { + return n; +} +ExpandoMerge.p1 = 111 +ExpandoMerge.m = function(n: number) { + return n + 1; +} +ExpandoMerge.p4 = 44444; +ExpandoMerge.p5 = 555555; +ExpandoMerge.p6 = 66666; +ExpandoMerge.p7 = 777777; +ExpandoMerge.p8 = false; // type error +ExpandoMerge.p9 = false; // type error +var n = ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 + ExpandoMerge.p7 + ExpandoMerge.p8 + ExpandoMerge.p9 + ExpandoMerge.m(12) + ExpandoMerge(1001); + + + +//// [ns.js] +var ExpandoMerge; +(function (ExpandoMerge) { + ExpandoMerge.p3 = 333; + ExpandoMerge.p4 = 4; + ExpandoMerge.p5 = 5; + ExpandoMerge.p6 = 6; + ExpandoMerge.p7 = 7; + ExpandoMerge.p8 = 6; + ExpandoMerge.p9 = 7; +})(ExpandoMerge || (ExpandoMerge = {})); +(function (ExpandoMerge) { + ExpandoMerge.p2 = 222; +})(ExpandoMerge || (ExpandoMerge = {})); +//// [expando.js] +function ExpandoMerge(n) { + return n; +} +ExpandoMerge.p1 = 111; +ExpandoMerge.m = function (n) { + return n + 1; +}; +ExpandoMerge.p4 = 44444; +ExpandoMerge.p5 = 555555; +ExpandoMerge.p6 = 66666; +ExpandoMerge.p7 = 777777; +ExpandoMerge.p8 = false; // type error +ExpandoMerge.p9 = false; // type error +var n = ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 + ExpandoMerge.p7 + ExpandoMerge.p8 + ExpandoMerge.p9 + ExpandoMerge.m(12) + ExpandoMerge(1001); diff --git a/tests/baselines/reference/typeFromPropertyAssignment33.symbols b/tests/baselines/reference/typeFromPropertyAssignment33.symbols new file mode 100644 index 00000000000..7b21df91b96 --- /dev/null +++ b/tests/baselines/reference/typeFromPropertyAssignment33.symbols @@ -0,0 +1,120 @@ +=== tests/cases/conformance/salsa/ns.ts === +namespace ExpandoMerge { +>ExpandoMerge : Symbol(ExpandoMerge, Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1), Decl(expando.ts, 0, 0), Decl(expando.ts, 3, 21)) + + export var p3 = 333; +>p3 : Symbol(p3, Decl(ns.ts, 1, 14)) + + export var p4 = 4; +>p4 : Symbol(p4, Decl(ns.ts, 2, 14), Decl(expando.ts, 6, 1)) + + export var p5 = 5; +>p5 : Symbol(p5, Decl(ns.ts, 3, 14), Decl(expando.ts, 7, 24)) + + export let p6 = 6; +>p6 : Symbol(p6, Decl(ns.ts, 4, 14), Decl(expando.ts, 8, 25)) + + export let p7 = 7; +>p7 : Symbol(p7, Decl(ns.ts, 5, 14), Decl(expando.ts, 9, 24)) + + export var p8 = 6; +>p8 : Symbol(p8, Decl(ns.ts, 6, 14), Decl(expando.ts, 10, 25)) + + export let p9 = 7; +>p9 : Symbol(p9, Decl(ns.ts, 7, 14), Decl(expando.ts, 11, 24)) +} +namespace ExpandoMerge { +>ExpandoMerge : Symbol(ExpandoMerge, Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1), Decl(expando.ts, 0, 0), Decl(expando.ts, 3, 21)) + + export var p2 = 222; +>p2 : Symbol(p2, Decl(ns.ts, 10, 14)) +} + + +=== tests/cases/conformance/salsa/expando.ts === +function ExpandoMerge(n: number) { +>ExpandoMerge : Symbol(ExpandoMerge, Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1), Decl(expando.ts, 0, 0), Decl(expando.ts, 3, 21)) +>n : Symbol(n, Decl(expando.ts, 0, 22)) + + return n; +>n : Symbol(n, Decl(expando.ts, 0, 22)) +} +ExpandoMerge.p1 = 111 +>ExpandoMerge.p1 : Symbol(ExpandoMerge.p1, Decl(expando.ts, 2, 1)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1), Decl(expando.ts, 0, 0), Decl(expando.ts, 3, 21)) +>p1 : Symbol(ExpandoMerge.p1, Decl(expando.ts, 2, 1)) + +ExpandoMerge.m = function(n: number) { +>ExpandoMerge.m : Symbol(ExpandoMerge.m, Decl(expando.ts, 3, 21)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1), Decl(expando.ts, 0, 0), Decl(expando.ts, 3, 21)) +>m : Symbol(ExpandoMerge.m, Decl(expando.ts, 3, 21)) +>n : Symbol(n, Decl(expando.ts, 4, 26)) + + return n + 1; +>n : Symbol(n, Decl(expando.ts, 4, 26)) +} +ExpandoMerge.p4 = 44444; +>ExpandoMerge.p4 : Symbol(ExpandoMerge.p4, Decl(ns.ts, 2, 14), Decl(expando.ts, 6, 1)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1), Decl(expando.ts, 0, 0), Decl(expando.ts, 3, 21)) +>p4 : Symbol(ExpandoMerge.p4, Decl(ns.ts, 2, 14), Decl(expando.ts, 6, 1)) + +ExpandoMerge.p5 = 555555; +>ExpandoMerge.p5 : Symbol(ExpandoMerge.p5, Decl(ns.ts, 3, 14), Decl(expando.ts, 7, 24)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1), Decl(expando.ts, 0, 0), Decl(expando.ts, 3, 21)) +>p5 : Symbol(ExpandoMerge.p5, Decl(ns.ts, 3, 14), Decl(expando.ts, 7, 24)) + +ExpandoMerge.p6 = 66666; +>ExpandoMerge.p6 : Symbol(ExpandoMerge.p6, Decl(ns.ts, 4, 14), Decl(expando.ts, 8, 25)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1), Decl(expando.ts, 0, 0), Decl(expando.ts, 3, 21)) +>p6 : Symbol(ExpandoMerge.p6, Decl(ns.ts, 4, 14), Decl(expando.ts, 8, 25)) + +ExpandoMerge.p7 = 777777; +>ExpandoMerge.p7 : Symbol(ExpandoMerge.p7, Decl(ns.ts, 5, 14), Decl(expando.ts, 9, 24)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1), Decl(expando.ts, 0, 0), Decl(expando.ts, 3, 21)) +>p7 : Symbol(ExpandoMerge.p7, Decl(ns.ts, 5, 14), Decl(expando.ts, 9, 24)) + +ExpandoMerge.p8 = false; // type error +>ExpandoMerge.p8 : Symbol(ExpandoMerge.p8, Decl(ns.ts, 6, 14), Decl(expando.ts, 10, 25)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1), Decl(expando.ts, 0, 0), Decl(expando.ts, 3, 21)) +>p8 : Symbol(ExpandoMerge.p8, Decl(ns.ts, 6, 14), Decl(expando.ts, 10, 25)) + +ExpandoMerge.p9 = false; // type error +>ExpandoMerge.p9 : Symbol(ExpandoMerge.p9, Decl(ns.ts, 7, 14), Decl(expando.ts, 11, 24)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1), Decl(expando.ts, 0, 0), Decl(expando.ts, 3, 21)) +>p9 : Symbol(ExpandoMerge.p9, Decl(ns.ts, 7, 14), Decl(expando.ts, 11, 24)) + +var n = ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 + ExpandoMerge.p7 + ExpandoMerge.p8 + ExpandoMerge.p9 + ExpandoMerge.m(12) + ExpandoMerge(1001); +>n : Symbol(n, Decl(expando.ts, 13, 3)) +>ExpandoMerge.p1 : Symbol(ExpandoMerge.p1, Decl(expando.ts, 2, 1)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1), Decl(expando.ts, 0, 0), Decl(expando.ts, 3, 21)) +>p1 : Symbol(ExpandoMerge.p1, Decl(expando.ts, 2, 1)) +>ExpandoMerge.p2 : Symbol(ExpandoMerge.p2, Decl(ns.ts, 10, 14)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1), Decl(expando.ts, 0, 0), Decl(expando.ts, 3, 21)) +>p2 : Symbol(ExpandoMerge.p2, Decl(ns.ts, 10, 14)) +>ExpandoMerge.p3 : Symbol(ExpandoMerge.p3, Decl(ns.ts, 1, 14)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1), Decl(expando.ts, 0, 0), Decl(expando.ts, 3, 21)) +>p3 : Symbol(ExpandoMerge.p3, Decl(ns.ts, 1, 14)) +>ExpandoMerge.p4 : Symbol(ExpandoMerge.p4, Decl(ns.ts, 2, 14), Decl(expando.ts, 6, 1)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1), Decl(expando.ts, 0, 0), Decl(expando.ts, 3, 21)) +>p4 : Symbol(ExpandoMerge.p4, Decl(ns.ts, 2, 14), Decl(expando.ts, 6, 1)) +>ExpandoMerge.p5 : Symbol(ExpandoMerge.p5, Decl(ns.ts, 3, 14), Decl(expando.ts, 7, 24)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1), Decl(expando.ts, 0, 0), Decl(expando.ts, 3, 21)) +>p5 : Symbol(ExpandoMerge.p5, Decl(ns.ts, 3, 14), Decl(expando.ts, 7, 24)) +>ExpandoMerge.p6 : Symbol(ExpandoMerge.p6, Decl(ns.ts, 4, 14), Decl(expando.ts, 8, 25)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1), Decl(expando.ts, 0, 0), Decl(expando.ts, 3, 21)) +>p6 : Symbol(ExpandoMerge.p6, Decl(ns.ts, 4, 14), Decl(expando.ts, 8, 25)) +>ExpandoMerge.p7 : Symbol(ExpandoMerge.p7, Decl(ns.ts, 5, 14), Decl(expando.ts, 9, 24)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1), Decl(expando.ts, 0, 0), Decl(expando.ts, 3, 21)) +>p7 : Symbol(ExpandoMerge.p7, Decl(ns.ts, 5, 14), Decl(expando.ts, 9, 24)) +>ExpandoMerge.p8 : Symbol(ExpandoMerge.p8, Decl(ns.ts, 6, 14), Decl(expando.ts, 10, 25)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1), Decl(expando.ts, 0, 0), Decl(expando.ts, 3, 21)) +>p8 : Symbol(ExpandoMerge.p8, Decl(ns.ts, 6, 14), Decl(expando.ts, 10, 25)) +>ExpandoMerge.p9 : Symbol(ExpandoMerge.p9, Decl(ns.ts, 7, 14), Decl(expando.ts, 11, 24)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1), Decl(expando.ts, 0, 0), Decl(expando.ts, 3, 21)) +>p9 : Symbol(ExpandoMerge.p9, Decl(ns.ts, 7, 14), Decl(expando.ts, 11, 24)) +>ExpandoMerge.m : Symbol(ExpandoMerge.m, Decl(expando.ts, 3, 21)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1), Decl(expando.ts, 0, 0), Decl(expando.ts, 3, 21)) +>m : Symbol(ExpandoMerge.m, Decl(expando.ts, 3, 21)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1), Decl(expando.ts, 0, 0), Decl(expando.ts, 3, 21)) + + diff --git a/tests/baselines/reference/typeFromPropertyAssignment33.types b/tests/baselines/reference/typeFromPropertyAssignment33.types new file mode 100644 index 00000000000..1416b798467 --- /dev/null +++ b/tests/baselines/reference/typeFromPropertyAssignment33.types @@ -0,0 +1,160 @@ +=== tests/cases/conformance/salsa/ns.ts === +namespace ExpandoMerge { +>ExpandoMerge : typeof ExpandoMerge + + export var p3 = 333; +>p3 : number +>333 : 333 + + export var p4 = 4; +>p4 : number +>4 : 4 + + export var p5 = 5; +>p5 : number +>5 : 5 + + export let p6 = 6; +>p6 : number +>6 : 6 + + export let p7 = 7; +>p7 : number +>7 : 7 + + export var p8 = 6; +>p8 : number +>6 : 6 + + export let p9 = 7; +>p9 : number +>7 : 7 +} +namespace ExpandoMerge { +>ExpandoMerge : typeof ExpandoMerge + + export var p2 = 222; +>p2 : number +>222 : 222 +} + + +=== tests/cases/conformance/salsa/expando.ts === +function ExpandoMerge(n: number) { +>ExpandoMerge : typeof ExpandoMerge +>n : number + + return n; +>n : number +} +ExpandoMerge.p1 = 111 +>ExpandoMerge.p1 = 111 : 111 +>ExpandoMerge.p1 : number +>ExpandoMerge : typeof ExpandoMerge +>p1 : number +>111 : 111 + +ExpandoMerge.m = function(n: number) { +>ExpandoMerge.m = function(n: number) { return n + 1;} : (n: number) => number +>ExpandoMerge.m : (n: number) => number +>ExpandoMerge : typeof ExpandoMerge +>m : (n: number) => number +>function(n: number) { return n + 1;} : (n: number) => number +>n : number + + return n + 1; +>n + 1 : number +>n : number +>1 : 1 +} +ExpandoMerge.p4 = 44444; +>ExpandoMerge.p4 = 44444 : 44444 +>ExpandoMerge.p4 : number +>ExpandoMerge : typeof ExpandoMerge +>p4 : number +>44444 : 44444 + +ExpandoMerge.p5 = 555555; +>ExpandoMerge.p5 = 555555 : 555555 +>ExpandoMerge.p5 : number +>ExpandoMerge : typeof ExpandoMerge +>p5 : number +>555555 : 555555 + +ExpandoMerge.p6 = 66666; +>ExpandoMerge.p6 = 66666 : 66666 +>ExpandoMerge.p6 : number +>ExpandoMerge : typeof ExpandoMerge +>p6 : number +>66666 : 66666 + +ExpandoMerge.p7 = 777777; +>ExpandoMerge.p7 = 777777 : 777777 +>ExpandoMerge.p7 : number +>ExpandoMerge : typeof ExpandoMerge +>p7 : number +>777777 : 777777 + +ExpandoMerge.p8 = false; // type error +>ExpandoMerge.p8 = false : false +>ExpandoMerge.p8 : number +>ExpandoMerge : typeof ExpandoMerge +>p8 : number +>false : false + +ExpandoMerge.p9 = false; // type error +>ExpandoMerge.p9 = false : false +>ExpandoMerge.p9 : number +>ExpandoMerge : typeof ExpandoMerge +>p9 : number +>false : false + +var n = ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 + ExpandoMerge.p7 + ExpandoMerge.p8 + ExpandoMerge.p9 + ExpandoMerge.m(12) + ExpandoMerge(1001); +>n : number +>ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 + ExpandoMerge.p7 + ExpandoMerge.p8 + ExpandoMerge.p9 + ExpandoMerge.m(12) + ExpandoMerge(1001) : number +>ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 + ExpandoMerge.p7 + ExpandoMerge.p8 + ExpandoMerge.p9 + ExpandoMerge.m(12) : number +>ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 + ExpandoMerge.p7 + ExpandoMerge.p8 + ExpandoMerge.p9 : number +>ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 + ExpandoMerge.p7 + ExpandoMerge.p8 : number +>ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 + ExpandoMerge.p7 : number +>ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 : number +>ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 : number +>ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 : number +>ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 : number +>ExpandoMerge.p1 + ExpandoMerge.p2 : number +>ExpandoMerge.p1 : number +>ExpandoMerge : typeof ExpandoMerge +>p1 : number +>ExpandoMerge.p2 : number +>ExpandoMerge : typeof ExpandoMerge +>p2 : number +>ExpandoMerge.p3 : number +>ExpandoMerge : typeof ExpandoMerge +>p3 : number +>ExpandoMerge.p4 : number +>ExpandoMerge : typeof ExpandoMerge +>p4 : number +>ExpandoMerge.p5 : number +>ExpandoMerge : typeof ExpandoMerge +>p5 : number +>ExpandoMerge.p6 : number +>ExpandoMerge : typeof ExpandoMerge +>p6 : number +>ExpandoMerge.p7 : number +>ExpandoMerge : typeof ExpandoMerge +>p7 : number +>ExpandoMerge.p8 : number +>ExpandoMerge : typeof ExpandoMerge +>p8 : number +>ExpandoMerge.p9 : number +>ExpandoMerge : typeof ExpandoMerge +>p9 : number +>ExpandoMerge.m(12) : number +>ExpandoMerge.m : (n: number) => number +>ExpandoMerge : typeof ExpandoMerge +>m : (n: number) => number +>12 : 12 +>ExpandoMerge(1001) : number +>ExpandoMerge : typeof ExpandoMerge +>1001 : 1001 + + diff --git a/tests/baselines/reference/typeParameterAsTypeParameterConstraint2.errors.txt b/tests/baselines/reference/typeParameterAsTypeParameterConstraint2.errors.txt index 08706d095b2..8f286e39863 100644 --- a/tests/baselines/reference/typeParameterAsTypeParameterConstraint2.errors.txt +++ b/tests/baselines/reference/typeParameterAsTypeParameterConstraint2.errors.txt @@ -1,12 +1,8 @@ tests/cases/conformance/types/typeParameters/typeArgumentLists/typeParameterAsTypeParameterConstraint2.ts(6,8): error TS2345: Argument of type '""' is not assignable to parameter of type 'number'. tests/cases/conformance/types/typeParameters/typeArgumentLists/typeParameterAsTypeParameterConstraint2.ts(7,8): error TS2345: Argument of type '{}' is not assignable to parameter of type 'number'. tests/cases/conformance/types/typeParameters/typeArgumentLists/typeParameterAsTypeParameterConstraint2.ts(13,17): error TS2345: Argument of type 'NumberVariant' is not assignable to parameter of type 'number'. -tests/cases/conformance/types/typeParameters/typeArgumentLists/typeParameterAsTypeParameterConstraint2.ts(16,9): error TS2345: Argument of type '{ length: string; }' is not assignable to parameter of type '{ length: number; }'. - Types of property 'length' are incompatible. - Type 'string' is not assignable to type 'number'. -tests/cases/conformance/types/typeParameters/typeArgumentLists/typeParameterAsTypeParameterConstraint2.ts(17,9): error TS2345: Argument of type '{ length: {}; }' is not assignable to parameter of type '{ length: number; }'. - Types of property 'length' are incompatible. - Type '{}' is not assignable to type 'number'. +tests/cases/conformance/types/typeParameters/typeArgumentLists/typeParameterAsTypeParameterConstraint2.ts(16,11): error TS2322: Type 'string' is not assignable to type 'number'. +tests/cases/conformance/types/typeParameters/typeArgumentLists/typeParameterAsTypeParameterConstraint2.ts(17,11): error TS2322: Type '{}' is not assignable to type 'number'. tests/cases/conformance/types/typeParameters/typeArgumentLists/typeParameterAsTypeParameterConstraint2.ts(18,10): error TS2345: Argument of type 'string[]' is not assignable to parameter of type '{ length: any[]; }'. Types of property 'length' are incompatible. Type 'number' is not assignable to type 'any[]'. @@ -35,15 +31,13 @@ tests/cases/conformance/types/typeParameters/typeArgumentLists/typeParameterAsTy function foo2(x: T, y: U) { return y; } // this is now an error foo2(1, { length: '' }); - ~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ length: string; }' is not assignable to parameter of type '{ length: number; }'. -!!! error TS2345: Types of property 'length' are incompatible. -!!! error TS2345: Type 'string' is not assignable to type 'number'. + ~~~~~~ +!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! related TS6500 tests/cases/conformance/types/typeParameters/typeArgumentLists/typeParameterAsTypeParameterConstraint2.ts:15:30: The expected type comes from property 'length' which is declared here on type '{ length: number; }' foo2(1, { length: {} }); - ~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ length: {}; }' is not assignable to parameter of type '{ length: number; }'. -!!! error TS2345: Types of property 'length' are incompatible. -!!! error TS2345: Type '{}' is not assignable to type 'number'. + ~~~~~~ +!!! error TS2322: Type '{}' is not assignable to type 'number'. +!!! related TS6500 tests/cases/conformance/types/typeParameters/typeArgumentLists/typeParameterAsTypeParameterConstraint2.ts:15:30: The expected type comes from property 'length' which is declared here on type '{ length: number; }' foo2([], ['']); ~~~~ !!! error TS2345: Argument of type 'string[]' is not assignable to parameter of type '{ length: any[]; }'. diff --git a/tests/baselines/reference/typedefTagWrapping.symbols b/tests/baselines/reference/typedefTagWrapping.symbols new file mode 100644 index 00000000000..ec93da5a45b --- /dev/null +++ b/tests/baselines/reference/typedefTagWrapping.symbols @@ -0,0 +1,23 @@ +=== tests/cases/conformance/jsdoc/mod1.js === +/** + * @typedef {function(string): boolean} + * MyType + */ + +/** + * Tries to use a type whose name is on a different + * line than the typedef tag. + * @param {MyType} func The function to call. + * @param {string} arg The argument to call it with. + * @returns {boolean} The return. + */ +function callIt(func, arg) { +>callIt : Symbol(callIt, Decl(mod1.js, 0, 0)) +>func : Symbol(func, Decl(mod1.js, 12, 16)) +>arg : Symbol(arg, Decl(mod1.js, 12, 21)) + + return func(arg); +>func : Symbol(func, Decl(mod1.js, 12, 16)) +>arg : Symbol(arg, Decl(mod1.js, 12, 21)) +} + diff --git a/tests/baselines/reference/typedefTagWrapping.types b/tests/baselines/reference/typedefTagWrapping.types new file mode 100644 index 00000000000..8c92717d1a1 --- /dev/null +++ b/tests/baselines/reference/typedefTagWrapping.types @@ -0,0 +1,24 @@ +=== tests/cases/conformance/jsdoc/mod1.js === +/** + * @typedef {function(string): boolean} + * MyType + */ + +/** + * Tries to use a type whose name is on a different + * line than the typedef tag. + * @param {MyType} func The function to call. + * @param {string} arg The argument to call it with. + * @returns {boolean} The return. + */ +function callIt(func, arg) { +>callIt : (func: (arg0: string) => boolean, arg: string) => boolean +>func : (arg0: string) => boolean +>arg : string + + return func(arg); +>func(arg) : boolean +>func : (arg0: string) => boolean +>arg : string +} + diff --git a/tests/baselines/reference/wrappedAndRecursiveConstraints4.errors.txt b/tests/baselines/reference/wrappedAndRecursiveConstraints4.errors.txt index 47e8e6ff4f2..65bfc5b20d5 100644 --- a/tests/baselines/reference/wrappedAndRecursiveConstraints4.errors.txt +++ b/tests/baselines/reference/wrappedAndRecursiveConstraints4.errors.txt @@ -1,4 +1,5 @@ -tests/cases/conformance/types/typeParameters/typeArgumentLists/wrappedAndRecursiveConstraints4.ts(13,12): error TS2345: Argument of type '{ length: number; charAt: (x: number) => void; }' is not assignable to parameter of type 'string'. +tests/cases/conformance/types/typeParameters/typeArgumentLists/wrappedAndRecursiveConstraints4.ts(13,25): error TS2322: Type '(x: number) => void' is not assignable to type '(pos: number) => string'. + Type 'void' is not assignable to type 'string'. ==== tests/cases/conformance/types/typeParameters/typeArgumentLists/wrappedAndRecursiveConstraints4.ts (1 errors) ==== @@ -15,5 +16,7 @@ tests/cases/conformance/types/typeParameters/typeArgumentLists/wrappedAndRecursi var c = new C({ length: 2 }); var r = c.foo(''); var r2 = r({ length: 3, charAt: (x: number) => { '' } }); // error - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ length: number; charAt: (x: number) => void; }' is not assignable to parameter of type 'string'. \ No newline at end of file + ~~~~~~ +!!! error TS2322: Type '(x: number) => void' is not assignable to type '(pos: number) => string'. +!!! error TS2322: Type 'void' is not assignable to type 'string'. +!!! related TS6500 /.ts/lib.es5.d.ts:332:5: The expected type comes from property 'charAt' which is declared here on type 'string' \ No newline at end of file diff --git a/tests/cases/compiler/contextualSignatureInstatiationContravariance.ts b/tests/cases/compiler/contextualSignatureInstatiationContravariance.ts index 83b5cbafb6a..2bd0673abd5 100644 --- a/tests/cases/compiler/contextualSignatureInstatiationContravariance.ts +++ b/tests/cases/compiler/contextualSignatureInstatiationContravariance.ts @@ -5,7 +5,7 @@ interface Elephant extends Animal { y2 } var f2: (x: T, y: T) => void; var g2: (g: Giraffe, e: Elephant) => void; -g2 = f2; // valid because both Giraffe and Elephant satisfy the constraint. T is Animal +g2 = f2; // error because Giraffe and Elephant are disjoint types var h2: (g1: Giraffe, g2: Giraffe) => void; h2 = f2; // valid because Giraffe satisfies the constraint. It is safe in the traditional contravariant fashion. \ No newline at end of file diff --git a/tests/cases/compiler/declarationEmitWithComposite.ts b/tests/cases/compiler/declarationEmitWithComposite.ts new file mode 100644 index 00000000000..9d039ce2271 --- /dev/null +++ b/tests/cases/compiler/declarationEmitWithComposite.ts @@ -0,0 +1,13 @@ +// @composite: true +// @fullEmitPaths: true + +// @filename: /foo/tsconfig.json +{ + "compilerOptions": { "composite": true, "outDir": "out" } +} + +// @filename: /foo/test.ts +interface Foo { + x: number; +} +export default Foo; diff --git a/tests/cases/conformance/functions/parameterInitializersForwardReferencing1.ts b/tests/cases/conformance/functions/parameterInitializersForwardReferencing1.ts index cf667840f20..a3b88150f4f 100644 --- a/tests/cases/conformance/functions/parameterInitializersForwardReferencing1.ts +++ b/tests/cases/conformance/functions/parameterInitializersForwardReferencing1.ts @@ -33,3 +33,5 @@ function f7({[foo]: bar}: any[]) { class Foo { constructor(public x = 12, public y = x) {} } + +function f8(foo1: string, bar = foo1) { } diff --git a/tests/cases/conformance/functions/parameterInitializersForwardReferencing1_es6.ts b/tests/cases/conformance/functions/parameterInitializersForwardReferencing1_es6.ts index 5643ea2cc0a..f83eb2dd34e 100644 --- a/tests/cases/conformance/functions/parameterInitializersForwardReferencing1_es6.ts +++ b/tests/cases/conformance/functions/parameterInitializersForwardReferencing1_es6.ts @@ -35,3 +35,5 @@ function f7({[foo]: bar}: any[]) { class Foo { constructor(public x = 12, public y = x) {} } + +function f8(foo1: string, bar = foo1) { } diff --git a/tests/cases/conformance/jsdoc/typedefTagWrapping.ts b/tests/cases/conformance/jsdoc/typedefTagWrapping.ts new file mode 100644 index 00000000000..53cff6d02c0 --- /dev/null +++ b/tests/cases/conformance/jsdoc/typedefTagWrapping.ts @@ -0,0 +1,20 @@ +// @noEmit: true +// @allowJs: true +// @checkJs: true +// @Filename: mod1.js + +/** + * @typedef {function(string): boolean} + * MyType + */ + +/** + * Tries to use a type whose name is on a different + * line than the typedef tag. + * @param {MyType} func The function to call. + * @param {string} arg The argument to call it with. + * @returns {boolean} The return. + */ +function callIt(func, arg) { + return func(arg); +} diff --git a/tests/cases/conformance/salsa/typeFromContextualThisType.ts b/tests/cases/conformance/salsa/typeFromContextualThisType.ts new file mode 100644 index 00000000000..062b238eb8d --- /dev/null +++ b/tests/cases/conformance/salsa/typeFromContextualThisType.ts @@ -0,0 +1,20 @@ +// @noEmit: true +// @allowJs: true +// @checkJs: true +// @strict: true +// @Filename: bug25926.js + +/** @type {{ a(): void; b?(n: number): number; }} */ +const o1 = { + a() { + this.b = n => n; + } +}; + +/** @type {{ d(): void; e?(n: number): number; f?(n: number): number; g?: number }} */ +const o2 = { + d() { + this.e = this.f = m => this.g || m; + } +}; + diff --git a/tests/cases/conformance/salsa/typeFromPropertyAssignment31.ts b/tests/cases/conformance/salsa/typeFromPropertyAssignment31.ts new file mode 100644 index 00000000000..7c11a2a64bb --- /dev/null +++ b/tests/cases/conformance/salsa/typeFromPropertyAssignment31.ts @@ -0,0 +1,26 @@ +function ExpandoMerge(n: number) { + return n; +} +ExpandoMerge.p1 = 111 +ExpandoMerge.m = function(n: number) { + return n + 1; +} +namespace ExpandoMerge { + export var p2 = 222; +} +ExpandoMerge.p4 = 44444; // ok +ExpandoMerge.p6 = 66666; // ok +ExpandoMerge.p8 = false; // type error +namespace ExpandoMerge { + export var p3 = 333; + export var p4 = 4; + export var p5 = 5; + export let p6 = 6; + export let p7 = 7; + export var p8 = 6; + export let p9 = 7; +} +ExpandoMerge.p5 = 555555; // ok +ExpandoMerge.p7 = 777777; // ok +ExpandoMerge.p9 = false; // type error +var n = ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 + ExpandoMerge.p7 + ExpandoMerge.p8 + ExpandoMerge.p9 + ExpandoMerge.m(12) + ExpandoMerge(1001); diff --git a/tests/cases/conformance/salsa/typeFromPropertyAssignment32.ts b/tests/cases/conformance/salsa/typeFromPropertyAssignment32.ts new file mode 100644 index 00000000000..498aa151e73 --- /dev/null +++ b/tests/cases/conformance/salsa/typeFromPropertyAssignment32.ts @@ -0,0 +1,29 @@ +// @Filename: expando.ts +function ExpandoMerge(n: number) { + return n; +} +ExpandoMerge.p1 = 111 +ExpandoMerge.m = function(n: number) { + return n + 1; +} +ExpandoMerge.p4 = 44444; +ExpandoMerge.p5 = 555555; +ExpandoMerge.p6 = 66666; +ExpandoMerge.p7 = 777777; +ExpandoMerge.p8 = false; // type error +ExpandoMerge.p9 = false; // type error +var n = ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 + ExpandoMerge.p7 + ExpandoMerge.p8 + ExpandoMerge.p9 + ExpandoMerge.m(12) + ExpandoMerge(1001); + +// @Filename: ns.ts +namespace ExpandoMerge { + export var p3 = 333; + export var p4 = 4; + export var p5 = 5; + export let p6 = 6; + export let p7 = 7; + export var p8 = 6; + export let p9 = 7; +} +namespace ExpandoMerge { + export var p2 = 222; +} diff --git a/tests/cases/conformance/salsa/typeFromPropertyAssignment33.ts b/tests/cases/conformance/salsa/typeFromPropertyAssignment33.ts new file mode 100644 index 00000000000..d98f689329d --- /dev/null +++ b/tests/cases/conformance/salsa/typeFromPropertyAssignment33.ts @@ -0,0 +1,31 @@ +// @Filename: ns.ts +namespace ExpandoMerge { + export var p3 = 333; + export var p4 = 4; + export var p5 = 5; + export let p6 = 6; + export let p7 = 7; + export var p8 = 6; + export let p9 = 7; +} +namespace ExpandoMerge { + export var p2 = 222; +} + + +// @Filename: expando.ts +function ExpandoMerge(n: number) { + return n; +} +ExpandoMerge.p1 = 111 +ExpandoMerge.m = function(n: number) { + return n + 1; +} +ExpandoMerge.p4 = 44444; +ExpandoMerge.p5 = 555555; +ExpandoMerge.p6 = 66666; +ExpandoMerge.p7 = 777777; +ExpandoMerge.p8 = false; // type error +ExpandoMerge.p9 = false; // type error +var n = ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 + ExpandoMerge.p7 + ExpandoMerge.p8 + ExpandoMerge.p9 + ExpandoMerge.m(12) + ExpandoMerge(1001); + diff --git a/tests/cases/conformance/types/spread/objectSpreadNegative.ts b/tests/cases/conformance/types/spread/objectSpreadNegative.ts index b6e7c5b88c9..789016762da 100644 --- a/tests/cases/conformance/types/spread/objectSpreadNegative.ts +++ b/tests/cases/conformance/types/spread/objectSpreadNegative.ts @@ -73,13 +73,3 @@ let overlapConflict: { id:string, a: string } = f({ a: 1 }, { a: 'mismatch' }) let overwriteId: { id: string, a: number, c: number, d: string } = f({ a: 1, id: true }, { c: 1, d: 'no' }) - -// excess property checks -type A = { a: string, b: string }; -type Extra = { a: string, b: string, extra: string }; -const extra1: A = { a: "a", b: "b", extra: "extra" }; -const extra2 = { a: "a", b: "b", extra: "extra" }; -const a1: A = { ...extra1 }; // error spans should be here -const a2: A = { ...extra2 }; // not on the symbol declarations above -const extra3: Extra = { a: "a", b: "b", extra: "extra" }; -const a3: A = { ...extra3 }; // same here diff --git a/tests/cases/conformance/types/spread/spreadExcessProperty.ts b/tests/cases/conformance/types/spread/spreadExcessProperty.ts new file mode 100644 index 00000000000..b5b304e2ff7 --- /dev/null +++ b/tests/cases/conformance/types/spread/spreadExcessProperty.ts @@ -0,0 +1,3 @@ +type A = { a: string, b: string }; +const extra1 = { a: "a", b: "b", extra: "extra" }; +const a1: A = { ...extra1 }; // spread should not give excess property errors diff --git a/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignatures2.ts b/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignatures2.ts index c4904413617..e2cc7a69ee5 100644 --- a/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignatures2.ts +++ b/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignatures2.ts @@ -11,6 +11,6 @@ interface B { var a: A; var b: B; -// Both ok +// Both errors a = b; b = a; diff --git a/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance2.ts b/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance2.ts index eaabadb7741..9e6cd52ac2b 100644 --- a/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance2.ts +++ b/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance2.ts @@ -61,7 +61,7 @@ interface I extends A { a11: (x: T, y: T) => T; // ok a12: >(x: Array, y: T) => Array; // ok, less specific parameter type a13: >(x: Array, y: T) => T; // ok, T = Array, satisfies constraint, contextual signature instantiation succeeds - a14: (x: { a: T; b: T }) => T; // ok, best common type yields T = {} but that's satisfactory for this signature + a14: (x: { a: T; b: U }) => T; // ok a15: (x: T) => T[]; // ok a16: (x: T) => number[]; // ok a17: (x: (a: T) => T) => T[]; // ok diff --git a/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance5.ts b/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance5.ts index b5aa243f6c1..bf60d6518cf 100644 --- a/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance5.ts +++ b/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance5.ts @@ -44,5 +44,5 @@ interface I extends B { a11: (x: T, y: T) => T; // ok a12: >(x: Array, y: T) => Array; // ok, less specific parameter type a13: >(x: Array, y: T) => T; // ok, T = Array, satisfies constraint, contextual signature instantiation succeeds - a14: (x: { a: T; b: T }) => T; // ok, best common type yields T = {} but that's satisfactory for this signature + a14: (x: { a: T; b: U }) => T; // ok } \ No newline at end of file diff --git a/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance2.ts b/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance2.ts index 2a598bb01ed..65e4f4c962e 100644 --- a/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance2.ts +++ b/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance2.ts @@ -61,7 +61,7 @@ interface I extends A { a11: new (x: T, y: T) => T; // ok a12: new >(x: Array, y: T) => Array; // ok, less specific parameter type a13: new >(x: Array, y: T) => T; // ok, T = Array, satisfies constraint, contextual signature instantiation succeeds - a14: new (x: { a: T; b: T }) => T; // ok, best common type yields T = {} but that's satisfactory for this signature + a14: new (x: { a: T; b: U }) => T; // ok a15: new (x: T) => T[]; // ok a16: new (x: T) => number[]; // ok a17: new (x: new (a: T) => T) => T[]; // ok diff --git a/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance5.ts b/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance5.ts index 43813faf8ae..f33820218ea 100644 --- a/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance5.ts +++ b/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance5.ts @@ -44,5 +44,5 @@ interface I extends B { a11: new (x: T, y: T) => T; // ok a12: new >(x: Array, y: T) => Array; // ok, less specific parameter type a13: new >(x: Array, y: T) => T; // ok, T = Array, satisfies constraint, contextual signature instantiation succeeds - a14: new (x: { a: T; b: T }) => T; // ok, best common type yields T = {} but that's satisfactory for this signature + a14: new (x: { a: T; b: U }) => T; // ok } \ No newline at end of file diff --git a/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithConstructSignatures5.ts b/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithConstructSignatures5.ts index 43813faf8ae..f33820218ea 100644 --- a/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithConstructSignatures5.ts +++ b/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithConstructSignatures5.ts @@ -44,5 +44,5 @@ interface I extends B { a11: new (x: T, y: T) => T; // ok a12: new >(x: Array, y: T) => Array; // ok, less specific parameter type a13: new >(x: Array, y: T) => T; // ok, T = Array, satisfies constraint, contextual signature instantiation succeeds - a14: new (x: { a: T; b: T }) => T; // ok, best common type yields T = {} but that's satisfactory for this signature + a14: new (x: { a: T; b: U }) => T; // ok } \ No newline at end of file diff --git a/tests/cases/conformance/types/typeRelationships/typeInference/contextualSignatureInstantiation.ts b/tests/cases/conformance/types/typeRelationships/typeInference/contextualSignatureInstantiation.ts index 393d0e10d37..30c6579dabb 100644 --- a/tests/cases/conformance/types/typeRelationships/typeInference/contextualSignatureInstantiation.ts +++ b/tests/cases/conformance/types/typeRelationships/typeInference/contextualSignatureInstantiation.ts @@ -16,9 +16,9 @@ var a = bar(1, 1, g); // Should be number var a = baz(1, 1, g); // Should be number var b: number | string; -var b = foo(g); // Should be number | string -var b = bar(1, "one", g); // Should be number | string -var b = bar("one", 1, g); // Should be number | string +var b = foo(g); // Error, number and string are disjoint types +var b = bar(1, "one", g); // Error, number and string are disjoint types +var b = bar("one", 1, g); // Error, number and string are disjoint types var b = baz(b, b, g); // Should be number | string var d: number[] | string[]; diff --git a/tests/cases/fourslash/completionsTuple.ts b/tests/cases/fourslash/completionsTuple.ts new file mode 100644 index 00000000000..9ce11b53d99 --- /dev/null +++ b/tests/cases/fourslash/completionsTuple.ts @@ -0,0 +1,18 @@ +/// + +////declare const x: [number, number]; +////x[|./**/|]; + +const replacementSpan = test.ranges()[0]; +verify.completions({ + marker: "", + includes: [ + { name: "0", insertText: '[0]', replacementSpan }, + { name: "1", insertText: '[1]', replacementSpan }, + "length", + ], + excludes: "2", + preferences: { + includeInsertTextCompletions: true, + }, +}); diff --git a/tests/cases/fourslash/importNameCodeFixNewImportBaseUrl0.ts b/tests/cases/fourslash/importNameCodeFixNewImportBaseUrl0.ts index fba8875a610..c30bee2b993 100644 --- a/tests/cases/fourslash/importNameCodeFixNewImportBaseUrl0.ts +++ b/tests/cases/fourslash/importNameCodeFixNewImportBaseUrl0.ts @@ -15,8 +15,5 @@ verify.importFixAtPosition([ `import { f1 } from "b"; -f1();`, -`import { f1 } from "./a/b"; - f1();`, ]); diff --git a/tests/cases/fourslash/importNameCodeFixNewImportBaseUrl1.ts b/tests/cases/fourslash/importNameCodeFixNewImportBaseUrl1.ts index fa28dea5fe2..285a2e6ff53 100644 --- a/tests/cases/fourslash/importNameCodeFixNewImportBaseUrl1.ts +++ b/tests/cases/fourslash/importNameCodeFixNewImportBaseUrl1.ts @@ -14,14 +14,11 @@ ////[|f1/*0*/();|] goTo.file("/a/b/y.ts"); -// Order the local import first because it's simpler. +// Use the local import because it's simpler. verify.importFixAtPosition([ `import { f1 } from "./x"; f1();`, -`import { f1 } from "b/x"; - -f1();` ]); verify.importFixAtPosition([ diff --git a/tests/cases/fourslash/importNameCodeFixNewImportBaseUrl2.ts b/tests/cases/fourslash/importNameCodeFixNewImportBaseUrl2.ts index 8fc9a97afe3..1923251d10e 100644 --- a/tests/cases/fourslash/importNameCodeFixNewImportBaseUrl2.ts +++ b/tests/cases/fourslash/importNameCodeFixNewImportBaseUrl2.ts @@ -19,9 +19,6 @@ verify.importFixAtPosition([ `import { f1 } from "b/x"; f1();`, -`import { f1 } from "../b/x"; - -f1();` ]); verify.importFixAtPosition([ diff --git a/tests/cases/fourslash/importNameCodeFixNewImportTypeRoots1.ts b/tests/cases/fourslash/importNameCodeFixNewImportTypeRoots1.ts index 9743d164a9c..f4aa86ca7d7 100644 --- a/tests/cases/fourslash/importNameCodeFixNewImportTypeRoots1.ts +++ b/tests/cases/fourslash/importNameCodeFixNewImportTypeRoots1.ts @@ -16,12 +16,9 @@ //// } //// } -// "typeRoots" does not affect module resolution. Importing from "random" would be a compile error. +// "typeRoots" does not affect module resolution, though "baseUrl" does. Importing from "random" would be a compile error. verify.importFixAtPosition([ `import { foo } from "types/random"; foo();`, -`import { foo } from "../types/random"; - -foo();` ]); diff --git a/tests/cases/fourslash/importNameCodeFix_fromPathMapping.ts b/tests/cases/fourslash/importNameCodeFix_fromPathMapping.ts index dda8b855123..4affd5e33ba 100644 --- a/tests/cases/fourslash/importNameCodeFix_fromPathMapping.ts +++ b/tests/cases/fourslash/importNameCodeFix_fromPathMapping.ts @@ -3,7 +3,7 @@ // @Filename: /a.ts ////export const foo = 0; -// @Filename: /b.ts +// @Filename: /x/y.ts ////foo; // @Filename: /tsconfig.json @@ -16,7 +16,7 @@ //// } ////} -goTo.file("/b.ts"); +goTo.file("/x/y.ts"); verify.importFixAtPosition([ `import { foo } from "@root/a"; diff --git a/tests/cases/fourslash/importNameCodeFix_preferBaseUrl.ts b/tests/cases/fourslash/importNameCodeFix_preferBaseUrl.ts new file mode 100644 index 00000000000..c2aaef471a4 --- /dev/null +++ b/tests/cases/fourslash/importNameCodeFix_preferBaseUrl.ts @@ -0,0 +1,17 @@ +/// + +// @Filename: /tsconfig.json +////{ "compilerOptions": { "baseUrl": "./src" } } + +// @Filename: /src/d0/d1/d2/file.ts +////foo/**/; + +// @Filename: /src/d0/a.ts +////export const foo = 0; + +goTo.file("/src/d0/d1/d2/file.ts"); +verify.importFixAtPosition([ +`import { foo } from "d0/a"; + +foo;` +]); diff --git a/tests/cases/fourslash/importNameCodeFix_rootDirs.ts b/tests/cases/fourslash/importNameCodeFix_rootDirs.ts index d19bb8f4fa5..1367f53b9f3 100644 --- a/tests/cases/fourslash/importNameCodeFix_rootDirs.ts +++ b/tests/cases/fourslash/importNameCodeFix_rootDirs.ts @@ -18,6 +18,6 @@ const nonRelative = 'import { a } from "a";\n\na;'; const relative = nonRelative.replace('"a"', '"./a"'); goTo.file("/b.ts"); -verify.importFixAtPosition([nonRelative, relative]); +verify.importFixAtPosition([nonRelative]); verify.importFixAtPosition([nonRelative], undefined, { importModuleSpecifierPreference: "non-relative" }); verify.importFixAtPosition([relative], undefined, { importModuleSpecifierPreference: "relative" }); diff --git a/tests/cases/fourslash/signatureHelpInRecursiveType.ts b/tests/cases/fourslash/signatureHelpInRecursiveType.ts new file mode 100644 index 00000000000..ca55be37b55 --- /dev/null +++ b/tests/cases/fourslash/signatureHelpInRecursiveType.ts @@ -0,0 +1,18 @@ +/// + +////type Tail = +//// ((...args: T) => any) extends ((head: any, ...tail: infer R) => any) ? R : never; +//// +////type Reverse = _Reverse; +//// +////type _Reverse = { +//// 1: Result, +//// 0: _Reverse, 0>, +////}[Source extends [] ? 1 : 0]; +//// +////type Foo = Reverse<[0,/**/]>; + +verify.signatureHelp({ + marker: "", + text: "Reverse", +}); \ No newline at end of file