Merge branch 'fixBuildBreak' into checkJSFiles

This commit is contained in:
Mohamed Hegazy 2017-03-08 23:17:28 -08:00
commit 3d03f8d8a5
157 changed files with 3743 additions and 619 deletions

View File

@ -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({

View File

@ -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");

View File

@ -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<void>, 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));
}
}
}
}
}
}

View File

@ -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<void>, 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);
}
}
}

View File

@ -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>): void {
if (ctx.sourceFile.text[0] === "\ufeff") {
ctx.addFailure(0, 1, Rule.FAILURE_STRING);
}
}

View File

@ -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>): 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);
}
}
}

View File

@ -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>): 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 &&
(<ts.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;
}
}

View File

@ -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>): 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);
}
}

View File

@ -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>): 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);
}
}

View File

@ -1,6 +1,11 @@
{
"compilerOptions": {
"noImplicitAny": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"strictNullChecks": true,
"module": "commonjs",
"outDir": "../../built/local/tslint"
}

View File

@ -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>): 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 = (<ts.UnionOrIntersectionTypeNode>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);
}
}

View File

@ -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, <PropertyAccessExpression>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((<Identifier>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<Symbol>();
// 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<Symbol>();
// 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;
}

View File

@ -1,4 +1,4 @@
/// <reference path="moduleNameResolver.ts"/>
/// <reference path="moduleNameResolver.ts"/>
/// <reference path="binder.ts"/>
/* @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<Symbol>();
/**
@ -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 ? <BinaryExpression>declaration :
declaration.kind === SyntaxKind.PropertyAccessExpression ? <BinaryExpression>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 ? <BinaryExpression>declaration :
declaration.kind === SyntaxKind.PropertyAccessExpression ? <BinaryExpression>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(<VariableLikeDeclaration>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) : (<InterfaceType>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<T> 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) {

View File

@ -1,4 +1,4 @@
/// <reference path="sys.ts"/>
/// <reference path="sys.ts"/>
/// <reference path="types.ts"/>
/// <reference path="core.ts"/>
/// <reference path="diagnosticInformationMap.generated.ts"/>

View File

@ -1,4 +1,4 @@
/// <reference path="types.ts"/>
/// <reference path="types.ts"/>
/// <reference path="performance.ts" />
namespace ts {

View File

@ -1,4 +1,4 @@
/// <reference path="checker.ts" />
/// <reference path="checker.ts" />
/// <reference path="transformer.ts" />
/// <reference path="declarationEmitter.ts" />
/// <reference path="sourcemap.ts" />
@ -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) {

View File

@ -1,4 +1,4 @@
/// <reference path="core.ts"/>
/// <reference path="core.ts"/>
/// <reference path="utilities.ts"/>
namespace ts {

View File

@ -290,6 +290,11 @@ namespace ts {
return resolutions;
}
interface DiagnosticCache {
perFile?: FileMap<Diagnostic[]>;
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<string>;
let cachedSemanticDiagnosticsForFile: DiagnosticCache = {};
let cachedDeclarationDiagnosticsForFile: DiagnosticCache = {};
let resolvedTypeReferenceDirectives = createMap<ResolvedTypeReferenceDirective>();
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<Diagnostic[]>();
}
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);
}

View File

@ -1,4 +1,4 @@
/// <reference path="core.ts"/>
/// <reference path="core.ts"/>
declare function setTimeout(handler: (...args: any[]) => void, timeout: number): any;
declare function clearTimeout(handle: any): void;

View File

@ -1,4 +1,4 @@
/// <reference path="visitor.ts" />
/// <reference path="visitor.ts" />
/// <reference path="transformers/ts.ts" />
/// <reference path="transformers/jsx.ts" />
/// <reference path="transformers/esnext.ts" />

View File

@ -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;

View File

@ -1,4 +1,4 @@
/// <reference path="../factory.ts" />
/// <reference path="../factory.ts" />
/// <reference path="../visitor.ts" />
// Transforms generator functions into a compatible ES5 representation with similar runtime

View File

@ -1,4 +1,4 @@
/// <reference path="../../factory.ts" />
/// <reference path="../../factory.ts" />
/// <reference path="../../visitor.ts" />
/// <reference path="../destructuring.ts" />
@ -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());
}

View File

@ -1,4 +1,4 @@
/// <reference path="../../factory.ts" />
/// <reference path="../../factory.ts" />
/// <reference path="../../visitor.ts" />
/// <reference path="../destructuring.ts" />

View File

@ -1,4 +1,4 @@
/// <reference path="../factory.ts" />
/// <reference path="../factory.ts" />
/// <reference path="../visitor.ts" />
/// <reference path="./destructuring.ts" />

View File

@ -1,4 +1,4 @@
/// <reference path="program.ts"/>
/// <reference path="program.ts"/>
/// <reference path="commandLineParser.ts"/>
namespace ts {

View File

@ -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 */

View File

@ -1,4 +1,4 @@
/// <reference path="sys.ts" />
/// <reference path="sys.ts" />
/* @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 && (<PropertyAccessExpression>node.parent).name === node);
}
export function isEmptyObjectLiteralOrArrayLiteral(expression: Node): boolean {
const kind = expression.kind;
if (kind === SyntaxKind.ObjectLiteralExpression) {
return (<ObjectLiteralExpression>expression).properties.length === 0;
}
if (kind === SyntaxKind.ArrayLiteralExpression) {
return (<ArrayLiteralExpression>expression).elements.length === 0;
}
return false;
export function isEmptyObjectLiteral(expression: Node): boolean {
return expression.kind === SyntaxKind.ObjectLiteralExpression &&
(<ObjectLiteralExpression>expression).properties.length === 0;
}
export function isEmptyArrayLiteral(expression: Node): boolean {
return expression.kind === SyntaxKind.ArrayLiteralExpression &&
(<ArrayLiteralExpression>expression).elements.length === 0;
}
export function getLocalSymbolForExportDefault(symbol: Symbol) {

View File

@ -1,4 +1,4 @@
/// <reference path="checker.ts" />
/// <reference path="checker.ts" />
/// <reference path="factory.ts" />
/// <reference path="utilities.ts" />

View File

@ -1,4 +1,4 @@
//
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");

View File

@ -6,6 +6,10 @@
"declaration": false,
"types": [
"node", "mocha", "chai"
],
"lib": [
"es6",
"scripthost"
]
},
"files": [

View File

@ -1,4 +1,4 @@
/// <reference path="..\harness.ts" />
/// <reference path="..\harness.ts" />
namespace ts {
interface File {

View File

@ -1,4 +1,4 @@
/// <reference path="..\harness.ts" />
/// <reference path="..\harness.ts" />
/// <reference path="..\..\compiler\commandLineParser.ts" />
namespace ts {

View File

@ -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));

View File

@ -1,4 +1,4 @@
/// <reference path="..\harness.ts" />
/// <reference path="..\harness.ts" />
/// <reference path="..\..\harness\harnessLanguageService.ts" />
namespace ts {

View File

@ -1,4 +1,4 @@
/// <reference path="..\..\harnessLanguageService.ts" />
/// <reference path="..\..\harnessLanguageService.ts" />
interface ClassificationEntry {
value: any;

View File

@ -1,4 +1,4 @@
/// <reference path="..\..\harnessLanguageService.ts" />
/// <reference path="..\..\harnessLanguageService.ts" />
describe("PreProcessFile:", function () {
function test(sourceText: string, readImportFile: boolean, detectJavaScriptImports: boolean, expectedPreProcess: ts.PreProcessedFileInfo): void {

View File

@ -1,4 +1,4 @@
/// <reference path="..\harness.ts" />
/// <reference path="..\harness.ts" />
const expect: typeof _chai.expect = _chai.expect;

View File

@ -1,4 +1,4 @@
/// <reference path="..\harness.ts" />
/// <reference path="..\harness.ts" />
/// <reference path="../../server/typingsInstaller/typingsInstaller.ts" />
namespace ts.projectSystem {

View File

@ -1,4 +1,4 @@
/// <reference path="../harness.ts" />
/// <reference path="../harness.ts" />
/// <reference path="./tsserverProjectSystem.ts" />
/// <reference path="../../server/typingsInstaller/typingsInstaller.ts" />

View File

@ -1,7 +1,6 @@
/// <reference path="..\compiler\commandLineParser.ts" />
/// <reference path="..\services\services.ts" />
/// <reference path="session.ts" />
/// <reference types="node" />
namespace ts.server {

View File

@ -37,7 +37,7 @@ function createCancellationToken(args: string[]): ServerCancellationToken {
// when client wants to signal cancellation it should create a named pipe with name=<cancellationPipeName>
// 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 <cancellationPipeName><request_seq>.
// in this case pipe name will be build dynamically as <cancellationPipeName><request_seq>.
if (cancellationPipeName.charAt(cancellationPipeName.length - 1) === "*") {
const namePrefix = cancellationPipeName.slice(0, -1);
if (namePrefix.length === 0 || namePrefix.indexOf("*") >= 0) {

View File

@ -5,6 +5,9 @@
"module": "commonjs",
"types": [
"node"
],
"lib": [
"es6"
]
},
"files": [

View File

@ -1,4 +1,4 @@
/// <reference path="..\compiler\commandLineParser.ts" />
/// <reference path="..\compiler\commandLineParser.ts" />
/// <reference path="..\services\services.ts" />
/// <reference path="utilities.ts" />
/// <reference path="session.ts" />

View File

@ -1,4 +1,4 @@
/// <reference path="..\services\services.ts" />
/// <reference path="..\services\services.ts" />
/// <reference path="utilities.ts"/>
/// <reference path="scriptInfo.ts"/>
/// <reference path="lsHost.ts"/>

View File

@ -10,7 +10,8 @@
"target": "es5",
"noUnusedLocals": true,
"noUnusedParameters": true,
"declaration": true
"declaration": true,
"types": []
},
"files": [
"editorServices.ts",

View File

@ -1,4 +1,4 @@
/// <reference path="typingsInstaller.ts"/>
/// <reference path="typingsInstaller.ts"/>
/// <reference types="node" />
namespace ts.server.typingsInstaller {

View File

@ -5,6 +5,10 @@
"outFile": "../../../built/local/typingsInstaller.js",
"types": [
"node"
],
"lib": [
"es6",
"scripthost"
]
},
"files": [

View File

@ -1,4 +1,4 @@
/// <reference path="../../compiler/core.ts" />
/// <reference path="../../compiler/core.ts" />
/// <reference path="../../compiler/moduleNameResolver.ts" />
/// <reference path="../../services/jsTyping.ts"/>
/// <reference path="../types.ts"/>

View File

@ -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"

View File

@ -1,4 +1,4 @@
/* @internal */
/* @internal */
namespace ts {
export interface CodeFix {
errorCodes: number[];

View File

@ -1,4 +1,4 @@
/* @internal */
/* @internal */
namespace ts.codefix {
type ImportCodeActionKind = "CodeChange" | "InsertingIntoExistingImport" | "NewImport";

View File

@ -1,4 +1,4 @@
/* @internal */
/* @internal */
namespace ts.codefix {
registerCodeFix({
errorCodes: [

View File

@ -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)

View File

@ -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);

View File

@ -1,4 +1,4 @@
/* @internal */
/* @internal */
namespace ts.GoToDefinition {
export function getDefinitionAtPosition(program: Program, sourceFile: SourceFile, position: number): DefinitionInfo[] {
/// Triple slash reference comments

View File

@ -1,4 +1,4 @@
/* @internal */
/* @internal */
namespace ts.JsDoc {
const jsDocTagNames = [
"augments",

View File

@ -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.
/// <reference path='../compiler/types.ts' />

View File

@ -1,4 +1,4 @@
/* @internal */
/* @internal */
namespace ts.NavigateTo {
type RawNavigateToItem = { name: string; fileName: string; matchKind: PatternMatchKind; isCaseSensitive: boolean; declaration: Declaration };

View File

@ -1,4 +1,4 @@
/// <reference path="..\compiler\program.ts"/>
/// <reference path="..\compiler\program.ts"/>
/// <reference path="..\compiler\commandLineParser.ts"/>
/// <reference path='types.ts' />

View File

@ -1,4 +1,4 @@
namespace ts {
namespace ts {
export interface TranspileOptions {
compilerOptions?: CompilerOptions;
fileName?: string;

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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

View File

@ -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() {

View File

@ -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): 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[]): 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, U>(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<T>(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<T>(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<T>(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<T>(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<T>(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<T>(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<T>(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<T>(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<T, U>(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<T, U>(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<T, U>(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<T> { }
>I : Symbol(I, Decl(a.ts, 16, 62))
>T : Symbol(T, Decl(a.ts, 17, 12))
declare function f15<T>(x: I<T>): 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<T>(x: Partial<T>): 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<T, K>(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<T, K extends keyof T>(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<T, K extends keyof T>(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))

View File

@ -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): T
>f1 : <T>(t: T) => T
>T : T
>t : T
>T : T
>T : T
declare function f2<T>(t: T[]): T;
>f2 : <T>(t: T[]) => T
>T : T
>t : T[]
>T : T
>T : T
declare function f3<T, U>(t: [T, U]): [T, U];
>f3 : <T, U>(t: [T, U]) => [T, U]
>T : T
>U : U
>t : [T, U]
>T : T
>U : U
>T : T
>U : U
declare function f4<T>(x: { bar: T; baz: T }): T;
>f4 : <T>(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<T>(x: (a: T) => void): T;
>f5 : <T>(x: (a: T) => void) => T
>T : T
>x : (a: T) => void
>a : T
>T : T
>T : T
declare function f6<T>(x: new (a: T) => {}): T;
>f6 : <T>(x: new (a: T) => {}) => T
>T : T
>x : new (a: T) => {}
>a : T
>T : T
>T : T
declare function f7<T>(x: (a: any) => a is T): T;
>f7 : <T>(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<T>(x: () => T): T;
>f8 : <T>(x: () => T) => T
>T : T
>x : () => T
>T : T
>T : T
declare function f9<T>(x: new () => T): T;
>f9 : <T>(x: new () => T) => T
>T : T
>x : new () => T
>T : T
>T : T
declare function f10<T>(x: { [x: string]: T }): T;
>f10 : <T>(x: { [x: string]: T; }) => T
>T : T
>x : { [x: string]: T; }
>x : string
>T : T
>T : T
declare function f11<T>(x: { [x: number]: T }): T;
>f11 : <T>(x: { [x: number]: T; }) => T
>T : T
>x : { [x: number]: T; }
>x : number
>T : T
>T : T
declare function f12<T, U>(x: T | U): [T, U];
>f12 : <T, U>(x: T | U) => [T, U]
>T : T
>U : U
>x : T | U
>T : T
>U : U
>T : T
>U : U
declare function f13<T, U>(x: T & U): [T, U];
>f13 : <T, U>(x: T & U) => [T, U]
>T : T
>U : U
>x : T & U
>T : T
>U : U
>T : T
>U : U
declare function f14<T, U>(x: { a: T | U, b: U & T }): [T, U];
>f14 : <T, U>(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<T> { }
>I : I<T>
>T : T
declare function f15<T>(x: I<T>): T;
>f15 : <T>(x: I<T>) => T
>T : T
>x : I<T>
>I : I<T>
>T : T
>T : T
declare function f16<T>(x: Partial<T>): T;
>f16 : <T>(x: Partial<T>) => T
>T : T
>x : Partial<T>
>Partial : Partial<T>
>T : T
>T : T
declare function f17<T, K>(x: {[P in keyof T]: K}): T;
>f17 : <T, K>(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<T, K extends keyof T>(x: {[P in K]: T[P]}): T;
>f18 : <T, K extends keyof T>(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<T, K extends keyof T>(k: K, x: T[K]): T;
>f19 : <T, K extends keyof T>(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) => T
>a : any
var a = f2(a);
>a : any
>f2(a) : any
>f2 : <T>(t: T[]) => T
>a : any
var t = f3(a);
>t : [any, any]
>f3(a) : [any, any]
>f3 : <T, U>(t: [T, U]) => [T, U]
>a : any
var a = f4(a);
>a : any
>f4(a) : any
>f4 : <T>(x: { bar: T; baz: T; }) => T
>a : any
var a = f5(a);
>a : any
>f5(a) : any
>f5 : <T>(x: (a: T) => void) => T
>a : any
var a = f6(a);
>a : any
>f6(a) : any
>f6 : <T>(x: new (a: T) => {}) => T
>a : any
var a = f7(a);
>a : any
>f7(a) : any
>f7 : <T>(x: (a: any) => a is T) => T
>a : any
var a = f8(a);
>a : any
>f8(a) : any
>f8 : <T>(x: () => T) => T
>a : any
var a = f9(a);
>a : any
>f9(a) : any
>f9 : <T>(x: new () => T) => T
>a : any
var a = f10(a);
>a : any
>f10(a) : any
>f10 : <T>(x: { [x: string]: T; }) => T
>a : any
var a = f11(a);
>a : any
>f11(a) : any
>f11 : <T>(x: { [x: number]: T; }) => T
>a : any
var t = f12(a);
>t : [any, any]
>f12(a) : [any, any]
>f12 : <T, U>(x: T | U) => [T, U]
>a : any
var t = f13(a);
>t : [any, any]
>f13(a) : [any, any]
>f13 : <T, U>(x: T & U) => [T, U]
>a : any
var t = f14(a);
>t : [any, any]
>f14(a) : [any, any]
>f14 : <T, U>(x: { a: T | U; b: U & T; }) => [T, U]
>a : any
var a = f15(a);
>a : any
>f15(a) : any
>f15 : <T>(x: I<T>) => T
>a : any
var a = f16(a);
>a : any
>f16(a) : any
>f16 : <T>(x: Partial<T>) => T
>a : any
var a = f17(a);
>a : any
>f17(a) : any
>f17 : <T, K>(x: { [P in keyof T]: K; }) => T
>a : any
var a = f18(a);
>a : any
>f18(a) : any
>f18 : <T, K extends keyof T>(x: { [P in K]: T[P]; }) => T
>a : any
var a = f19(a, a);
>a : any
>f19(a, a) : any
>f19 : <T, K extends keyof T>(k: K, x: T[K]) => T
>a : any
>a : any

View File

@ -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;

View File

@ -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))

View File

@ -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

View File

@ -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);
});

View File

@ -6,5 +6,4 @@ run(1);
//// [isolatedModulesPlainFile-CommonJS.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
run(1);

View File

@ -15,6 +15,5 @@ run(1);
}
})(function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
run(1);
});

View File

@ -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

View File

@ -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;

View File

@ -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))

View File

@ -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

View File

@ -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))

View File

@ -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

View File

@ -23,3 +23,5 @@ const enum E2 {
}
// comment9
console.log(1 + 2);
// comment10
function functionWithDefaultArgValue(argument: string = "defaultValue"): void { }

View File

@ -15,3 +15,4 @@ const enum E2 {
second
}
console.log(1 + 2);
function functionWithDefaultArgValue(argument: string = "defaultValue"): void { }

View File

@ -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<T>, '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<D, M> = {
data?: D;
methods?: M & ThisType<D & M>;

View File

@ -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<T>, 'this' is of type T.
type ObjectDescriptor<D, M> = {
>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<D & M>; // 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<D, M>(desc: ObjectDescriptor<D, M>): 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<T>, 'this' is of type T.
type ObjectDescriptor2<D, M> = ThisType<D & M> & {
>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<D, M>(desc: ObjectDescriptor<D, M>): 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<T> = {
>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<T> = {
>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<T[K]>;
>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<T, K extends string, U>(obj: T, name: K, desc: PropDesc<U> & ThisType<T>): T & Record<K, U>;
>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<T, U>(obj: T, descs: PropDescMap<U> & ThisType<T>): 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<T> = { [K in keyof T]: (() => T[K]) | Computed<T[K]> };
>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<T> = { [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<T> = {
>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<D, M, P> = ThisType<D & M & P> & {
>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<P>;
>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 <D, M, P>(options: VueOptions<D, M, P>) => 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))

View File

@ -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<T>, 'this' is of type T.

View File

@ -1,4 +1,3 @@
"use strict";
exports.__esModule = true;
var x = 0;
//# sourceMappingURL=file.js.map

View File

@ -1,5 +1,4 @@
"use strict";
exports.__esModule = true;
a;
b;
//# sourceMappingURL=file.js.map

View File

@ -1,6 +1,5 @@
define(["require", "exports"], function (require, exports) {
"use strict";
exports.__esModule = true;
var x = 0;
});
//# sourceMappingURL=file.js.map

View File

@ -1,5 +1,4 @@
"use strict";
exports.__esModule = true;
/// <reference path="file2.ts" />
var x = 0;
//# sourceMappingURL=file.js.map

View File

@ -1,4 +1,3 @@
"use strict";
exports.__esModule = true;
var x = 0;
//# sourceMappingURL=file.js.map

View File

@ -1,4 +1,3 @@
"use strict";
exports.__esModule = true;
var x = 0;
//# sourceMappingURL=file.js.map

View File

@ -1,3 +1,2 @@
"use strict";
exports.__esModule = true;
//# sourceMappingURL=file.js.map

View File

@ -1,3 +1,2 @@
"use strict";
exports.__esModule = true;
//# sourceMappingURL=file.js.map

View File

@ -1,4 +1,3 @@
"use strict";
exports.__esModule = true;
var a = 10;
//# sourceMappingURL=input.js.map

View File

@ -1,4 +1,3 @@
"use strict";
exports.__esModule = true;
var a = 10;
//# sourceMappingURL=input.js.map

View File

@ -1,4 +1,3 @@
"use strict";
exports.__esModule = true;
var x;
//# sourceMappingURL=b.js.map

View File

@ -1,4 +1,3 @@
"use strict";
exports.__esModule = true;
x;
//# sourceMappingURL=input.js.map

View File

@ -1,4 +1,3 @@
"use strict";
exports.__esModule = true;
x;
//# sourceMappingURL=input.js.map

View File

@ -1,4 +1,3 @@
"use strict";
exports.__esModule = true;
x;
//# sourceMappingURL=input.js.map

View File

@ -1,4 +1,3 @@
"use strict";
exports.__esModule = true;
x;
//# sourceMappingURL=input.js.map

Some files were not shown because too many files have changed in this diff Show More