diff --git a/Gulpfile.ts b/Gulpfile.ts index 3d4bae39a32..e025ce6eaa8 100644 --- a/Gulpfile.ts +++ b/Gulpfile.ts @@ -416,7 +416,7 @@ gulp.task(servicesFile, false, ["lib", "generate-diagnostics"], () => { file.path = nodeDefinitionsFile; return content + "\r\nexport = ts;"; })) - .pipe(gulp.dest(".")), + .pipe(gulp.dest("src/services")), completedDts.pipe(clone()) .pipe(insert.transform((content, file) => { file.path = nodeStandaloneDefinitionsFile; @@ -477,12 +477,12 @@ gulp.task(tsserverLibraryFile, false, [servicesFile], (done) => { return merge2([ js.pipe(prependCopyright()) .pipe(sourcemaps.write(".")) - .pipe(gulp.dest(".")), + .pipe(gulp.dest("src/server")), dts.pipe(prependCopyright(/*outputCopyright*/true)) .pipe(insert.transform((content) => { return content + "\r\nexport = ts;\r\nexport as namespace ts;"; })) - .pipe(gulp.dest(".")) + .pipe(gulp.dest("src/server")) ]); }); @@ -960,7 +960,7 @@ gulp.task("update-sublime", "Updates the sublime plugin's tsserver", ["local", s }); gulp.task("build-rules", "Compiles tslint rules to js", () => { - const settings: tsc.Settings = getCompilerSettings({ module: "commonjs" }, /*useBuiltCompiler*/ false); + const settings: tsc.Settings = getCompilerSettings({ module: "commonjs", "lib": ["es6"] }, /*useBuiltCompiler*/ false); const dest = path.join(builtLocalDirectory, "tslint"); return gulp.src("scripts/tslint/**/*.ts") .pipe(newer({ diff --git a/Jakefile.js b/Jakefile.js index 4a31c8da179..595875dfc32 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -584,16 +584,16 @@ compileFile( file(typescriptServicesDts, [servicesFile]); var cancellationTokenFile = path.join(builtLocalDirectory, "cancellationToken.js"); -compileFile(cancellationTokenFile, cancellationTokenSources, [builtLocalDirectory].concat(cancellationTokenSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { outDir: builtLocalDirectory, noOutFile: true }); +compileFile(cancellationTokenFile, cancellationTokenSources, [builtLocalDirectory].concat(cancellationTokenSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { types: ["node"], outDir: builtLocalDirectory, noOutFile: true, lib: "es6" }); var typingsInstallerFile = path.join(builtLocalDirectory, "typingsInstaller.js"); -compileFile(typingsInstallerFile, typingsInstallerSources, [builtLocalDirectory].concat(typingsInstallerSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { outDir: builtLocalDirectory, noOutFile: false }); +compileFile(typingsInstallerFile, typingsInstallerSources, [builtLocalDirectory].concat(typingsInstallerSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { types: ["node"], outDir: builtLocalDirectory, noOutFile: false, lib: "es6,scripthost" }); var watchGuardFile = path.join(builtLocalDirectory, "watchGuard.js"); -compileFile(watchGuardFile, watchGuardSources, [builtLocalDirectory].concat(watchGuardSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { outDir: builtLocalDirectory, noOutFile: false }); +compileFile(watchGuardFile, watchGuardSources, [builtLocalDirectory].concat(watchGuardSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { types: ["node"], outDir: builtLocalDirectory, noOutFile: false, lib: "es6" }); var serverFile = path.join(builtLocalDirectory, "tsserver.js"); -compileFile(serverFile, serverSources, [builtLocalDirectory, copyright, cancellationTokenFile, typingsInstallerFile, watchGuardFile].concat(serverSources).concat(servicesSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { types: ["node"], preserveConstEnums: true }); +compileFile(serverFile, serverSources, [builtLocalDirectory, copyright, cancellationTokenFile, typingsInstallerFile, watchGuardFile].concat(serverSources).concat(servicesSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { types: ["node"], preserveConstEnums: true, lib: "es6,scripthost" }); var tsserverLibraryFile = path.join(builtLocalDirectory, "tsserverlibrary.js"); var tsserverLibraryDefinitionFile = path.join(builtLocalDirectory, "tsserverlibrary.d.ts"); compileFile( @@ -717,7 +717,7 @@ compileFile( /*prereqs*/[builtLocalDirectory, tscFile].concat(libraryTargets).concat(servicesSources).concat(harnessSources), /*prefixes*/[], /*useBuiltCompiler:*/ true, - /*opts*/ { inlineSourceMap: true, types: ["node", "mocha", "chai"] }); + /*opts*/ { inlineSourceMap: true, types: ["node", "mocha", "chai"], lib: "es6,scripthost" }); var internalTests = "internal/"; @@ -1104,7 +1104,8 @@ var tslintRules = [ "noInOperatorRule", "noIncrementDecrementRule", "objectLiteralSurroundingSpaceRule", - "noTypeAssertionWhitespaceRule" + "noTypeAssertionWhitespaceRule", + "noBomRule" ]; var tslintRulesFiles = tslintRules.map(function (p) { return path.join(tslintRuleDir, p + ".ts"); diff --git a/scripts/tslint/booleanTriviaRule.ts b/scripts/tslint/booleanTriviaRule.ts index db6abcbf17b..e79275c6392 100644 --- a/scripts/tslint/booleanTriviaRule.ts +++ b/scripts/tslint/booleanTriviaRule.ts @@ -2,52 +2,62 @@ import * as Lint from "tslint/lib"; import * as ts from "typescript"; export class Rule extends Lint.Rules.AbstractRule { - public static FAILURE_STRING_FACTORY = (name: string, currently: string) => `Tag boolean argument as '${name}' (currently '${currently}')`; + public static FAILURE_STRING_FACTORY(name: string, currently?: string): string { + const current = currently ? ` (currently '${currently}')` : ""; + return `Tag boolean argument as '${name}'${current}`; + } public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] { + // Cheat to get type checker const program = ts.createProgram([sourceFile.fileName], Lint.createCompilerOptions()); const checker = program.getTypeChecker(); - return this.applyWithWalker(new BooleanTriviaWalker(checker, program.getSourceFile(sourceFile.fileName), this.getOptions())); + return this.applyWithFunction(program.getSourceFile(sourceFile.fileName), ctx => walk(ctx, checker)); } } -class BooleanTriviaWalker extends Lint.RuleWalker { - constructor(private checker: ts.TypeChecker, file: ts.SourceFile, opts: Lint.IOptions) { - super(file, opts); +function walk(ctx: Lint.WalkContext, checker: ts.TypeChecker): void { + ts.forEachChild(ctx.sourceFile, recur); + function recur(node: ts.Node): void { + if (node.kind === ts.SyntaxKind.CallExpression) { + checkCall(node as ts.CallExpression); + } + ts.forEachChild(node, recur); } - visitCallExpression(node: ts.CallExpression) { - super.visitCallExpression(node); - if (node.arguments && node.arguments.some(arg => arg.kind === ts.SyntaxKind.TrueKeyword || arg.kind === ts.SyntaxKind.FalseKeyword)) { - const targetCallSignature = this.checker.getResolvedSignature(node); - if (!!targetCallSignature) { - const targetParameters = targetCallSignature.getParameters(); - const source = this.getSourceFile(); - for (let index = 0; index < targetParameters.length; index++) { - const param = targetParameters[index]; - const arg = node.arguments[index]; - if (!(arg && param)) { - continue; - } + function checkCall(node: ts.CallExpression): void { + if (!node.arguments || !node.arguments.some(arg => arg.kind === ts.SyntaxKind.TrueKeyword || arg.kind === ts.SyntaxKind.FalseKeyword)) { + return; + } - const argType = this.checker.getContextualType(arg); - if (argType && (argType.getFlags() & ts.TypeFlags.Boolean)) { - if (arg.kind !== ts.SyntaxKind.TrueKeyword && arg.kind !== ts.SyntaxKind.FalseKeyword) { - continue; - } - let triviaContent: string; - const ranges = ts.getLeadingCommentRanges(arg.getFullText(), 0); - if (ranges && ranges.length === 1 && ranges[0].kind === ts.SyntaxKind.MultiLineCommentTrivia) { - triviaContent = arg.getFullText().slice(ranges[0].pos + 2, ranges[0].end - 2); // +/-2 to remove /**/ - } + const targetCallSignature = checker.getResolvedSignature(node); + if (!targetCallSignature) { + return; + } - const paramName = param.getName(); - if (triviaContent !== paramName && triviaContent !== paramName + ":") { - this.addFailure(this.createFailure(arg.getStart(source), arg.getWidth(source), Rule.FAILURE_STRING_FACTORY(param.getName(), triviaContent))); - } - } + const targetParameters = targetCallSignature.getParameters(); + for (let index = 0; index < targetParameters.length; index++) { + const param = targetParameters[index]; + const arg = node.arguments[index]; + if (!(arg && param)) { + continue; + } + + const argType = checker.getContextualType(arg); + if (argType && (argType.getFlags() & ts.TypeFlags.Boolean)) { + if (arg.kind !== ts.SyntaxKind.TrueKeyword && arg.kind !== ts.SyntaxKind.FalseKeyword) { + continue; + } + let triviaContent: string | undefined; + const ranges = ts.getLeadingCommentRanges(arg.getFullText(), 0); + if (ranges && ranges.length === 1 && ranges[0].kind === ts.SyntaxKind.MultiLineCommentTrivia) { + triviaContent = arg.getFullText().slice(ranges[0].pos + 2, ranges[0].end - 2); // +/-2 to remove /**/ + } + + const paramName = param.getName(); + if (triviaContent !== paramName && triviaContent !== paramName + ":") { + ctx.addFailureAtNode(arg, Rule.FAILURE_STRING_FACTORY(param.getName(), triviaContent)); } } } } -} +} \ No newline at end of file diff --git a/scripts/tslint/nextLineRule.ts b/scripts/tslint/nextLineRule.ts index 2dee393bd84..b149d09eb38 100644 --- a/scripts/tslint/nextLineRule.ts +++ b/scripts/tslint/nextLineRule.ts @@ -9,50 +9,56 @@ export class Rule extends Lint.Rules.AbstractRule { public static ELSE_FAILURE_STRING = "'else' should not be on the same line as the preceeding block's curly brace"; public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] { - return this.applyWithWalker(new NextLineWalker(sourceFile, this.getOptions())); + const options = this.getOptions().ruleArguments; + const checkCatch = options.indexOf(OPTION_CATCH) !== -1; + const checkElse = options.indexOf(OPTION_ELSE) !== -1; + return this.applyWithFunction(sourceFile, ctx => walk(ctx, checkCatch, checkElse)); } } -class NextLineWalker extends Lint.RuleWalker { - public visitIfStatement(node: ts.IfStatement) { - const sourceFile = node.getSourceFile(); - const thenStatement = node.thenStatement; - - const elseStatement = node.elseStatement; - if (!!elseStatement) { - // find the else keyword - const elseKeyword = getFirstChildOfKind(node, ts.SyntaxKind.ElseKeyword); - if (this.hasOption(OPTION_ELSE) && !!elseKeyword) { - const thenStatementEndLoc = sourceFile.getLineAndCharacterOfPosition(thenStatement.getEnd()); - const elseKeywordLoc = sourceFile.getLineAndCharacterOfPosition(elseKeyword.getStart(sourceFile)); - if (thenStatementEndLoc.line === elseKeywordLoc.line) { - const failure = this.createFailure(elseKeyword.getStart(sourceFile), elseKeyword.getWidth(sourceFile), Rule.ELSE_FAILURE_STRING); - this.addFailure(failure); - } - } +function walk(ctx: Lint.WalkContext, checkCatch: boolean, checkElse: boolean): void { + const { sourceFile } = ctx; + function recur(node: ts.Node): void { + switch (node.kind) { + case ts.SyntaxKind.IfStatement: + checkIf(node as ts.IfStatement); + break; + case ts.SyntaxKind.TryStatement: + checkTry(node as ts.TryStatement); + break; } - - super.visitIfStatement(node); + ts.forEachChild(node, recur); } - public visitTryStatement(node: ts.TryStatement) { - const sourceFile = node.getSourceFile(); - const catchClause = node.catchClause; + function checkIf(node: ts.IfStatement): void { + const { thenStatement, elseStatement } = node; + if (!elseStatement) { + return; + } - // "visit" try block - const tryBlock = node.tryBlock; - - if (this.hasOption(OPTION_CATCH) && !!catchClause) { - const tryClosingBrace = tryBlock.getLastToken(sourceFile); - const catchKeyword = catchClause.getFirstToken(sourceFile); - const tryClosingBraceLoc = sourceFile.getLineAndCharacterOfPosition(tryClosingBrace.getEnd()); - const catchKeywordLoc = sourceFile.getLineAndCharacterOfPosition(catchKeyword.getStart(sourceFile)); - if (tryClosingBraceLoc.line === catchKeywordLoc.line) { - const failure = this.createFailure(catchKeyword.getStart(sourceFile), catchKeyword.getWidth(sourceFile), Rule.CATCH_FAILURE_STRING); - this.addFailure(failure); + // find the else keyword + const elseKeyword = getFirstChildOfKind(node, ts.SyntaxKind.ElseKeyword); + if (checkElse && !!elseKeyword) { + const thenStatementEndLoc = sourceFile.getLineAndCharacterOfPosition(thenStatement.getEnd()); + const elseKeywordLoc = sourceFile.getLineAndCharacterOfPosition(elseKeyword.getStart(sourceFile)); + if (thenStatementEndLoc.line === elseKeywordLoc.line) { + ctx.addFailureAtNode(elseKeyword, Rule.ELSE_FAILURE_STRING); } } - super.visitTryStatement(node); + } + + function checkTry({ tryBlock, catchClause }: ts.TryStatement): void { + if (!checkCatch || !catchClause) { + return; + } + + const tryClosingBrace = tryBlock.getLastToken(sourceFile); + const catchKeyword = catchClause.getFirstToken(sourceFile); + const tryClosingBraceLoc = sourceFile.getLineAndCharacterOfPosition(tryClosingBrace.getEnd()); + const catchKeywordLoc = sourceFile.getLineAndCharacterOfPosition(catchKeyword.getStart(sourceFile)); + if (tryClosingBraceLoc.line === catchKeywordLoc.line) { + ctx.addFailureAtNode(catchKeyword, Rule.CATCH_FAILURE_STRING); + } } } diff --git a/scripts/tslint/noBomRule.ts b/scripts/tslint/noBomRule.ts new file mode 100644 index 00000000000..105e2d2d68c --- /dev/null +++ b/scripts/tslint/noBomRule.ts @@ -0,0 +1,16 @@ +import * as Lint from "tslint/lib"; +import * as ts from "typescript"; + +export class Rule extends Lint.Rules.AbstractRule { + public static FAILURE_STRING = "This file has a BOM."; + + public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] { + return this.applyWithFunction(sourceFile, walk); + } +} + +function walk(ctx: Lint.WalkContext): void { + if (ctx.sourceFile.text[0] === "\ufeff") { + ctx.addFailure(0, 1, Rule.FAILURE_STRING); + } +} diff --git a/scripts/tslint/noInOperatorRule.ts b/scripts/tslint/noInOperatorRule.ts index 307f0dffd6a..95f052ccaa6 100644 --- a/scripts/tslint/noInOperatorRule.ts +++ b/scripts/tslint/noInOperatorRule.ts @@ -1,20 +1,19 @@ import * as Lint from "tslint/lib"; import * as ts from "typescript"; - export class Rule extends Lint.Rules.AbstractRule { public static FAILURE_STRING = "Don't use the 'in' keyword - use 'hasProperty' to check for key presence instead"; public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] { - return this.applyWithWalker(new InWalker(sourceFile, this.getOptions())); + return this.applyWithFunction(sourceFile, walk); } } -class InWalker extends Lint.RuleWalker { - visitNode(node: ts.Node) { - super.visitNode(node); - if (node.kind === ts.SyntaxKind.InKeyword && node.parent && node.parent.kind === ts.SyntaxKind.BinaryExpression) { - this.addFailure(this.createFailure(node.getStart(), node.getWidth(), Rule.FAILURE_STRING)); +function walk(ctx: Lint.WalkContext): void { + ts.forEachChild(ctx.sourceFile, recur); + function recur(node: ts.Node): void { + if (node.kind === ts.SyntaxKind.InKeyword && node.parent.kind === ts.SyntaxKind.BinaryExpression) { + ctx.addFailureAtNode(node, Rule.FAILURE_STRING); } } } diff --git a/scripts/tslint/noIncrementDecrementRule.ts b/scripts/tslint/noIncrementDecrementRule.ts index 2a957b36af5..ff2d81b1962 100644 --- a/scripts/tslint/noIncrementDecrementRule.ts +++ b/scripts/tslint/noIncrementDecrementRule.ts @@ -1,44 +1,55 @@ import * as Lint from "tslint/lib"; import * as ts from "typescript"; - export class Rule extends Lint.Rules.AbstractRule { public static POSTFIX_FAILURE_STRING = "Don't use '++' or '--' postfix operators outside statements or for loops."; public static PREFIX_FAILURE_STRING = "Don't use '++' or '--' prefix operators."; public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] { - return this.applyWithWalker(new IncrementDecrementWalker(sourceFile, this.getOptions())); + return this.applyWithFunction(sourceFile, walk); } } -class IncrementDecrementWalker extends Lint.RuleWalker { +function walk(ctx: Lint.WalkContext): void { + ts.forEachChild(ctx.sourceFile, recur); + function recur(node: ts.Node): void { + switch (node.kind) { + case ts.SyntaxKind.PrefixUnaryExpression: + const { operator } = node as ts.PrefixUnaryExpression; + if (operator === ts.SyntaxKind.PlusPlusToken || operator === ts.SyntaxKind.MinusMinusToken) { + check(node as ts.PrefixUnaryExpression); + } + break; - visitPostfixUnaryExpression(node: ts.PostfixUnaryExpression) { - super.visitPostfixUnaryExpression(node); - if (node.operator === ts.SyntaxKind.PlusPlusToken || node.operator == ts.SyntaxKind.MinusMinusToken) { - this.visitIncrementDecrement(node); + case ts.SyntaxKind.PostfixUnaryExpression: + check(node as ts.PostfixUnaryExpression); + break; } } - visitPrefixUnaryExpression(node: ts.PrefixUnaryExpression) { - super.visitPrefixUnaryExpression(node); - if (node.operator === ts.SyntaxKind.PlusPlusToken || node.operator == ts.SyntaxKind.MinusMinusToken) { - this.addFailure(this.createFailure(node.getStart(), node.getWidth(), Rule.PREFIX_FAILURE_STRING)); + function check(node: ts.UnaryExpression): void { + if (!isAllowedLocation(node.parent!)) { + ctx.addFailureAtNode(node, Rule.POSTFIX_FAILURE_STRING); } } - - visitIncrementDecrement(node: ts.UnaryExpression) { - if (node.parent && ( - // Can be a statement - node.parent.kind === ts.SyntaxKind.ExpressionStatement || - // Can be directly in a for-statement - node.parent.kind === ts.SyntaxKind.ForStatement || - // Can be in a comma operator in a for statement (`for (let a = 0, b = 10; a < b; a++, b--)`) - node.parent.kind === ts.SyntaxKind.BinaryExpression && - (node.parent).operatorToken.kind === ts.SyntaxKind.CommaToken && - node.parent.parent.kind === ts.SyntaxKind.ForStatement)) { - return; - } - this.addFailure(this.createFailure(node.getStart(), node.getWidth(), Rule.POSTFIX_FAILURE_STRING)); - } +} + +function isAllowedLocation(node: ts.Node): boolean { + switch (node.kind) { + // Can be a statement + case ts.SyntaxKind.ExpressionStatement: + return true; + + // Can be directly in a for-statement + case ts.SyntaxKind.ForStatement: + return true; + + // Can be in a comma operator in a for statement (`for (let a = 0, b = 10; a < b; a++, b--)`) + case ts.SyntaxKind.BinaryExpression: + return (node as ts.BinaryExpression).operatorToken.kind === ts.SyntaxKind.CommaToken && + node.parent!.kind === ts.SyntaxKind.ForStatement; + + default: + return false; + } } diff --git a/scripts/tslint/noTypeAssertionWhitespaceRule.ts b/scripts/tslint/noTypeAssertionWhitespaceRule.ts index 5368dcf74ba..37017fb60e4 100644 --- a/scripts/tslint/noTypeAssertionWhitespaceRule.ts +++ b/scripts/tslint/noTypeAssertionWhitespaceRule.ts @@ -1,25 +1,25 @@ import * as Lint from "tslint/lib"; import * as ts from "typescript"; - export class Rule extends Lint.Rules.AbstractRule { public static TRAILING_FAILURE_STRING = "Excess trailing whitespace found around type assertion."; public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] { - return this.applyWithWalker(new TypeAssertionWhitespaceWalker(sourceFile, this.getOptions())); + return this.applyWithFunction(sourceFile, walk); } } -class TypeAssertionWhitespaceWalker extends Lint.RuleWalker { - public visitNode(node: ts.Node) { +function walk(ctx: Lint.WalkContext): void { + ts.forEachChild(ctx.sourceFile, recur); + function recur(node: ts.Node) { if (node.kind === ts.SyntaxKind.TypeAssertionExpression) { const refined = node as ts.TypeAssertion; const leftSideWhitespaceStart = refined.type.getEnd() + 1; const rightSideWhitespaceEnd = refined.expression.getStart(); if (leftSideWhitespaceStart !== rightSideWhitespaceEnd) { - this.addFailure(this.createFailure(leftSideWhitespaceStart, rightSideWhitespaceEnd, Rule.TRAILING_FAILURE_STRING)); + ctx.addFailure(leftSideWhitespaceStart, rightSideWhitespaceEnd, Rule.TRAILING_FAILURE_STRING); } } - super.visitNode(node); + ts.forEachChild(node, recur); } } diff --git a/scripts/tslint/objectLiteralSurroundingSpaceRule.ts b/scripts/tslint/objectLiteralSurroundingSpaceRule.ts index a705e56c969..8546aa6c973 100644 --- a/scripts/tslint/objectLiteralSurroundingSpaceRule.ts +++ b/scripts/tslint/objectLiteralSurroundingSpaceRule.ts @@ -1,7 +1,6 @@ import * as Lint from "tslint/lib"; import * as ts from "typescript"; - export class Rule extends Lint.Rules.AbstractRule { public static LEADING_FAILURE_STRING = "No leading whitespace found on single-line object literal."; public static TRAILING_FAILURE_STRING = "No trailing whitespace found on single-line object literal."; @@ -9,34 +8,37 @@ export class Rule extends Lint.Rules.AbstractRule { public static TRAILING_EXCESS_FAILURE_STRING = "Excess trailing whitespace found on single-line object literal."; public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] { - return this.applyWithWalker(new ObjectLiteralSpaceWalker(sourceFile, this.getOptions())); + return this.applyWithFunction(sourceFile, walk); } } -class ObjectLiteralSpaceWalker extends Lint.RuleWalker { - public visitNode(node: ts.Node) { +function walk(ctx: Lint.WalkContext): void { + const { sourceFile } = ctx; + ts.forEachChild(sourceFile, recur); + function recur(node: ts.Node): void { if (node.kind === ts.SyntaxKind.ObjectLiteralExpression) { - const literal = node as ts.ObjectLiteralExpression; - const text = literal.getText(); - if (text.match(/^{[^\n]+}$/g)) { - if (text.charAt(1) !== " ") { - const failure = this.createFailure(node.pos, node.getWidth(), Rule.LEADING_FAILURE_STRING); - this.addFailure(failure); - } - if (text.charAt(2) === " ") { - const failure = this.createFailure(node.pos + 2, 1, Rule.LEADING_EXCESS_FAILURE_STRING); - this.addFailure(failure); - } - if (text.charAt(text.length - 2) !== " ") { - const failure = this.createFailure(node.pos, node.getWidth(), Rule.TRAILING_FAILURE_STRING); - this.addFailure(failure); - } - if (text.charAt(text.length - 3) === " ") { - const failure = this.createFailure(node.pos + node.getWidth() - 3, 1, Rule.TRAILING_EXCESS_FAILURE_STRING); - this.addFailure(failure); - } - } + check(node as ts.ObjectLiteralExpression); + } + ts.forEachChild(node, recur); + } + + function check(node: ts.ObjectLiteralExpression): void { + const text = node.getText(sourceFile); + if (!text.match(/^{[^\n]+}$/g)) { + return; + } + + if (text.charAt(1) !== " ") { + ctx.addFailureAtNode(node, Rule.LEADING_FAILURE_STRING); + } + if (text.charAt(2) === " ") { + ctx.addFailureAt(node.pos + 2, 1, Rule.LEADING_EXCESS_FAILURE_STRING); + } + if (text.charAt(text.length - 2) !== " ") { + ctx.addFailureAtNode(node, Rule.TRAILING_FAILURE_STRING); + } + if (text.charAt(text.length - 3) === " ") { + ctx.addFailureAt(node.pos + node.getWidth() - 3, 1, Rule.TRAILING_EXCESS_FAILURE_STRING); } - super.visitNode(node); } } diff --git a/scripts/tslint/tsconfig.json b/scripts/tslint/tsconfig.json index db018ce2776..c9bf8dc01dc 100644 --- a/scripts/tslint/tsconfig.json +++ b/scripts/tslint/tsconfig.json @@ -1,6 +1,11 @@ { "compilerOptions": { "noImplicitAny": true, + "noImplicitReturns": true, + "noImplicitThis": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "strictNullChecks": true, "module": "commonjs", "outDir": "../../built/local/tslint" } diff --git a/scripts/tslint/typeOperatorSpacingRule.ts b/scripts/tslint/typeOperatorSpacingRule.ts index 50f2971a0ee..4bd70e6eefa 100644 --- a/scripts/tslint/typeOperatorSpacingRule.ts +++ b/scripts/tslint/typeOperatorSpacingRule.ts @@ -1,34 +1,36 @@ import * as Lint from "tslint/lib"; import * as ts from "typescript"; - export class Rule extends Lint.Rules.AbstractRule { public static FAILURE_STRING = "The '|' and '&' operators must be surrounded by single spaces"; public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] { - return this.applyWithWalker(new TypeOperatorSpacingWalker(sourceFile, this.getOptions())); + return this.applyWithFunction(sourceFile, walk); } } -class TypeOperatorSpacingWalker extends Lint.RuleWalker { - public visitNode(node: ts.Node) { +function walk(ctx: Lint.WalkContext): void { + const { sourceFile } = ctx; + ts.forEachChild(sourceFile, recur); + function recur(node: ts.Node): void { if (node.kind === ts.SyntaxKind.UnionType || node.kind === ts.SyntaxKind.IntersectionType) { - const types = (node).types; - let expectedStart = types[0].end + 2; // space, | or & - for (let i = 1; i < types.length; i++) { - const currentType = types[i]; - if (expectedStart !== currentType.pos || currentType.getLeadingTriviaWidth() !== 1) { - const sourceFile = currentType.getSourceFile(); - const previousTypeEndPos = sourceFile.getLineAndCharacterOfPosition(types[i - 1].end); - const currentTypeStartPos = sourceFile.getLineAndCharacterOfPosition(currentType.pos); - if (previousTypeEndPos.line === currentTypeStartPos.line) { - const failure = this.createFailure(currentType.pos, currentType.getWidth(), Rule.FAILURE_STRING); - this.addFailure(failure); - } - } - expectedStart = currentType.end + 2; - } + check((node as ts.UnionOrIntersectionTypeNode).types); + } + ts.forEachChild(node, recur); + } + + function check(types: ts.TypeNode[]): void { + let expectedStart = types[0].end + 2; // space, | or & + for (let i = 1; i < types.length; i++) { + const currentType = types[i]; + if (expectedStart !== currentType.pos || currentType.getLeadingTriviaWidth() !== 1) { + const previousTypeEndPos = sourceFile.getLineAndCharacterOfPosition(types[i - 1].end); + const currentTypeStartPos = sourceFile.getLineAndCharacterOfPosition(currentType.pos); + if (previousTypeEndPos.line === currentTypeStartPos.line) { + ctx.addFailureAtNode(currentType, Rule.FAILURE_STRING); + } + } + expectedStart = currentType.end + 2; } - super.visitNode(node); } } diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index ef00a3aecde..418905e604c 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -1903,7 +1903,7 @@ namespace ts { // Even though in the AST the jsdoc @typedef node belongs to the current node, // its symbol might be in the same scope with the current node's symbol. Consider: - // + // // /** @typedef {string | number} MyType */ // function foo(); // @@ -2289,7 +2289,42 @@ namespace ts { declareSymbol(file.symbol.exports, file.symbol, node.left, SymbolFlags.Property | SymbolFlags.Export, SymbolFlags.None); } + function isExportsOrModuleExportsOrAlias(node: Node): boolean { + return isExportsIdentifier(node) || + isModuleExportsPropertyAccessExpression(node) || + isNameOfExportsOrModuleExportsAliasDeclaration(node); + } + + function isNameOfExportsOrModuleExportsAliasDeclaration(node: Node) { + if (node.kind === SyntaxKind.Identifier) { + const symbol = container.locals.get((node).text); + if (symbol && symbol.valueDeclaration && symbol.valueDeclaration.kind === SyntaxKind.VariableDeclaration) { + const declaration = symbol.valueDeclaration as VariableDeclaration; + if (declaration.initializer) { + return isExportsOrModuleExportsOrAliasOrAssignemnt(declaration.initializer); + } + } + } + return false; + } + + function isExportsOrModuleExportsOrAliasOrAssignemnt(node: Node): boolean { + return isExportsOrModuleExportsOrAlias(node) || + (isAssignmentExpression(node, /*excludeCompoundAssignements*/ true) && (isExportsOrModuleExportsOrAliasOrAssignemnt(node.left) || isExportsOrModuleExportsOrAliasOrAssignemnt(node.right))); + } + function bindModuleExportsAssignment(node: BinaryExpression) { + // A common practice in node modules is to set 'export = module.exports = {}', this ensures that 'exports' + // is still pointing to 'module.exports'. + // We do not want to consider this as 'export=' since a module can have only one of these. + // Similarlly we do not want to treat 'module.exports = exports' as an 'export='. + const assignedExpression = getRightMostAssignedExpression(node.right); + if (isEmptyObjectLiteral(assignedExpression) || isExportsOrModuleExportsOrAlias(assignedExpression)) { + // Mark it as a module in case there are no other exports in the file + setCommonJsModuleIndicator(node); + return; + } + // 'module.exports = expr' assignment setCommonJsModuleIndicator(node); declareSymbol(file.symbol.exports, file.symbol, node, SymbolFlags.Property | SymbolFlags.Export | SymbolFlags.ValueModule, SymbolFlags.None); @@ -2297,23 +2332,28 @@ namespace ts { function bindThisPropertyAssignment(node: BinaryExpression) { Debug.assert(isInJavaScriptFile(node)); - // Declare a 'member' if the container is an ES5 class or ES6 constructor - if (container.kind === SyntaxKind.FunctionDeclaration || container.kind === SyntaxKind.FunctionExpression) { - container.symbol.members = container.symbol.members || createMap(); - // It's acceptable for multiple 'this' assignments of the same identifier to occur - declareSymbol(container.symbol.members, container.symbol, node, SymbolFlags.Property, SymbolFlags.PropertyExcludes & ~SymbolFlags.Property); - } - else if (container.kind === SyntaxKind.Constructor) { - // this.foo assignment in a JavaScript class - // Bind this property to the containing class - const saveContainer = container; - container = container.parent; - const symbol = bindPropertyOrMethodOrAccessor(node, SymbolFlags.Property, SymbolFlags.None); - if (symbol) { - // constructor-declared symbols can be overwritten by subsequent method declarations - (symbol as Symbol).isReplaceableByMethod = true; - } - container = saveContainer; + switch (container.kind) { + case SyntaxKind.FunctionDeclaration: + case SyntaxKind.FunctionExpression: + // Declare a 'member' if the container is an ES5 class or ES6 constructor + container.symbol.members = container.symbol.members || createMap(); + // It's acceptable for multiple 'this' assignments of the same identifier to occur + declareSymbol(container.symbol.members, container.symbol, node, SymbolFlags.Property, SymbolFlags.PropertyExcludes & ~SymbolFlags.Property); + break; + + case SyntaxKind.Constructor: + case SyntaxKind.MethodDeclaration: + case SyntaxKind.GetAccessor: + case SyntaxKind.SetAccessor: + // this.foo assignment in a JavaScript class + // Bind this property to the containing class + const containingClass = container.parent; + const symbol = declareSymbol(hasModifier(container, ModifierFlags.Static) ? containingClass.symbol.exports : containingClass.symbol.members, containingClass.symbol, node, SymbolFlags.Property, SymbolFlags.None); + if (symbol) { + // symbols declared through 'this' property assignements can be overwritten by subsequent method declarations + (symbol as Symbol).isReplaceableByMethod = true; + } + break; } } @@ -2346,11 +2386,20 @@ namespace ts { leftSideOfAssignment.parent = node; target.parent = leftSideOfAssignment; - bindPropertyAssignment(target.text, leftSideOfAssignment, /*isPrototypeProperty*/ false); + if (isNameOfExportsOrModuleExportsAliasDeclaration(target)) { + // This can be an alias for the 'exports' or 'module.exports' names, e.g. + // var util = module.exports; + // util.property = function ... + bindExportsPropertyAssignment(node); + } + else { + bindPropertyAssignment(target.text, leftSideOfAssignment, /*isPrototypeProperty*/ false); + } } function bindPropertyAssignment(functionName: string, propertyAccessExpression: PropertyAccessExpression, isPrototypeProperty: boolean) { let targetSymbol = container.locals.get(functionName); + if (targetSymbol && isDeclarationOfFunctionOrClassExpression(targetSymbol)) { targetSymbol = (targetSymbol.valueDeclaration as VariableDeclaration).initializer.symbol; } diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 5d45af57343..f36f471ee75 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1,4 +1,4 @@ -/// +/// /// /* @internal */ @@ -244,6 +244,7 @@ namespace ts { const silentNeverSignature = createSignature(undefined, undefined, undefined, emptyArray, silentNeverType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); const enumNumberIndexInfo = createIndexInfo(stringType, /*isReadonly*/ true); + const jsObjectLiteralIndexInfo = createIndexInfo(anyType, /*isReadonly*/ false); const globals = createMap(); /** @@ -3368,16 +3369,6 @@ namespace ts { return strictNullChecks && optional ? includeFalsyTypes(type, TypeFlags.Undefined) : type; } - /** remove undefined from the annotated type of a parameter when there is an initializer (that doesn't include undefined) */ - function removeOptionalityFromAnnotation(annotatedType: Type, declaration: VariableLikeDeclaration): Type { - const annotationIncludesUndefined = strictNullChecks && - declaration.kind === SyntaxKind.Parameter && - declaration.initializer && - getFalsyFlags(annotatedType) & TypeFlags.Undefined && - !(getFalsyFlags(checkExpression(declaration.initializer)) & TypeFlags.Undefined); - return annotationIncludesUndefined ? getNonNullableType(annotatedType) : annotatedType; - } - // Return the inferred type for a variable, parameter, or property declaration function getTypeForVariableLikeDeclaration(declaration: VariableLikeDeclaration, includeOptionality: boolean): Type { if (declaration.flags & NodeFlags.JavaScriptFile) { @@ -3412,7 +3403,7 @@ namespace ts { // Use type from type annotation if one is present if (declaration.type) { - const declaredType = removeOptionalityFromAnnotation(getTypeFromTypeNode(declaration.type), declaration); + const declaredType = getTypeFromTypeNode(declaration.type); return addOptionality(declaredType, /*optional*/ declaration.questionToken && includeOptionality); } @@ -3487,25 +3478,41 @@ namespace ts { return undefined; } - // Return the inferred type for a variable, parameter, or property declaration - function getTypeForJSSpecialPropertyDeclaration(declaration: Declaration): Type { - const expression = declaration.kind === SyntaxKind.BinaryExpression ? declaration : - declaration.kind === SyntaxKind.PropertyAccessExpression ? getAncestor(declaration, SyntaxKind.BinaryExpression) : - undefined; + function getWidenedTypeFromJSSpecialPropertyDeclarations(symbol: Symbol) { + const types: Type[] = []; + let definedInConstructor = false; + let definedInMethod = false; + for (const declaration of symbol.declarations) { + const expression = declaration.kind === SyntaxKind.BinaryExpression ? declaration : + declaration.kind === SyntaxKind.PropertyAccessExpression ? getAncestor(declaration, SyntaxKind.BinaryExpression) : + undefined; - if (!expression) { - return unknownType; - } - - if (expression.flags & NodeFlags.JavaScriptFile) { - // If there is a JSDoc type, use it - const type = getTypeForDeclarationFromJSDocComment(expression.parent); - if (type && type !== unknownType) { - return getWidenedType(type); + if (!expression) { + return unknownType; } + + if (isPropertyAccessExpression(expression.left) && expression.left.expression.kind === SyntaxKind.ThisKeyword) { + if (getThisContainer(expression, /*includeArrowFunctions*/ false).kind === SyntaxKind.Constructor) { + definedInConstructor = true; + } + else { + definedInMethod = true; + } + } + + if (expression.flags & NodeFlags.JavaScriptFile) { + // If there is a JSDoc type, use it + const type = getTypeForDeclarationFromJSDocComment(expression.parent); + if (type && type !== unknownType) { + types.push(getWidenedType(type)); + continue; + } + } + + types.push(getWidenedLiteralType(checkExpressionCached(expression.right))); } - return getWidenedLiteralType(checkExpressionCached(expression.right)); + return getWidenedType(addOptionality(getUnionType(types, /*subtypeReduction*/ true), definedInMethod && !definedInConstructor)); } // Return the type implied by a binding pattern element. This is the type of the initializer of the element if @@ -3662,7 +3669,7 @@ namespace ts { // * className.prototype.method = expr if (declaration.kind === SyntaxKind.BinaryExpression || declaration.kind === SyntaxKind.PropertyAccessExpression && declaration.parent.kind === SyntaxKind.BinaryExpression) { - type = getWidenedType(getUnionType(map(symbol.declarations, getTypeForJSSpecialPropertyDeclaration), /*subtypeReduction*/ true)); + type = getWidenedTypeFromJSSpecialPropertyDeclarations(symbol); } else { type = getWidenedTypeForVariableLikeDeclaration(declaration, /*reportErrors*/ true); @@ -9177,13 +9184,14 @@ namespace ts { } } - function createInferenceContext(signature: Signature, inferUnionTypes: boolean): InferenceContext { + function createInferenceContext(signature: Signature, inferUnionTypes: boolean, useAnyForNoInferences: boolean): InferenceContext { const inferences = map(signature.typeParameters, createTypeInferencesObject); return { signature, inferUnionTypes, inferences, inferredTypes: new Array(signature.typeParameters.length), + useAnyForNoInferences }; } @@ -9597,7 +9605,7 @@ namespace ts { getInferenceMapper(context))); } else { - inferredType = emptyObjectType; + inferredType = context.useAnyForNoInferences ? anyType : emptyObjectType; } inferenceSucceeded = true; @@ -10248,14 +10256,11 @@ namespace ts { return false; } - function getFlowTypeOfReference(reference: Node, declaredType: Type, assumeInitialized: boolean, flowContainer: Node) { + function getFlowTypeOfReference(reference: Node, declaredType: Type, initialType = declaredType, flowContainer?: Node, couldBeUninitialized?: boolean) { let key: string; - if (!reference.flowNode || assumeInitialized && !(declaredType.flags & TypeFlags.Narrowable)) { + if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & TypeFlags.Narrowable)) { return declaredType; } - const initialType = assumeInitialized ? declaredType : - declaredType === autoType || declaredType === autoArrayType ? undefinedType : - includeFalsyTypes(declaredType, TypeFlags.Undefined); const visitedFlowStart = visitedFlowCount; const evolvedType = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); visitedFlowCount = visitedFlowStart; @@ -10934,6 +10939,16 @@ namespace ts { return symbol.flags & SymbolFlags.Variable && (getDeclarationNodeFlagsFromSymbol(symbol) & NodeFlags.Const) !== 0 && getTypeOfSymbol(symbol) !== autoArrayType; } + /** remove undefined from the annotated type of a parameter when there is an initializer (that doesn't include undefined) */ + function removeOptionalityFromDeclaredType(declaredType: Type, declaration: VariableLikeDeclaration): Type { + const annotationIncludesUndefined = strictNullChecks && + declaration.kind === SyntaxKind.Parameter && + declaration.initializer && + getFalsyFlags(declaredType) & TypeFlags.Undefined && + !(getFalsyFlags(checkExpression(declaration.initializer)) & TypeFlags.Undefined); + return annotationIncludesUndefined ? getTypeWithFacts(declaredType, TypeFacts.NEUndefined) : declaredType; + } + function checkIdentifier(node: Identifier): Type { const symbol = getResolvedSymbol(node); if (symbol === unknownSymbol) { @@ -11052,7 +11067,10 @@ namespace ts { const assumeInitialized = isParameter || isOuterVariable || type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & TypeFlags.Any) !== 0 || isInTypeQuery(node)) || isInAmbientContext(declaration); - const flowType = getFlowTypeOfReference(node, type, assumeInitialized, flowContainer); + const initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, getRootDeclaration(declaration) as VariableLikeDeclaration) : type) : + type === autoType || type === autoArrayType ? undefinedType : + includeFalsyTypes(type, TypeFlags.Undefined); + const flowType = getFlowTypeOfReference(node, type, initialType, flowContainer, !assumeInitialized); // A variable is considered uninitialized when it is possible to analyze the entire control flow graph // from declaration to use, and when the variable's declared type doesn't include undefined but the // control flow based type does include undefined. @@ -11318,7 +11336,7 @@ namespace ts { if (isClassLike(container.parent)) { const symbol = getSymbolOfNode(container.parent); const type = hasModifier(container, ModifierFlags.Static) ? getTypeOfSymbol(symbol) : (getDeclaredTypeOfSymbol(symbol)).thisType; - return getFlowTypeOfReference(node, type, /*assumeInitialized*/ true, /*flowContainer*/ undefined); + return getFlowTypeOfReference(node, type); } if (isInJavaScriptFile(node)) { @@ -11584,7 +11602,7 @@ namespace ts { } } } - if (compilerOptions.noImplicitThis) { + if (noImplicitThis) { const containingLiteral = getContainingObjectLiteral(func); if (containingLiteral) { // We have an object literal method. Check if the containing object literal has a contextual type @@ -11605,9 +11623,9 @@ namespace ts { type = getApparentTypeOfContextualType(literal); } // There was no contextual ThisType for the containing object literal, so the contextual type - // for 'this' is the contextual type for the containing object literal or the type of the object - // literal itself. - return contextualType || checkExpressionCached(containingLiteral); + // for 'this' is the non-null form of the contextual type for the containing object literal or + // the type of the object literal itself. + return contextualType ? getNonNullableType(contextualType) : checkExpressionCached(containingLiteral); } // In an assignment of the form 'obj.xxx = function(...)' or 'obj[xxx] = function(...)', the // contextual type for 'this' is 'obj'. @@ -12252,6 +12270,7 @@ namespace ts { const contextualType = getApparentTypeOfContextualType(node); const contextualTypeHasPattern = contextualType && contextualType.pattern && (contextualType.pattern.kind === SyntaxKind.ObjectBindingPattern || contextualType.pattern.kind === SyntaxKind.ObjectLiteralExpression); + const isJSObjectLiteral = !contextualType && isInJavaScriptFile(node); let typeFlags: TypeFlags = 0; let patternWithComputedProperties = false; let hasComputedStringProperty = false; @@ -12389,8 +12408,8 @@ namespace ts { return createObjectLiteralType(); function createObjectLiteralType() { - const stringIndexInfo = hasComputedStringProperty ? getObjectLiteralIndexInfo(node.properties, offset, propertiesArray, IndexKind.String) : undefined; - const numberIndexInfo = hasComputedNumberProperty ? getObjectLiteralIndexInfo(node.properties, offset, propertiesArray, IndexKind.Number) : undefined; + const stringIndexInfo = isJSObjectLiteral ? jsObjectLiteralIndexInfo : hasComputedStringProperty ? getObjectLiteralIndexInfo(node.properties, offset, propertiesArray, IndexKind.String) : undefined; + const numberIndexInfo = hasComputedNumberProperty && !isJSObjectLiteral ? getObjectLiteralIndexInfo(node.properties, offset, propertiesArray, IndexKind.Number) : undefined; const result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); const freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : TypeFlags.FreshLiteral; result.flags |= TypeFlags.ContainsObjectLiteral | freshObjectLiteralFlag | (typeFlags & TypeFlags.PropagatingFlags); @@ -13309,7 +13328,7 @@ namespace ts { !(prop.flags & SymbolFlags.Method && propType.flags & TypeFlags.Union)) { return propType; } - const flowType = getFlowTypeOfReference(node, propType, /*assumeInitialized*/ true, /*flowContainer*/ undefined); + const flowType = getFlowTypeOfReference(node, propType); return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType; } @@ -13634,7 +13653,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): Signature { - const context = createInferenceContext(signature, /*inferUnionTypes*/ true); + const context = createInferenceContext(signature, /*inferUnionTypes*/ true, /*useAnyForNoInferences*/ false); forEachMatchingParameterType(contextualSignature, signature, (source, target) => { // Type parameters from outer context referenced by source type are fixed by instantiation of the source type inferTypesWithContext(context, instantiateType(source, contextualMapper), target); @@ -14335,7 +14354,7 @@ namespace ts { let candidate: Signature; let typeArgumentsAreValid: boolean; const inferenceContext = originalCandidate.typeParameters - ? createInferenceContext(originalCandidate, /*inferUnionTypes*/ false) + ? createInferenceContext(originalCandidate, /*inferUnionTypes*/ false, /*useAnyForNoInferences*/ isInJavaScriptFile(node)) : undefined; while (true) { diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 70966c48e7c..100a241415e 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -1,4 +1,4 @@ -/// +/// /// /// /// diff --git a/src/compiler/core.ts b/src/compiler/core.ts index c3c0ba77fe4..c380a39611d 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -1,4 +1,4 @@ -/// +/// /// namespace ts { diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index ee224befd45..b10f2e7cb17 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -1,4 +1,4 @@ -/// +/// /// /// /// @@ -819,8 +819,8 @@ namespace ts { writeIfPresent(node.dotDotDotToken, "..."); emit(node.name); writeIfPresent(node.questionToken, "?"); - emitExpressionWithPrefix(" = ", node.initializer); emitWithPrefix(": ", node.type); + emitExpressionWithPrefix(" = ", node.initializer); } function emitDecorator(decorator: Decorator) { diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index cfafaabebff..3ff3bc2782f 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -1,4 +1,4 @@ -/// +/// /// namespace ts { diff --git a/src/compiler/program.ts b/src/compiler/program.ts index d46c3b2479f..67e9f62fe2d 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -290,6 +290,11 @@ namespace ts { return resolutions; } + interface DiagnosticCache { + perFile?: FileMap; + allDiagnostics?: Diagnostic[]; + } + export function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program { let program: Program; let files: SourceFile[] = []; @@ -298,6 +303,9 @@ namespace ts { let noDiagnosticsTypeChecker: TypeChecker; let classifiableNames: Map; + let cachedSemanticDiagnosticsForFile: DiagnosticCache = {}; + let cachedDeclarationDiagnosticsForFile: DiagnosticCache = {}; + let resolvedTypeReferenceDirectives = createMap(); let fileProcessingDiagnostics = createDiagnosticCollection(); @@ -899,6 +907,10 @@ namespace ts { } function getSemanticDiagnosticsForFile(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] { + return getAndCacheDiagnostics(sourceFile, cancellationToken, cachedSemanticDiagnosticsForFile, getSemanticDiagnosticsForFileNoCache); + } + + function getSemanticDiagnosticsForFileNoCache(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] { return runWithCancellationToken(() => { const typeChecker = getDiagnosticsProducingTypeChecker(); @@ -1094,7 +1106,11 @@ namespace ts { }); } - function getDeclarationDiagnosticsWorker(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] { + function getDeclarationDiagnosticsWorker(sourceFile: SourceFile | undefined, cancellationToken: CancellationToken): Diagnostic[] { + return getAndCacheDiagnostics(sourceFile, cancellationToken, cachedDeclarationDiagnosticsForFile, getDeclarationDiagnosticsForFileNoCache); + } + + function getDeclarationDiagnosticsForFileNoCache(sourceFile: SourceFile| undefined, cancellationToken: CancellationToken) { return runWithCancellationToken(() => { const resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile, cancellationToken); // Don't actually write any files since we're just getting diagnostics. @@ -1102,6 +1118,32 @@ namespace ts { }); } + function getAndCacheDiagnostics( + sourceFile: SourceFile | undefined, + cancellationToken: CancellationToken, + cache: DiagnosticCache, + getDiagnostics: (sourceFile: SourceFile, cancellationToken: CancellationToken) => Diagnostic[]) { + + const cachedResult = sourceFile + ? cache.perFile && cache.perFile.get(sourceFile.path) + : cache.allDiagnostics; + + if (cachedResult) { + return cachedResult; + } + const result = getDiagnostics(sourceFile, cancellationToken) || emptyArray; + if (sourceFile) { + if (!cache.perFile) { + cache.perFile = createFileMap(); + } + cache.perFile.set(sourceFile.path, result); + } + else { + cache.allDiagnostics = result; + } + return result; + } + function getDeclarationDiagnosticsForFile(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] { return isDeclarationFile(sourceFile) ? [] : getDeclarationDiagnosticsWorker(sourceFile, cancellationToken); } diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index cf50ab6482b..2a15df80102 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -1,4 +1,4 @@ -/// +/// declare function setTimeout(handler: (...args: any[]) => void, timeout: number): any; declare function clearTimeout(handle: any): void; diff --git a/src/compiler/transformer.ts b/src/compiler/transformer.ts index d51fdb12ac3..bb1732b57ea 100644 --- a/src/compiler/transformer.ts +++ b/src/compiler/transformer.ts @@ -1,4 +1,4 @@ -/// +/// /// /// /// diff --git a/src/compiler/transformers/destructuring.ts b/src/compiler/transformers/destructuring.ts index bb129cd1187..df372fd9a2c 100644 --- a/src/compiler/transformers/destructuring.ts +++ b/src/compiler/transformers/destructuring.ts @@ -43,7 +43,7 @@ namespace ts { let value: Expression; if (isDestructuringAssignment(node)) { value = node.right; - while (isEmptyObjectLiteralOrArrayLiteral(node.left)) { + while (isEmptyArrayLiteral(node.left) || isEmptyObjectLiteral(node.left)) { if (isDestructuringAssignment(value)) { location = node = value; value = node.right; diff --git a/src/compiler/transformers/generators.ts b/src/compiler/transformers/generators.ts index 57e85f50f39..e55cfc76db3 100644 --- a/src/compiler/transformers/generators.ts +++ b/src/compiler/transformers/generators.ts @@ -1,4 +1,4 @@ -/// +/// /// // Transforms generator functions into a compatible ES5 representation with similar runtime diff --git a/src/compiler/transformers/module/module.ts b/src/compiler/transformers/module/module.ts index 52c6db707c1..80a8c985c56 100644 --- a/src/compiler/transformers/module/module.ts +++ b/src/compiler/transformers/module/module.ts @@ -1,4 +1,4 @@ -/// +/// /// /// @@ -55,9 +55,7 @@ namespace ts { * @param node The SourceFile node. */ function transformSourceFile(node: SourceFile) { - if (isDeclarationFile(node) - || !(isExternalModule(node) - || compilerOptions.isolatedModules)) { + if (isDeclarationFile(node) || !(isExternalModule(node) || compilerOptions.isolatedModules)) { return node; } @@ -74,6 +72,14 @@ namespace ts { return aggregateTransformFlags(updated); } + + function shouldEmitUnderscoreUnderscoreESModule() { + if (!currentModuleInfo.exportEquals && isExternalModule(currentSourceFile)) { + return true; + } + return false; + } + /** * Transforms a SourceFile into a CommonJS module. * @@ -85,7 +91,7 @@ namespace ts { const statements: Statement[] = []; const statementOffset = addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, sourceElementVisitor); - if (!currentModuleInfo.exportEquals) { + if (shouldEmitUnderscoreUnderscoreESModule()) { append(statements, createUnderscoreUnderscoreESModule()); } @@ -378,7 +384,7 @@ namespace ts { const statements: Statement[] = []; const statementOffset = addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, sourceElementVisitor); - if (!currentModuleInfo.exportEquals) { + if (shouldEmitUnderscoreUnderscoreESModule()) { append(statements, createUnderscoreUnderscoreESModule()); } diff --git a/src/compiler/transformers/module/system.ts b/src/compiler/transformers/module/system.ts index 7488c51ed91..1a362c47fd1 100644 --- a/src/compiler/transformers/module/system.ts +++ b/src/compiler/transformers/module/system.ts @@ -1,4 +1,4 @@ -/// +/// /// /// diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index b3696c31153..885f8fad898 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -1,4 +1,4 @@ -/// +/// /// /// diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index b1ffcff43a4..32b6a90e268 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -1,4 +1,4 @@ -/// +/// /// namespace ts { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 7e7fe7c28e4..2d9bd9c8033 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1,4 +1,4 @@ -namespace ts { +namespace ts { /** * Type of objects whose values are all of the same type. * The `in` and `for-in` operators can *not* be safely used, @@ -3240,6 +3240,7 @@ mapper?: TypeMapper; // Type mapper for this inference context failedTypeParameterIndex?: number; // Index of type parameter for which inference failed // It is optional because in contextual signature instantiation, nothing fails + useAnyForNoInferences?: boolean; // Use any instead of {} for no inferences } /* @internal */ diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index e107c4b669b..a5229b614be 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1,4 +1,4 @@ -/// +/// /* @internal */ namespace ts { @@ -1425,6 +1425,21 @@ namespace ts { return false; } + export function getRightMostAssignedExpression(node: Node) { + while (isAssignmentExpression(node, /*excludeCompoundAssignements*/ true)) { + node = node.right; + } + return node; + } + + export function isExportsIdentifier(node: Node) { + return isIdentifier(node) && node.text === "exports"; + } + + export function isModuleExportsPropertyAccessExpression(node: Node) { + return isPropertyAccessExpression(node) && isIdentifier(node.expression) && node.expression.text === "module" && node.name.text === "exports"; + } + /// Given a BinaryExpression, returns SpecialPropertyAssignmentKind for the various kinds of property /// assignments we treat as special in the binder export function getSpecialPropertyAssignmentKind(expression: Node): SpecialPropertyAssignmentKind { @@ -3148,15 +3163,14 @@ namespace ts { (node.parent.kind === SyntaxKind.PropertyAccessExpression && (node.parent).name === node); } - export function isEmptyObjectLiteralOrArrayLiteral(expression: Node): boolean { - const kind = expression.kind; - if (kind === SyntaxKind.ObjectLiteralExpression) { - return (expression).properties.length === 0; - } - if (kind === SyntaxKind.ArrayLiteralExpression) { - return (expression).elements.length === 0; - } - return false; + export function isEmptyObjectLiteral(expression: Node): boolean { + return expression.kind === SyntaxKind.ObjectLiteralExpression && + (expression).properties.length === 0; + } + + export function isEmptyArrayLiteral(expression: Node): boolean { + return expression.kind === SyntaxKind.ArrayLiteralExpression && + (expression).elements.length === 0; } export function getLocalSymbolForExportDefault(symbol: Symbol) { diff --git a/src/compiler/visitor.ts b/src/compiler/visitor.ts index 2d75d646128..0f4a4ed6561 100644 --- a/src/compiler/visitor.ts +++ b/src/compiler/visitor.ts @@ -1,4 +1,4 @@ -/// +/// /// /// diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 2532a1875d9..0df9f4f4dd2 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -1,4 +1,4 @@ -// +// // Copyright (c) Microsoft Corporation. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/harness/tsconfig.json b/src/harness/tsconfig.json index 32af0eb2601..21622325368 100644 --- a/src/harness/tsconfig.json +++ b/src/harness/tsconfig.json @@ -6,6 +6,10 @@ "declaration": false, "types": [ "node", "mocha", "chai" + ], + "lib": [ + "es6", + "scripthost" ] }, "files": [ diff --git a/src/harness/unittests/cachingInServerLSHost.ts b/src/harness/unittests/cachingInServerLSHost.ts index caeab18958e..5ea45d2a5f6 100644 --- a/src/harness/unittests/cachingInServerLSHost.ts +++ b/src/harness/unittests/cachingInServerLSHost.ts @@ -1,4 +1,4 @@ -/// +/// namespace ts { interface File { diff --git a/src/harness/unittests/initializeTSConfig.ts b/src/harness/unittests/initializeTSConfig.ts index cb995212a94..ab9aaea0001 100644 --- a/src/harness/unittests/initializeTSConfig.ts +++ b/src/harness/unittests/initializeTSConfig.ts @@ -1,4 +1,4 @@ -/// +/// /// namespace ts { diff --git a/src/harness/unittests/printer.ts b/src/harness/unittests/printer.ts index 1a5a5a12f9e..e5167b592c2 100644 --- a/src/harness/unittests/printer.ts +++ b/src/harness/unittests/printer.ts @@ -45,6 +45,9 @@ namespace ts { // comment9 console.log(1 + 2); + + // comment10 + function functionWithDefaultArgValue(argument: string = "defaultValue"): void { } `, ScriptTarget.ES2015); printsCorrectly("default", {}, printer => printer.printFile(sourceFile)); diff --git a/src/harness/unittests/reuseProgramStructure.ts b/src/harness/unittests/reuseProgramStructure.ts index d13dd7a26fa..c9ecef0de44 100644 --- a/src/harness/unittests/reuseProgramStructure.ts +++ b/src/harness/unittests/reuseProgramStructure.ts @@ -1,4 +1,4 @@ -/// +/// /// namespace ts { diff --git a/src/harness/unittests/services/colorization.ts b/src/harness/unittests/services/colorization.ts index 70592ea4151..fd7d932885a 100644 --- a/src/harness/unittests/services/colorization.ts +++ b/src/harness/unittests/services/colorization.ts @@ -1,4 +1,4 @@ -/// +/// interface ClassificationEntry { value: any; diff --git a/src/harness/unittests/services/preProcessFile.ts b/src/harness/unittests/services/preProcessFile.ts index 403cccc8cf3..b7d319a690f 100644 --- a/src/harness/unittests/services/preProcessFile.ts +++ b/src/harness/unittests/services/preProcessFile.ts @@ -1,4 +1,4 @@ -/// +/// describe("PreProcessFile:", function () { function test(sourceText: string, readImportFile: boolean, detectJavaScriptImports: boolean, expectedPreProcess: ts.PreProcessedFileInfo): void { diff --git a/src/harness/unittests/session.ts b/src/harness/unittests/session.ts index 8d306a6099b..d3ea153e235 100644 --- a/src/harness/unittests/session.ts +++ b/src/harness/unittests/session.ts @@ -1,4 +1,4 @@ -/// +/// const expect: typeof _chai.expect = _chai.expect; diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index 1531b18bb9d..4d1b2a0b10c 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -1,4 +1,4 @@ -/// +/// /// namespace ts.projectSystem { diff --git a/src/harness/unittests/typingsInstaller.ts b/src/harness/unittests/typingsInstaller.ts index 2eae01c3520..12e62aaa7b9 100644 --- a/src/harness/unittests/typingsInstaller.ts +++ b/src/harness/unittests/typingsInstaller.ts @@ -1,4 +1,4 @@ -/// +/// /// /// diff --git a/src/server/builder.ts b/src/server/builder.ts index a5e7b06e64b..e056f0ae8c7 100644 --- a/src/server/builder.ts +++ b/src/server/builder.ts @@ -1,7 +1,6 @@ /// /// /// -/// namespace ts.server { diff --git a/src/server/cancellationToken/cancellationToken.ts b/src/server/cancellationToken/cancellationToken.ts index 71a31d14016..0e7969c1e45 100644 --- a/src/server/cancellationToken/cancellationToken.ts +++ b/src/server/cancellationToken/cancellationToken.ts @@ -37,7 +37,7 @@ function createCancellationToken(args: string[]): ServerCancellationToken { // when client wants to signal cancellation it should create a named pipe with name= // server will synchronously check the presence of the pipe and treat its existance as indicator that current request should be canceled. // in case if client prefers to use more fine-grained schema than one name for all request it can add '*' to the end of cancelellationPipeName. - // in this case pipe name will be build dynamically as . + // in this case pipe name will be build dynamically as . if (cancellationPipeName.charAt(cancellationPipeName.length - 1) === "*") { const namePrefix = cancellationPipeName.slice(0, -1); if (namePrefix.length === 0 || namePrefix.indexOf("*") >= 0) { diff --git a/src/server/cancellationToken/tsconfig.json b/src/server/cancellationToken/tsconfig.json index fa7f88ca994..604b92b4cf2 100644 --- a/src/server/cancellationToken/tsconfig.json +++ b/src/server/cancellationToken/tsconfig.json @@ -5,6 +5,9 @@ "module": "commonjs", "types": [ "node" + ], + "lib": [ + "es6" ] }, "files": [ diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index cbbe23650fb..397de9ead30 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -1,4 +1,4 @@ -/// +/// /// /// /// diff --git a/src/server/project.ts b/src/server/project.ts index 339f0288688..385816b1029 100644 --- a/src/server/project.ts +++ b/src/server/project.ts @@ -1,4 +1,4 @@ -/// +/// /// /// /// diff --git a/src/server/tsconfig.library.json b/src/server/tsconfig.library.json index 76d700dd291..e47600f9f52 100644 --- a/src/server/tsconfig.library.json +++ b/src/server/tsconfig.library.json @@ -10,7 +10,8 @@ "target": "es5", "noUnusedLocals": true, "noUnusedParameters": true, - "declaration": true + "declaration": true, + "types": [] }, "files": [ "editorServices.ts", diff --git a/src/server/typingsInstaller/nodeTypingsInstaller.ts b/src/server/typingsInstaller/nodeTypingsInstaller.ts index 447a2c05429..0a69d701953 100644 --- a/src/server/typingsInstaller/nodeTypingsInstaller.ts +++ b/src/server/typingsInstaller/nodeTypingsInstaller.ts @@ -1,4 +1,4 @@ -/// +/// /// namespace ts.server.typingsInstaller { diff --git a/src/server/typingsInstaller/tsconfig.json b/src/server/typingsInstaller/tsconfig.json index 7bfb6c8b1ed..4cfa26f8d9c 100644 --- a/src/server/typingsInstaller/tsconfig.json +++ b/src/server/typingsInstaller/tsconfig.json @@ -5,6 +5,10 @@ "outFile": "../../../built/local/typingsInstaller.js", "types": [ "node" + ], + "lib": [ + "es6", + "scripthost" ] }, "files": [ diff --git a/src/server/typingsInstaller/typingsInstaller.ts b/src/server/typingsInstaller/typingsInstaller.ts index e889f98789a..fa533450b26 100644 --- a/src/server/typingsInstaller/typingsInstaller.ts +++ b/src/server/typingsInstaller/typingsInstaller.ts @@ -1,4 +1,4 @@ -/// +/// /// /// /// diff --git a/src/server/watchGuard/tsconfig.json b/src/server/watchGuard/tsconfig.json index ef9b0ab0603..354d3d7f499 100644 --- a/src/server/watchGuard/tsconfig.json +++ b/src/server/watchGuard/tsconfig.json @@ -1,8 +1,14 @@ { - "extends": "../../tsconfig-base", + "extends": "../../tsconfig-base", "compilerOptions": { "removeComments": true, - "outFile": "../../../built/local/watchGuard.js" + "outFile": "../../../built/local/watchGuard.js", + "types": [ + "node" + ], + "lib": [ + "es6" + ] }, "files": [ "watchGuard.ts" diff --git a/src/services/codeFixProvider.ts b/src/services/codeFixProvider.ts index 10d0b8eef34..c22ba779d19 100644 --- a/src/services/codeFixProvider.ts +++ b/src/services/codeFixProvider.ts @@ -1,4 +1,4 @@ -/* @internal */ +/* @internal */ namespace ts { export interface CodeFix { errorCodes: number[]; diff --git a/src/services/codefixes/importFixes.ts b/src/services/codefixes/importFixes.ts index 1c157257051..3e07efbc3de 100644 --- a/src/services/codefixes/importFixes.ts +++ b/src/services/codefixes/importFixes.ts @@ -1,4 +1,4 @@ -/* @internal */ +/* @internal */ namespace ts.codefix { type ImportCodeActionKind = "CodeChange" | "InsertingIntoExistingImport" | "NewImport"; diff --git a/src/services/codefixes/unusedIdentifierFixes.ts b/src/services/codefixes/unusedIdentifierFixes.ts index a45a3c26dba..61d48bdc3bc 100644 --- a/src/services/codefixes/unusedIdentifierFixes.ts +++ b/src/services/codefixes/unusedIdentifierFixes.ts @@ -1,4 +1,4 @@ -/* @internal */ +/* @internal */ namespace ts.codefix { registerCodeFix({ errorCodes: [ diff --git a/src/services/documentRegistry.ts b/src/services/documentRegistry.ts index 80b0133ccfe..e2cd20a4463 100644 --- a/src/services/documentRegistry.ts +++ b/src/services/documentRegistry.ts @@ -1,4 +1,4 @@ -namespace ts { +namespace ts { /** * The document registry represents a store of SourceFile objects that can be shared between * multiple LanguageService instances. A LanguageService instance holds on the SourceFile (AST) diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index b6a8f5b5d23..bc1e50391c8 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -1,4 +1,4 @@ -/* @internal */ +/* @internal */ namespace ts.FindAllReferences { export function findReferencedSymbols(typeChecker: TypeChecker, cancellationToken: CancellationToken, sourceFiles: SourceFile[], sourceFile: SourceFile, position: number, findInStrings: boolean, findInComments: boolean, isForRename: boolean): ReferencedSymbol[] | undefined { const node = getTouchingPropertyName(sourceFile, position, /*includeJsDocComment*/ true); diff --git a/src/services/goToDefinition.ts b/src/services/goToDefinition.ts index b732d8a1193..f2602903be3 100644 --- a/src/services/goToDefinition.ts +++ b/src/services/goToDefinition.ts @@ -1,4 +1,4 @@ -/* @internal */ +/* @internal */ namespace ts.GoToDefinition { export function getDefinitionAtPosition(program: Program, sourceFile: SourceFile, position: number): DefinitionInfo[] { /// Triple slash reference comments diff --git a/src/services/jsDoc.ts b/src/services/jsDoc.ts index a2a32f95fa4..d0cf8c0aec8 100644 --- a/src/services/jsDoc.ts +++ b/src/services/jsDoc.ts @@ -1,4 +1,4 @@ -/* @internal */ +/* @internal */ namespace ts.JsDoc { const jsDocTagNames = [ "augments", diff --git a/src/services/jsTyping.ts b/src/services/jsTyping.ts index 248ceef1bd3..e7196e8f491 100644 --- a/src/services/jsTyping.ts +++ b/src/services/jsTyping.ts @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0. +// Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0. // See LICENSE.txt in the project root for complete license information. /// diff --git a/src/services/navigateTo.ts b/src/services/navigateTo.ts index 05ccbcc71f4..2c8d43b535b 100644 --- a/src/services/navigateTo.ts +++ b/src/services/navigateTo.ts @@ -1,4 +1,4 @@ -/* @internal */ +/* @internal */ namespace ts.NavigateTo { type RawNavigateToItem = { name: string; fileName: string; matchKind: PatternMatchKind; isCaseSensitive: boolean; declaration: Declaration }; diff --git a/src/services/services.ts b/src/services/services.ts index a77bacb9a86..24744c0d204 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1,4 +1,4 @@ -/// +/// /// /// diff --git a/src/services/transpile.ts b/src/services/transpile.ts index 86c6a3e8904..89ddb887809 100644 --- a/src/services/transpile.ts +++ b/src/services/transpile.ts @@ -1,4 +1,4 @@ -namespace ts { +namespace ts { export interface TranspileOptions { compilerOptions?: CompilerOptions; fileName?: string; diff --git a/src/services/utilities.ts b/src/services/utilities.ts index a4f574b9c28..7c5bf862fc8 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -1,4 +1,4 @@ -// These utilities are common to multiple language service features. +// These utilities are common to multiple language service features. /* @internal */ namespace ts { export const scanner: Scanner = createScanner(ScriptTarget.Latest, /*skipTrivia*/ true); diff --git a/tests/baselines/reference/defaultParameterAddsUndefinedWithStrictNullChecks.js b/tests/baselines/reference/defaultParameterAddsUndefinedWithStrictNullChecks.js index 329c2fb19ce..0477481c95c 100644 --- a/tests/baselines/reference/defaultParameterAddsUndefinedWithStrictNullChecks.js +++ b/tests/baselines/reference/defaultParameterAddsUndefinedWithStrictNullChecks.js @@ -18,12 +18,21 @@ function foo2(x = "string", b: number) { function foo3(x: string | undefined = "string", b: number) { x.length; // ok, should be string + x = undefined; } function foo4(x: string | undefined = undefined, b: number) { x; // should be string | undefined + x = undefined; } +type OptionalNullableString = string | null | undefined; +function allowsNull(val: OptionalNullableString = "") { + val = null; + val = 'string and null are both ok'; +} +allowsNull(null); // still allows passing null + // .d.ts should have `string | undefined` for foo1, foo2, foo3 and foo4 @@ -72,11 +81,19 @@ function foo2(x, b) { function foo3(x, b) { if (x === void 0) { x = "string"; } x.length; // ok, should be string + x = undefined; } function foo4(x, b) { if (x === void 0) { x = undefined; } x; // should be string | undefined + x = undefined; } +function allowsNull(val) { + if (val === void 0) { val = ""; } + val = null; + val = 'string and null are both ok'; +} +allowsNull(null); // still allows passing null // .d.ts should have `string | undefined` for foo1, foo2, foo3 and foo4 foo1(undefined, 1); foo2(undefined, 1); @@ -107,6 +124,8 @@ declare function foo1(x: string | undefined, b: number): void; declare function foo2(x: string | undefined, b: number): void; declare function foo3(x: string | undefined, b: number): void; declare function foo4(x: string | undefined, b: number): void; +declare type OptionalNullableString = string | null | undefined; +declare function allowsNull(val?: OptionalNullableString): void; declare function removeUndefinedButNotFalse(x?: boolean): false | undefined; declare const cond: boolean; declare function removeNothing(y?: boolean | undefined): boolean; diff --git a/tests/baselines/reference/defaultParameterAddsUndefinedWithStrictNullChecks.symbols b/tests/baselines/reference/defaultParameterAddsUndefinedWithStrictNullChecks.symbols index fb0fce7dc7f..80abc32ee73 100644 --- a/tests/baselines/reference/defaultParameterAddsUndefinedWithStrictNullChecks.symbols +++ b/tests/baselines/reference/defaultParameterAddsUndefinedWithStrictNullChecks.symbols @@ -66,18 +66,43 @@ function foo3(x: string | undefined = "string", b: number) { >x.length : Symbol(String.length, Decl(lib.d.ts, --, --)) >x : Symbol(x, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 17, 14)) >length : Symbol(String.length, Decl(lib.d.ts, --, --)) + + x = undefined; +>x : Symbol(x, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 17, 14)) +>undefined : Symbol(undefined) } function foo4(x: string | undefined = undefined, b: number) { ->foo4 : Symbol(foo4, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 19, 1)) ->x : Symbol(x, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 21, 14)) +>foo4 : Symbol(foo4, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 20, 1)) +>x : Symbol(x, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 22, 14)) >undefined : Symbol(undefined) ->b : Symbol(b, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 21, 48)) +>b : Symbol(b, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 22, 48)) x; // should be string | undefined ->x : Symbol(x, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 21, 14)) +>x : Symbol(x, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 22, 14)) + + x = undefined; +>x : Symbol(x, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 22, 14)) +>undefined : Symbol(undefined) } +type OptionalNullableString = string | null | undefined; +>OptionalNullableString : Symbol(OptionalNullableString, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 25, 1)) + +function allowsNull(val: OptionalNullableString = "") { +>allowsNull : Symbol(allowsNull, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 27, 56)) +>val : Symbol(val, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 28, 20)) +>OptionalNullableString : Symbol(OptionalNullableString, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 25, 1)) + + val = null; +>val : Symbol(val, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 28, 20)) + + val = 'string and null are both ok'; +>val : Symbol(val, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 28, 20)) +} +allowsNull(null); // still allows passing null +>allowsNull : Symbol(allowsNull, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 27, 56)) + // .d.ts should have `string | undefined` for foo1, foo2, foo3 and foo4 @@ -94,40 +119,40 @@ foo3(undefined, 1); >undefined : Symbol(undefined) foo4(undefined, 1); ->foo4 : Symbol(foo4, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 19, 1)) +>foo4 : Symbol(foo4, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 20, 1)) >undefined : Symbol(undefined) function removeUndefinedButNotFalse(x = true) { ->removeUndefinedButNotFalse : Symbol(removeUndefinedButNotFalse, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 31, 19)) ->x : Symbol(x, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 34, 36)) +>removeUndefinedButNotFalse : Symbol(removeUndefinedButNotFalse, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 40, 19)) +>x : Symbol(x, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 43, 36)) if (x === false) { ->x : Symbol(x, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 34, 36)) +>x : Symbol(x, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 43, 36)) return x; ->x : Symbol(x, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 34, 36)) +>x : Symbol(x, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 43, 36)) } } declare const cond: boolean; ->cond : Symbol(cond, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 40, 13)) +>cond : Symbol(cond, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 49, 13)) function removeNothing(y = cond ? true : undefined) { ->removeNothing : Symbol(removeNothing, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 40, 28)) ->y : Symbol(y, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 41, 23)) ->cond : Symbol(cond, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 40, 13)) +>removeNothing : Symbol(removeNothing, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 49, 28)) +>y : Symbol(y, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 50, 23)) +>cond : Symbol(cond, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 49, 13)) >undefined : Symbol(undefined) if (y !== undefined) { ->y : Symbol(y, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 41, 23)) +>y : Symbol(y, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 50, 23)) >undefined : Symbol(undefined) if (y === false) { ->y : Symbol(y, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 41, 23)) +>y : Symbol(y, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 50, 23)) return y; ->y : Symbol(y, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 41, 23)) +>y : Symbol(y, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 50, 23)) } } return true; diff --git a/tests/baselines/reference/defaultParameterAddsUndefinedWithStrictNullChecks.types b/tests/baselines/reference/defaultParameterAddsUndefinedWithStrictNullChecks.types index d95f9259891..8b8aea6370f 100644 --- a/tests/baselines/reference/defaultParameterAddsUndefinedWithStrictNullChecks.types +++ b/tests/baselines/reference/defaultParameterAddsUndefinedWithStrictNullChecks.types @@ -86,7 +86,7 @@ function foo2(x = "string", b: number) { function foo3(x: string | undefined = "string", b: number) { >foo3 : (x: string | undefined, b: number) => void ->x : string +>x : string | undefined >"string" : "string" >b : number @@ -94,6 +94,11 @@ function foo3(x: string | undefined = "string", b: number) { >x.length : number >x : string >length : number + + x = undefined; +>x = undefined : undefined +>x : string | undefined +>undefined : undefined } function foo4(x: string | undefined = undefined, b: number) { @@ -104,8 +109,38 @@ function foo4(x: string | undefined = undefined, b: number) { x; // should be string | undefined >x : string | undefined + + x = undefined; +>x = undefined : undefined +>x : string | undefined +>undefined : undefined } +type OptionalNullableString = string | null | undefined; +>OptionalNullableString : OptionalNullableString +>null : null + +function allowsNull(val: OptionalNullableString = "") { +>allowsNull : (val?: OptionalNullableString) => void +>val : OptionalNullableString +>OptionalNullableString : OptionalNullableString +>"" : "" + + val = null; +>val = null : null +>val : OptionalNullableString +>null : null + + val = 'string and null are both ok'; +>val = 'string and null are both ok' : "string and null are both ok" +>val : OptionalNullableString +>'string and null are both ok' : "string and null are both ok" +} +allowsNull(null); // still allows passing null +>allowsNull(null) : void +>allowsNull : (val?: OptionalNullableString) => void +>null : null + // .d.ts should have `string | undefined` for foo1, foo2, foo3 and foo4 diff --git a/tests/baselines/reference/importHelpersInIsolatedModules.js b/tests/baselines/reference/importHelpersInIsolatedModules.js index 72a91ac365e..454fde430d3 100644 --- a/tests/baselines/reference/importHelpersInIsolatedModules.js +++ b/tests/baselines/reference/importHelpersInIsolatedModules.js @@ -69,7 +69,6 @@ C = tslib_1.__decorate([ ], C); //// [script.js] "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); var A = (function () { function A() { diff --git a/tests/baselines/reference/inferingFromAny.symbols b/tests/baselines/reference/inferingFromAny.symbols new file mode 100644 index 00000000000..cabb8fb07b7 --- /dev/null +++ b/tests/baselines/reference/inferingFromAny.symbols @@ -0,0 +1,282 @@ +=== tests/cases/conformance/salsa/a.ts === + +var a: any; +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) + +var t: [any, any]; +>t : Symbol(t, Decl(a.ts, 2, 3), Decl(a.js, 2, 3), Decl(a.js, 11, 3), Decl(a.js, 12, 3), Decl(a.js, 13, 3)) + +declare function f1(t: T): T +>f1 : Symbol(f1, Decl(a.ts, 2, 18)) +>T : Symbol(T, Decl(a.ts, 3, 20)) +>t : Symbol(t, Decl(a.ts, 3, 23)) +>T : Symbol(T, Decl(a.ts, 3, 20)) +>T : Symbol(T, Decl(a.ts, 3, 20)) + +declare function f2(t: T[]): T; +>f2 : Symbol(f2, Decl(a.ts, 3, 31)) +>T : Symbol(T, Decl(a.ts, 4, 20)) +>t : Symbol(t, Decl(a.ts, 4, 23)) +>T : Symbol(T, Decl(a.ts, 4, 20)) +>T : Symbol(T, Decl(a.ts, 4, 20)) + +declare function f3(t: [T, U]): [T, U]; +>f3 : Symbol(f3, Decl(a.ts, 4, 34)) +>T : Symbol(T, Decl(a.ts, 5, 20)) +>U : Symbol(U, Decl(a.ts, 5, 22)) +>t : Symbol(t, Decl(a.ts, 5, 26)) +>T : Symbol(T, Decl(a.ts, 5, 20)) +>U : Symbol(U, Decl(a.ts, 5, 22)) +>T : Symbol(T, Decl(a.ts, 5, 20)) +>U : Symbol(U, Decl(a.ts, 5, 22)) + +declare function f4(x: { bar: T; baz: T }): T; +>f4 : Symbol(f4, Decl(a.ts, 5, 45)) +>T : Symbol(T, Decl(a.ts, 6, 20)) +>x : Symbol(x, Decl(a.ts, 6, 23)) +>bar : Symbol(bar, Decl(a.ts, 6, 27)) +>T : Symbol(T, Decl(a.ts, 6, 20)) +>baz : Symbol(baz, Decl(a.ts, 6, 35)) +>T : Symbol(T, Decl(a.ts, 6, 20)) +>T : Symbol(T, Decl(a.ts, 6, 20)) + +declare function f5(x: (a: T) => void): T; +>f5 : Symbol(f5, Decl(a.ts, 6, 49)) +>T : Symbol(T, Decl(a.ts, 7, 20)) +>x : Symbol(x, Decl(a.ts, 7, 23)) +>a : Symbol(a, Decl(a.ts, 7, 27)) +>T : Symbol(T, Decl(a.ts, 7, 20)) +>T : Symbol(T, Decl(a.ts, 7, 20)) + +declare function f6(x: new (a: T) => {}): T; +>f6 : Symbol(f6, Decl(a.ts, 7, 45)) +>T : Symbol(T, Decl(a.ts, 8, 20)) +>x : Symbol(x, Decl(a.ts, 8, 23)) +>a : Symbol(a, Decl(a.ts, 8, 31)) +>T : Symbol(T, Decl(a.ts, 8, 20)) +>T : Symbol(T, Decl(a.ts, 8, 20)) + +declare function f7(x: (a: any) => a is T): T; +>f7 : Symbol(f7, Decl(a.ts, 8, 47)) +>T : Symbol(T, Decl(a.ts, 9, 20)) +>x : Symbol(x, Decl(a.ts, 9, 23)) +>a : Symbol(a, Decl(a.ts, 9, 27)) +>a : Symbol(a, Decl(a.ts, 9, 27)) +>T : Symbol(T, Decl(a.ts, 9, 20)) +>T : Symbol(T, Decl(a.ts, 9, 20)) + +declare function f8(x: () => T): T; +>f8 : Symbol(f8, Decl(a.ts, 9, 49)) +>T : Symbol(T, Decl(a.ts, 10, 20)) +>x : Symbol(x, Decl(a.ts, 10, 23)) +>T : Symbol(T, Decl(a.ts, 10, 20)) +>T : Symbol(T, Decl(a.ts, 10, 20)) + +declare function f9(x: new () => T): T; +>f9 : Symbol(f9, Decl(a.ts, 10, 38)) +>T : Symbol(T, Decl(a.ts, 11, 20)) +>x : Symbol(x, Decl(a.ts, 11, 23)) +>T : Symbol(T, Decl(a.ts, 11, 20)) +>T : Symbol(T, Decl(a.ts, 11, 20)) + +declare function f10(x: { [x: string]: T }): T; +>f10 : Symbol(f10, Decl(a.ts, 11, 42)) +>T : Symbol(T, Decl(a.ts, 12, 21)) +>x : Symbol(x, Decl(a.ts, 12, 24)) +>x : Symbol(x, Decl(a.ts, 12, 30)) +>T : Symbol(T, Decl(a.ts, 12, 21)) +>T : Symbol(T, Decl(a.ts, 12, 21)) + +declare function f11(x: { [x: number]: T }): T; +>f11 : Symbol(f11, Decl(a.ts, 12, 50)) +>T : Symbol(T, Decl(a.ts, 13, 21)) +>x : Symbol(x, Decl(a.ts, 13, 24)) +>x : Symbol(x, Decl(a.ts, 13, 30)) +>T : Symbol(T, Decl(a.ts, 13, 21)) +>T : Symbol(T, Decl(a.ts, 13, 21)) + +declare function f12(x: T | U): [T, U]; +>f12 : Symbol(f12, Decl(a.ts, 13, 50)) +>T : Symbol(T, Decl(a.ts, 14, 21)) +>U : Symbol(U, Decl(a.ts, 14, 23)) +>x : Symbol(x, Decl(a.ts, 14, 27)) +>T : Symbol(T, Decl(a.ts, 14, 21)) +>U : Symbol(U, Decl(a.ts, 14, 23)) +>T : Symbol(T, Decl(a.ts, 14, 21)) +>U : Symbol(U, Decl(a.ts, 14, 23)) + +declare function f13(x: T & U): [T, U]; +>f13 : Symbol(f13, Decl(a.ts, 14, 45)) +>T : Symbol(T, Decl(a.ts, 15, 21)) +>U : Symbol(U, Decl(a.ts, 15, 23)) +>x : Symbol(x, Decl(a.ts, 15, 27)) +>T : Symbol(T, Decl(a.ts, 15, 21)) +>U : Symbol(U, Decl(a.ts, 15, 23)) +>T : Symbol(T, Decl(a.ts, 15, 21)) +>U : Symbol(U, Decl(a.ts, 15, 23)) + +declare function f14(x: { a: T | U, b: U & T }): [T, U]; +>f14 : Symbol(f14, Decl(a.ts, 15, 45)) +>T : Symbol(T, Decl(a.ts, 16, 21)) +>U : Symbol(U, Decl(a.ts, 16, 23)) +>x : Symbol(x, Decl(a.ts, 16, 27)) +>a : Symbol(a, Decl(a.ts, 16, 31)) +>T : Symbol(T, Decl(a.ts, 16, 21)) +>U : Symbol(U, Decl(a.ts, 16, 23)) +>b : Symbol(b, Decl(a.ts, 16, 41)) +>U : Symbol(U, Decl(a.ts, 16, 23)) +>T : Symbol(T, Decl(a.ts, 16, 21)) +>T : Symbol(T, Decl(a.ts, 16, 21)) +>U : Symbol(U, Decl(a.ts, 16, 23)) + +interface I { } +>I : Symbol(I, Decl(a.ts, 16, 62)) +>T : Symbol(T, Decl(a.ts, 17, 12)) + +declare function f15(x: I): T; +>f15 : Symbol(f15, Decl(a.ts, 17, 18)) +>T : Symbol(T, Decl(a.ts, 18, 21)) +>x : Symbol(x, Decl(a.ts, 18, 24)) +>I : Symbol(I, Decl(a.ts, 16, 62)) +>T : Symbol(T, Decl(a.ts, 18, 21)) +>T : Symbol(T, Decl(a.ts, 18, 21)) + +declare function f16(x: Partial): T; +>f16 : Symbol(f16, Decl(a.ts, 18, 36)) +>T : Symbol(T, Decl(a.ts, 19, 21)) +>x : Symbol(x, Decl(a.ts, 19, 24)) +>Partial : Symbol(Partial, Decl(lib.d.ts, --, --)) +>T : Symbol(T, Decl(a.ts, 19, 21)) +>T : Symbol(T, Decl(a.ts, 19, 21)) + +declare function f17(x: {[P in keyof T]: K}): T; +>f17 : Symbol(f17, Decl(a.ts, 19, 42)) +>T : Symbol(T, Decl(a.ts, 20, 21)) +>K : Symbol(K, Decl(a.ts, 20, 23)) +>x : Symbol(x, Decl(a.ts, 20, 27)) +>P : Symbol(P, Decl(a.ts, 20, 32)) +>T : Symbol(T, Decl(a.ts, 20, 21)) +>K : Symbol(K, Decl(a.ts, 20, 23)) +>T : Symbol(T, Decl(a.ts, 20, 21)) + +declare function f18(x: {[P in K]: T[P]}): T; +>f18 : Symbol(f18, Decl(a.ts, 20, 54)) +>T : Symbol(T, Decl(a.ts, 21, 21)) +>K : Symbol(K, Decl(a.ts, 21, 23)) +>T : Symbol(T, Decl(a.ts, 21, 21)) +>x : Symbol(x, Decl(a.ts, 21, 43)) +>P : Symbol(P, Decl(a.ts, 21, 48)) +>K : Symbol(K, Decl(a.ts, 21, 23)) +>T : Symbol(T, Decl(a.ts, 21, 21)) +>P : Symbol(P, Decl(a.ts, 21, 48)) +>T : Symbol(T, Decl(a.ts, 21, 21)) + +declare function f19(k: K, x: T[K]): T; +>f19 : Symbol(f19, Decl(a.ts, 21, 67)) +>T : Symbol(T, Decl(a.ts, 22, 21)) +>K : Symbol(K, Decl(a.ts, 22, 23)) +>T : Symbol(T, Decl(a.ts, 22, 21)) +>k : Symbol(k, Decl(a.ts, 22, 43)) +>K : Symbol(K, Decl(a.ts, 22, 23)) +>x : Symbol(x, Decl(a.ts, 22, 48)) +>T : Symbol(T, Decl(a.ts, 22, 21)) +>K : Symbol(K, Decl(a.ts, 22, 23)) +>T : Symbol(T, Decl(a.ts, 22, 21)) + +=== tests/cases/conformance/salsa/a.js === +var a = f1(a); +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) +>f1 : Symbol(f1, Decl(a.ts, 2, 18)) +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) + +var a = f2(a); +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) +>f2 : Symbol(f2, Decl(a.ts, 3, 31)) +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) + +var t = f3(a); +>t : Symbol(t, Decl(a.ts, 2, 3), Decl(a.js, 2, 3), Decl(a.js, 11, 3), Decl(a.js, 12, 3), Decl(a.js, 13, 3)) +>f3 : Symbol(f3, Decl(a.ts, 4, 34)) +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) + +var a = f4(a); +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) +>f4 : Symbol(f4, Decl(a.ts, 5, 45)) +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) + +var a = f5(a); +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) +>f5 : Symbol(f5, Decl(a.ts, 6, 49)) +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) + +var a = f6(a); +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) +>f6 : Symbol(f6, Decl(a.ts, 7, 45)) +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) + +var a = f7(a); +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) +>f7 : Symbol(f7, Decl(a.ts, 8, 47)) +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) + +var a = f8(a); +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) +>f8 : Symbol(f8, Decl(a.ts, 9, 49)) +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) + +var a = f9(a); +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) +>f9 : Symbol(f9, Decl(a.ts, 10, 38)) +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) + +var a = f10(a); +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) +>f10 : Symbol(f10, Decl(a.ts, 11, 42)) +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) + +var a = f11(a); +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) +>f11 : Symbol(f11, Decl(a.ts, 12, 50)) +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) + +var t = f12(a); +>t : Symbol(t, Decl(a.ts, 2, 3), Decl(a.js, 2, 3), Decl(a.js, 11, 3), Decl(a.js, 12, 3), Decl(a.js, 13, 3)) +>f12 : Symbol(f12, Decl(a.ts, 13, 50)) +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) + +var t = f13(a); +>t : Symbol(t, Decl(a.ts, 2, 3), Decl(a.js, 2, 3), Decl(a.js, 11, 3), Decl(a.js, 12, 3), Decl(a.js, 13, 3)) +>f13 : Symbol(f13, Decl(a.ts, 14, 45)) +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) + +var t = f14(a); +>t : Symbol(t, Decl(a.ts, 2, 3), Decl(a.js, 2, 3), Decl(a.js, 11, 3), Decl(a.js, 12, 3), Decl(a.js, 13, 3)) +>f14 : Symbol(f14, Decl(a.ts, 15, 45)) +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) + +var a = f15(a); +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) +>f15 : Symbol(f15, Decl(a.ts, 17, 18)) +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) + +var a = f16(a); +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) +>f16 : Symbol(f16, Decl(a.ts, 18, 36)) +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) + +var a = f17(a); +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) +>f17 : Symbol(f17, Decl(a.ts, 19, 42)) +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) + +var a = f18(a); +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) +>f18 : Symbol(f18, Decl(a.ts, 20, 54)) +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) + +var a = f19(a, a); +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) +>f19 : Symbol(f19, Decl(a.ts, 21, 67)) +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) + diff --git a/tests/baselines/reference/inferingFromAny.types b/tests/baselines/reference/inferingFromAny.types new file mode 100644 index 00000000000..c991f12f45c --- /dev/null +++ b/tests/baselines/reference/inferingFromAny.types @@ -0,0 +1,301 @@ +=== tests/cases/conformance/salsa/a.ts === + +var a: any; +>a : any + +var t: [any, any]; +>t : [any, any] + +declare function f1(t: T): T +>f1 : (t: T) => T +>T : T +>t : T +>T : T +>T : T + +declare function f2(t: T[]): T; +>f2 : (t: T[]) => T +>T : T +>t : T[] +>T : T +>T : T + +declare function f3(t: [T, U]): [T, U]; +>f3 : (t: [T, U]) => [T, U] +>T : T +>U : U +>t : [T, U] +>T : T +>U : U +>T : T +>U : U + +declare function f4(x: { bar: T; baz: T }): T; +>f4 : (x: { bar: T; baz: T; }) => T +>T : T +>x : { bar: T; baz: T; } +>bar : T +>T : T +>baz : T +>T : T +>T : T + +declare function f5(x: (a: T) => void): T; +>f5 : (x: (a: T) => void) => T +>T : T +>x : (a: T) => void +>a : T +>T : T +>T : T + +declare function f6(x: new (a: T) => {}): T; +>f6 : (x: new (a: T) => {}) => T +>T : T +>x : new (a: T) => {} +>a : T +>T : T +>T : T + +declare function f7(x: (a: any) => a is T): T; +>f7 : (x: (a: any) => a is T) => T +>T : T +>x : (a: any) => a is T +>a : any +>a : any +>T : T +>T : T + +declare function f8(x: () => T): T; +>f8 : (x: () => T) => T +>T : T +>x : () => T +>T : T +>T : T + +declare function f9(x: new () => T): T; +>f9 : (x: new () => T) => T +>T : T +>x : new () => T +>T : T +>T : T + +declare function f10(x: { [x: string]: T }): T; +>f10 : (x: { [x: string]: T; }) => T +>T : T +>x : { [x: string]: T; } +>x : string +>T : T +>T : T + +declare function f11(x: { [x: number]: T }): T; +>f11 : (x: { [x: number]: T; }) => T +>T : T +>x : { [x: number]: T; } +>x : number +>T : T +>T : T + +declare function f12(x: T | U): [T, U]; +>f12 : (x: T | U) => [T, U] +>T : T +>U : U +>x : T | U +>T : T +>U : U +>T : T +>U : U + +declare function f13(x: T & U): [T, U]; +>f13 : (x: T & U) => [T, U] +>T : T +>U : U +>x : T & U +>T : T +>U : U +>T : T +>U : U + +declare function f14(x: { a: T | U, b: U & T }): [T, U]; +>f14 : (x: { a: T | U; b: U & T; }) => [T, U] +>T : T +>U : U +>x : { a: T | U; b: U & T; } +>a : T | U +>T : T +>U : U +>b : U & T +>U : U +>T : T +>T : T +>U : U + +interface I { } +>I : I +>T : T + +declare function f15(x: I): T; +>f15 : (x: I) => T +>T : T +>x : I +>I : I +>T : T +>T : T + +declare function f16(x: Partial): T; +>f16 : (x: Partial) => T +>T : T +>x : Partial +>Partial : Partial +>T : T +>T : T + +declare function f17(x: {[P in keyof T]: K}): T; +>f17 : (x: { [P in keyof T]: K; }) => T +>T : T +>K : K +>x : { [P in keyof T]: K; } +>P : P +>T : T +>K : K +>T : T + +declare function f18(x: {[P in K]: T[P]}): T; +>f18 : (x: { [P in K]: T[P]; }) => T +>T : T +>K : K +>T : T +>x : { [P in K]: T[P]; } +>P : P +>K : K +>T : T +>P : P +>T : T + +declare function f19(k: K, x: T[K]): T; +>f19 : (k: K, x: T[K]) => T +>T : T +>K : K +>T : T +>k : K +>K : K +>x : T[K] +>T : T +>K : K +>T : T + +=== tests/cases/conformance/salsa/a.js === +var a = f1(a); +>a : any +>f1(a) : any +>f1 : (t: T) => T +>a : any + +var a = f2(a); +>a : any +>f2(a) : any +>f2 : (t: T[]) => T +>a : any + +var t = f3(a); +>t : [any, any] +>f3(a) : [any, any] +>f3 : (t: [T, U]) => [T, U] +>a : any + +var a = f4(a); +>a : any +>f4(a) : any +>f4 : (x: { bar: T; baz: T; }) => T +>a : any + +var a = f5(a); +>a : any +>f5(a) : any +>f5 : (x: (a: T) => void) => T +>a : any + +var a = f6(a); +>a : any +>f6(a) : any +>f6 : (x: new (a: T) => {}) => T +>a : any + +var a = f7(a); +>a : any +>f7(a) : any +>f7 : (x: (a: any) => a is T) => T +>a : any + +var a = f8(a); +>a : any +>f8(a) : any +>f8 : (x: () => T) => T +>a : any + +var a = f9(a); +>a : any +>f9(a) : any +>f9 : (x: new () => T) => T +>a : any + +var a = f10(a); +>a : any +>f10(a) : any +>f10 : (x: { [x: string]: T; }) => T +>a : any + +var a = f11(a); +>a : any +>f11(a) : any +>f11 : (x: { [x: number]: T; }) => T +>a : any + +var t = f12(a); +>t : [any, any] +>f12(a) : [any, any] +>f12 : (x: T | U) => [T, U] +>a : any + +var t = f13(a); +>t : [any, any] +>f13(a) : [any, any] +>f13 : (x: T & U) => [T, U] +>a : any + +var t = f14(a); +>t : [any, any] +>f14(a) : [any, any] +>f14 : (x: { a: T | U; b: U & T; }) => [T, U] +>a : any + +var a = f15(a); +>a : any +>f15(a) : any +>f15 : (x: I) => T +>a : any + +var a = f16(a); +>a : any +>f16(a) : any +>f16 : (x: Partial) => T +>a : any + +var a = f17(a); +>a : any +>f17(a) : any +>f17 : (x: { [P in keyof T]: K; }) => T +>a : any + +var a = f18(a); +>a : any +>f18(a) : any +>f18 : (x: { [P in K]: T[P]; }) => T +>a : any + +var a = f19(a, a); +>a : any +>f19(a, a) : any +>f19 : (k: K, x: T[K]) => T +>a : any +>a : any + diff --git a/tests/baselines/reference/inferringClassMembersFromAssignments.js b/tests/baselines/reference/inferringClassMembersFromAssignments.js new file mode 100644 index 00000000000..a7b9e4ff8f0 --- /dev/null +++ b/tests/baselines/reference/inferringClassMembersFromAssignments.js @@ -0,0 +1,163 @@ +//// [tests/cases/conformance/salsa/inferringClassMembersFromAssignments.ts] //// + +//// [a.js] + +class C { + constructor() { + if (Math.random()) { + this.inConstructor = 0; + } + else { + this.inConstructor = "string" + } + this.inMultiple = 0; + } + method() { + if (Math.random()) { + this.inMethod = 0; + } + else { + this.inMethod = "string" + } + this.inMultiple = "string"; + } + get() { + if (Math.random()) { + this.inGetter = 0; + } + else { + this.inGetter = "string" + } + this.inMultiple = false; + } + set() { + if (Math.random()) { + this.inSetter = 0; + } + else { + this.inSetter = "string" + } + } + static method() { + if (Math.random()) { + this.inStaticMethod = 0; + } + else { + this.inStaticMethod = "string" + } + } + static get() { + if (Math.random()) { + this.inStaticGetter = 0; + } + else { + this.inStaticGetter = "string" + } + } + static set() { + if (Math.random()) { + this.inStaticSetter = 0; + } + else { + this.inStaticSetter = "string" + } + } +} + +//// [b.ts] +var c = new C(); + +var stringOrNumber: string | number; +var stringOrNumber = c.inConstructor; + +var stringOrNumberOrUndefined: string | number | undefined; + +var stringOrNumberOrUndefined = c.inMethod; +var stringOrNumberOrUndefined = c.inGetter; +var stringOrNumberOrUndefined = c.inSetter; + +var stringOrNumberOrBoolean: string | number | boolean; + +var stringOrNumberOrBoolean = c.inMultiple; + + +var stringOrNumberOrUndefined = C.inStaticMethod; +var stringOrNumberOrUndefined = C.inStaticGetter; +var stringOrNumberOrUndefined = C.inStaticSetter; + + +//// [output.js] +var C = (function () { + function C() { + if (Math.random()) { + this.inConstructor = 0; + } + else { + this.inConstructor = "string"; + } + this.inMultiple = 0; + } + C.prototype.method = function () { + if (Math.random()) { + this.inMethod = 0; + } + else { + this.inMethod = "string"; + } + this.inMultiple = "string"; + }; + C.prototype.get = function () { + if (Math.random()) { + this.inGetter = 0; + } + else { + this.inGetter = "string"; + } + this.inMultiple = false; + }; + C.prototype.set = function () { + if (Math.random()) { + this.inSetter = 0; + } + else { + this.inSetter = "string"; + } + }; + C.method = function () { + if (Math.random()) { + this.inStaticMethod = 0; + } + else { + this.inStaticMethod = "string"; + } + }; + C.get = function () { + if (Math.random()) { + this.inStaticGetter = 0; + } + else { + this.inStaticGetter = "string"; + } + }; + C.set = function () { + if (Math.random()) { + this.inStaticSetter = 0; + } + else { + this.inStaticSetter = "string"; + } + }; + return C; +}()); +var c = new C(); +var stringOrNumber; +var stringOrNumber = c.inConstructor; +var stringOrNumberOrUndefined; +var stringOrNumberOrUndefined = c.inMethod; +var stringOrNumberOrUndefined = c.inGetter; +var stringOrNumberOrUndefined = c.inSetter; +var stringOrNumberOrBoolean; +var stringOrNumberOrBoolean = c.inMultiple; +var stringOrNumberOrUndefined = C.inStaticMethod; +var stringOrNumberOrUndefined = C.inStaticGetter; +var stringOrNumberOrUndefined = C.inStaticSetter; diff --git a/tests/baselines/reference/inferringClassMembersFromAssignments.symbols b/tests/baselines/reference/inferringClassMembersFromAssignments.symbols new file mode 100644 index 00000000000..9951339f8a8 --- /dev/null +++ b/tests/baselines/reference/inferringClassMembersFromAssignments.symbols @@ -0,0 +1,220 @@ +=== tests/cases/conformance/salsa/a.js === + +class C { +>C : Symbol(C, Decl(a.js, 0, 0)) + + constructor() { + if (Math.random()) { +>Math.random : Symbol(Math.random, Decl(lib.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>random : Symbol(Math.random, Decl(lib.d.ts, --, --)) + + this.inConstructor = 0; +>this.inConstructor : Symbol(C.inConstructor, Decl(a.js, 3, 28), Decl(a.js, 6, 14)) +>this : Symbol(C, Decl(a.js, 0, 0)) +>inConstructor : Symbol(C.inConstructor, Decl(a.js, 3, 28), Decl(a.js, 6, 14)) + } + else { + this.inConstructor = "string" +>this.inConstructor : Symbol(C.inConstructor, Decl(a.js, 3, 28), Decl(a.js, 6, 14)) +>this : Symbol(C, Decl(a.js, 0, 0)) +>inConstructor : Symbol(C.inConstructor, Decl(a.js, 3, 28), Decl(a.js, 6, 14)) + } + this.inMultiple = 0; +>this.inMultiple : Symbol(C.inMultiple, Decl(a.js, 8, 9), Decl(a.js, 17, 9), Decl(a.js, 26, 9)) +>this : Symbol(C, Decl(a.js, 0, 0)) +>inMultiple : Symbol(C.inMultiple, Decl(a.js, 8, 9), Decl(a.js, 17, 9), Decl(a.js, 26, 9)) + } + method() { +>method : Symbol(C.method, Decl(a.js, 10, 5)) + + if (Math.random()) { +>Math.random : Symbol(Math.random, Decl(lib.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>random : Symbol(Math.random, Decl(lib.d.ts, --, --)) + + this.inMethod = 0; +>this.inMethod : Symbol(C.inMethod, Decl(a.js, 12, 28), Decl(a.js, 15, 14)) +>this : Symbol(C, Decl(a.js, 0, 0)) +>inMethod : Symbol(C.inMethod, Decl(a.js, 12, 28), Decl(a.js, 15, 14)) + } + else { + this.inMethod = "string" +>this.inMethod : Symbol(C.inMethod, Decl(a.js, 12, 28), Decl(a.js, 15, 14)) +>this : Symbol(C, Decl(a.js, 0, 0)) +>inMethod : Symbol(C.inMethod, Decl(a.js, 12, 28), Decl(a.js, 15, 14)) + } + this.inMultiple = "string"; +>this.inMultiple : Symbol(C.inMultiple, Decl(a.js, 8, 9), Decl(a.js, 17, 9), Decl(a.js, 26, 9)) +>this : Symbol(C, Decl(a.js, 0, 0)) +>inMultiple : Symbol(C.inMultiple, Decl(a.js, 8, 9), Decl(a.js, 17, 9), Decl(a.js, 26, 9)) + } + get() { +>get : Symbol(C.get, Decl(a.js, 19, 5)) + + if (Math.random()) { +>Math.random : Symbol(Math.random, Decl(lib.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>random : Symbol(Math.random, Decl(lib.d.ts, --, --)) + + this.inGetter = 0; +>this.inGetter : Symbol(C.inGetter, Decl(a.js, 21, 28), Decl(a.js, 24, 14)) +>this : Symbol(C, Decl(a.js, 0, 0)) +>inGetter : Symbol(C.inGetter, Decl(a.js, 21, 28), Decl(a.js, 24, 14)) + } + else { + this.inGetter = "string" +>this.inGetter : Symbol(C.inGetter, Decl(a.js, 21, 28), Decl(a.js, 24, 14)) +>this : Symbol(C, Decl(a.js, 0, 0)) +>inGetter : Symbol(C.inGetter, Decl(a.js, 21, 28), Decl(a.js, 24, 14)) + } + this.inMultiple = false; +>this.inMultiple : Symbol(C.inMultiple, Decl(a.js, 8, 9), Decl(a.js, 17, 9), Decl(a.js, 26, 9)) +>this : Symbol(C, Decl(a.js, 0, 0)) +>inMultiple : Symbol(C.inMultiple, Decl(a.js, 8, 9), Decl(a.js, 17, 9), Decl(a.js, 26, 9)) + } + set() { +>set : Symbol(C.set, Decl(a.js, 28, 5)) + + if (Math.random()) { +>Math.random : Symbol(Math.random, Decl(lib.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>random : Symbol(Math.random, Decl(lib.d.ts, --, --)) + + this.inSetter = 0; +>this.inSetter : Symbol(C.inSetter, Decl(a.js, 30, 28), Decl(a.js, 33, 14)) +>this : Symbol(C, Decl(a.js, 0, 0)) +>inSetter : Symbol(C.inSetter, Decl(a.js, 30, 28), Decl(a.js, 33, 14)) + } + else { + this.inSetter = "string" +>this.inSetter : Symbol(C.inSetter, Decl(a.js, 30, 28), Decl(a.js, 33, 14)) +>this : Symbol(C, Decl(a.js, 0, 0)) +>inSetter : Symbol(C.inSetter, Decl(a.js, 30, 28), Decl(a.js, 33, 14)) + } + } + static method() { +>method : Symbol(C.method, Decl(a.js, 36, 5)) + + if (Math.random()) { +>Math.random : Symbol(Math.random, Decl(lib.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>random : Symbol(Math.random, Decl(lib.d.ts, --, --)) + + this.inStaticMethod = 0; +>this.inStaticMethod : Symbol(C.inStaticMethod, Decl(a.js, 38, 28), Decl(a.js, 41, 14)) +>this : Symbol(C, Decl(a.js, 0, 0)) +>inStaticMethod : Symbol(C.inStaticMethod, Decl(a.js, 38, 28), Decl(a.js, 41, 14)) + } + else { + this.inStaticMethod = "string" +>this.inStaticMethod : Symbol(C.inStaticMethod, Decl(a.js, 38, 28), Decl(a.js, 41, 14)) +>this : Symbol(C, Decl(a.js, 0, 0)) +>inStaticMethod : Symbol(C.inStaticMethod, Decl(a.js, 38, 28), Decl(a.js, 41, 14)) + } + } + static get() { +>get : Symbol(C.get, Decl(a.js, 44, 5)) + + if (Math.random()) { +>Math.random : Symbol(Math.random, Decl(lib.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>random : Symbol(Math.random, Decl(lib.d.ts, --, --)) + + this.inStaticGetter = 0; +>this.inStaticGetter : Symbol(C.inStaticGetter, Decl(a.js, 46, 28), Decl(a.js, 49, 14)) +>this : Symbol(C, Decl(a.js, 0, 0)) +>inStaticGetter : Symbol(C.inStaticGetter, Decl(a.js, 46, 28), Decl(a.js, 49, 14)) + } + else { + this.inStaticGetter = "string" +>this.inStaticGetter : Symbol(C.inStaticGetter, Decl(a.js, 46, 28), Decl(a.js, 49, 14)) +>this : Symbol(C, Decl(a.js, 0, 0)) +>inStaticGetter : Symbol(C.inStaticGetter, Decl(a.js, 46, 28), Decl(a.js, 49, 14)) + } + } + static set() { +>set : Symbol(C.set, Decl(a.js, 52, 5)) + + if (Math.random()) { +>Math.random : Symbol(Math.random, Decl(lib.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>random : Symbol(Math.random, Decl(lib.d.ts, --, --)) + + this.inStaticSetter = 0; +>this.inStaticSetter : Symbol(C.inStaticSetter, Decl(a.js, 54, 28), Decl(a.js, 57, 14)) +>this : Symbol(C, Decl(a.js, 0, 0)) +>inStaticSetter : Symbol(C.inStaticSetter, Decl(a.js, 54, 28), Decl(a.js, 57, 14)) + } + else { + this.inStaticSetter = "string" +>this.inStaticSetter : Symbol(C.inStaticSetter, Decl(a.js, 54, 28), Decl(a.js, 57, 14)) +>this : Symbol(C, Decl(a.js, 0, 0)) +>inStaticSetter : Symbol(C.inStaticSetter, Decl(a.js, 54, 28), Decl(a.js, 57, 14)) + } + } +} + +=== tests/cases/conformance/salsa/b.ts === +var c = new C(); +>c : Symbol(c, Decl(b.ts, 0, 3)) +>C : Symbol(C, Decl(a.js, 0, 0)) + +var stringOrNumber: string | number; +>stringOrNumber : Symbol(stringOrNumber, Decl(b.ts, 2, 3), Decl(b.ts, 3, 3)) + +var stringOrNumber = c.inConstructor; +>stringOrNumber : Symbol(stringOrNumber, Decl(b.ts, 2, 3), Decl(b.ts, 3, 3)) +>c.inConstructor : Symbol(C.inConstructor, Decl(a.js, 3, 28), Decl(a.js, 6, 14)) +>c : Symbol(c, Decl(b.ts, 0, 3)) +>inConstructor : Symbol(C.inConstructor, Decl(a.js, 3, 28), Decl(a.js, 6, 14)) + +var stringOrNumberOrUndefined: string | number | undefined; +>stringOrNumberOrUndefined : Symbol(stringOrNumberOrUndefined, Decl(b.ts, 5, 3), Decl(b.ts, 7, 3), Decl(b.ts, 8, 3), Decl(b.ts, 9, 3), Decl(b.ts, 16, 3), Decl(b.ts, 17, 3), Decl(b.ts, 18, 3)) + +var stringOrNumberOrUndefined = c.inMethod; +>stringOrNumberOrUndefined : Symbol(stringOrNumberOrUndefined, Decl(b.ts, 5, 3), Decl(b.ts, 7, 3), Decl(b.ts, 8, 3), Decl(b.ts, 9, 3), Decl(b.ts, 16, 3), Decl(b.ts, 17, 3), Decl(b.ts, 18, 3)) +>c.inMethod : Symbol(C.inMethod, Decl(a.js, 12, 28), Decl(a.js, 15, 14)) +>c : Symbol(c, Decl(b.ts, 0, 3)) +>inMethod : Symbol(C.inMethod, Decl(a.js, 12, 28), Decl(a.js, 15, 14)) + +var stringOrNumberOrUndefined = c.inGetter; +>stringOrNumberOrUndefined : Symbol(stringOrNumberOrUndefined, Decl(b.ts, 5, 3), Decl(b.ts, 7, 3), Decl(b.ts, 8, 3), Decl(b.ts, 9, 3), Decl(b.ts, 16, 3), Decl(b.ts, 17, 3), Decl(b.ts, 18, 3)) +>c.inGetter : Symbol(C.inGetter, Decl(a.js, 21, 28), Decl(a.js, 24, 14)) +>c : Symbol(c, Decl(b.ts, 0, 3)) +>inGetter : Symbol(C.inGetter, Decl(a.js, 21, 28), Decl(a.js, 24, 14)) + +var stringOrNumberOrUndefined = c.inSetter; +>stringOrNumberOrUndefined : Symbol(stringOrNumberOrUndefined, Decl(b.ts, 5, 3), Decl(b.ts, 7, 3), Decl(b.ts, 8, 3), Decl(b.ts, 9, 3), Decl(b.ts, 16, 3), Decl(b.ts, 17, 3), Decl(b.ts, 18, 3)) +>c.inSetter : Symbol(C.inSetter, Decl(a.js, 30, 28), Decl(a.js, 33, 14)) +>c : Symbol(c, Decl(b.ts, 0, 3)) +>inSetter : Symbol(C.inSetter, Decl(a.js, 30, 28), Decl(a.js, 33, 14)) + +var stringOrNumberOrBoolean: string | number | boolean; +>stringOrNumberOrBoolean : Symbol(stringOrNumberOrBoolean, Decl(b.ts, 11, 3), Decl(b.ts, 13, 3)) + +var stringOrNumberOrBoolean = c.inMultiple; +>stringOrNumberOrBoolean : Symbol(stringOrNumberOrBoolean, Decl(b.ts, 11, 3), Decl(b.ts, 13, 3)) +>c.inMultiple : Symbol(C.inMultiple, Decl(a.js, 8, 9), Decl(a.js, 17, 9), Decl(a.js, 26, 9)) +>c : Symbol(c, Decl(b.ts, 0, 3)) +>inMultiple : Symbol(C.inMultiple, Decl(a.js, 8, 9), Decl(a.js, 17, 9), Decl(a.js, 26, 9)) + + +var stringOrNumberOrUndefined = C.inStaticMethod; +>stringOrNumberOrUndefined : Symbol(stringOrNumberOrUndefined, Decl(b.ts, 5, 3), Decl(b.ts, 7, 3), Decl(b.ts, 8, 3), Decl(b.ts, 9, 3), Decl(b.ts, 16, 3), Decl(b.ts, 17, 3), Decl(b.ts, 18, 3)) +>C.inStaticMethod : Symbol(C.inStaticMethod, Decl(a.js, 38, 28), Decl(a.js, 41, 14)) +>C : Symbol(C, Decl(a.js, 0, 0)) +>inStaticMethod : Symbol(C.inStaticMethod, Decl(a.js, 38, 28), Decl(a.js, 41, 14)) + +var stringOrNumberOrUndefined = C.inStaticGetter; +>stringOrNumberOrUndefined : Symbol(stringOrNumberOrUndefined, Decl(b.ts, 5, 3), Decl(b.ts, 7, 3), Decl(b.ts, 8, 3), Decl(b.ts, 9, 3), Decl(b.ts, 16, 3), Decl(b.ts, 17, 3), Decl(b.ts, 18, 3)) +>C.inStaticGetter : Symbol(C.inStaticGetter, Decl(a.js, 46, 28), Decl(a.js, 49, 14)) +>C : Symbol(C, Decl(a.js, 0, 0)) +>inStaticGetter : Symbol(C.inStaticGetter, Decl(a.js, 46, 28), Decl(a.js, 49, 14)) + +var stringOrNumberOrUndefined = C.inStaticSetter; +>stringOrNumberOrUndefined : Symbol(stringOrNumberOrUndefined, Decl(b.ts, 5, 3), Decl(b.ts, 7, 3), Decl(b.ts, 8, 3), Decl(b.ts, 9, 3), Decl(b.ts, 16, 3), Decl(b.ts, 17, 3), Decl(b.ts, 18, 3)) +>C.inStaticSetter : Symbol(C.inStaticSetter, Decl(a.js, 54, 28), Decl(a.js, 57, 14)) +>C : Symbol(C, Decl(a.js, 0, 0)) +>inStaticSetter : Symbol(C.inStaticSetter, Decl(a.js, 54, 28), Decl(a.js, 57, 14)) + diff --git a/tests/baselines/reference/inferringClassMembersFromAssignments.types b/tests/baselines/reference/inferringClassMembersFromAssignments.types new file mode 100644 index 00000000000..547cc62ba32 --- /dev/null +++ b/tests/baselines/reference/inferringClassMembersFromAssignments.types @@ -0,0 +1,262 @@ +=== tests/cases/conformance/salsa/a.js === + +class C { +>C : C + + constructor() { + if (Math.random()) { +>Math.random() : number +>Math.random : () => number +>Math : Math +>random : () => number + + this.inConstructor = 0; +>this.inConstructor = 0 : 0 +>this.inConstructor : string | number +>this : this +>inConstructor : string | number +>0 : 0 + } + else { + this.inConstructor = "string" +>this.inConstructor = "string" : "string" +>this.inConstructor : string | number +>this : this +>inConstructor : string | number +>"string" : "string" + } + this.inMultiple = 0; +>this.inMultiple = 0 : 0 +>this.inMultiple : string | number | boolean +>this : this +>inMultiple : string | number | boolean +>0 : 0 + } + method() { +>method : () => void + + if (Math.random()) { +>Math.random() : number +>Math.random : () => number +>Math : Math +>random : () => number + + this.inMethod = 0; +>this.inMethod = 0 : 0 +>this.inMethod : string | number | undefined +>this : this +>inMethod : string | number | undefined +>0 : 0 + } + else { + this.inMethod = "string" +>this.inMethod = "string" : "string" +>this.inMethod : string | number | undefined +>this : this +>inMethod : string | number | undefined +>"string" : "string" + } + this.inMultiple = "string"; +>this.inMultiple = "string" : "string" +>this.inMultiple : string | number | boolean +>this : this +>inMultiple : string | number | boolean +>"string" : "string" + } + get() { +>get : () => void + + if (Math.random()) { +>Math.random() : number +>Math.random : () => number +>Math : Math +>random : () => number + + this.inGetter = 0; +>this.inGetter = 0 : 0 +>this.inGetter : string | number | undefined +>this : this +>inGetter : string | number | undefined +>0 : 0 + } + else { + this.inGetter = "string" +>this.inGetter = "string" : "string" +>this.inGetter : string | number | undefined +>this : this +>inGetter : string | number | undefined +>"string" : "string" + } + this.inMultiple = false; +>this.inMultiple = false : false +>this.inMultiple : string | number | boolean +>this : this +>inMultiple : string | number | boolean +>false : false + } + set() { +>set : () => void + + if (Math.random()) { +>Math.random() : number +>Math.random : () => number +>Math : Math +>random : () => number + + this.inSetter = 0; +>this.inSetter = 0 : 0 +>this.inSetter : string | number | undefined +>this : this +>inSetter : string | number | undefined +>0 : 0 + } + else { + this.inSetter = "string" +>this.inSetter = "string" : "string" +>this.inSetter : string | number | undefined +>this : this +>inSetter : string | number | undefined +>"string" : "string" + } + } + static method() { +>method : () => void + + if (Math.random()) { +>Math.random() : number +>Math.random : () => number +>Math : Math +>random : () => number + + this.inStaticMethod = 0; +>this.inStaticMethod = 0 : 0 +>this.inStaticMethod : string | number | undefined +>this : typeof C +>inStaticMethod : string | number | undefined +>0 : 0 + } + else { + this.inStaticMethod = "string" +>this.inStaticMethod = "string" : "string" +>this.inStaticMethod : string | number | undefined +>this : typeof C +>inStaticMethod : string | number | undefined +>"string" : "string" + } + } + static get() { +>get : () => void + + if (Math.random()) { +>Math.random() : number +>Math.random : () => number +>Math : Math +>random : () => number + + this.inStaticGetter = 0; +>this.inStaticGetter = 0 : 0 +>this.inStaticGetter : string | number | undefined +>this : typeof C +>inStaticGetter : string | number | undefined +>0 : 0 + } + else { + this.inStaticGetter = "string" +>this.inStaticGetter = "string" : "string" +>this.inStaticGetter : string | number | undefined +>this : typeof C +>inStaticGetter : string | number | undefined +>"string" : "string" + } + } + static set() { +>set : () => void + + if (Math.random()) { +>Math.random() : number +>Math.random : () => number +>Math : Math +>random : () => number + + this.inStaticSetter = 0; +>this.inStaticSetter = 0 : 0 +>this.inStaticSetter : string | number | undefined +>this : typeof C +>inStaticSetter : string | number | undefined +>0 : 0 + } + else { + this.inStaticSetter = "string" +>this.inStaticSetter = "string" : "string" +>this.inStaticSetter : string | number | undefined +>this : typeof C +>inStaticSetter : string | number | undefined +>"string" : "string" + } + } +} + +=== tests/cases/conformance/salsa/b.ts === +var c = new C(); +>c : C +>new C() : C +>C : typeof C + +var stringOrNumber: string | number; +>stringOrNumber : string | number + +var stringOrNumber = c.inConstructor; +>stringOrNumber : string | number +>c.inConstructor : string | number +>c : C +>inConstructor : string | number + +var stringOrNumberOrUndefined: string | number | undefined; +>stringOrNumberOrUndefined : string | number | undefined + +var stringOrNumberOrUndefined = c.inMethod; +>stringOrNumberOrUndefined : string | number | undefined +>c.inMethod : string | number | undefined +>c : C +>inMethod : string | number | undefined + +var stringOrNumberOrUndefined = c.inGetter; +>stringOrNumberOrUndefined : string | number | undefined +>c.inGetter : string | number | undefined +>c : C +>inGetter : string | number | undefined + +var stringOrNumberOrUndefined = c.inSetter; +>stringOrNumberOrUndefined : string | number | undefined +>c.inSetter : string | number | undefined +>c : C +>inSetter : string | number | undefined + +var stringOrNumberOrBoolean: string | number | boolean; +>stringOrNumberOrBoolean : string | number | boolean + +var stringOrNumberOrBoolean = c.inMultiple; +>stringOrNumberOrBoolean : string | number | boolean +>c.inMultiple : string | number | boolean +>c : C +>inMultiple : string | number | boolean + + +var stringOrNumberOrUndefined = C.inStaticMethod; +>stringOrNumberOrUndefined : string | number | undefined +>C.inStaticMethod : string | number | undefined +>C : typeof C +>inStaticMethod : string | number | undefined + +var stringOrNumberOrUndefined = C.inStaticGetter; +>stringOrNumberOrUndefined : string | number | undefined +>C.inStaticGetter : string | number | undefined +>C : typeof C +>inStaticGetter : string | number | undefined + +var stringOrNumberOrUndefined = C.inStaticSetter; +>stringOrNumberOrUndefined : string | number | undefined +>C.inStaticSetter : string | number | undefined +>C : typeof C +>inStaticSetter : string | number | undefined + diff --git a/tests/baselines/reference/isolatedModulesPlainFile-AMD.js b/tests/baselines/reference/isolatedModulesPlainFile-AMD.js index 4ed1fdf2c77..1e45ee159d6 100644 --- a/tests/baselines/reference/isolatedModulesPlainFile-AMD.js +++ b/tests/baselines/reference/isolatedModulesPlainFile-AMD.js @@ -7,6 +7,5 @@ run(1); //// [isolatedModulesPlainFile-AMD.js] define(["require", "exports"], function (require, exports) { "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); run(1); }); diff --git a/tests/baselines/reference/isolatedModulesPlainFile-CommonJS.js b/tests/baselines/reference/isolatedModulesPlainFile-CommonJS.js index 38739a700ef..f40d2173685 100644 --- a/tests/baselines/reference/isolatedModulesPlainFile-CommonJS.js +++ b/tests/baselines/reference/isolatedModulesPlainFile-CommonJS.js @@ -6,5 +6,4 @@ run(1); //// [isolatedModulesPlainFile-CommonJS.js] "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); run(1); diff --git a/tests/baselines/reference/isolatedModulesPlainFile-UMD.js b/tests/baselines/reference/isolatedModulesPlainFile-UMD.js index f37962a84ab..ece949b9100 100644 --- a/tests/baselines/reference/isolatedModulesPlainFile-UMD.js +++ b/tests/baselines/reference/isolatedModulesPlainFile-UMD.js @@ -15,6 +15,5 @@ run(1); } })(function (require, exports) { "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); run(1); }); diff --git a/tests/baselines/reference/jsFileCompilationShortHandProperty.types b/tests/baselines/reference/jsFileCompilationShortHandProperty.types index d6badf44909..ab8892b4661 100644 --- a/tests/baselines/reference/jsFileCompilationShortHandProperty.types +++ b/tests/baselines/reference/jsFileCompilationShortHandProperty.types @@ -1,7 +1,7 @@ === tests/cases/compiler/a.js === function foo() { ->foo : () => { a: number; b: string; } +>foo : () => { [x: string]: any; a: number; b: string; } var a = 10; >a : number @@ -12,7 +12,7 @@ function foo() { >"Hello" : "Hello" return { ->{ a, b } : { a: number; b: string; } +>{ a, b } : { [x: string]: any; a: number; b: string; } a, >a : number diff --git a/tests/baselines/reference/jsObjectsMarkedAsOpenEnded.js b/tests/baselines/reference/jsObjectsMarkedAsOpenEnded.js new file mode 100644 index 00000000000..c9bec8b56af --- /dev/null +++ b/tests/baselines/reference/jsObjectsMarkedAsOpenEnded.js @@ -0,0 +1,63 @@ +//// [tests/cases/conformance/salsa/jsObjectsMarkedAsOpenEnded.ts] //// + +//// [a.js] + +var variable = {}; +variable.a = 0; + +class C { + initializedMember = {}; + constructor() { + this.member = {}; + this.member.a = 0; + } +} + +var obj = { + property: {} +}; + +obj.property.a = 0; + +var arr = [{}]; + +function getObj() { + return {}; +} + + +//// [b.ts] +variable.a = 1; +(new C()).member.a = 1; +(new C()).initializedMember.a = 1; +obj.property.a = 1; +arr[0].a = 1; +getObj().a = 1; + + + +//// [output.js] +var variable = {}; +variable.a = 0; +var C = (function () { + function C() { + this.initializedMember = {}; + this.member = {}; + this.member.a = 0; + } + return C; +}()); +var obj = { + property: {} +}; +obj.property.a = 0; +var arr = [{}]; +function getObj() { + return {}; +} +variable.a = 1; +(new C()).member.a = 1; +(new C()).initializedMember.a = 1; +obj.property.a = 1; +arr[0].a = 1; +getObj().a = 1; diff --git a/tests/baselines/reference/jsObjectsMarkedAsOpenEnded.symbols b/tests/baselines/reference/jsObjectsMarkedAsOpenEnded.symbols new file mode 100644 index 00000000000..35a39ac6a80 --- /dev/null +++ b/tests/baselines/reference/jsObjectsMarkedAsOpenEnded.symbols @@ -0,0 +1,76 @@ +=== tests/cases/conformance/salsa/a.js === + +var variable = {}; +>variable : Symbol(variable, Decl(a.js, 1, 3)) + +variable.a = 0; +>variable : Symbol(variable, Decl(a.js, 1, 3)) + +class C { +>C : Symbol(C, Decl(a.js, 2, 15)) + + initializedMember = {}; +>initializedMember : Symbol(C.initializedMember, Decl(a.js, 4, 9)) + + constructor() { + this.member = {}; +>this.member : Symbol(C.member, Decl(a.js, 6, 19)) +>this : Symbol(C, Decl(a.js, 2, 15)) +>member : Symbol(C.member, Decl(a.js, 6, 19)) + + this.member.a = 0; +>this.member : Symbol(C.member, Decl(a.js, 6, 19)) +>this : Symbol(C, Decl(a.js, 2, 15)) +>member : Symbol(C.member, Decl(a.js, 6, 19)) + } +} + +var obj = { +>obj : Symbol(obj, Decl(a.js, 12, 3)) + + property: {} +>property : Symbol(property, Decl(a.js, 12, 11)) + +}; + +obj.property.a = 0; +>obj.property : Symbol(property, Decl(a.js, 12, 11)) +>obj : Symbol(obj, Decl(a.js, 12, 3)) +>property : Symbol(property, Decl(a.js, 12, 11)) + +var arr = [{}]; +>arr : Symbol(arr, Decl(a.js, 18, 3)) + +function getObj() { +>getObj : Symbol(getObj, Decl(a.js, 18, 15)) + + return {}; +} + + +=== tests/cases/conformance/salsa/b.ts === +variable.a = 1; +>variable : Symbol(variable, Decl(a.js, 1, 3)) + +(new C()).member.a = 1; +>(new C()).member : Symbol(C.member, Decl(a.js, 6, 19)) +>C : Symbol(C, Decl(a.js, 2, 15)) +>member : Symbol(C.member, Decl(a.js, 6, 19)) + +(new C()).initializedMember.a = 1; +>(new C()).initializedMember : Symbol(C.initializedMember, Decl(a.js, 4, 9)) +>C : Symbol(C, Decl(a.js, 2, 15)) +>initializedMember : Symbol(C.initializedMember, Decl(a.js, 4, 9)) + +obj.property.a = 1; +>obj.property : Symbol(property, Decl(a.js, 12, 11)) +>obj : Symbol(obj, Decl(a.js, 12, 3)) +>property : Symbol(property, Decl(a.js, 12, 11)) + +arr[0].a = 1; +>arr : Symbol(arr, Decl(a.js, 18, 3)) + +getObj().a = 1; +>getObj : Symbol(getObj, Decl(a.js, 18, 15)) + + diff --git a/tests/baselines/reference/jsObjectsMarkedAsOpenEnded.types b/tests/baselines/reference/jsObjectsMarkedAsOpenEnded.types new file mode 100644 index 00000000000..97f61e68a5a --- /dev/null +++ b/tests/baselines/reference/jsObjectsMarkedAsOpenEnded.types @@ -0,0 +1,128 @@ +=== tests/cases/conformance/salsa/a.js === + +var variable = {}; +>variable : { [x: string]: any; } +>{} : { [x: string]: any; } + +variable.a = 0; +>variable.a = 0 : 0 +>variable.a : any +>variable : { [x: string]: any; } +>a : any +>0 : 0 + +class C { +>C : C + + initializedMember = {}; +>initializedMember : { [x: string]: any; } +>{} : { [x: string]: any; } + + constructor() { + this.member = {}; +>this.member = {} : { [x: string]: any; } +>this.member : { [x: string]: any; } +>this : this +>member : { [x: string]: any; } +>{} : { [x: string]: any; } + + this.member.a = 0; +>this.member.a = 0 : 0 +>this.member.a : any +>this.member : { [x: string]: any; } +>this : this +>member : { [x: string]: any; } +>a : any +>0 : 0 + } +} + +var obj = { +>obj : { [x: string]: any; property: { [x: string]: any; }; } +>{ property: {}} : { [x: string]: any; property: { [x: string]: any; }; } + + property: {} +>property : { [x: string]: any; } +>{} : { [x: string]: any; } + +}; + +obj.property.a = 0; +>obj.property.a = 0 : 0 +>obj.property.a : any +>obj.property : { [x: string]: any; } +>obj : { [x: string]: any; property: { [x: string]: any; }; } +>property : { [x: string]: any; } +>a : any +>0 : 0 + +var arr = [{}]; +>arr : { [x: string]: any; }[] +>[{}] : { [x: string]: any; }[] +>{} : { [x: string]: any; } + +function getObj() { +>getObj : () => { [x: string]: any; } + + return {}; +>{} : { [x: string]: any; } +} + + +=== tests/cases/conformance/salsa/b.ts === +variable.a = 1; +>variable.a = 1 : 1 +>variable.a : any +>variable : { [x: string]: any; } +>a : any +>1 : 1 + +(new C()).member.a = 1; +>(new C()).member.a = 1 : 1 +>(new C()).member.a : any +>(new C()).member : { [x: string]: any; } +>(new C()) : C +>new C() : C +>C : typeof C +>member : { [x: string]: any; } +>a : any +>1 : 1 + +(new C()).initializedMember.a = 1; +>(new C()).initializedMember.a = 1 : 1 +>(new C()).initializedMember.a : any +>(new C()).initializedMember : { [x: string]: any; } +>(new C()) : C +>new C() : C +>C : typeof C +>initializedMember : { [x: string]: any; } +>a : any +>1 : 1 + +obj.property.a = 1; +>obj.property.a = 1 : 1 +>obj.property.a : any +>obj.property : { [x: string]: any; } +>obj : { [x: string]: any; property: { [x: string]: any; }; } +>property : { [x: string]: any; } +>a : any +>1 : 1 + +arr[0].a = 1; +>arr[0].a = 1 : 1 +>arr[0].a : any +>arr[0] : { [x: string]: any; } +>arr : { [x: string]: any; }[] +>0 : 0 +>a : any +>1 : 1 + +getObj().a = 1; +>getObj().a = 1 : 1 +>getObj().a : any +>getObj() : { [x: string]: any; } +>getObj : () => { [x: string]: any; } +>a : any +>1 : 1 + + diff --git a/tests/baselines/reference/moduleExportAlias.symbols b/tests/baselines/reference/moduleExportAlias.symbols new file mode 100644 index 00000000000..b78b6e214f3 --- /dev/null +++ b/tests/baselines/reference/moduleExportAlias.symbols @@ -0,0 +1,227 @@ +=== tests/cases/conformance/salsa/a.ts === + +import b = require("./b.js"); +>b : Symbol(b, Decl(a.ts, 0, 0)) + +b.func1; +>b.func1 : Symbol(b.func1, Decl(b.js, 0, 27)) +>b : Symbol(b, Decl(a.ts, 0, 0)) +>func1 : Symbol(b.func1, Decl(b.js, 0, 27)) + +b.func2; +>b.func2 : Symbol(b.func2, Decl(b.js, 1, 37)) +>b : Symbol(b, Decl(a.ts, 0, 0)) +>func2 : Symbol(b.func2, Decl(b.js, 1, 37)) + +b.func3; +>b.func3 : Symbol(b.func3, Decl(b.js, 4, 40)) +>b : Symbol(b, Decl(a.ts, 0, 0)) +>func3 : Symbol(b.func3, Decl(b.js, 4, 40)) + +b.func4; +>b.func4 : Symbol(b.func4, Decl(b.js, 5, 43)) +>b : Symbol(b, Decl(a.ts, 0, 0)) +>func4 : Symbol(b.func4, Decl(b.js, 5, 43)) + +b.func5; +>b.func5 : Symbol(b.func5, Decl(b.js, 8, 57)) +>b : Symbol(b, Decl(a.ts, 0, 0)) +>func5 : Symbol(b.func5, Decl(b.js, 8, 57)) + +b.func6; +>b.func6 : Symbol(b.func6, Decl(b.js, 11, 57)) +>b : Symbol(b, Decl(a.ts, 0, 0)) +>func6 : Symbol(b.func6, Decl(b.js, 11, 57)) + +b.func7; +>b.func7 : Symbol(b.func7, Decl(b.js, 15, 60)) +>b : Symbol(b, Decl(a.ts, 0, 0)) +>func7 : Symbol(b.func7, Decl(b.js, 15, 60)) + +b.func8; +>b.func8 : Symbol(b.func8, Decl(b.js, 18, 67)) +>b : Symbol(b, Decl(a.ts, 0, 0)) +>func8 : Symbol(b.func8, Decl(b.js, 18, 67)) + +b.func9; +>b.func9 : Symbol(b.func9, Decl(b.js, 21, 62)) +>b : Symbol(b, Decl(a.ts, 0, 0)) +>func9 : Symbol(b.func9, Decl(b.js, 21, 62)) + +b.func10; +>b.func10 : Symbol(b.func10, Decl(b.js, 24, 62)) +>b : Symbol(b, Decl(a.ts, 0, 0)) +>func10 : Symbol(b.func10, Decl(b.js, 24, 62)) + +b.func11; +>b.func11 : Symbol(b.func11, Decl(b.js, 27, 50), Decl(b.js, 31, 50)) +>b : Symbol(b, Decl(a.ts, 0, 0)) +>func11 : Symbol(b.func11, Decl(b.js, 27, 50), Decl(b.js, 31, 50)) + +b.func12; +>b.func12 : Symbol(b.func12, Decl(b.js, 28, 33), Decl(b.js, 32, 33)) +>b : Symbol(b, Decl(a.ts, 0, 0)) +>func12 : Symbol(b.func12, Decl(b.js, 28, 33), Decl(b.js, 32, 33)) + +b.func13; +>b.func13 : Symbol(b.func13, Decl(b.js, 35, 30)) +>b : Symbol(b, Decl(a.ts, 0, 0)) +>func13 : Symbol(b.func13, Decl(b.js, 35, 30)) + +b.func14; +>b.func14 : Symbol(b.func14, Decl(b.js, 36, 33)) +>b : Symbol(b, Decl(a.ts, 0, 0)) +>func14 : Symbol(b.func14, Decl(b.js, 36, 33)) + +b.func15; +>b.func15 : Symbol(b.func15, Decl(b.js, 39, 30)) +>b : Symbol(b, Decl(a.ts, 0, 0)) +>func15 : Symbol(b.func15, Decl(b.js, 39, 30)) + +b.func16; +>b.func16 : Symbol(b.func16, Decl(b.js, 40, 33)) +>b : Symbol(b, Decl(a.ts, 0, 0)) +>func16 : Symbol(b.func16, Decl(b.js, 40, 33)) + +b.func17; +>b.func17 : Symbol(b.func17, Decl(b.js, 43, 30)) +>b : Symbol(b, Decl(a.ts, 0, 0)) +>func17 : Symbol(b.func17, Decl(b.js, 43, 30)) + +b.func18; +>b.func18 : Symbol(b.func18, Decl(b.js, 44, 33)) +>b : Symbol(b, Decl(a.ts, 0, 0)) +>func18 : Symbol(b.func18, Decl(b.js, 44, 33)) + +b.func19; +>b.func19 : Symbol(b.func19, Decl(b.js, 47, 20)) +>b : Symbol(b, Decl(a.ts, 0, 0)) +>func19 : Symbol(b.func19, Decl(b.js, 47, 20)) + +b.func20; +>b.func20 : Symbol(b.func20, Decl(b.js, 48, 33)) +>b : Symbol(b, Decl(a.ts, 0, 0)) +>func20 : Symbol(b.func20, Decl(b.js, 48, 33)) + + +=== tests/cases/conformance/salsa/b.js === +var exportsAlias = exports; +>exportsAlias : Symbol(exportsAlias, Decl(b.js, 0, 3)) + +exportsAlias.func1 = function () { }; +>exportsAlias : Symbol(exportsAlias, Decl(b.js, 0, 3)) + +exports.func2 = function () { }; +>exports : Symbol(func2, Decl(b.js, 1, 37)) +>func2 : Symbol(func2, Decl(b.js, 1, 37)) + +var moduleExportsAlias = module.exports; +>moduleExportsAlias : Symbol(moduleExportsAlias, Decl(b.js, 4, 3)) + +moduleExportsAlias.func3 = function () { }; +>moduleExportsAlias : Symbol(moduleExportsAlias, Decl(b.js, 4, 3)) + +module.exports.func4 = function () { }; +>module.exports : Symbol(func4, Decl(b.js, 5, 43)) +>func4 : Symbol(func4, Decl(b.js, 5, 43)) + +var multipleDeclarationAlias1 = exports = module.exports; +>multipleDeclarationAlias1 : Symbol(multipleDeclarationAlias1, Decl(b.js, 8, 3)) + +multipleDeclarationAlias1.func5 = function () { }; +>multipleDeclarationAlias1 : Symbol(multipleDeclarationAlias1, Decl(b.js, 8, 3)) + +var multipleDeclarationAlias2 = module.exports = exports; +>multipleDeclarationAlias2 : Symbol(multipleDeclarationAlias2, Decl(b.js, 11, 3)) + +multipleDeclarationAlias2.func6 = function () { }; +>multipleDeclarationAlias2 : Symbol(multipleDeclarationAlias2, Decl(b.js, 11, 3)) + +var someOtherVariable; +>someOtherVariable : Symbol(someOtherVariable, Decl(b.js, 14, 3)) + +var multipleDeclarationAlias3 = someOtherVariable = exports; +>multipleDeclarationAlias3 : Symbol(multipleDeclarationAlias3, Decl(b.js, 15, 3)) +>someOtherVariable : Symbol(someOtherVariable, Decl(b.js, 14, 3)) + +multipleDeclarationAlias3.func7 = function () { }; +>multipleDeclarationAlias3 : Symbol(multipleDeclarationAlias3, Decl(b.js, 15, 3)) + +var multipleDeclarationAlias4 = someOtherVariable = module.exports; +>multipleDeclarationAlias4 : Symbol(multipleDeclarationAlias4, Decl(b.js, 18, 3)) +>someOtherVariable : Symbol(someOtherVariable, Decl(b.js, 14, 3)) + +multipleDeclarationAlias4.func8 = function () { }; +>multipleDeclarationAlias4 : Symbol(multipleDeclarationAlias4, Decl(b.js, 18, 3)) + +var multipleDeclarationAlias5 = module.exports = exports = {}; +>multipleDeclarationAlias5 : Symbol(multipleDeclarationAlias5, Decl(b.js, 21, 3)) + +multipleDeclarationAlias5.func9 = function () { }; +>multipleDeclarationAlias5 : Symbol(multipleDeclarationAlias5, Decl(b.js, 21, 3)) + +var multipleDeclarationAlias6 = exports = module.exports = {}; +>multipleDeclarationAlias6 : Symbol(multipleDeclarationAlias6, Decl(b.js, 24, 3)) + +multipleDeclarationAlias6.func10 = function () { }; +>multipleDeclarationAlias6 : Symbol(multipleDeclarationAlias6, Decl(b.js, 24, 3)) + +exports = module.exports = someOtherVariable = {}; +>someOtherVariable : Symbol(someOtherVariable, Decl(b.js, 14, 3)) + +exports.func11 = function () { }; +>exports : Symbol(func11, Decl(b.js, 27, 50), Decl(b.js, 31, 50)) +>func11 : Symbol(func11, Decl(b.js, 27, 50), Decl(b.js, 31, 50)) + +module.exports.func12 = function () { }; +>module.exports : Symbol(func12, Decl(b.js, 28, 33), Decl(b.js, 32, 33)) +>func12 : Symbol(func12, Decl(b.js, 28, 33), Decl(b.js, 32, 33)) + +exports = module.exports = someOtherVariable = {}; +>someOtherVariable : Symbol(someOtherVariable, Decl(b.js, 14, 3)) + +exports.func11 = function () { }; +>exports : Symbol(func11, Decl(b.js, 27, 50), Decl(b.js, 31, 50)) +>func11 : Symbol(func11, Decl(b.js, 27, 50), Decl(b.js, 31, 50)) + +module.exports.func12 = function () { }; +>module.exports : Symbol(func12, Decl(b.js, 28, 33), Decl(b.js, 32, 33)) +>func12 : Symbol(func12, Decl(b.js, 28, 33), Decl(b.js, 32, 33)) + +exports = module.exports = {}; +exports.func13 = function () { }; +>exports : Symbol(func13, Decl(b.js, 35, 30)) +>func13 : Symbol(func13, Decl(b.js, 35, 30)) + +module.exports.func14 = function () { }; +>module.exports : Symbol(func14, Decl(b.js, 36, 33)) +>func14 : Symbol(func14, Decl(b.js, 36, 33)) + +exports = module.exports = {}; +exports.func15 = function () { }; +>exports : Symbol(func15, Decl(b.js, 39, 30)) +>func15 : Symbol(func15, Decl(b.js, 39, 30)) + +module.exports.func16 = function () { }; +>module.exports : Symbol(func16, Decl(b.js, 40, 33)) +>func16 : Symbol(func16, Decl(b.js, 40, 33)) + +module.exports = exports = {}; +exports.func17 = function () { }; +>exports : Symbol(func17, Decl(b.js, 43, 30)) +>func17 : Symbol(func17, Decl(b.js, 43, 30)) + +module.exports.func18 = function () { }; +>module.exports : Symbol(func18, Decl(b.js, 44, 33)) +>func18 : Symbol(func18, Decl(b.js, 44, 33)) + +module.exports = {}; +exports.func19 = function () { }; +>exports : Symbol(func19, Decl(b.js, 47, 20)) +>func19 : Symbol(func19, Decl(b.js, 47, 20)) + +module.exports.func20 = function () { }; +>module.exports : Symbol(func20, Decl(b.js, 48, 33)) +>func20 : Symbol(func20, Decl(b.js, 48, 33)) + + diff --git a/tests/baselines/reference/moduleExportAlias.types b/tests/baselines/reference/moduleExportAlias.types new file mode 100644 index 00000000000..9fda7560e37 --- /dev/null +++ b/tests/baselines/reference/moduleExportAlias.types @@ -0,0 +1,395 @@ +=== tests/cases/conformance/salsa/a.ts === + +import b = require("./b.js"); +>b : typeof b + +b.func1; +>b.func1 : () => void +>b : typeof b +>func1 : () => void + +b.func2; +>b.func2 : () => void +>b : typeof b +>func2 : () => void + +b.func3; +>b.func3 : () => void +>b : typeof b +>func3 : () => void + +b.func4; +>b.func4 : () => void +>b : typeof b +>func4 : () => void + +b.func5; +>b.func5 : () => void +>b : typeof b +>func5 : () => void + +b.func6; +>b.func6 : () => void +>b : typeof b +>func6 : () => void + +b.func7; +>b.func7 : () => void +>b : typeof b +>func7 : () => void + +b.func8; +>b.func8 : () => void +>b : typeof b +>func8 : () => void + +b.func9; +>b.func9 : () => void +>b : typeof b +>func9 : () => void + +b.func10; +>b.func10 : () => void +>b : typeof b +>func10 : () => void + +b.func11; +>b.func11 : () => void +>b : typeof b +>func11 : () => void + +b.func12; +>b.func12 : () => void +>b : typeof b +>func12 : () => void + +b.func13; +>b.func13 : () => void +>b : typeof b +>func13 : () => void + +b.func14; +>b.func14 : () => void +>b : typeof b +>func14 : () => void + +b.func15; +>b.func15 : () => void +>b : typeof b +>func15 : () => void + +b.func16; +>b.func16 : () => void +>b : typeof b +>func16 : () => void + +b.func17; +>b.func17 : () => void +>b : typeof b +>func17 : () => void + +b.func18; +>b.func18 : () => void +>b : typeof b +>func18 : () => void + +b.func19; +>b.func19 : () => void +>b : typeof b +>func19 : () => void + +b.func20; +>b.func20 : () => void +>b : typeof b +>func20 : () => void + + +=== tests/cases/conformance/salsa/b.js === +var exportsAlias = exports; +>exportsAlias : any +>exports : any + +exportsAlias.func1 = function () { }; +>exportsAlias.func1 = function () { } : () => void +>exportsAlias.func1 : any +>exportsAlias : any +>func1 : any +>function () { } : () => void + +exports.func2 = function () { }; +>exports.func2 = function () { } : () => void +>exports.func2 : any +>exports : any +>func2 : any +>function () { } : () => void + +var moduleExportsAlias = module.exports; +>moduleExportsAlias : any +>module.exports : any +>module : any +>exports : any + +moduleExportsAlias.func3 = function () { }; +>moduleExportsAlias.func3 = function () { } : () => void +>moduleExportsAlias.func3 : any +>moduleExportsAlias : any +>func3 : any +>function () { } : () => void + +module.exports.func4 = function () { }; +>module.exports.func4 = function () { } : () => void +>module.exports.func4 : any +>module.exports : any +>module : any +>exports : any +>func4 : any +>function () { } : () => void + +var multipleDeclarationAlias1 = exports = module.exports; +>multipleDeclarationAlias1 : any +>exports = module.exports : any +>exports : any +>module.exports : any +>module : any +>exports : any + +multipleDeclarationAlias1.func5 = function () { }; +>multipleDeclarationAlias1.func5 = function () { } : () => void +>multipleDeclarationAlias1.func5 : any +>multipleDeclarationAlias1 : any +>func5 : any +>function () { } : () => void + +var multipleDeclarationAlias2 = module.exports = exports; +>multipleDeclarationAlias2 : any +>module.exports = exports : any +>module.exports : any +>module : any +>exports : any +>exports : any + +multipleDeclarationAlias2.func6 = function () { }; +>multipleDeclarationAlias2.func6 = function () { } : () => void +>multipleDeclarationAlias2.func6 : any +>multipleDeclarationAlias2 : any +>func6 : any +>function () { } : () => void + +var someOtherVariable; +>someOtherVariable : any + +var multipleDeclarationAlias3 = someOtherVariable = exports; +>multipleDeclarationAlias3 : any +>someOtherVariable = exports : any +>someOtherVariable : any +>exports : any + +multipleDeclarationAlias3.func7 = function () { }; +>multipleDeclarationAlias3.func7 = function () { } : () => void +>multipleDeclarationAlias3.func7 : any +>multipleDeclarationAlias3 : any +>func7 : any +>function () { } : () => void + +var multipleDeclarationAlias4 = someOtherVariable = module.exports; +>multipleDeclarationAlias4 : any +>someOtherVariable = module.exports : any +>someOtherVariable : any +>module.exports : any +>module : any +>exports : any + +multipleDeclarationAlias4.func8 = function () { }; +>multipleDeclarationAlias4.func8 = function () { } : () => void +>multipleDeclarationAlias4.func8 : any +>multipleDeclarationAlias4 : any +>func8 : any +>function () { } : () => void + +var multipleDeclarationAlias5 = module.exports = exports = {}; +>multipleDeclarationAlias5 : {} +>module.exports = exports = {} : {} +>module.exports : any +>module : any +>exports : any +>exports = {} : {} +>exports : any +>{} : {} + +multipleDeclarationAlias5.func9 = function () { }; +>multipleDeclarationAlias5.func9 = function () { } : () => void +>multipleDeclarationAlias5.func9 : any +>multipleDeclarationAlias5 : {} +>func9 : any +>function () { } : () => void + +var multipleDeclarationAlias6 = exports = module.exports = {}; +>multipleDeclarationAlias6 : { [x: string]: any; } +>exports = module.exports = {} : { [x: string]: any; } +>exports : any +>module.exports = {} : { [x: string]: any; } +>module.exports : any +>module : any +>exports : any +>{} : { [x: string]: any; } + +multipleDeclarationAlias6.func10 = function () { }; +>multipleDeclarationAlias6.func10 = function () { } : () => void +>multipleDeclarationAlias6.func10 : any +>multipleDeclarationAlias6 : { [x: string]: any; } +>func10 : any +>function () { } : () => void + +exports = module.exports = someOtherVariable = {}; +>exports = module.exports = someOtherVariable = {} : {} +>exports : any +>module.exports = someOtherVariable = {} : {} +>module.exports : any +>module : any +>exports : any +>someOtherVariable = {} : {} +>someOtherVariable : any +>{} : {} + +exports.func11 = function () { }; +>exports.func11 = function () { } : () => void +>exports.func11 : any +>exports : any +>func11 : any +>function () { } : () => void + +module.exports.func12 = function () { }; +>module.exports.func12 = function () { } : () => void +>module.exports.func12 : any +>module.exports : any +>module : any +>exports : any +>func12 : any +>function () { } : () => void + +exports = module.exports = someOtherVariable = {}; +>exports = module.exports = someOtherVariable = {} : {} +>exports : any +>module.exports = someOtherVariable = {} : {} +>module.exports : any +>module : any +>exports : any +>someOtherVariable = {} : {} +>someOtherVariable : any +>{} : {} + +exports.func11 = function () { }; +>exports.func11 = function () { } : () => void +>exports.func11 : any +>exports : any +>func11 : any +>function () { } : () => void + +module.exports.func12 = function () { }; +>module.exports.func12 = function () { } : () => void +>module.exports.func12 : any +>module.exports : any +>module : any +>exports : any +>func12 : any +>function () { } : () => void + +exports = module.exports = {}; +>exports = module.exports = {} : { [x: string]: any; } +>exports : any +>module.exports = {} : { [x: string]: any; } +>module.exports : any +>module : any +>exports : any +>{} : { [x: string]: any; } + +exports.func13 = function () { }; +>exports.func13 = function () { } : () => void +>exports.func13 : any +>exports : any +>func13 : any +>function () { } : () => void + +module.exports.func14 = function () { }; +>module.exports.func14 = function () { } : () => void +>module.exports.func14 : any +>module.exports : any +>module : any +>exports : any +>func14 : any +>function () { } : () => void + +exports = module.exports = {}; +>exports = module.exports = {} : { [x: string]: any; } +>exports : any +>module.exports = {} : { [x: string]: any; } +>module.exports : any +>module : any +>exports : any +>{} : { [x: string]: any; } + +exports.func15 = function () { }; +>exports.func15 = function () { } : () => void +>exports.func15 : any +>exports : any +>func15 : any +>function () { } : () => void + +module.exports.func16 = function () { }; +>module.exports.func16 = function () { } : () => void +>module.exports.func16 : any +>module.exports : any +>module : any +>exports : any +>func16 : any +>function () { } : () => void + +module.exports = exports = {}; +>module.exports = exports = {} : {} +>module.exports : any +>module : any +>exports : any +>exports = {} : {} +>exports : any +>{} : {} + +exports.func17 = function () { }; +>exports.func17 = function () { } : () => void +>exports.func17 : any +>exports : any +>func17 : any +>function () { } : () => void + +module.exports.func18 = function () { }; +>module.exports.func18 = function () { } : () => void +>module.exports.func18 : any +>module.exports : any +>module : any +>exports : any +>func18 : any +>function () { } : () => void + +module.exports = {}; +>module.exports = {} : { [x: string]: any; } +>module.exports : any +>module : any +>exports : any +>{} : { [x: string]: any; } + +exports.func19 = function () { }; +>exports.func19 = function () { } : () => void +>exports.func19 : any +>exports : any +>func19 : any +>function () { } : () => void + +module.exports.func20 = function () { }; +>module.exports.func20 = function () { } : () => void +>module.exports.func20 : any +>module.exports : any +>module : any +>exports : any +>func20 : any +>function () { } : () => void + + diff --git a/tests/baselines/reference/printerApi/printsFileCorrectly.default.js b/tests/baselines/reference/printerApi/printsFileCorrectly.default.js index 9bff9d656b3..576c8bf68ed 100644 --- a/tests/baselines/reference/printerApi/printsFileCorrectly.default.js +++ b/tests/baselines/reference/printerApi/printsFileCorrectly.default.js @@ -23,3 +23,5 @@ const enum E2 { } // comment9 console.log(1 + 2); +// comment10 +function functionWithDefaultArgValue(argument: string = "defaultValue"): void { } diff --git a/tests/baselines/reference/printerApi/printsFileCorrectly.removeComments.js b/tests/baselines/reference/printerApi/printsFileCorrectly.removeComments.js index b511aff5e78..8e839c069a9 100644 --- a/tests/baselines/reference/printerApi/printsFileCorrectly.removeComments.js +++ b/tests/baselines/reference/printerApi/printsFileCorrectly.removeComments.js @@ -15,3 +15,4 @@ const enum E2 { second } console.log(1 + 2); +function functionWithDefaultArgValue(argument: string = "defaultValue"): void { } diff --git a/tests/baselines/reference/thisTypeInObjectLiterals2.js b/tests/baselines/reference/thisTypeInObjectLiterals2.js index 88cbd2555f6..a9b666fda8f 100644 --- a/tests/baselines/reference/thisTypeInObjectLiterals2.js +++ b/tests/baselines/reference/thisTypeInObjectLiterals2.js @@ -47,6 +47,42 @@ let p1: Point = { } }; +let p2: Point | null = { + x: 10, + y: 20, + moveBy(dx, dy, dz) { + this.x += dx; + this.y += dy; + if (this.z && dz) { + this.z += dz; + } + } +}; + +let p3: Point | undefined = { + x: 10, + y: 20, + moveBy(dx, dy, dz) { + this.x += dx; + this.y += dy; + if (this.z && dz) { + this.z += dz; + } + } +}; + +let p4: Point | null | undefined = { + x: 10, + y: 20, + moveBy(dx, dy, dz) { + this.x += dx; + this.y += dy; + if (this.z && dz) { + this.z += dz; + } + } +}; + declare function f1(p: Point): void; f1({ @@ -61,6 +97,20 @@ f1({ } }); +declare function f2(p: Point | null | undefined): void; + +f2({ + x: 10, + y: 20, + moveBy(dx, dy, dz) { + this.x += dx; + this.y += dy; + if (this.z && dz) { + this.z += dz; + } + } +}); + // In methods of an object literal with a contextual type that includes some // ThisType, 'this' is of type T. @@ -196,6 +246,7 @@ vue.hello; //// [thisTypeInObjectLiterals2.js] // In methods of an object literal with no contextual type, 'this' has the type // of the object literal. +"use strict"; var obj1 = { a: 1, f: function () { @@ -228,6 +279,39 @@ var p1 = { } } }; +var p2 = { + x: 10, + y: 20, + moveBy: function (dx, dy, dz) { + this.x += dx; + this.y += dy; + if (this.z && dz) { + this.z += dz; + } + } +}; +var p3 = { + x: 10, + y: 20, + moveBy: function (dx, dy, dz) { + this.x += dx; + this.y += dy; + if (this.z && dz) { + this.z += dz; + } + } +}; +var p4 = { + x: 10, + y: 20, + moveBy: function (dx, dy, dz) { + this.x += dx; + this.y += dy; + if (this.z && dz) { + this.z += dz; + } + } +}; f1({ x: 10, y: 20, @@ -239,6 +323,17 @@ f1({ } } }); +f2({ + x: 10, + y: 20, + moveBy: function (dx, dy, dz) { + this.x += dx; + this.y += dy; + if (this.z && dz) { + this.z += dz; + } + } +}); var x1 = makeObject({ data: { x: 0, y: 0 }, methods: { @@ -328,7 +423,11 @@ declare type Point = { moveBy(dx: number, dy: number, dz?: number): void; }; declare let p1: Point; +declare let p2: Point | null; +declare let p3: Point | undefined; +declare let p4: Point | null | undefined; declare function f1(p: Point): void; +declare function f2(p: Point | null | undefined): void; declare type ObjectDescriptor = { data?: D; methods?: M & ThisType; diff --git a/tests/baselines/reference/thisTypeInObjectLiterals2.symbols b/tests/baselines/reference/thisTypeInObjectLiterals2.symbols index e7412ab487f..4c3e60c7536 100644 --- a/tests/baselines/reference/thisTypeInObjectLiterals2.symbols +++ b/tests/baselines/reference/thisTypeInObjectLiterals2.symbols @@ -128,49 +128,225 @@ let p1: Point = { } }; -declare function f1(p: Point): void; ->f1 : Symbol(f1, Decl(thisTypeInObjectLiterals2.ts, 46, 2)) ->p : Symbol(p, Decl(thisTypeInObjectLiterals2.ts, 48, 20)) +let p2: Point | null = { +>p2 : Symbol(p2, Decl(thisTypeInObjectLiterals2.ts, 48, 3)) >Point : Symbol(Point, Decl(thisTypeInObjectLiterals2.ts, 24, 2)) -f1({ ->f1 : Symbol(f1, Decl(thisTypeInObjectLiterals2.ts, 46, 2)) - x: 10, ->x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 50, 4)) +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 48, 24)) y: 20, ->y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 51, 10)) +>y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 49, 10)) moveBy(dx, dy, dz) { ->moveBy : Symbol(moveBy, Decl(thisTypeInObjectLiterals2.ts, 52, 10)) ->dx : Symbol(dx, Decl(thisTypeInObjectLiterals2.ts, 53, 11)) ->dy : Symbol(dy, Decl(thisTypeInObjectLiterals2.ts, 53, 14)) ->dz : Symbol(dz, Decl(thisTypeInObjectLiterals2.ts, 53, 18)) +>moveBy : Symbol(moveBy, Decl(thisTypeInObjectLiterals2.ts, 50, 10)) +>dx : Symbol(dx, Decl(thisTypeInObjectLiterals2.ts, 51, 11)) +>dy : Symbol(dy, Decl(thisTypeInObjectLiterals2.ts, 51, 14)) +>dz : Symbol(dz, Decl(thisTypeInObjectLiterals2.ts, 51, 18)) this.x += dx; >this.x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 29, 14)) >this : Symbol(__type, Decl(thisTypeInObjectLiterals2.ts, 29, 12)) >x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 29, 14)) ->dx : Symbol(dx, Decl(thisTypeInObjectLiterals2.ts, 53, 11)) +>dx : Symbol(dx, Decl(thisTypeInObjectLiterals2.ts, 51, 11)) this.y += dy; >this.y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 30, 14)) >this : Symbol(__type, Decl(thisTypeInObjectLiterals2.ts, 29, 12)) >y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 30, 14)) ->dy : Symbol(dy, Decl(thisTypeInObjectLiterals2.ts, 53, 14)) +>dy : Symbol(dy, Decl(thisTypeInObjectLiterals2.ts, 51, 14)) if (this.z && dz) { >this.z : Symbol(z, Decl(thisTypeInObjectLiterals2.ts, 31, 14)) >this : Symbol(__type, Decl(thisTypeInObjectLiterals2.ts, 29, 12)) >z : Symbol(z, Decl(thisTypeInObjectLiterals2.ts, 31, 14)) ->dz : Symbol(dz, Decl(thisTypeInObjectLiterals2.ts, 53, 18)) +>dz : Symbol(dz, Decl(thisTypeInObjectLiterals2.ts, 51, 18)) this.z += dz; >this.z : Symbol(z, Decl(thisTypeInObjectLiterals2.ts, 31, 14)) >this : Symbol(__type, Decl(thisTypeInObjectLiterals2.ts, 29, 12)) >z : Symbol(z, Decl(thisTypeInObjectLiterals2.ts, 31, 14)) ->dz : Symbol(dz, Decl(thisTypeInObjectLiterals2.ts, 53, 18)) +>dz : Symbol(dz, Decl(thisTypeInObjectLiterals2.ts, 51, 18)) + } + } +}; + +let p3: Point | undefined = { +>p3 : Symbol(p3, Decl(thisTypeInObjectLiterals2.ts, 60, 3)) +>Point : Symbol(Point, Decl(thisTypeInObjectLiterals2.ts, 24, 2)) + + x: 10, +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 60, 29)) + + y: 20, +>y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 61, 10)) + + moveBy(dx, dy, dz) { +>moveBy : Symbol(moveBy, Decl(thisTypeInObjectLiterals2.ts, 62, 10)) +>dx : Symbol(dx, Decl(thisTypeInObjectLiterals2.ts, 63, 11)) +>dy : Symbol(dy, Decl(thisTypeInObjectLiterals2.ts, 63, 14)) +>dz : Symbol(dz, Decl(thisTypeInObjectLiterals2.ts, 63, 18)) + + this.x += dx; +>this.x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 29, 14)) +>this : Symbol(__type, Decl(thisTypeInObjectLiterals2.ts, 29, 12)) +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 29, 14)) +>dx : Symbol(dx, Decl(thisTypeInObjectLiterals2.ts, 63, 11)) + + this.y += dy; +>this.y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 30, 14)) +>this : Symbol(__type, Decl(thisTypeInObjectLiterals2.ts, 29, 12)) +>y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 30, 14)) +>dy : Symbol(dy, Decl(thisTypeInObjectLiterals2.ts, 63, 14)) + + if (this.z && dz) { +>this.z : Symbol(z, Decl(thisTypeInObjectLiterals2.ts, 31, 14)) +>this : Symbol(__type, Decl(thisTypeInObjectLiterals2.ts, 29, 12)) +>z : Symbol(z, Decl(thisTypeInObjectLiterals2.ts, 31, 14)) +>dz : Symbol(dz, Decl(thisTypeInObjectLiterals2.ts, 63, 18)) + + this.z += dz; +>this.z : Symbol(z, Decl(thisTypeInObjectLiterals2.ts, 31, 14)) +>this : Symbol(__type, Decl(thisTypeInObjectLiterals2.ts, 29, 12)) +>z : Symbol(z, Decl(thisTypeInObjectLiterals2.ts, 31, 14)) +>dz : Symbol(dz, Decl(thisTypeInObjectLiterals2.ts, 63, 18)) + } + } +}; + +let p4: Point | null | undefined = { +>p4 : Symbol(p4, Decl(thisTypeInObjectLiterals2.ts, 72, 3)) +>Point : Symbol(Point, Decl(thisTypeInObjectLiterals2.ts, 24, 2)) + + x: 10, +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 72, 36)) + + y: 20, +>y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 73, 10)) + + moveBy(dx, dy, dz) { +>moveBy : Symbol(moveBy, Decl(thisTypeInObjectLiterals2.ts, 74, 10)) +>dx : Symbol(dx, Decl(thisTypeInObjectLiterals2.ts, 75, 11)) +>dy : Symbol(dy, Decl(thisTypeInObjectLiterals2.ts, 75, 14)) +>dz : Symbol(dz, Decl(thisTypeInObjectLiterals2.ts, 75, 18)) + + this.x += dx; +>this.x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 29, 14)) +>this : Symbol(__type, Decl(thisTypeInObjectLiterals2.ts, 29, 12)) +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 29, 14)) +>dx : Symbol(dx, Decl(thisTypeInObjectLiterals2.ts, 75, 11)) + + this.y += dy; +>this.y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 30, 14)) +>this : Symbol(__type, Decl(thisTypeInObjectLiterals2.ts, 29, 12)) +>y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 30, 14)) +>dy : Symbol(dy, Decl(thisTypeInObjectLiterals2.ts, 75, 14)) + + if (this.z && dz) { +>this.z : Symbol(z, Decl(thisTypeInObjectLiterals2.ts, 31, 14)) +>this : Symbol(__type, Decl(thisTypeInObjectLiterals2.ts, 29, 12)) +>z : Symbol(z, Decl(thisTypeInObjectLiterals2.ts, 31, 14)) +>dz : Symbol(dz, Decl(thisTypeInObjectLiterals2.ts, 75, 18)) + + this.z += dz; +>this.z : Symbol(z, Decl(thisTypeInObjectLiterals2.ts, 31, 14)) +>this : Symbol(__type, Decl(thisTypeInObjectLiterals2.ts, 29, 12)) +>z : Symbol(z, Decl(thisTypeInObjectLiterals2.ts, 31, 14)) +>dz : Symbol(dz, Decl(thisTypeInObjectLiterals2.ts, 75, 18)) + } + } +}; + +declare function f1(p: Point): void; +>f1 : Symbol(f1, Decl(thisTypeInObjectLiterals2.ts, 82, 2)) +>p : Symbol(p, Decl(thisTypeInObjectLiterals2.ts, 84, 20)) +>Point : Symbol(Point, Decl(thisTypeInObjectLiterals2.ts, 24, 2)) + +f1({ +>f1 : Symbol(f1, Decl(thisTypeInObjectLiterals2.ts, 82, 2)) + + x: 10, +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 86, 4)) + + y: 20, +>y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 87, 10)) + + moveBy(dx, dy, dz) { +>moveBy : Symbol(moveBy, Decl(thisTypeInObjectLiterals2.ts, 88, 10)) +>dx : Symbol(dx, Decl(thisTypeInObjectLiterals2.ts, 89, 11)) +>dy : Symbol(dy, Decl(thisTypeInObjectLiterals2.ts, 89, 14)) +>dz : Symbol(dz, Decl(thisTypeInObjectLiterals2.ts, 89, 18)) + + this.x += dx; +>this.x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 29, 14)) +>this : Symbol(__type, Decl(thisTypeInObjectLiterals2.ts, 29, 12)) +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 29, 14)) +>dx : Symbol(dx, Decl(thisTypeInObjectLiterals2.ts, 89, 11)) + + this.y += dy; +>this.y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 30, 14)) +>this : Symbol(__type, Decl(thisTypeInObjectLiterals2.ts, 29, 12)) +>y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 30, 14)) +>dy : Symbol(dy, Decl(thisTypeInObjectLiterals2.ts, 89, 14)) + + if (this.z && dz) { +>this.z : Symbol(z, Decl(thisTypeInObjectLiterals2.ts, 31, 14)) +>this : Symbol(__type, Decl(thisTypeInObjectLiterals2.ts, 29, 12)) +>z : Symbol(z, Decl(thisTypeInObjectLiterals2.ts, 31, 14)) +>dz : Symbol(dz, Decl(thisTypeInObjectLiterals2.ts, 89, 18)) + + this.z += dz; +>this.z : Symbol(z, Decl(thisTypeInObjectLiterals2.ts, 31, 14)) +>this : Symbol(__type, Decl(thisTypeInObjectLiterals2.ts, 29, 12)) +>z : Symbol(z, Decl(thisTypeInObjectLiterals2.ts, 31, 14)) +>dz : Symbol(dz, Decl(thisTypeInObjectLiterals2.ts, 89, 18)) + } + } +}); + +declare function f2(p: Point | null | undefined): void; +>f2 : Symbol(f2, Decl(thisTypeInObjectLiterals2.ts, 96, 3)) +>p : Symbol(p, Decl(thisTypeInObjectLiterals2.ts, 98, 20)) +>Point : Symbol(Point, Decl(thisTypeInObjectLiterals2.ts, 24, 2)) + +f2({ +>f2 : Symbol(f2, Decl(thisTypeInObjectLiterals2.ts, 96, 3)) + + x: 10, +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 100, 4)) + + y: 20, +>y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 101, 10)) + + moveBy(dx, dy, dz) { +>moveBy : Symbol(moveBy, Decl(thisTypeInObjectLiterals2.ts, 102, 10)) +>dx : Symbol(dx, Decl(thisTypeInObjectLiterals2.ts, 103, 11)) +>dy : Symbol(dy, Decl(thisTypeInObjectLiterals2.ts, 103, 14)) +>dz : Symbol(dz, Decl(thisTypeInObjectLiterals2.ts, 103, 18)) + + this.x += dx; +>this.x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 29, 14)) +>this : Symbol(__type, Decl(thisTypeInObjectLiterals2.ts, 29, 12)) +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 29, 14)) +>dx : Symbol(dx, Decl(thisTypeInObjectLiterals2.ts, 103, 11)) + + this.y += dy; +>this.y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 30, 14)) +>this : Symbol(__type, Decl(thisTypeInObjectLiterals2.ts, 29, 12)) +>y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 30, 14)) +>dy : Symbol(dy, Decl(thisTypeInObjectLiterals2.ts, 103, 14)) + + if (this.z && dz) { +>this.z : Symbol(z, Decl(thisTypeInObjectLiterals2.ts, 31, 14)) +>this : Symbol(__type, Decl(thisTypeInObjectLiterals2.ts, 29, 12)) +>z : Symbol(z, Decl(thisTypeInObjectLiterals2.ts, 31, 14)) +>dz : Symbol(dz, Decl(thisTypeInObjectLiterals2.ts, 103, 18)) + + this.z += dz; +>this.z : Symbol(z, Decl(thisTypeInObjectLiterals2.ts, 31, 14)) +>this : Symbol(__type, Decl(thisTypeInObjectLiterals2.ts, 29, 12)) +>z : Symbol(z, Decl(thisTypeInObjectLiterals2.ts, 31, 14)) +>dz : Symbol(dz, Decl(thisTypeInObjectLiterals2.ts, 103, 18)) } } }); @@ -179,59 +355,59 @@ f1({ // ThisType, 'this' is of type T. type ObjectDescriptor = { ->ObjectDescriptor : Symbol(ObjectDescriptor, Decl(thisTypeInObjectLiterals2.ts, 60, 3)) ->D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 65, 22)) ->M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 65, 24)) +>ObjectDescriptor : Symbol(ObjectDescriptor, Decl(thisTypeInObjectLiterals2.ts, 110, 3)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 115, 22)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 115, 24)) data?: D; ->data : Symbol(data, Decl(thisTypeInObjectLiterals2.ts, 65, 31)) ->D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 65, 22)) +>data : Symbol(data, Decl(thisTypeInObjectLiterals2.ts, 115, 31)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 115, 22)) methods?: M & ThisType; // Type of 'this' in methods is D & M ->methods : Symbol(methods, Decl(thisTypeInObjectLiterals2.ts, 66, 13)) ->M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 65, 24)) +>methods : Symbol(methods, Decl(thisTypeInObjectLiterals2.ts, 116, 13)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 115, 24)) >ThisType : Symbol(ThisType, Decl(lib.d.ts, --, --)) ->D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 65, 22)) ->M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 65, 24)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 115, 22)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 115, 24)) } declare function makeObject(desc: ObjectDescriptor): D & M; ->makeObject : Symbol(makeObject, Decl(thisTypeInObjectLiterals2.ts, 68, 1)) ->D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 70, 28)) ->M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 70, 30)) ->desc : Symbol(desc, Decl(thisTypeInObjectLiterals2.ts, 70, 34)) ->ObjectDescriptor : Symbol(ObjectDescriptor, Decl(thisTypeInObjectLiterals2.ts, 60, 3)) ->D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 70, 28)) ->M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 70, 30)) ->D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 70, 28)) ->M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 70, 30)) +>makeObject : Symbol(makeObject, Decl(thisTypeInObjectLiterals2.ts, 118, 1)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 120, 28)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 120, 30)) +>desc : Symbol(desc, Decl(thisTypeInObjectLiterals2.ts, 120, 34)) +>ObjectDescriptor : Symbol(ObjectDescriptor, Decl(thisTypeInObjectLiterals2.ts, 110, 3)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 120, 28)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 120, 30)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 120, 28)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 120, 30)) let x1 = makeObject({ ->x1 : Symbol(x1, Decl(thisTypeInObjectLiterals2.ts, 72, 3)) ->makeObject : Symbol(makeObject, Decl(thisTypeInObjectLiterals2.ts, 68, 1)) +>x1 : Symbol(x1, Decl(thisTypeInObjectLiterals2.ts, 122, 3)) +>makeObject : Symbol(makeObject, Decl(thisTypeInObjectLiterals2.ts, 118, 1)) data: { x: 0, y: 0 }, ->data : Symbol(data, Decl(thisTypeInObjectLiterals2.ts, 72, 21)) ->x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 73, 11)) ->y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 73, 17)) +>data : Symbol(data, Decl(thisTypeInObjectLiterals2.ts, 122, 21)) +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 123, 11)) +>y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 123, 17)) methods: { ->methods : Symbol(methods, Decl(thisTypeInObjectLiterals2.ts, 73, 25)) +>methods : Symbol(methods, Decl(thisTypeInObjectLiterals2.ts, 123, 25)) moveBy(dx: number, dy: number) { ->moveBy : Symbol(moveBy, Decl(thisTypeInObjectLiterals2.ts, 74, 14)) ->dx : Symbol(dx, Decl(thisTypeInObjectLiterals2.ts, 75, 15)) ->dy : Symbol(dy, Decl(thisTypeInObjectLiterals2.ts, 75, 26)) +>moveBy : Symbol(moveBy, Decl(thisTypeInObjectLiterals2.ts, 124, 14)) +>dx : Symbol(dx, Decl(thisTypeInObjectLiterals2.ts, 125, 15)) +>dy : Symbol(dy, Decl(thisTypeInObjectLiterals2.ts, 125, 26)) this.x += dx; // Strongly typed this ->this.x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 73, 11)) ->x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 73, 11)) ->dx : Symbol(dx, Decl(thisTypeInObjectLiterals2.ts, 75, 15)) +>this.x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 123, 11)) +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 123, 11)) +>dx : Symbol(dx, Decl(thisTypeInObjectLiterals2.ts, 125, 15)) this.y += dy; // Strongly typed this ->this.y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 73, 17)) ->y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 73, 17)) ->dy : Symbol(dy, Decl(thisTypeInObjectLiterals2.ts, 75, 26)) +>this.y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 123, 17)) +>y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 123, 17)) +>dy : Symbol(dy, Decl(thisTypeInObjectLiterals2.ts, 125, 26)) } } }); @@ -240,59 +416,59 @@ let x1 = makeObject({ // some ThisType, 'this' is of type T. type ObjectDescriptor2 = ThisType & { ->ObjectDescriptor2 : Symbol(ObjectDescriptor2, Decl(thisTypeInObjectLiterals2.ts, 80, 3)) ->D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 85, 23)) ->M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 85, 25)) +>ObjectDescriptor2 : Symbol(ObjectDescriptor2, Decl(thisTypeInObjectLiterals2.ts, 130, 3)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 135, 23)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 135, 25)) >ThisType : Symbol(ThisType, Decl(lib.d.ts, --, --)) ->D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 85, 23)) ->M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 85, 25)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 135, 23)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 135, 25)) data?: D; ->data : Symbol(data, Decl(thisTypeInObjectLiterals2.ts, 85, 50)) ->D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 85, 23)) +>data : Symbol(data, Decl(thisTypeInObjectLiterals2.ts, 135, 50)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 135, 23)) methods?: M; ->methods : Symbol(methods, Decl(thisTypeInObjectLiterals2.ts, 86, 13)) ->M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 85, 25)) +>methods : Symbol(methods, Decl(thisTypeInObjectLiterals2.ts, 136, 13)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 135, 25)) } declare function makeObject2(desc: ObjectDescriptor): D & M; ->makeObject2 : Symbol(makeObject2, Decl(thisTypeInObjectLiterals2.ts, 88, 1)) ->D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 90, 29)) ->M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 90, 31)) ->desc : Symbol(desc, Decl(thisTypeInObjectLiterals2.ts, 90, 35)) ->ObjectDescriptor : Symbol(ObjectDescriptor, Decl(thisTypeInObjectLiterals2.ts, 60, 3)) ->D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 90, 29)) ->M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 90, 31)) ->D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 90, 29)) ->M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 90, 31)) +>makeObject2 : Symbol(makeObject2, Decl(thisTypeInObjectLiterals2.ts, 138, 1)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 140, 29)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 140, 31)) +>desc : Symbol(desc, Decl(thisTypeInObjectLiterals2.ts, 140, 35)) +>ObjectDescriptor : Symbol(ObjectDescriptor, Decl(thisTypeInObjectLiterals2.ts, 110, 3)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 140, 29)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 140, 31)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 140, 29)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 140, 31)) let x2 = makeObject2({ ->x2 : Symbol(x2, Decl(thisTypeInObjectLiterals2.ts, 92, 3)) ->makeObject2 : Symbol(makeObject2, Decl(thisTypeInObjectLiterals2.ts, 88, 1)) +>x2 : Symbol(x2, Decl(thisTypeInObjectLiterals2.ts, 142, 3)) +>makeObject2 : Symbol(makeObject2, Decl(thisTypeInObjectLiterals2.ts, 138, 1)) data: { x: 0, y: 0 }, ->data : Symbol(data, Decl(thisTypeInObjectLiterals2.ts, 92, 22)) ->x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 93, 11)) ->y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 93, 17)) +>data : Symbol(data, Decl(thisTypeInObjectLiterals2.ts, 142, 22)) +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 143, 11)) +>y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 143, 17)) methods: { ->methods : Symbol(methods, Decl(thisTypeInObjectLiterals2.ts, 93, 25)) +>methods : Symbol(methods, Decl(thisTypeInObjectLiterals2.ts, 143, 25)) moveBy(dx: number, dy: number) { ->moveBy : Symbol(moveBy, Decl(thisTypeInObjectLiterals2.ts, 94, 14)) ->dx : Symbol(dx, Decl(thisTypeInObjectLiterals2.ts, 95, 15)) ->dy : Symbol(dy, Decl(thisTypeInObjectLiterals2.ts, 95, 26)) +>moveBy : Symbol(moveBy, Decl(thisTypeInObjectLiterals2.ts, 144, 14)) +>dx : Symbol(dx, Decl(thisTypeInObjectLiterals2.ts, 145, 15)) +>dy : Symbol(dy, Decl(thisTypeInObjectLiterals2.ts, 145, 26)) this.x += dx; // Strongly typed this ->this.x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 93, 11)) ->x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 93, 11)) ->dx : Symbol(dx, Decl(thisTypeInObjectLiterals2.ts, 95, 15)) +>this.x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 143, 11)) +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 143, 11)) +>dx : Symbol(dx, Decl(thisTypeInObjectLiterals2.ts, 145, 15)) this.y += dy; // Strongly typed this ->this.y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 93, 17)) ->y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 93, 17)) ->dy : Symbol(dy, Decl(thisTypeInObjectLiterals2.ts, 95, 26)) +>this.y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 143, 17)) +>y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 143, 17)) +>dy : Symbol(dy, Decl(thisTypeInObjectLiterals2.ts, 145, 26)) } } }); @@ -300,89 +476,89 @@ let x2 = makeObject2({ // Check pattern similar to Object.defineProperty and Object.defineProperties type PropDesc = { ->PropDesc : Symbol(PropDesc, Decl(thisTypeInObjectLiterals2.ts, 100, 3)) ->T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 104, 14)) +>PropDesc : Symbol(PropDesc, Decl(thisTypeInObjectLiterals2.ts, 150, 3)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 154, 14)) value?: T; ->value : Symbol(value, Decl(thisTypeInObjectLiterals2.ts, 104, 20)) ->T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 104, 14)) +>value : Symbol(value, Decl(thisTypeInObjectLiterals2.ts, 154, 20)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 154, 14)) get?(): T; ->get : Symbol(get, Decl(thisTypeInObjectLiterals2.ts, 105, 14)) ->T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 104, 14)) +>get : Symbol(get, Decl(thisTypeInObjectLiterals2.ts, 155, 14)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 154, 14)) set?(value: T): void; ->set : Symbol(set, Decl(thisTypeInObjectLiterals2.ts, 106, 14)) ->value : Symbol(value, Decl(thisTypeInObjectLiterals2.ts, 107, 9)) ->T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 104, 14)) +>set : Symbol(set, Decl(thisTypeInObjectLiterals2.ts, 156, 14)) +>value : Symbol(value, Decl(thisTypeInObjectLiterals2.ts, 157, 9)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 154, 14)) } type PropDescMap = { ->PropDescMap : Symbol(PropDescMap, Decl(thisTypeInObjectLiterals2.ts, 108, 1)) ->T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 110, 17)) +>PropDescMap : Symbol(PropDescMap, Decl(thisTypeInObjectLiterals2.ts, 158, 1)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 160, 17)) [K in keyof T]: PropDesc; ->K : Symbol(K, Decl(thisTypeInObjectLiterals2.ts, 111, 5)) ->T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 110, 17)) ->PropDesc : Symbol(PropDesc, Decl(thisTypeInObjectLiterals2.ts, 100, 3)) ->T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 110, 17)) ->K : Symbol(K, Decl(thisTypeInObjectLiterals2.ts, 111, 5)) +>K : Symbol(K, Decl(thisTypeInObjectLiterals2.ts, 161, 5)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 160, 17)) +>PropDesc : Symbol(PropDesc, Decl(thisTypeInObjectLiterals2.ts, 150, 3)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 160, 17)) +>K : Symbol(K, Decl(thisTypeInObjectLiterals2.ts, 161, 5)) } declare function defineProp(obj: T, name: K, desc: PropDesc & ThisType): T & Record; ->defineProp : Symbol(defineProp, Decl(thisTypeInObjectLiterals2.ts, 112, 1)) ->T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 114, 28)) ->K : Symbol(K, Decl(thisTypeInObjectLiterals2.ts, 114, 30)) ->U : Symbol(U, Decl(thisTypeInObjectLiterals2.ts, 114, 48)) ->obj : Symbol(obj, Decl(thisTypeInObjectLiterals2.ts, 114, 52)) ->T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 114, 28)) ->name : Symbol(name, Decl(thisTypeInObjectLiterals2.ts, 114, 59)) ->K : Symbol(K, Decl(thisTypeInObjectLiterals2.ts, 114, 30)) ->desc : Symbol(desc, Decl(thisTypeInObjectLiterals2.ts, 114, 68)) ->PropDesc : Symbol(PropDesc, Decl(thisTypeInObjectLiterals2.ts, 100, 3)) ->U : Symbol(U, Decl(thisTypeInObjectLiterals2.ts, 114, 48)) +>defineProp : Symbol(defineProp, Decl(thisTypeInObjectLiterals2.ts, 162, 1)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 164, 28)) +>K : Symbol(K, Decl(thisTypeInObjectLiterals2.ts, 164, 30)) +>U : Symbol(U, Decl(thisTypeInObjectLiterals2.ts, 164, 48)) +>obj : Symbol(obj, Decl(thisTypeInObjectLiterals2.ts, 164, 52)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 164, 28)) +>name : Symbol(name, Decl(thisTypeInObjectLiterals2.ts, 164, 59)) +>K : Symbol(K, Decl(thisTypeInObjectLiterals2.ts, 164, 30)) +>desc : Symbol(desc, Decl(thisTypeInObjectLiterals2.ts, 164, 68)) +>PropDesc : Symbol(PropDesc, Decl(thisTypeInObjectLiterals2.ts, 150, 3)) +>U : Symbol(U, Decl(thisTypeInObjectLiterals2.ts, 164, 48)) >ThisType : Symbol(ThisType, Decl(lib.d.ts, --, --)) ->T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 114, 28)) ->T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 114, 28)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 164, 28)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 164, 28)) >Record : Symbol(Record, Decl(lib.d.ts, --, --)) ->K : Symbol(K, Decl(thisTypeInObjectLiterals2.ts, 114, 30)) ->U : Symbol(U, Decl(thisTypeInObjectLiterals2.ts, 114, 48)) +>K : Symbol(K, Decl(thisTypeInObjectLiterals2.ts, 164, 30)) +>U : Symbol(U, Decl(thisTypeInObjectLiterals2.ts, 164, 48)) declare function defineProps(obj: T, descs: PropDescMap & ThisType): T & U; ->defineProps : Symbol(defineProps, Decl(thisTypeInObjectLiterals2.ts, 114, 120)) ->T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 116, 29)) ->U : Symbol(U, Decl(thisTypeInObjectLiterals2.ts, 116, 31)) ->obj : Symbol(obj, Decl(thisTypeInObjectLiterals2.ts, 116, 35)) ->T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 116, 29)) ->descs : Symbol(descs, Decl(thisTypeInObjectLiterals2.ts, 116, 42)) ->PropDescMap : Symbol(PropDescMap, Decl(thisTypeInObjectLiterals2.ts, 108, 1)) ->U : Symbol(U, Decl(thisTypeInObjectLiterals2.ts, 116, 31)) +>defineProps : Symbol(defineProps, Decl(thisTypeInObjectLiterals2.ts, 164, 120)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 166, 29)) +>U : Symbol(U, Decl(thisTypeInObjectLiterals2.ts, 166, 31)) +>obj : Symbol(obj, Decl(thisTypeInObjectLiterals2.ts, 166, 35)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 166, 29)) +>descs : Symbol(descs, Decl(thisTypeInObjectLiterals2.ts, 166, 42)) +>PropDescMap : Symbol(PropDescMap, Decl(thisTypeInObjectLiterals2.ts, 158, 1)) +>U : Symbol(U, Decl(thisTypeInObjectLiterals2.ts, 166, 31)) >ThisType : Symbol(ThisType, Decl(lib.d.ts, --, --)) ->T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 116, 29)) ->T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 116, 29)) ->U : Symbol(U, Decl(thisTypeInObjectLiterals2.ts, 116, 31)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 166, 29)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 166, 29)) +>U : Symbol(U, Decl(thisTypeInObjectLiterals2.ts, 166, 31)) let p10 = defineProp(p1, "foo", { value: 42 }); ->p10 : Symbol(p10, Decl(thisTypeInObjectLiterals2.ts, 118, 3)) ->defineProp : Symbol(defineProp, Decl(thisTypeInObjectLiterals2.ts, 112, 1)) +>p10 : Symbol(p10, Decl(thisTypeInObjectLiterals2.ts, 168, 3)) +>defineProp : Symbol(defineProp, Decl(thisTypeInObjectLiterals2.ts, 162, 1)) >p1 : Symbol(p1, Decl(thisTypeInObjectLiterals2.ts, 36, 3)) ->value : Symbol(value, Decl(thisTypeInObjectLiterals2.ts, 118, 33)) +>value : Symbol(value, Decl(thisTypeInObjectLiterals2.ts, 168, 33)) p10.foo = p10.foo + 1; >p10.foo : Symbol(foo) ->p10 : Symbol(p10, Decl(thisTypeInObjectLiterals2.ts, 118, 3)) +>p10 : Symbol(p10, Decl(thisTypeInObjectLiterals2.ts, 168, 3)) >foo : Symbol(foo) >p10.foo : Symbol(foo) ->p10 : Symbol(p10, Decl(thisTypeInObjectLiterals2.ts, 118, 3)) +>p10 : Symbol(p10, Decl(thisTypeInObjectLiterals2.ts, 168, 3)) >foo : Symbol(foo) let p11 = defineProp(p1, "bar", { ->p11 : Symbol(p11, Decl(thisTypeInObjectLiterals2.ts, 121, 3)) ->defineProp : Symbol(defineProp, Decl(thisTypeInObjectLiterals2.ts, 112, 1)) +>p11 : Symbol(p11, Decl(thisTypeInObjectLiterals2.ts, 171, 3)) +>defineProp : Symbol(defineProp, Decl(thisTypeInObjectLiterals2.ts, 162, 1)) >p1 : Symbol(p1, Decl(thisTypeInObjectLiterals2.ts, 36, 3)) get() { ->get : Symbol(get, Decl(thisTypeInObjectLiterals2.ts, 121, 33)) +>get : Symbol(get, Decl(thisTypeInObjectLiterals2.ts, 171, 33)) return this.x; >this.x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 29, 14)) @@ -391,41 +567,41 @@ let p11 = defineProp(p1, "bar", { }, set(value: number) { ->set : Symbol(set, Decl(thisTypeInObjectLiterals2.ts, 124, 6)) ->value : Symbol(value, Decl(thisTypeInObjectLiterals2.ts, 125, 8)) +>set : Symbol(set, Decl(thisTypeInObjectLiterals2.ts, 174, 6)) +>value : Symbol(value, Decl(thisTypeInObjectLiterals2.ts, 175, 8)) this.x = value; >this.x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 29, 14)) >this : Symbol(__type, Decl(thisTypeInObjectLiterals2.ts, 29, 12)) >x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 29, 14)) ->value : Symbol(value, Decl(thisTypeInObjectLiterals2.ts, 125, 8)) +>value : Symbol(value, Decl(thisTypeInObjectLiterals2.ts, 175, 8)) } }); p11.bar = p11.bar + 1; >p11.bar : Symbol(bar) ->p11 : Symbol(p11, Decl(thisTypeInObjectLiterals2.ts, 121, 3)) +>p11 : Symbol(p11, Decl(thisTypeInObjectLiterals2.ts, 171, 3)) >bar : Symbol(bar) >p11.bar : Symbol(bar) ->p11 : Symbol(p11, Decl(thisTypeInObjectLiterals2.ts, 121, 3)) +>p11 : Symbol(p11, Decl(thisTypeInObjectLiterals2.ts, 171, 3)) >bar : Symbol(bar) let p12 = defineProps(p1, { ->p12 : Symbol(p12, Decl(thisTypeInObjectLiterals2.ts, 131, 3)) ->defineProps : Symbol(defineProps, Decl(thisTypeInObjectLiterals2.ts, 114, 120)) +>p12 : Symbol(p12, Decl(thisTypeInObjectLiterals2.ts, 181, 3)) +>defineProps : Symbol(defineProps, Decl(thisTypeInObjectLiterals2.ts, 164, 120)) >p1 : Symbol(p1, Decl(thisTypeInObjectLiterals2.ts, 36, 3)) foo: { ->foo : Symbol(foo, Decl(thisTypeInObjectLiterals2.ts, 131, 27)) +>foo : Symbol(foo, Decl(thisTypeInObjectLiterals2.ts, 181, 27)) value: 42 ->value : Symbol(value, Decl(thisTypeInObjectLiterals2.ts, 132, 10)) +>value : Symbol(value, Decl(thisTypeInObjectLiterals2.ts, 182, 10)) }, bar: { ->bar : Symbol(bar, Decl(thisTypeInObjectLiterals2.ts, 134, 6)) +>bar : Symbol(bar, Decl(thisTypeInObjectLiterals2.ts, 184, 6)) get(): number { ->get : Symbol(get, Decl(thisTypeInObjectLiterals2.ts, 135, 10)) +>get : Symbol(get, Decl(thisTypeInObjectLiterals2.ts, 185, 10)) return this.x; >this.x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 29, 14)) @@ -434,173 +610,173 @@ let p12 = defineProps(p1, { }, set(value: number) { ->set : Symbol(set, Decl(thisTypeInObjectLiterals2.ts, 138, 10)) ->value : Symbol(value, Decl(thisTypeInObjectLiterals2.ts, 139, 12)) +>set : Symbol(set, Decl(thisTypeInObjectLiterals2.ts, 188, 10)) +>value : Symbol(value, Decl(thisTypeInObjectLiterals2.ts, 189, 12)) this.x = value; >this.x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 29, 14)) >this : Symbol(__type, Decl(thisTypeInObjectLiterals2.ts, 29, 12)) >x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 29, 14)) ->value : Symbol(value, Decl(thisTypeInObjectLiterals2.ts, 139, 12)) +>value : Symbol(value, Decl(thisTypeInObjectLiterals2.ts, 189, 12)) } } }); p12.foo = p12.foo + 1; ->p12.foo : Symbol(foo, Decl(thisTypeInObjectLiterals2.ts, 131, 27)) ->p12 : Symbol(p12, Decl(thisTypeInObjectLiterals2.ts, 131, 3)) ->foo : Symbol(foo, Decl(thisTypeInObjectLiterals2.ts, 131, 27)) ->p12.foo : Symbol(foo, Decl(thisTypeInObjectLiterals2.ts, 131, 27)) ->p12 : Symbol(p12, Decl(thisTypeInObjectLiterals2.ts, 131, 3)) ->foo : Symbol(foo, Decl(thisTypeInObjectLiterals2.ts, 131, 27)) +>p12.foo : Symbol(foo, Decl(thisTypeInObjectLiterals2.ts, 181, 27)) +>p12 : Symbol(p12, Decl(thisTypeInObjectLiterals2.ts, 181, 3)) +>foo : Symbol(foo, Decl(thisTypeInObjectLiterals2.ts, 181, 27)) +>p12.foo : Symbol(foo, Decl(thisTypeInObjectLiterals2.ts, 181, 27)) +>p12 : Symbol(p12, Decl(thisTypeInObjectLiterals2.ts, 181, 3)) +>foo : Symbol(foo, Decl(thisTypeInObjectLiterals2.ts, 181, 27)) p12.bar = p12.bar + 1; ->p12.bar : Symbol(bar, Decl(thisTypeInObjectLiterals2.ts, 134, 6)) ->p12 : Symbol(p12, Decl(thisTypeInObjectLiterals2.ts, 131, 3)) ->bar : Symbol(bar, Decl(thisTypeInObjectLiterals2.ts, 134, 6)) ->p12.bar : Symbol(bar, Decl(thisTypeInObjectLiterals2.ts, 134, 6)) ->p12 : Symbol(p12, Decl(thisTypeInObjectLiterals2.ts, 131, 3)) ->bar : Symbol(bar, Decl(thisTypeInObjectLiterals2.ts, 134, 6)) +>p12.bar : Symbol(bar, Decl(thisTypeInObjectLiterals2.ts, 184, 6)) +>p12 : Symbol(p12, Decl(thisTypeInObjectLiterals2.ts, 181, 3)) +>bar : Symbol(bar, Decl(thisTypeInObjectLiterals2.ts, 184, 6)) +>p12.bar : Symbol(bar, Decl(thisTypeInObjectLiterals2.ts, 184, 6)) +>p12 : Symbol(p12, Decl(thisTypeInObjectLiterals2.ts, 181, 3)) +>bar : Symbol(bar, Decl(thisTypeInObjectLiterals2.ts, 184, 6)) // Proof of concept for typing of Vue.js type Accessors = { [K in keyof T]: (() => T[K]) | Computed }; ->Accessors : Symbol(Accessors, Decl(thisTypeInObjectLiterals2.ts, 145, 22)) ->T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 149, 15)) ->K : Symbol(K, Decl(thisTypeInObjectLiterals2.ts, 149, 23)) ->T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 149, 15)) ->T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 149, 15)) ->K : Symbol(K, Decl(thisTypeInObjectLiterals2.ts, 149, 23)) ->Computed : Symbol(Computed, Decl(thisTypeInObjectLiterals2.ts, 151, 39)) ->T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 149, 15)) ->K : Symbol(K, Decl(thisTypeInObjectLiterals2.ts, 149, 23)) +>Accessors : Symbol(Accessors, Decl(thisTypeInObjectLiterals2.ts, 195, 22)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 199, 15)) +>K : Symbol(K, Decl(thisTypeInObjectLiterals2.ts, 199, 23)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 199, 15)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 199, 15)) +>K : Symbol(K, Decl(thisTypeInObjectLiterals2.ts, 199, 23)) +>Computed : Symbol(Computed, Decl(thisTypeInObjectLiterals2.ts, 201, 39)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 199, 15)) +>K : Symbol(K, Decl(thisTypeInObjectLiterals2.ts, 199, 23)) type Dictionary = { [x: string]: T } ->Dictionary : Symbol(Dictionary, Decl(thisTypeInObjectLiterals2.ts, 149, 70)) ->T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 151, 16)) ->x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 151, 24)) ->T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 151, 16)) +>Dictionary : Symbol(Dictionary, Decl(thisTypeInObjectLiterals2.ts, 199, 70)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 201, 16)) +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 201, 24)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 201, 16)) type Computed = { ->Computed : Symbol(Computed, Decl(thisTypeInObjectLiterals2.ts, 151, 39)) ->T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 153, 14)) +>Computed : Symbol(Computed, Decl(thisTypeInObjectLiterals2.ts, 201, 39)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 203, 14)) get?(): T; ->get : Symbol(get, Decl(thisTypeInObjectLiterals2.ts, 153, 20)) ->T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 153, 14)) +>get : Symbol(get, Decl(thisTypeInObjectLiterals2.ts, 203, 20)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 203, 14)) set?(value: T): void; ->set : Symbol(set, Decl(thisTypeInObjectLiterals2.ts, 154, 14)) ->value : Symbol(value, Decl(thisTypeInObjectLiterals2.ts, 155, 9)) ->T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 153, 14)) +>set : Symbol(set, Decl(thisTypeInObjectLiterals2.ts, 204, 14)) +>value : Symbol(value, Decl(thisTypeInObjectLiterals2.ts, 205, 9)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 203, 14)) } type VueOptions = ThisType & { ->VueOptions : Symbol(VueOptions, Decl(thisTypeInObjectLiterals2.ts, 156, 1)) ->D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 158, 16)) ->M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 158, 18)) ->P : Symbol(P, Decl(thisTypeInObjectLiterals2.ts, 158, 21)) +>VueOptions : Symbol(VueOptions, Decl(thisTypeInObjectLiterals2.ts, 206, 1)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 208, 16)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 208, 18)) +>P : Symbol(P, Decl(thisTypeInObjectLiterals2.ts, 208, 21)) >ThisType : Symbol(ThisType, Decl(lib.d.ts, --, --)) ->D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 158, 16)) ->M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 158, 18)) ->P : Symbol(P, Decl(thisTypeInObjectLiterals2.ts, 158, 21)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 208, 16)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 208, 18)) +>P : Symbol(P, Decl(thisTypeInObjectLiterals2.ts, 208, 21)) data?: D | (() => D); ->data : Symbol(data, Decl(thisTypeInObjectLiterals2.ts, 158, 50)) ->D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 158, 16)) ->D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 158, 16)) +>data : Symbol(data, Decl(thisTypeInObjectLiterals2.ts, 208, 50)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 208, 16)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 208, 16)) methods?: M; ->methods : Symbol(methods, Decl(thisTypeInObjectLiterals2.ts, 159, 25)) ->M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 158, 18)) +>methods : Symbol(methods, Decl(thisTypeInObjectLiterals2.ts, 209, 25)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 208, 18)) computed?: Accessors

; ->computed : Symbol(computed, Decl(thisTypeInObjectLiterals2.ts, 160, 16)) ->Accessors : Symbol(Accessors, Decl(thisTypeInObjectLiterals2.ts, 145, 22)) ->P : Symbol(P, Decl(thisTypeInObjectLiterals2.ts, 158, 21)) +>computed : Symbol(computed, Decl(thisTypeInObjectLiterals2.ts, 210, 16)) +>Accessors : Symbol(Accessors, Decl(thisTypeInObjectLiterals2.ts, 195, 22)) +>P : Symbol(P, Decl(thisTypeInObjectLiterals2.ts, 208, 21)) } declare const Vue: new (options: VueOptions) => D & M & P; ->Vue : Symbol(Vue, Decl(thisTypeInObjectLiterals2.ts, 164, 13)) ->D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 164, 24)) ->M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 164, 26)) ->P : Symbol(P, Decl(thisTypeInObjectLiterals2.ts, 164, 29)) ->options : Symbol(options, Decl(thisTypeInObjectLiterals2.ts, 164, 33)) ->VueOptions : Symbol(VueOptions, Decl(thisTypeInObjectLiterals2.ts, 156, 1)) ->D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 164, 24)) ->M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 164, 26)) ->P : Symbol(P, Decl(thisTypeInObjectLiterals2.ts, 164, 29)) ->D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 164, 24)) ->M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 164, 26)) ->P : Symbol(P, Decl(thisTypeInObjectLiterals2.ts, 164, 29)) +>Vue : Symbol(Vue, Decl(thisTypeInObjectLiterals2.ts, 214, 13)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 214, 24)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 214, 26)) +>P : Symbol(P, Decl(thisTypeInObjectLiterals2.ts, 214, 29)) +>options : Symbol(options, Decl(thisTypeInObjectLiterals2.ts, 214, 33)) +>VueOptions : Symbol(VueOptions, Decl(thisTypeInObjectLiterals2.ts, 206, 1)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 214, 24)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 214, 26)) +>P : Symbol(P, Decl(thisTypeInObjectLiterals2.ts, 214, 29)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 214, 24)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 214, 26)) +>P : Symbol(P, Decl(thisTypeInObjectLiterals2.ts, 214, 29)) let vue = new Vue({ ->vue : Symbol(vue, Decl(thisTypeInObjectLiterals2.ts, 166, 3)) ->Vue : Symbol(Vue, Decl(thisTypeInObjectLiterals2.ts, 164, 13)) +>vue : Symbol(vue, Decl(thisTypeInObjectLiterals2.ts, 216, 3)) +>Vue : Symbol(Vue, Decl(thisTypeInObjectLiterals2.ts, 214, 13)) data: () => ({ x: 1, y: 2 }), ->data : Symbol(data, Decl(thisTypeInObjectLiterals2.ts, 166, 19)) ->x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 167, 18)) ->y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 167, 24)) +>data : Symbol(data, Decl(thisTypeInObjectLiterals2.ts, 216, 19)) +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 217, 18)) +>y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 217, 24)) methods: { ->methods : Symbol(methods, Decl(thisTypeInObjectLiterals2.ts, 167, 33)) +>methods : Symbol(methods, Decl(thisTypeInObjectLiterals2.ts, 217, 33)) f(x: string) { ->f : Symbol(f, Decl(thisTypeInObjectLiterals2.ts, 168, 14)) ->x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 169, 10)) +>f : Symbol(f, Decl(thisTypeInObjectLiterals2.ts, 218, 14)) +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 219, 10)) return this.x; ->this.x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 167, 18)) ->x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 167, 18)) +>this.x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 217, 18)) +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 217, 18)) } }, computed: { ->computed : Symbol(computed, Decl(thisTypeInObjectLiterals2.ts, 172, 6)) +>computed : Symbol(computed, Decl(thisTypeInObjectLiterals2.ts, 222, 6)) test(): number { ->test : Symbol(test, Decl(thisTypeInObjectLiterals2.ts, 173, 15)) +>test : Symbol(test, Decl(thisTypeInObjectLiterals2.ts, 223, 15)) return this.x; ->this.x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 167, 18)) ->x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 167, 18)) +>this.x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 217, 18)) +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 217, 18)) }, hello: { ->hello : Symbol(hello, Decl(thisTypeInObjectLiterals2.ts, 176, 10)) +>hello : Symbol(hello, Decl(thisTypeInObjectLiterals2.ts, 226, 10)) get() { ->get : Symbol(get, Decl(thisTypeInObjectLiterals2.ts, 177, 16)) +>get : Symbol(get, Decl(thisTypeInObjectLiterals2.ts, 227, 16)) return "hi"; }, set(value: string) { ->set : Symbol(set, Decl(thisTypeInObjectLiterals2.ts, 180, 14)) ->value : Symbol(value, Decl(thisTypeInObjectLiterals2.ts, 181, 16)) +>set : Symbol(set, Decl(thisTypeInObjectLiterals2.ts, 230, 14)) +>value : Symbol(value, Decl(thisTypeInObjectLiterals2.ts, 231, 16)) } } } }); vue; ->vue : Symbol(vue, Decl(thisTypeInObjectLiterals2.ts, 166, 3)) +>vue : Symbol(vue, Decl(thisTypeInObjectLiterals2.ts, 216, 3)) vue.x; ->vue.x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 167, 18)) ->vue : Symbol(vue, Decl(thisTypeInObjectLiterals2.ts, 166, 3)) ->x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 167, 18)) +>vue.x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 217, 18)) +>vue : Symbol(vue, Decl(thisTypeInObjectLiterals2.ts, 216, 3)) +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 217, 18)) vue.f("abc"); ->vue.f : Symbol(f, Decl(thisTypeInObjectLiterals2.ts, 168, 14)) ->vue : Symbol(vue, Decl(thisTypeInObjectLiterals2.ts, 166, 3)) ->f : Symbol(f, Decl(thisTypeInObjectLiterals2.ts, 168, 14)) +>vue.f : Symbol(f, Decl(thisTypeInObjectLiterals2.ts, 218, 14)) +>vue : Symbol(vue, Decl(thisTypeInObjectLiterals2.ts, 216, 3)) +>f : Symbol(f, Decl(thisTypeInObjectLiterals2.ts, 218, 14)) vue.test; ->vue.test : Symbol(test, Decl(thisTypeInObjectLiterals2.ts, 173, 15)) ->vue : Symbol(vue, Decl(thisTypeInObjectLiterals2.ts, 166, 3)) ->test : Symbol(test, Decl(thisTypeInObjectLiterals2.ts, 173, 15)) +>vue.test : Symbol(test, Decl(thisTypeInObjectLiterals2.ts, 223, 15)) +>vue : Symbol(vue, Decl(thisTypeInObjectLiterals2.ts, 216, 3)) +>test : Symbol(test, Decl(thisTypeInObjectLiterals2.ts, 223, 15)) vue.hello; ->vue.hello : Symbol(hello, Decl(thisTypeInObjectLiterals2.ts, 176, 10)) ->vue : Symbol(vue, Decl(thisTypeInObjectLiterals2.ts, 166, 3)) ->hello : Symbol(hello, Decl(thisTypeInObjectLiterals2.ts, 176, 10)) +>vue.hello : Symbol(hello, Decl(thisTypeInObjectLiterals2.ts, 226, 10)) +>vue : Symbol(vue, Decl(thisTypeInObjectLiterals2.ts, 216, 3)) +>hello : Symbol(hello, Decl(thisTypeInObjectLiterals2.ts, 226, 10)) diff --git a/tests/baselines/reference/thisTypeInObjectLiterals2.types b/tests/baselines/reference/thisTypeInObjectLiterals2.types index cc41be6b8c6..2742ad2c408 100644 --- a/tests/baselines/reference/thisTypeInObjectLiterals2.types +++ b/tests/baselines/reference/thisTypeInObjectLiterals2.types @@ -141,6 +141,158 @@ let p1: Point = { } }; +let p2: Point | null = { +>p2 : Point | null +>Point : Point +>null : null +>{ x: 10, y: 20, moveBy(dx, dy, dz) { this.x += dx; this.y += dy; if (this.z && dz) { this.z += dz; } }} : { x: number; y: number; moveBy(dx: number, dy: number, dz: number | undefined): void; } + + x: 10, +>x : number +>10 : 10 + + y: 20, +>y : number +>20 : 20 + + moveBy(dx, dy, dz) { +>moveBy : (dx: number, dy: number, dz: number | undefined) => void +>dx : number +>dy : number +>dz : number | undefined + + this.x += dx; +>this.x += dx : number +>this.x : number +>this : Point +>x : number +>dx : number + + this.y += dy; +>this.y += dy : number +>this.y : number +>this : Point +>y : number +>dy : number + + if (this.z && dz) { +>this.z && dz : number | undefined +>this.z : number | undefined +>this : Point +>z : number | undefined +>dz : number | undefined + + this.z += dz; +>this.z += dz : number +>this.z : number +>this : Point +>z : number +>dz : number + } + } +}; + +let p3: Point | undefined = { +>p3 : Point | undefined +>Point : Point +>{ x: 10, y: 20, moveBy(dx, dy, dz) { this.x += dx; this.y += dy; if (this.z && dz) { this.z += dz; } }} : { x: number; y: number; moveBy(dx: number, dy: number, dz: number | undefined): void; } + + x: 10, +>x : number +>10 : 10 + + y: 20, +>y : number +>20 : 20 + + moveBy(dx, dy, dz) { +>moveBy : (dx: number, dy: number, dz: number | undefined) => void +>dx : number +>dy : number +>dz : number | undefined + + this.x += dx; +>this.x += dx : number +>this.x : number +>this : Point +>x : number +>dx : number + + this.y += dy; +>this.y += dy : number +>this.y : number +>this : Point +>y : number +>dy : number + + if (this.z && dz) { +>this.z && dz : number | undefined +>this.z : number | undefined +>this : Point +>z : number | undefined +>dz : number | undefined + + this.z += dz; +>this.z += dz : number +>this.z : number +>this : Point +>z : number +>dz : number + } + } +}; + +let p4: Point | null | undefined = { +>p4 : Point | null | undefined +>Point : Point +>null : null +>{ x: 10, y: 20, moveBy(dx, dy, dz) { this.x += dx; this.y += dy; if (this.z && dz) { this.z += dz; } }} : { x: number; y: number; moveBy(dx: number, dy: number, dz: number | undefined): void; } + + x: 10, +>x : number +>10 : 10 + + y: 20, +>y : number +>20 : 20 + + moveBy(dx, dy, dz) { +>moveBy : (dx: number, dy: number, dz: number | undefined) => void +>dx : number +>dy : number +>dz : number | undefined + + this.x += dx; +>this.x += dx : number +>this.x : number +>this : Point +>x : number +>dx : number + + this.y += dy; +>this.y += dy : number +>this.y : number +>this : Point +>y : number +>dy : number + + if (this.z && dz) { +>this.z && dz : number | undefined +>this.z : number | undefined +>this : Point +>z : number | undefined +>dz : number | undefined + + this.z += dz; +>this.z += dz : number +>this.z : number +>this : Point +>z : number +>dz : number + } + } +}; + declare function f1(p: Point): void; >f1 : (p: Point) => void >p : Point @@ -196,6 +348,62 @@ f1({ } }); +declare function f2(p: Point | null | undefined): void; +>f2 : (p: Point | null | undefined) => void +>p : Point | null | undefined +>Point : Point +>null : null + +f2({ +>f2({ x: 10, y: 20, moveBy(dx, dy, dz) { this.x += dx; this.y += dy; if (this.z && dz) { this.z += dz; } }}) : void +>f2 : (p: Point | null | undefined) => void +>{ x: 10, y: 20, moveBy(dx, dy, dz) { this.x += dx; this.y += dy; if (this.z && dz) { this.z += dz; } }} : { x: number; y: number; moveBy(dx: number, dy: number, dz: number | undefined): void; } + + x: 10, +>x : number +>10 : 10 + + y: 20, +>y : number +>20 : 20 + + moveBy(dx, dy, dz) { +>moveBy : (dx: number, dy: number, dz: number | undefined) => void +>dx : number +>dy : number +>dz : number | undefined + + this.x += dx; +>this.x += dx : number +>this.x : number +>this : Point +>x : number +>dx : number + + this.y += dy; +>this.y += dy : number +>this.y : number +>this : Point +>y : number +>dy : number + + if (this.z && dz) { +>this.z && dz : number | undefined +>this.z : number | undefined +>this : Point +>z : number | undefined +>dz : number | undefined + + this.z += dz; +>this.z += dz : number +>this.z : number +>this : Point +>z : number +>dz : number + } + } +}); + // In methods of an object literal with a contextual type that includes some // ThisType, 'this' is of type T. diff --git a/tests/baselines/reference/transpile/Does not generate semantic diagnostics.js b/tests/baselines/reference/transpile/Does not generate semantic diagnostics.js index 4571caffa31..61a703e13bb 100644 --- a/tests/baselines/reference/transpile/Does not generate semantic diagnostics.js +++ b/tests/baselines/reference/transpile/Does not generate semantic diagnostics.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; var x = 0; //# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Generates expected syntactic diagnostics.js b/tests/baselines/reference/transpile/Generates expected syntactic diagnostics.js index 4d133b7655c..9d108d63313 100644 --- a/tests/baselines/reference/transpile/Generates expected syntactic diagnostics.js +++ b/tests/baselines/reference/transpile/Generates expected syntactic diagnostics.js @@ -1,5 +1,4 @@ "use strict"; -exports.__esModule = true; a; b; //# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Generates module output.js b/tests/baselines/reference/transpile/Generates module output.js index 2c7bb7add09..9eadd1f2717 100644 --- a/tests/baselines/reference/transpile/Generates module output.js +++ b/tests/baselines/reference/transpile/Generates module output.js @@ -1,6 +1,5 @@ define(["require", "exports"], function (require, exports) { "use strict"; - exports.__esModule = true; var x = 0; }); //# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Generates no diagnostics for missing file references.js b/tests/baselines/reference/transpile/Generates no diagnostics for missing file references.js index 04ba1d12e5e..88d98628eee 100644 --- a/tests/baselines/reference/transpile/Generates no diagnostics for missing file references.js +++ b/tests/baselines/reference/transpile/Generates no diagnostics for missing file references.js @@ -1,5 +1,4 @@ "use strict"; -exports.__esModule = true; /// var x = 0; //# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Generates no diagnostics with valid inputs.js b/tests/baselines/reference/transpile/Generates no diagnostics with valid inputs.js index 4571caffa31..61a703e13bb 100644 --- a/tests/baselines/reference/transpile/Generates no diagnostics with valid inputs.js +++ b/tests/baselines/reference/transpile/Generates no diagnostics with valid inputs.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; var x = 0; //# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/No extra errors for file without extension.js b/tests/baselines/reference/transpile/No extra errors for file without extension.js index 4571caffa31..61a703e13bb 100644 --- a/tests/baselines/reference/transpile/No extra errors for file without extension.js +++ b/tests/baselines/reference/transpile/No extra errors for file without extension.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; var x = 0; //# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.js b/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.js index e9493d9d591..1ceb1bcd146 100644 --- a/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.js +++ b/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.js @@ -1,3 +1,2 @@ "use strict"; -exports.__esModule = true; //# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.js b/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.js index e9493d9d591..1ceb1bcd146 100644 --- a/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.js +++ b/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.js @@ -1,3 +1,2 @@ "use strict"; -exports.__esModule = true; //# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Support options with lib values.js b/tests/baselines/reference/transpile/Support options with lib values.js index 72e077de381..36c68f08b9f 100644 --- a/tests/baselines/reference/transpile/Support options with lib values.js +++ b/tests/baselines/reference/transpile/Support options with lib values.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; var a = 10; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Support options with types values.js b/tests/baselines/reference/transpile/Support options with types values.js index 72e077de381..36c68f08b9f 100644 --- a/tests/baselines/reference/transpile/Support options with types values.js +++ b/tests/baselines/reference/transpile/Support options with types values.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; var a = 10; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports backslashes in file name.js b/tests/baselines/reference/transpile/Supports backslashes in file name.js index 8ef38d2b617..942449753b0 100644 --- a/tests/baselines/reference/transpile/Supports backslashes in file name.js +++ b/tests/baselines/reference/transpile/Supports backslashes in file name.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; var x; //# sourceMappingURL=b.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting allowJs.js b/tests/baselines/reference/transpile/Supports setting allowJs.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting allowJs.js +++ b/tests/baselines/reference/transpile/Supports setting allowJs.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting allowSyntheticDefaultImports.js b/tests/baselines/reference/transpile/Supports setting allowSyntheticDefaultImports.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting allowSyntheticDefaultImports.js +++ b/tests/baselines/reference/transpile/Supports setting allowSyntheticDefaultImports.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting allowUnreachableCode.js b/tests/baselines/reference/transpile/Supports setting allowUnreachableCode.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting allowUnreachableCode.js +++ b/tests/baselines/reference/transpile/Supports setting allowUnreachableCode.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting allowUnusedLabels.js b/tests/baselines/reference/transpile/Supports setting allowUnusedLabels.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting allowUnusedLabels.js +++ b/tests/baselines/reference/transpile/Supports setting allowUnusedLabels.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting alwaysStrict.js b/tests/baselines/reference/transpile/Supports setting alwaysStrict.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting alwaysStrict.js +++ b/tests/baselines/reference/transpile/Supports setting alwaysStrict.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting baseUrl.js b/tests/baselines/reference/transpile/Supports setting baseUrl.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting baseUrl.js +++ b/tests/baselines/reference/transpile/Supports setting baseUrl.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting charset.js b/tests/baselines/reference/transpile/Supports setting charset.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting charset.js +++ b/tests/baselines/reference/transpile/Supports setting charset.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting declaration.js b/tests/baselines/reference/transpile/Supports setting declaration.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting declaration.js +++ b/tests/baselines/reference/transpile/Supports setting declaration.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting declarationDir.js b/tests/baselines/reference/transpile/Supports setting declarationDir.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting declarationDir.js +++ b/tests/baselines/reference/transpile/Supports setting declarationDir.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting emitBOM.js b/tests/baselines/reference/transpile/Supports setting emitBOM.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting emitBOM.js +++ b/tests/baselines/reference/transpile/Supports setting emitBOM.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting emitDecoratorMetadata.js b/tests/baselines/reference/transpile/Supports setting emitDecoratorMetadata.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting emitDecoratorMetadata.js +++ b/tests/baselines/reference/transpile/Supports setting emitDecoratorMetadata.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting experimentalDecorators.js b/tests/baselines/reference/transpile/Supports setting experimentalDecorators.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting experimentalDecorators.js +++ b/tests/baselines/reference/transpile/Supports setting experimentalDecorators.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting forceConsistentCasingInFileNames.js b/tests/baselines/reference/transpile/Supports setting forceConsistentCasingInFileNames.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting forceConsistentCasingInFileNames.js +++ b/tests/baselines/reference/transpile/Supports setting forceConsistentCasingInFileNames.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting isolatedModules.js b/tests/baselines/reference/transpile/Supports setting isolatedModules.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting isolatedModules.js +++ b/tests/baselines/reference/transpile/Supports setting isolatedModules.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting jsx.js b/tests/baselines/reference/transpile/Supports setting jsx.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting jsx.js +++ b/tests/baselines/reference/transpile/Supports setting jsx.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting jsxFactory.js b/tests/baselines/reference/transpile/Supports setting jsxFactory.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting jsxFactory.js +++ b/tests/baselines/reference/transpile/Supports setting jsxFactory.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting lib.js b/tests/baselines/reference/transpile/Supports setting lib.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting lib.js +++ b/tests/baselines/reference/transpile/Supports setting lib.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting locale.js b/tests/baselines/reference/transpile/Supports setting locale.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting locale.js +++ b/tests/baselines/reference/transpile/Supports setting locale.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting module.js b/tests/baselines/reference/transpile/Supports setting module.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting module.js +++ b/tests/baselines/reference/transpile/Supports setting module.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting moduleResolution.js b/tests/baselines/reference/transpile/Supports setting moduleResolution.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting moduleResolution.js +++ b/tests/baselines/reference/transpile/Supports setting moduleResolution.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting newLine.js b/tests/baselines/reference/transpile/Supports setting newLine.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting newLine.js +++ b/tests/baselines/reference/transpile/Supports setting newLine.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting noEmit.js b/tests/baselines/reference/transpile/Supports setting noEmit.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting noEmit.js +++ b/tests/baselines/reference/transpile/Supports setting noEmit.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting noEmitHelpers.js b/tests/baselines/reference/transpile/Supports setting noEmitHelpers.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting noEmitHelpers.js +++ b/tests/baselines/reference/transpile/Supports setting noEmitHelpers.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting noEmitOnError.js b/tests/baselines/reference/transpile/Supports setting noEmitOnError.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting noEmitOnError.js +++ b/tests/baselines/reference/transpile/Supports setting noEmitOnError.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting noErrorTruncation.js b/tests/baselines/reference/transpile/Supports setting noErrorTruncation.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting noErrorTruncation.js +++ b/tests/baselines/reference/transpile/Supports setting noErrorTruncation.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting noFallthroughCasesInSwitch.js b/tests/baselines/reference/transpile/Supports setting noFallthroughCasesInSwitch.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting noFallthroughCasesInSwitch.js +++ b/tests/baselines/reference/transpile/Supports setting noFallthroughCasesInSwitch.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting noImplicitAny.js b/tests/baselines/reference/transpile/Supports setting noImplicitAny.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting noImplicitAny.js +++ b/tests/baselines/reference/transpile/Supports setting noImplicitAny.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting noImplicitReturns.js b/tests/baselines/reference/transpile/Supports setting noImplicitReturns.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting noImplicitReturns.js +++ b/tests/baselines/reference/transpile/Supports setting noImplicitReturns.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting noImplicitThis.js b/tests/baselines/reference/transpile/Supports setting noImplicitThis.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting noImplicitThis.js +++ b/tests/baselines/reference/transpile/Supports setting noImplicitThis.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting noImplicitUseStrict.js b/tests/baselines/reference/transpile/Supports setting noImplicitUseStrict.js index 8124d51fde3..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting noImplicitUseStrict.js +++ b/tests/baselines/reference/transpile/Supports setting noImplicitUseStrict.js @@ -1,3 +1,2 @@ -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting noLib.js b/tests/baselines/reference/transpile/Supports setting noLib.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting noLib.js +++ b/tests/baselines/reference/transpile/Supports setting noLib.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting noResolve.js b/tests/baselines/reference/transpile/Supports setting noResolve.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting noResolve.js +++ b/tests/baselines/reference/transpile/Supports setting noResolve.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting out.js b/tests/baselines/reference/transpile/Supports setting out.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting out.js +++ b/tests/baselines/reference/transpile/Supports setting out.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting outDir.js b/tests/baselines/reference/transpile/Supports setting outDir.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting outDir.js +++ b/tests/baselines/reference/transpile/Supports setting outDir.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting outFile.js b/tests/baselines/reference/transpile/Supports setting outFile.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting outFile.js +++ b/tests/baselines/reference/transpile/Supports setting outFile.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting paths.js b/tests/baselines/reference/transpile/Supports setting paths.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting paths.js +++ b/tests/baselines/reference/transpile/Supports setting paths.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting preserveConstEnums.js b/tests/baselines/reference/transpile/Supports setting preserveConstEnums.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting preserveConstEnums.js +++ b/tests/baselines/reference/transpile/Supports setting preserveConstEnums.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting reactNamespace.js b/tests/baselines/reference/transpile/Supports setting reactNamespace.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting reactNamespace.js +++ b/tests/baselines/reference/transpile/Supports setting reactNamespace.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting removeComments.js b/tests/baselines/reference/transpile/Supports setting removeComments.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting removeComments.js +++ b/tests/baselines/reference/transpile/Supports setting removeComments.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting rootDir.js b/tests/baselines/reference/transpile/Supports setting rootDir.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting rootDir.js +++ b/tests/baselines/reference/transpile/Supports setting rootDir.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting rootDirs.js b/tests/baselines/reference/transpile/Supports setting rootDirs.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting rootDirs.js +++ b/tests/baselines/reference/transpile/Supports setting rootDirs.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting skipDefaultLibCheck.js b/tests/baselines/reference/transpile/Supports setting skipDefaultLibCheck.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting skipDefaultLibCheck.js +++ b/tests/baselines/reference/transpile/Supports setting skipDefaultLibCheck.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting skipLibCheck.js b/tests/baselines/reference/transpile/Supports setting skipLibCheck.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting skipLibCheck.js +++ b/tests/baselines/reference/transpile/Supports setting skipLibCheck.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting strictNullChecks.js b/tests/baselines/reference/transpile/Supports setting strictNullChecks.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting strictNullChecks.js +++ b/tests/baselines/reference/transpile/Supports setting strictNullChecks.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting stripInternal.js b/tests/baselines/reference/transpile/Supports setting stripInternal.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting stripInternal.js +++ b/tests/baselines/reference/transpile/Supports setting stripInternal.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting suppressExcessPropertyErrors.js b/tests/baselines/reference/transpile/Supports setting suppressExcessPropertyErrors.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting suppressExcessPropertyErrors.js +++ b/tests/baselines/reference/transpile/Supports setting suppressExcessPropertyErrors.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting suppressImplicitAnyIndexErrors.js b/tests/baselines/reference/transpile/Supports setting suppressImplicitAnyIndexErrors.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting suppressImplicitAnyIndexErrors.js +++ b/tests/baselines/reference/transpile/Supports setting suppressImplicitAnyIndexErrors.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting typeRoots.js b/tests/baselines/reference/transpile/Supports setting typeRoots.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting typeRoots.js +++ b/tests/baselines/reference/transpile/Supports setting typeRoots.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting types.js b/tests/baselines/reference/transpile/Supports setting types.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting types.js +++ b/tests/baselines/reference/transpile/Supports setting types.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports urls in file name.js b/tests/baselines/reference/transpile/Supports urls in file name.js index 933981306d2..3923d3c9a41 100644 --- a/tests/baselines/reference/transpile/Supports urls in file name.js +++ b/tests/baselines/reference/transpile/Supports urls in file name.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; var x; //# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Uses correct newLine character.js b/tests/baselines/reference/transpile/Uses correct newLine character.js index 04042012d18..bab9c3c4443 100644 --- a/tests/baselines/reference/transpile/Uses correct newLine character.js +++ b/tests/baselines/reference/transpile/Uses correct newLine character.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; var x = 0; //# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/transpile .js files.js b/tests/baselines/reference/transpile/transpile .js files.js index b9048bd515d..c17099d84ba 100644 --- a/tests/baselines/reference/transpile/transpile .js files.js +++ b/tests/baselines/reference/transpile/transpile .js files.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; var a = 10; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/transpile file as tsx if jsx is specified.js b/tests/baselines/reference/transpile/transpile file as tsx if jsx is specified.js index 2a73615e476..baa27ee64ce 100644 --- a/tests/baselines/reference/transpile/transpile file as tsx if jsx is specified.js +++ b/tests/baselines/reference/transpile/transpile file as tsx if jsx is specified.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; var x = React.createElement("div", null); //# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/untypedModuleImport_allowJs.types b/tests/baselines/reference/untypedModuleImport_allowJs.types index 5a34fdcb646..108ba60ccb3 100644 --- a/tests/baselines/reference/untypedModuleImport_allowJs.types +++ b/tests/baselines/reference/untypedModuleImport_allowJs.types @@ -1,22 +1,22 @@ === /a.ts === import foo from "foo"; ->foo : { bar(): number; } +>foo : { [x: string]: any; bar(): number; } foo.bar(); >foo.bar() : number >foo.bar : () => number ->foo : { bar(): number; } +>foo : { [x: string]: any; bar(): number; } >bar : () => number === /node_modules/foo/index.js === // Same as untypedModuleImport.ts but with --allowJs, so the package will actually be typed. exports.default = { bar() { return 0; } } ->exports.default = { bar() { return 0; } } : { bar(): number; } +>exports.default = { bar() { return 0; } } : { [x: string]: any; bar(): number; } >exports.default : any >exports : any >default : any ->{ bar() { return 0; } } : { bar(): number; } +>{ bar() { return 0; } } : { [x: string]: any; bar(): number; } >bar : () => number >0 : 0 diff --git a/tests/cases/compiler/defaultParameterAddsUndefinedWithStrictNullChecks.ts b/tests/cases/compiler/defaultParameterAddsUndefinedWithStrictNullChecks.ts index 8abea19f6cd..d2e167c83a3 100644 --- a/tests/cases/compiler/defaultParameterAddsUndefinedWithStrictNullChecks.ts +++ b/tests/cases/compiler/defaultParameterAddsUndefinedWithStrictNullChecks.ts @@ -19,12 +19,21 @@ function foo2(x = "string", b: number) { function foo3(x: string | undefined = "string", b: number) { x.length; // ok, should be string + x = undefined; } function foo4(x: string | undefined = undefined, b: number) { x; // should be string | undefined + x = undefined; } +type OptionalNullableString = string | null | undefined; +function allowsNull(val: OptionalNullableString = "") { + val = null; + val = 'string and null are both ok'; +} +allowsNull(null); // still allows passing null + // .d.ts should have `string | undefined` for foo1, foo2, foo3 and foo4 diff --git a/tests/cases/conformance/salsa/inferingFromAny.ts b/tests/cases/conformance/salsa/inferingFromAny.ts new file mode 100644 index 00000000000..60519b2a5b6 --- /dev/null +++ b/tests/cases/conformance/salsa/inferingFromAny.ts @@ -0,0 +1,47 @@ +// @allowJs: true +// @noEmit: true + +// @fileName: a.ts +var a: any; +var t: [any, any]; +declare function f1(t: T): T +declare function f2(t: T[]): T; +declare function f3(t: [T, U]): [T, U]; +declare function f4(x: { bar: T; baz: T }): T; +declare function f5(x: (a: T) => void): T; +declare function f6(x: new (a: T) => {}): T; +declare function f7(x: (a: any) => a is T): T; +declare function f8(x: () => T): T; +declare function f9(x: new () => T): T; +declare function f10(x: { [x: string]: T }): T; +declare function f11(x: { [x: number]: T }): T; +declare function f12(x: T | U): [T, U]; +declare function f13(x: T & U): [T, U]; +declare function f14(x: { a: T | U, b: U & T }): [T, U]; +interface I { } +declare function f15(x: I): T; +declare function f16(x: Partial): T; +declare function f17(x: {[P in keyof T]: K}): T; +declare function f18(x: {[P in K]: T[P]}): T; +declare function f19(k: K, x: T[K]): T; + +// @fileName: a.js +var a = f1(a); +var a = f2(a); +var t = f3(a); +var a = f4(a); +var a = f5(a); +var a = f6(a); +var a = f7(a); +var a = f8(a); +var a = f9(a); +var a = f10(a); +var a = f11(a); +var t = f12(a); +var t = f13(a); +var t = f14(a); +var a = f15(a); +var a = f16(a); +var a = f17(a); +var a = f18(a); +var a = f19(a, a); \ No newline at end of file diff --git a/tests/cases/conformance/salsa/inferringClassMembersFromAssignments.ts b/tests/cases/conformance/salsa/inferringClassMembersFromAssignments.ts new file mode 100644 index 00000000000..d843e86b725 --- /dev/null +++ b/tests/cases/conformance/salsa/inferringClassMembersFromAssignments.ts @@ -0,0 +1,87 @@ +// @out: output.js +// @allowJs: true +// @strictNullChecks: true + +// @filename: a.js +class C { + constructor() { + if (Math.random()) { + this.inConstructor = 0; + } + else { + this.inConstructor = "string" + } + this.inMultiple = 0; + } + method() { + if (Math.random()) { + this.inMethod = 0; + } + else { + this.inMethod = "string" + } + this.inMultiple = "string"; + } + get() { + if (Math.random()) { + this.inGetter = 0; + } + else { + this.inGetter = "string" + } + this.inMultiple = false; + } + set() { + if (Math.random()) { + this.inSetter = 0; + } + else { + this.inSetter = "string" + } + } + static method() { + if (Math.random()) { + this.inStaticMethod = 0; + } + else { + this.inStaticMethod = "string" + } + } + static get() { + if (Math.random()) { + this.inStaticGetter = 0; + } + else { + this.inStaticGetter = "string" + } + } + static set() { + if (Math.random()) { + this.inStaticSetter = 0; + } + else { + this.inStaticSetter = "string" + } + } +} + +// @filename: b.ts +var c = new C(); + +var stringOrNumber: string | number; +var stringOrNumber = c.inConstructor; + +var stringOrNumberOrUndefined: string | number | undefined; + +var stringOrNumberOrUndefined = c.inMethod; +var stringOrNumberOrUndefined = c.inGetter; +var stringOrNumberOrUndefined = c.inSetter; + +var stringOrNumberOrBoolean: string | number | boolean; + +var stringOrNumberOrBoolean = c.inMultiple; + + +var stringOrNumberOrUndefined = C.inStaticMethod; +var stringOrNumberOrUndefined = C.inStaticGetter; +var stringOrNumberOrUndefined = C.inStaticSetter; diff --git a/tests/cases/conformance/salsa/jsObjectsMarkedAsOpenEnded.ts b/tests/cases/conformance/salsa/jsObjectsMarkedAsOpenEnded.ts new file mode 100644 index 00000000000..52b27641f0d --- /dev/null +++ b/tests/cases/conformance/salsa/jsObjectsMarkedAsOpenEnded.ts @@ -0,0 +1,36 @@ +// @out: output.js +// @allowJs: true + +// @filename: a.js +var variable = {}; +variable.a = 0; + +class C { + initializedMember = {}; + constructor() { + this.member = {}; + this.member.a = 0; + } +} + +var obj = { + property: {} +}; + +obj.property.a = 0; + +var arr = [{}]; + +function getObj() { + return {}; +} + + +// @filename: b.ts +variable.a = 1; +(new C()).member.a = 1; +(new C()).initializedMember.a = 1; +obj.property.a = 1; +arr[0].a = 1; +getObj().a = 1; + diff --git a/tests/cases/conformance/salsa/moduleExportAlias.ts b/tests/cases/conformance/salsa/moduleExportAlias.ts new file mode 100644 index 00000000000..60220271a57 --- /dev/null +++ b/tests/cases/conformance/salsa/moduleExportAlias.ts @@ -0,0 +1,79 @@ +// @allowJS: true +// @noEmit: true + +// @filename: a.ts +import b = require("./b.js"); +b.func1; +b.func2; +b.func3; +b.func4; +b.func5; +b.func6; +b.func7; +b.func8; +b.func9; +b.func10; +b.func11; +b.func12; +b.func13; +b.func14; +b.func15; +b.func16; +b.func17; +b.func18; +b.func19; +b.func20; + + +// @filename: b.js +var exportsAlias = exports; +exportsAlias.func1 = function () { }; +exports.func2 = function () { }; + +var moduleExportsAlias = module.exports; +moduleExportsAlias.func3 = function () { }; +module.exports.func4 = function () { }; + +var multipleDeclarationAlias1 = exports = module.exports; +multipleDeclarationAlias1.func5 = function () { }; + +var multipleDeclarationAlias2 = module.exports = exports; +multipleDeclarationAlias2.func6 = function () { }; + +var someOtherVariable; +var multipleDeclarationAlias3 = someOtherVariable = exports; +multipleDeclarationAlias3.func7 = function () { }; + +var multipleDeclarationAlias4 = someOtherVariable = module.exports; +multipleDeclarationAlias4.func8 = function () { }; + +var multipleDeclarationAlias5 = module.exports = exports = {}; +multipleDeclarationAlias5.func9 = function () { }; + +var multipleDeclarationAlias6 = exports = module.exports = {}; +multipleDeclarationAlias6.func10 = function () { }; + +exports = module.exports = someOtherVariable = {}; +exports.func11 = function () { }; +module.exports.func12 = function () { }; + +exports = module.exports = someOtherVariable = {}; +exports.func11 = function () { }; +module.exports.func12 = function () { }; + +exports = module.exports = {}; +exports.func13 = function () { }; +module.exports.func14 = function () { }; + +exports = module.exports = {}; +exports.func15 = function () { }; +module.exports.func16 = function () { }; + +module.exports = exports = {}; +exports.func17 = function () { }; +module.exports.func18 = function () { }; + +module.exports = {}; +exports.func19 = function () { }; +module.exports.func20 = function () { }; + diff --git a/tests/cases/conformance/types/thisType/thisTypeInObjectLiterals2.ts b/tests/cases/conformance/types/thisType/thisTypeInObjectLiterals2.ts index d476679aef1..27861f81da6 100644 --- a/tests/cases/conformance/types/thisType/thisTypeInObjectLiterals2.ts +++ b/tests/cases/conformance/types/thisType/thisTypeInObjectLiterals2.ts @@ -1,7 +1,5 @@ // @declaration: true -// @strictNullChecks: true -// @noImplicitAny: true -// @noImplicitThis: true +// @strict: true // @target: es5 // In methods of an object literal with no contextual type, 'this' has the type @@ -51,6 +49,42 @@ let p1: Point = { } }; +let p2: Point | null = { + x: 10, + y: 20, + moveBy(dx, dy, dz) { + this.x += dx; + this.y += dy; + if (this.z && dz) { + this.z += dz; + } + } +}; + +let p3: Point | undefined = { + x: 10, + y: 20, + moveBy(dx, dy, dz) { + this.x += dx; + this.y += dy; + if (this.z && dz) { + this.z += dz; + } + } +}; + +let p4: Point | null | undefined = { + x: 10, + y: 20, + moveBy(dx, dy, dz) { + this.x += dx; + this.y += dy; + if (this.z && dz) { + this.z += dz; + } + } +}; + declare function f1(p: Point): void; f1({ @@ -65,6 +99,20 @@ f1({ } }); +declare function f2(p: Point | null | undefined): void; + +f2({ + x: 10, + y: 20, + moveBy(dx, dy, dz) { + this.x += dx; + this.y += dy; + if (this.z && dz) { + this.z += dz; + } + } +}); + // In methods of an object literal with a contextual type that includes some // ThisType, 'this' is of type T. diff --git a/tslint.json b/tslint.json index 3952d4fac29..5e72aedf065 100644 --- a/tslint.json +++ b/tslint.json @@ -1,5 +1,6 @@ { "rules": { + "no-bom": true, "class-name": true, "comment-format": [true, "check-space"