Merge branch 'master' into overloadCompatibility

This commit is contained in:
Daniel Rosenwasser
2015-12-11 13:51:50 -08:00
3918 changed files with 25016 additions and 11164 deletions
+2 -1
View File
@@ -544,7 +544,8 @@ compileFile(word2mdJs,
// The generated spec.md; built for the 'generate-spec' task
file(specMd, [word2mdJs, specWord], function () {
var specWordFullPath = path.resolve(specWord);
var cmd = "cscript //nologo " + word2mdJs + ' "' + specWordFullPath + '" ' + specMd;
var specMDFullPath = path.resolve(specMd);
var cmd = "cscript //nologo " + word2mdJs + ' "' + specWordFullPath + '" ' + '"' + specMDFullPath + '"';
console.log(cmd);
child_process.exec(cmd, function () {
complete();
+13 -1
View File
@@ -1189,7 +1189,8 @@ namespace ts {
case SyntaxKind.ThisType:
seenThisKeyword = true;
return;
case SyntaxKind.TypePredicate:
return checkTypePredicate(node as TypePredicateNode);
case SyntaxKind.TypeParameter:
return declareSymbolAndAddToSymbolTable(<Declaration>node, SymbolFlags.TypeParameter, SymbolFlags.TypeParameterExcludes);
case SyntaxKind.Parameter:
@@ -1275,6 +1276,17 @@ namespace ts {
}
}
function checkTypePredicate(node: TypePredicateNode) {
const { parameterName, type } = node;
if (parameterName && parameterName.kind === SyntaxKind.Identifier) {
checkStrictModeIdentifier(parameterName as Identifier);
}
if (parameterName && parameterName.kind === SyntaxKind.ThisType) {
seenThisKeyword = true;
}
bind(type);
}
function bindSourceFileIfExternalModule() {
setExportContextFlag(file);
if (isExternalModule(file)) {
+374 -233
View File
File diff suppressed because it is too large Load Diff
+3 -3
View File
@@ -1309,6 +1309,9 @@ namespace ts {
}
function emitSignatureDeclaration(node: SignatureDeclaration) {
const prevEnclosingDeclaration = enclosingDeclaration;
enclosingDeclaration = node;
// Construct signature or constructor type write new Signature
if (node.kind === SyntaxKind.ConstructSignature || node.kind === SyntaxKind.ConstructorType) {
write("new ");
@@ -1321,9 +1324,6 @@ namespace ts {
write("(");
}
const prevEnclosingDeclaration = enclosingDeclaration;
enclosingDeclaration = node;
// Parameters
emitCommaList(node.parameters, emitParameterDeclaration);
+10 -2
View File
@@ -435,7 +435,7 @@
"category": "Error",
"code": 1147
},
"Cannot compile modules unless the '--module' flag is provided.": {
"Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file.": {
"category": "Error",
"code": 1148
},
@@ -867,7 +867,7 @@
"category": "Error",
"code": 2312
},
"Constraint of a type parameter cannot reference any type parameter from the same type parameter list.": {
"Type parameter '{0}' has a circular constraint.": {
"category": "Error",
"code": 2313
},
@@ -1647,6 +1647,14 @@
"category": "Error",
"code": 2517
},
"A 'this'-based type guard is not compatible with a parameter-based type guard.": {
"category": "Error",
"code": 2518
},
"A 'this'-based type predicate is only allowed within a class or interface's members, get accessors, or return type positions for functions and methods.": {
"category": "Error",
"code": 2519
},
"Duplicate identifier '{0}'. Compiler uses declaration '{1}' to support async functions.": {
"category": "Error",
"code": 2520
+25 -19
View File
@@ -499,7 +499,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
let externalImports: (ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration)[];
let exportSpecifiers: Map<ExportSpecifier[]>;
let exportEquals: ExportAssignment;
let hasExportStars: boolean;
let hasExportStarsToExportValues: boolean;
let detachedCommentsInfo: { nodePos: number; detachedCommentEndPos: number }[];
@@ -574,7 +574,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
externalImports = undefined;
exportSpecifiers = undefined;
exportEquals = undefined;
hasExportStars = undefined;
hasExportStarsToExportValues = undefined;
detachedCommentsInfo = undefined;
sourceMapData = undefined;
isEs6Module = false;
@@ -5260,11 +5260,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
writeLine();
emitToken(SyntaxKind.CloseBraceToken, node.members.end);
emitStart(node);
write(")(");
write("(");
if (baseTypeNode) {
emit(baseTypeNode.expression);
}
write(")");
write("))");
if (node.kind === SyntaxKind.ClassDeclaration) {
write(";");
}
@@ -6231,15 +6231,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
}
else {
// export * from "foo"
writeLine();
write("__export(");
if (modulekind !== ModuleKind.AMD) {
emitRequire(getExternalModuleName(node));
if (hasExportStarsToExportValues && resolver.moduleExportsSomeValue(node.moduleSpecifier)) {
writeLine();
write("__export(");
if (modulekind !== ModuleKind.AMD) {
emitRequire(getExternalModuleName(node));
}
else {
write(generatedName);
}
write(");");
}
else {
write(generatedName);
}
write(");");
}
emitEnd(node);
}
@@ -6327,7 +6329,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
externalImports = [];
exportSpecifiers = {};
exportEquals = undefined;
hasExportStars = false;
hasExportStarsToExportValues = false;
for (const node of sourceFile.statements) {
switch (node.kind) {
case SyntaxKind.ImportDeclaration:
@@ -6350,8 +6352,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
if ((<ExportDeclaration>node).moduleSpecifier) {
if (!(<ExportDeclaration>node).exportClause) {
// export * from "mod"
externalImports.push(<ExportDeclaration>node);
hasExportStars = true;
if (resolver.moduleExportsSomeValue((<ExportDeclaration>node).moduleSpecifier)) {
externalImports.push(<ExportDeclaration>node);
hasExportStarsToExportValues = true;
}
}
else if (resolver.isValueAliasDeclaration(node)) {
// export { x, y } from "mod" where at least one export is a value symbol
@@ -6377,7 +6381,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
}
function emitExportStarHelper() {
if (hasExportStars) {
if (hasExportStarsToExportValues) {
writeLine();
write("function __export(m) {");
increaseIndent();
@@ -6455,7 +6459,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
// should always win over entries with similar names that were added via star exports
// to support this we store names of local/indirect exported entries in a set.
// this set is used to filter names brought by star expors.
if (!hasExportStars) {
if (!hasExportStarsToExportValues) {
// local names set is needed only in presence of star exports
return undefined;
}
@@ -6880,6 +6884,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
write("});");
}
else {
// collectExternalModuleInfo prefilters star exports to keep only ones that export values
// this means that check 'resolver.moduleExportsSomeValue' is redundant and can be omitted here
writeLine();
// export * from 'foo'
// emit as:
@@ -7148,7 +7154,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
externalImports = undefined;
exportSpecifiers = undefined;
exportEquals = undefined;
hasExportStars = false;
hasExportStarsToExportValues = false;
const startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false);
emitEmitHelpers(node);
emitCaptureThisForNodeIfNecessary(node);
@@ -7372,7 +7378,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
externalImports = undefined;
exportSpecifiers = undefined;
exportEquals = undefined;
hasExportStars = false;
hasExportStarsToExportValues = false;
emitEmitHelpers(node);
emitCaptureThisForNodeIfNecessary(node);
emitLinesStartingAt(node.statements, startIndex);
+22 -10
View File
@@ -1963,11 +1963,7 @@ namespace ts {
function parseTypeReferenceOrTypePredicate(): TypeReferenceNode | TypePredicateNode {
const typeName = parseEntityName(/*allowReservedWords*/ false, Diagnostics.Type_expected);
if (typeName.kind === SyntaxKind.Identifier && token === SyntaxKind.IsKeyword && !scanner.hasPrecedingLineBreak()) {
nextToken();
const node = <TypePredicateNode>createNode(SyntaxKind.TypePredicate, typeName.pos);
node.parameterName = <Identifier>typeName;
node.type = parseType();
return finishNode(node);
return parseTypePredicate(typeName as Identifier);
}
const node = <TypeReferenceNode>createNode(SyntaxKind.TypeReference, typeName.pos);
node.typeName = typeName;
@@ -1977,8 +1973,16 @@ namespace ts {
return finishNode(node);
}
function parseThisTypeNode(): TypeNode {
const node = <TypeNode>createNode(SyntaxKind.ThisType);
function parseTypePredicate(lhs: Identifier | ThisTypeNode): TypePredicateNode {
nextToken();
const node = createNode(SyntaxKind.TypePredicate, lhs.pos) as TypePredicateNode;
node.parameterName = lhs;
node.type = parseType();
return finishNode(node);
}
function parseThisTypeNode(): ThisTypeNode {
const node = createNode(SyntaxKind.ThisType) as ThisTypeNode;
nextToken();
return finishNode(node);
}
@@ -2424,8 +2428,15 @@ namespace ts {
return parseStringLiteralTypeNode();
case SyntaxKind.VoidKeyword:
return parseTokenNode<TypeNode>();
case SyntaxKind.ThisKeyword:
return parseThisTypeNode();
case SyntaxKind.ThisKeyword: {
const thisKeyword = parseThisTypeNode();
if (token === SyntaxKind.IsKeyword && !scanner.hasPrecedingLineBreak()) {
return parseTypePredicate(thisKeyword);
}
else {
return thisKeyword;
}
}
case SyntaxKind.TypeOfKeyword:
return parseTypeQuery();
case SyntaxKind.OpenBraceToken:
@@ -3639,7 +3650,7 @@ namespace ts {
parseExpected(SyntaxKind.OpenBraceToken);
if (token !== SyntaxKind.CloseBraceToken) {
node.expression = parseExpression();
node.expression = parseAssignmentExpressionOrHigher();
}
if (inExpressionContext) {
parseExpected(SyntaxKind.CloseBraceToken);
@@ -3981,6 +3992,7 @@ namespace ts {
}
else {
const propertyAssignment = <PropertyAssignment>createNode(SyntaxKind.PropertyAssignment, fullStart);
propertyAssignment.modifiers = modifiers;
propertyAssignment.name = propertyName;
propertyAssignment.questionToken = questionToken;
parseExpected(SyntaxKind.ColonToken);
+1 -1
View File
@@ -1234,7 +1234,7 @@ namespace ts {
else if (firstExternalModuleSourceFile && languageVersion < ScriptTarget.ES6 && !options.module) {
// We cannot use createDiagnosticFromNode because nodes do not have parents yet
const span = getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator);
programDiagnostics.add(createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided));
programDiagnostics.add(createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided_Consider_setting_the_module_compiler_option_in_a_tsconfig_json_file));
}
// Cannot specify module gen target of es6 when below es6
-5
View File
@@ -411,11 +411,6 @@ namespace ts {
// and is more efficient than `fs.watchFile` (ref: https://github.com/nodejs/node/pull/2649
// and https://github.com/Microsoft/TypeScript/issues/4643), therefore
// if the current node.js version is newer than 4, use `fs.watch` instead.
if (isNode4OrLater()) {
// Note: in node the callback of fs.watch is given only the relative file name as a parameter
return _fs.watch(fileName, (eventName: string, relativeFileName: string) => callback(fileName));
}
const watchedFile = watchedFileSet.addFile(fileName, callback);
return {
close: () => watchedFileSet.removeFile(watchedFile)
+32 -6
View File
@@ -733,11 +733,15 @@ namespace ts {
// @kind(SyntaxKind.StringKeyword)
// @kind(SyntaxKind.SymbolKeyword)
// @kind(SyntaxKind.VoidKeyword)
// @kind(SyntaxKind.ThisType)
export interface TypeNode extends Node {
_typeNodeBrand: any;
}
// @kind(SyntaxKind.ThisType)
export interface ThisTypeNode extends TypeNode {
_thisTypeNodeBrand: any;
}
export interface FunctionOrConstructorTypeNode extends TypeNode, SignatureDeclaration {
_functionOrConstructorTypeNodeBrand: any;
}
@@ -756,7 +760,7 @@ namespace ts {
// @kind(SyntaxKind.TypePredicate)
export interface TypePredicateNode extends TypeNode {
parameterName: Identifier;
parameterName: Identifier | ThisTypeNode;
type: TypeNode;
}
@@ -1820,10 +1824,25 @@ namespace ts {
CannotBeNamed
}
export const enum TypePredicateKind {
This,
Identifier
}
export interface TypePredicate {
kind: TypePredicateKind;
type: Type;
}
// @kind (TypePredicateKind.This)
export interface ThisTypePredicate extends TypePredicate {
_thisTypePredicateBrand: any;
}
// @kind (TypePredicateKind.Identifier)
export interface IdentifierTypePredicate extends TypePredicate {
parameterName: string;
parameterIndex: number;
type: Type;
}
/* @internal */
@@ -1887,6 +1906,7 @@ namespace ts {
getReferencedValueDeclaration(reference: Identifier): Declaration;
getTypeReferenceSerializationKind(typeName: EntityName): TypeReferenceSerializationKind;
isOptionalParameter(node: ParameterDeclaration): boolean;
moduleExportsSomeValue(moduleReferenceExpression: Expression): boolean;
isArgumentsLocalBinding(node: Identifier): boolean;
getExternalModuleFileFromDeclaration(declaration: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration): SourceFile;
}
@@ -2005,6 +2025,7 @@ namespace ts {
exportsChecked?: boolean; // True if exports of external module have been checked
isNestedRedeclaration?: boolean; // True if symbol is block scoped redeclaration
bindingElement?: BindingElement; // Binding element associated with property symbol
exportsSomeValue?: boolean; // true if module exports some value (not just types)
}
/* @internal */
@@ -2045,7 +2066,6 @@ namespace ts {
resolvedSymbol?: Symbol; // Cached name resolution result
flags?: NodeCheckFlags; // Set of flags specific to Node
enumMemberValue?: number; // Constant value of enum member
isIllegalTypeReferenceInConstraint?: boolean; // Is type reference in constraint refers to the type parameter from the same list
isVisible?: boolean; // Is this node visible
generatedName?: string; // Generated name for module, enum, or import declaration
generatedNames?: Map<string>; // Generated names table for source file
@@ -2089,6 +2109,7 @@ namespace ts {
ESSymbol = 0x01000000, // Type of symbol primitive introduced in ES6
ThisType = 0x02000000, // This type
ObjectLiteralPatternWithComputedProperties = 0x04000000, // Object literal type implied by binding pattern has computed properties
PredicateType = 0x08000000, // Predicate types are also Boolean types, but should not be considered Intrinsics - there's no way to capture this with flags
/* @internal */
Intrinsic = Any | String | Number | Boolean | ESSymbol | Void | Undefined | Null,
@@ -2100,7 +2121,7 @@ namespace ts {
UnionOrIntersection = Union | Intersection,
StructuredType = ObjectType | Union | Intersection,
/* @internal */
RequiresWidening = ContainsUndefinedOrNull | ContainsObjectLiteral,
RequiresWidening = ContainsUndefinedOrNull | ContainsObjectLiteral | PredicateType,
/* @internal */
PropagatingFlags = ContainsUndefinedOrNull | ContainsObjectLiteral | ContainsAnyFunctionType
}
@@ -2121,6 +2142,11 @@ namespace ts {
intrinsicName: string; // Name of intrinsic type
}
// Predicate types (TypeFlags.Predicate)
export interface PredicateType extends Type {
predicate: ThisTypePredicate | IdentifierTypePredicate;
}
// String literal types (TypeFlags.StringLiteral)
export interface StringLiteralType extends Type {
text: string; // Text of string literal
@@ -2237,7 +2263,6 @@ namespace ts {
declaration: SignatureDeclaration; // Originating declaration
typeParameters: TypeParameter[]; // Type parameters (undefined if non-generic)
parameters: Symbol[]; // Parameters
typePredicate?: TypePredicate; // Type predicate
/* @internal */
resolvedReturnType: Type; // Resolved return type
/* @internal */
@@ -2286,6 +2311,7 @@ namespace ts {
inferUnionTypes: boolean; // Infer union types for disjoint candidates (otherwise undefinedType)
inferences: TypeInferences[]; // Inferences made for each type parameter
inferredTypes: Type[]; // Inferred type for each type parameter
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
}
+5
View File
@@ -342,6 +342,7 @@ namespace ts {
case SyntaxKind.EnumMember:
case SyntaxKind.FunctionDeclaration:
case SyntaxKind.FunctionExpression:
case SyntaxKind.MethodDeclaration:
errorNode = (<Declaration>node).name;
break;
}
@@ -692,6 +693,10 @@ namespace ts {
return node && node.kind === SyntaxKind.MethodDeclaration && node.parent.kind === SyntaxKind.ObjectLiteralExpression;
}
export function isIdentifierTypePredicate(predicate: TypePredicate): predicate is IdentifierTypePredicate {
return predicate && predicate.kind === TypePredicateKind.Identifier;
}
export function getContainingFunction(node: Node): FunctionLikeDeclaration {
while (true) {
node = node.parent;
+23 -3
View File
@@ -6923,7 +6923,7 @@ interface IDBDatabase extends EventTarget {
onerror: (ev: Event) => any;
version: string;
close(): void;
createObjectStore(name: string, optionalParameters?: any): IDBObjectStore;
createObjectStore(name: string, optionalParameters?: IDBObjectStoreParameters): IDBObjectStore;
deleteObjectStore(name: string): void;
transaction(storeNames: any, mode?: string): IDBTransaction;
addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void;
@@ -6948,10 +6948,11 @@ declare var IDBFactory: {
}
interface IDBIndex {
keyPath: string;
keyPath: string | string[];
name: string;
objectStore: IDBObjectStore;
unique: boolean;
multiEntry: boolean;
count(key?: any): IDBRequest;
get(key: any): IDBRequest;
getKey(key: any): IDBRequest;
@@ -6988,7 +6989,7 @@ interface IDBObjectStore {
add(value: any, key?: any): IDBRequest;
clear(): IDBRequest;
count(key?: any): IDBRequest;
createIndex(name: string, keyPath: string, optionalParameters?: any): IDBIndex;
createIndex(name: string, keyPath: string | string[], optionalParameters?: IDBIndexParameters): IDBIndex;
delete(key: any): IDBRequest;
deleteIndex(indexName: string): void;
get(key: any): IDBRequest;
@@ -12575,6 +12576,16 @@ interface XMLHttpRequestEventTarget {
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
}
interface IDBObjectStoreParameters {
keyPath?: string | string[];
autoIncrement?: boolean;
}
interface IDBIndexParameters {
unique?: boolean;
multiEntry?: boolean;
}
interface NodeListOf<TNode extends Node> extends NodeList {
length: number;
item(index: number): TNode;
@@ -12610,6 +12621,15 @@ interface ProgressEventInit extends EventInit {
total?: number;
}
interface HTMLTemplateElement extends HTMLElement {
content: DocumentFragment;
}
declare var HTMLTemplateElement: {
prototype: HTMLTemplateElement;
new(): HTMLTemplateElement;
}
declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject;
interface ErrorEventHandler {
+14 -3
View File
@@ -311,7 +311,7 @@ interface IDBDatabase extends EventTarget {
onerror: (ev: Event) => any;
version: string;
close(): void;
createObjectStore(name: string, optionalParameters?: any): IDBObjectStore;
createObjectStore(name: string, optionalParameters?: IDBObjectStoreParameters): IDBObjectStore;
deleteObjectStore(name: string): void;
transaction(storeNames: any, mode?: string): IDBTransaction;
addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void;
@@ -336,10 +336,11 @@ declare var IDBFactory: {
}
interface IDBIndex {
keyPath: string;
keyPath: string | string[];
name: string;
objectStore: IDBObjectStore;
unique: boolean;
multiEntry: boolean;
count(key?: any): IDBRequest;
get(key: any): IDBRequest;
getKey(key: any): IDBRequest;
@@ -376,7 +377,7 @@ interface IDBObjectStore {
add(value: any, key?: any): IDBRequest;
clear(): IDBRequest;
count(key?: any): IDBRequest;
createIndex(name: string, keyPath: string, optionalParameters?: any): IDBIndex;
createIndex(name: string, keyPath: string | string[], optionalParameters?: IDBIndexParameters): IDBIndex;
delete(key: any): IDBRequest;
deleteIndex(indexName: string): void;
get(key: any): IDBRequest;
@@ -892,6 +893,16 @@ interface WorkerUtils extends Object, WindowBase64 {
setTimeout(handler: any, timeout?: any, ...args: any[]): number;
}
interface IDBObjectStoreParameters {
keyPath?: string | string[];
autoIncrement?: boolean;
}
interface IDBIndexParameters {
unique?: boolean;
multiEntry?: boolean;
}
interface BlobPropertyBag {
type?: string;
endings?: string;
+34 -47
View File
@@ -31,8 +31,8 @@ namespace ts.formatting {
* the first token in line so it should be indented
*/
interface DynamicIndentation {
getIndentationForToken(tokenLine: number, tokenKind: SyntaxKind): number;
getIndentationForComment(owningToken: SyntaxKind, tokenIndentation: number): number;
getIndentationForToken(tokenLine: number, tokenKind: SyntaxKind, container: Node): number;
getIndentationForComment(owningToken: SyntaxKind, tokenIndentation: number, container: Node): number;
/**
* Indentation for open and close tokens of the node if it is block or another node that needs special indentation
* ... {
@@ -54,7 +54,7 @@ namespace ts.formatting {
* so bar inherits indentation from foo and bar.delta will be 4
*
*/
getDelta(): number;
getDelta(child: TextRangeWithKind): number;
/**
* Formatter calls this function when rule adds or deletes new lines from the text
* so indentation scope can adjust values of indentation and delta.
@@ -282,19 +282,19 @@ namespace ts.formatting {
*/
function getOwnOrInheritedDelta(n: Node, options: FormatCodeOptions, sourceFile: SourceFile): number {
let previousLine = Constants.Unknown;
let childKind = SyntaxKind.Unknown;
let child: Node;
while (n) {
let line = sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)).line;
if (previousLine !== Constants.Unknown && line !== previousLine) {
break;
}
if (SmartIndenter.shouldIndentChildNode(n.kind, childKind)) {
if (SmartIndenter.shouldIndentChildNode(n, child)) {
return options.IndentSize;
}
previousLine = line;
childKind = n.kind;
child = n;
n = n.parent;
}
return 0;
@@ -386,34 +386,7 @@ namespace ts.formatting {
effectiveParentStartLine: number): Indentation {
let indentation = inheritedIndentation;
if (indentation === Constants.Unknown) {
if (isSomeBlock(node.kind)) {
// blocks should be indented in
// - other blocks
// - source file
// - switch\default clauses
if (isSomeBlock(parent.kind) ||
parent.kind === SyntaxKind.SourceFile ||
parent.kind === SyntaxKind.CaseClause ||
parent.kind === SyntaxKind.DefaultClause) {
indentation = parentDynamicIndentation.getIndentation() + parentDynamicIndentation.getDelta();
}
else {
indentation = parentDynamicIndentation.getIndentation();
}
}
else {
if (SmartIndenter.childStartsOnTheSameLineWithElseInIfStatement(parent, node, startLine, sourceFile)) {
indentation = parentDynamicIndentation.getIndentation();
}
else {
indentation = parentDynamicIndentation.getIndentation() + parentDynamicIndentation.getDelta();
}
}
}
var delta = SmartIndenter.shouldIndentChildNode(node.kind, SyntaxKind.Unknown) ? options.IndentSize : 0;
var delta = SmartIndenter.shouldIndentChildNode(node) ? options.IndentSize : 0;
if (effectiveParentStartLine === startLine) {
// if node is located on the same line with the parent
@@ -422,8 +395,17 @@ namespace ts.formatting {
indentation = startLine === lastIndentedLine
? indentationOnLastIndentedLine
: parentDynamicIndentation.getIndentation();
delta = Math.min(options.IndentSize, parentDynamicIndentation.getDelta() + delta);
delta = Math.min(options.IndentSize, parentDynamicIndentation.getDelta(node) + delta);
}
else if (indentation === Constants.Unknown) {
if (SmartIndenter.childStartsOnTheSameLineWithElseInIfStatement(parent, node, startLine, sourceFile)) {
indentation = parentDynamicIndentation.getIndentation();
}
else {
indentation = parentDynamicIndentation.getIndentation() + parentDynamicIndentation.getDelta(node);
}
}
return {
indentation,
delta
@@ -455,7 +437,7 @@ namespace ts.formatting {
function getDynamicIndentation(node: Node, nodeStartLine: number, indentation: number, delta: number): DynamicIndentation {
return {
getIndentationForComment: (kind, tokenIndentation) => {
getIndentationForComment: (kind, tokenIndentation, container) => {
switch (kind) {
// preceding comment to the token that closes the indentation scope inherits the indentation from the scope
// .. {
@@ -464,11 +446,11 @@ namespace ts.formatting {
case SyntaxKind.CloseBraceToken:
case SyntaxKind.CloseBracketToken:
case SyntaxKind.CloseParenToken:
return indentation + delta;
return indentation + getEffectiveDelta(delta, container);
}
return tokenIndentation !== Constants.Unknown ? tokenIndentation : indentation;
},
getIndentationForToken: (line, kind) => {
getIndentationForToken: (line, kind, container) => {
if (nodeStartLine !== line && node.decorators) {
if (kind === getFirstNonDecoratorTokenOfNode(node)) {
// if this token is the first token following the list of decorators, we do not need to indent
@@ -489,13 +471,13 @@ namespace ts.formatting {
return indentation;
default:
// if token line equals to the line of containing node (this is a first token in the node) - use node indentation
return nodeStartLine !== line ? indentation + delta : indentation;
return nodeStartLine !== line ? indentation + getEffectiveDelta(delta, container) : indentation;
}
},
getIndentation: () => indentation,
getDelta: () => delta,
getDelta: child => getEffectiveDelta(delta, child),
recomputeIndentation: lineAdded => {
if (node.parent && SmartIndenter.shouldIndentChildNode(node.parent.kind, node.kind)) {
if (node.parent && SmartIndenter.shouldIndentChildNode(node.parent, node)) {
if (lineAdded) {
indentation += options.IndentSize;
}
@@ -503,14 +485,19 @@ namespace ts.formatting {
indentation -= options.IndentSize;
}
if (SmartIndenter.shouldIndentChildNode(node.kind, SyntaxKind.Unknown)) {
if (SmartIndenter.shouldIndentChildNode(node)) {
delta = options.IndentSize;
}
else {
delta = 0;
}
}
},
}
}
function getEffectiveDelta(delta: number, child: TextRangeWithKind) {
// Delta value should be zero when the node explicitly prevents indentation of the child node
return SmartIndenter.nodeWillIndentChild(node, child, true) ? delta : 0;
}
}
@@ -610,7 +597,7 @@ namespace ts.formatting {
// if child node is a token, it does not impact indentation, proceed it using parent indentation scope rules
let tokenInfo = formattingScanner.readTokenInfo(child);
Debug.assert(tokenInfo.token.end === child.end);
consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation);
consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child);
return inheritedIndentation;
}
@@ -679,7 +666,7 @@ namespace ts.formatting {
}
}
function consumeTokenAndAdvanceScanner(currentTokenInfo: TokenInfo, parent: Node, dynamicIndentation: DynamicIndentation): void {
function consumeTokenAndAdvanceScanner(currentTokenInfo: TokenInfo, parent: Node, dynamicIndentation: DynamicIndentation, container?: Node): void {
Debug.assert(rangeContainsRange(parent, currentTokenInfo.token));
let lastTriviaWasNewLine = formattingScanner.lastTrailingTriviaWasNewLine();
@@ -720,11 +707,11 @@ namespace ts.formatting {
if (indentToken) {
let tokenIndentation = (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) ?
dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind) :
dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind, container) :
Constants.Unknown;
if (currentTokenInfo.leadingTrivia) {
let commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind, tokenIndentation);
let commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind, tokenIndentation, container);
let indentNextTokenOrTrivia = true;
for (let triviaItem of currentTokenInfo.leadingTrivia) {
+7 -7
View File
@@ -123,6 +123,7 @@ namespace ts.formatting {
public SpaceAfterModuleName: Rule;
// Lambda expressions
public SpaceBeforeArrow: Rule;
public SpaceAfterArrow: Rule;
// Optional parameters and let args
@@ -254,7 +255,7 @@ namespace ts.formatting {
// No space before and after indexer
this.NoSpaceBeforeOpenBracket = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.OpenBracketToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
this.NoSpaceAfterCloseBracket = new Rule(RuleDescriptor.create3(SyntaxKind.CloseBracketToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBeforeBlockInFunctionDeclarationContext ), RuleAction.Delete));
this.NoSpaceAfterCloseBracket = new Rule(RuleDescriptor.create3(SyntaxKind.CloseBracketToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBeforeBlockInFunctionDeclarationContext), RuleAction.Delete));
// Place a space before open brace in a function declaration
this.FunctionOpenBraceLeftTokenRange = Shared.TokenRange.AnyIncludingMultilineComments;
@@ -342,6 +343,7 @@ namespace ts.formatting {
this.SpaceAfterModuleName = new Rule(RuleDescriptor.create1(SyntaxKind.StringLiteral, SyntaxKind.OpenBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsModuleDeclContext), RuleAction.Space));
// Lambda expressions
this.SpaceBeforeArrow = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.EqualsGreaterThanToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
this.SpaceAfterArrow = new Rule(RuleDescriptor.create3(SyntaxKind.EqualsGreaterThanToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
// Optional parameters and let args
@@ -379,8 +381,7 @@ namespace ts.formatting {
this.NoSpaceBeforeTemplateMiddleAndTail = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.FromTokens([SyntaxKind.TemplateMiddle, SyntaxKind.TemplateTail])), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
// These rules are higher in priority than user-configurable rules.
this.HighPriorityCommonRules =
[
this.HighPriorityCommonRules = [
this.IgnoreBeforeComment, this.IgnoreAfterLineComment,
this.NoSpaceBeforeColon, this.SpaceAfterColon, this.NoSpaceBeforeQuestionMark, this.SpaceAfterQuestionMarkInConditionalOperator,
this.NoSpaceAfterQuestionMark,
@@ -411,7 +412,7 @@ namespace ts.formatting {
this.NoSpaceAfterConstructor, this.NoSpaceAfterModuleImport,
this.SpaceAfterCertainTypeScriptKeywords, this.SpaceBeforeCertainTypeScriptKeywords,
this.SpaceAfterModuleName,
this.SpaceAfterArrow,
this.SpaceBeforeArrow, this.SpaceAfterArrow,
this.NoSpaceAfterEllipsis,
this.NoSpaceAfterOptionalParameters,
this.NoSpaceBetweenEmptyInterfaceBraceBrackets,
@@ -427,8 +428,7 @@ namespace ts.formatting {
];
// These rules are lower in priority than user-configurable rules.
this.LowPriorityCommonRules =
[
this.LowPriorityCommonRules = [
this.NoSpaceBeforeSemicolon,
this.SpaceBeforeOpenBraceInControl, this.SpaceBeforeOpenBraceInFunction, this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock,
this.NoSpaceBeforeComma,
@@ -732,7 +732,7 @@ namespace ts.formatting {
}
static IsStartOfVariableDeclarationList(context: FormattingContext): boolean {
return context.currentTokenParent.kind === SyntaxKind.VariableDeclarationList &&
return context.currentTokenParent.kind === SyntaxKind.VariableDeclarationList &&
context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos;
}
+16 -11
View File
@@ -68,7 +68,7 @@ namespace ts.formatting {
let indentationDelta: number;
while (current) {
if (positionBelongsToNode(current, position, sourceFile) && shouldIndentChildNode(current.kind, previous ? previous.kind : SyntaxKind.Unknown)) {
if (positionBelongsToNode(current, position, sourceFile) && shouldIndentChildNode(current, previous)) {
currentStart = getStartLineAndCharacterForNode(current, sourceFile);
if (nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile)) {
@@ -153,7 +153,7 @@ namespace ts.formatting {
}
// increase indentation if parent node wants its content to be indented and parent and child nodes don't start on the same line
if (shouldIndentChildNode(parent.kind, current.kind) && !parentAndChildShareLine) {
if (shouldIndentChildNode(parent, current) && !parentAndChildShareLine) {
indentationDelta += options.IndentSize;
}
@@ -466,12 +466,10 @@ namespace ts.formatting {
}
return false;
}
export function shouldIndentChildNode(parent: SyntaxKind, child: SyntaxKind): boolean {
if (nodeContentIsAlwaysIndented(parent)) {
return true;
}
switch (parent) {
export function nodeWillIndentChild(parent: TextRangeWithKind, child: TextRangeWithKind, indentByDefault: boolean) {
let childKind = child ? child.kind : SyntaxKind.Unknown;
switch (parent.kind) {
case SyntaxKind.DoStatement:
case SyntaxKind.WhileStatement:
case SyntaxKind.ForInStatement:
@@ -485,10 +483,17 @@ namespace ts.formatting {
case SyntaxKind.Constructor:
case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor:
return child !== SyntaxKind.Block;
default:
return false;
return childKind !== SyntaxKind.Block;
}
// No explicit rule for given nodes so the result will follow the default value argument
return indentByDefault;
}
/*
Function returns true when the parent node should indent the given child by an explicit rule
*/
export function shouldIndentChildNode(parent: TextRangeWithKind, child?: TextRangeWithKind): boolean {
return nodeContentIsAlwaysIndented(parent.kind) || nodeWillIndentChild(parent, child, false);
}
}
}
+3 -3
View File
@@ -20,12 +20,12 @@ var Cell = (function () {
function Cell() {
}
return Cell;
})();
}());
var Ship = (function () {
function Ship() {
}
return Ship;
})();
}());
var Board = (function () {
function Board() {
}
@@ -33,4 +33,4 @@ var Board = (function () {
return this.ships.every(function (val) { return val.isSunk; });
};
return Board;
})();
}());
@@ -31,7 +31,7 @@ var A;
this.y = y;
}
return Point;
})();
}());
A.Point = Point;
})(A || (A = {}));
//// [test.js]
@@ -55,7 +55,7 @@ var clodule1 = (function () {
function clodule1() {
}
return clodule1;
})();
}());
var clodule1;
(function (clodule1) {
function f(x) { }
@@ -64,7 +64,7 @@ var clodule2 = (function () {
function clodule2() {
}
return clodule2;
})();
}());
var clodule2;
(function (clodule2) {
var x;
@@ -72,13 +72,13 @@ var clodule2;
function D() {
}
return D;
})();
}());
})(clodule2 || (clodule2 = {}));
var clodule3 = (function () {
function clodule3() {
}
return clodule3;
})();
}());
var clodule3;
(function (clodule3) {
clodule3.y = { id: T };
@@ -87,12 +87,12 @@ var clodule4 = (function () {
function clodule4() {
}
return clodule4;
})();
}());
var clodule4;
(function (clodule4) {
var D = (function () {
function D() {
}
return D;
})();
}());
})(clodule4 || (clodule4 = {}));
@@ -21,7 +21,7 @@ var clodule = (function () {
}
clodule.fn = function (id) { };
return clodule;
})();
}());
var clodule;
(function (clodule) {
// error: duplicate identifier expected
@@ -21,7 +21,7 @@ var clodule = (function () {
}
clodule.fn = function (id) { };
return clodule;
})();
}());
var clodule;
(function (clodule) {
// error: duplicate identifier expected
@@ -21,7 +21,7 @@ var clodule = (function () {
}
clodule.sfn = function (id) { return 42; };
return clodule;
})();
}());
var clodule;
(function (clodule) {
// error: duplicate identifier expected
@@ -30,7 +30,7 @@ var Point = (function () {
}
Point.Origin = function () { return { x: 0, y: 0 }; }; // unexpected error here bug 840246
return Point;
})();
}());
var Point;
(function (Point) {
function Origin() { return null; }
@@ -45,7 +45,7 @@ var A;
}
Point.Origin = function () { return { x: 0, y: 0 }; }; // unexpected error here bug 840246
return Point;
})();
}());
A.Point = Point;
var Point;
(function (Point) {
@@ -30,7 +30,7 @@ var Point = (function () {
}
Point.Origin = function () { return { x: 0, y: 0 }; };
return Point;
})();
}());
var Point;
(function (Point) {
function Origin() { return ""; } // not an error, since not exported
@@ -44,7 +44,7 @@ var A;
}
Point.Origin = function () { return { x: 0, y: 0 }; };
return Point;
})();
}());
A.Point = Point;
var Point;
(function (Point) {
@@ -30,7 +30,7 @@ var Point = (function () {
}
Point.Origin = { x: 0, y: 0 };
return Point;
})();
}());
var Point;
(function (Point) {
Point.Origin = ""; //expected duplicate identifier error
@@ -44,7 +44,7 @@ var A;
}
Point.Origin = { x: 0, y: 0 };
return Point;
})();
}());
A.Point = Point;
var Point;
(function (Point) {
@@ -30,7 +30,7 @@ var Point = (function () {
}
Point.Origin = { x: 0, y: 0 };
return Point;
})();
}());
var Point;
(function (Point) {
var Origin = ""; // not an error, since not exported
@@ -44,7 +44,7 @@ var A;
}
Point.Origin = { x: 0, y: 0 };
return Point;
})();
}());
A.Point = Point;
var Point;
(function (Point) {
@@ -51,7 +51,7 @@ var X;
this.y = y;
}
return Point;
})();
}());
Y.Point = Point;
})(Y = X.Y || (X.Y = {}));
})(X || (X = {}));
@@ -75,7 +75,7 @@ var A = (function () {
function A() {
}
return A;
})();
}());
var A;
(function (A) {
A.Instance = new A();
@@ -9,4 +9,4 @@ var C = (function () {
function C() {
}
return C;
})();
}());
@@ -10,4 +10,4 @@ var C = (function () {
}
C.prototype.foo = function () { };
return C;
})();
}());
@@ -10,4 +10,4 @@ var C = (function () {
}
C.prototype.bar = function () { };
return C;
})();
}());
@@ -9,4 +9,4 @@ var C = (function () {
function C() {
}
return C;
})();
}());
@@ -9,4 +9,4 @@ var C = (function () {
function C() {
}
return C;
})();
}());
@@ -10,4 +10,4 @@ var C = (function () {
}
C.prototype[1] = function () { };
return C;
})();
}());
@@ -10,4 +10,4 @@ var C = (function () {
}
C.prototype["bar"] = function () { };
return C;
})();
}());
@@ -7,4 +7,4 @@ var any = (function () {
function any() {
}
return any;
})();
}());
@@ -14,4 +14,4 @@ var List = (function () {
function List() {
}
return List;
})();
}());
@@ -11,5 +11,5 @@ var C = (function () {
this.foo = 10;
}
return C;
})();
}());
var constructor = function () { };
@@ -8,4 +8,4 @@ var C = (function () {
function C() {
}
return C;
})();
}());
@@ -8,4 +8,4 @@ var C = (function () {
function C() {
}
return C;
})();
}());
@@ -9,4 +9,4 @@ var AtomicNumbers = (function () {
}
AtomicNumbers.H = 1;
return AtomicNumbers;
})();
}());
@@ -10,4 +10,4 @@ var C = (function () {
this.x = 10;
}
return C;
})();
}());
@@ -32,4 +32,4 @@ var StringIterator = (function () {
return this;
};
return StringIterator;
})();
}());
@@ -19,7 +19,7 @@ var M;
}
C.prototype[Symbol.iterator] = function () { };
return C;
})();
}());
M.C = C;
(new C)[Symbol.iterator];
})(M || (M = {}));
@@ -14,5 +14,5 @@ var C = (function () {
}
C.prototype[Symbol.iterator] = function () { };
return C;
})();
}());
(new C)[Symbol.iterator];
@@ -14,5 +14,5 @@ var C = (function () {
}
C.prototype[Symbol.iterator] = function () { };
return C;
})();
}());
(new C)[Symbol.iterator];
@@ -14,5 +14,5 @@ var C = (function () {
}
C.prototype[Symbol.iterator] = function () { };
return C;
})();
}());
(new C)[Symbol.iterator](0); // Should error
@@ -11,5 +11,5 @@ var C = (function () {
}
C.prototype[Symbol.iterator] = function () { };
return C;
})();
}());
(new C)[Symbol.iterator];
@@ -14,5 +14,5 @@ var C = (function () {
}
C.prototype[Symbol.iterator] = function () { };
return C;
})();
}());
(new C)[Symbol.iterator];
@@ -30,7 +30,7 @@ var enumdule;
this.y = y;
}
return Point;
})();
}());
enumdule.Point = Point;
})(enumdule || (enumdule = {}));
var x;
@@ -1,4 +1,4 @@
tests/cases/compiler/ExportAssignment7.ts(1,14): error TS1148: Cannot compile modules unless the '--module' flag is provided.
tests/cases/compiler/ExportAssignment7.ts(1,14): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file.
tests/cases/compiler/ExportAssignment7.ts(4,1): error TS2309: An export assignment cannot be used in a module with other exported elements.
tests/cases/compiler/ExportAssignment7.ts(4,10): error TS2304: Cannot find name 'B'.
@@ -6,7 +6,7 @@ tests/cases/compiler/ExportAssignment7.ts(4,10): error TS2304: Cannot find name
==== tests/cases/compiler/ExportAssignment7.ts (3 errors) ====
export class C {
~
!!! error TS1148: Cannot compile modules unless the '--module' flag is provided.
!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file.
}
export = B;
@@ -10,5 +10,5 @@ var C = (function () {
function C() {
}
return C;
})();
}());
exports.C = C;
@@ -1,4 +1,4 @@
tests/cases/compiler/ExportAssignment8.ts(1,1): error TS1148: Cannot compile modules unless the '--module' flag is provided.
tests/cases/compiler/ExportAssignment8.ts(1,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file.
tests/cases/compiler/ExportAssignment8.ts(1,1): error TS2309: An export assignment cannot be used in a module with other exported elements.
tests/cases/compiler/ExportAssignment8.ts(1,10): error TS2304: Cannot find name 'B'.
@@ -6,7 +6,7 @@ tests/cases/compiler/ExportAssignment8.ts(1,10): error TS2304: Cannot find name
==== tests/cases/compiler/ExportAssignment8.ts (3 errors) ====
export = B;
~~~~~~~~~~~
!!! error TS1148: Cannot compile modules unless the '--module' flag is provided.
!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file.
~~~~~~~~~~~
!!! error TS2309: An export assignment cannot be used in a module with other exported elements.
~
@@ -10,5 +10,5 @@ var C = (function () {
function C() {
}
return C;
})();
}());
exports.C = C;
@@ -31,6 +31,6 @@ var A;
return 1;
};
return Point2d;
})();
}());
A.Point2d = Point2d;
})(A || (A = {}));
@@ -32,7 +32,7 @@ var A;
function Point() {
}
return Point;
})();
}());
A.Point = Point;
A.Origin = { x: 0, y: 0 };
var Point3d = (function (_super) {
@@ -41,7 +41,7 @@ var A;
_super.apply(this, arguments);
}
return Point3d;
})(Point);
}(Point));
A.Point3d = Point3d;
A.Origin3d = { x: 0, y: 0, z: 0 };
var Line = (function () {
@@ -50,6 +50,6 @@ var A;
this.end = end;
}
return Line;
})();
}());
A.Line = Line;
})(A || (A = {}));
@@ -22,11 +22,11 @@ var A;
function Point() {
}
return Point;
})();
}());
var points = (function () {
function points() {
}
return points;
})();
}());
A.points = points;
})(A || (A = {}));
@@ -36,7 +36,7 @@ var A;
function Point() {
}
return Point;
})();
}());
A.Origin = { x: 0, y: 0 };
var Point3d = (function (_super) {
__extends(Point3d, _super);
@@ -44,7 +44,7 @@ var A;
_super.apply(this, arguments);
}
return Point3d;
})(Point);
}(Point));
A.Point3d = Point3d;
A.Origin3d = { x: 0, y: 0, z: 0 };
var Line = (function () {
@@ -56,6 +56,6 @@ var A;
return null;
};
return Line;
})();
}());
A.Line = Line;
})(A || (A = {}));
@@ -22,7 +22,7 @@ var A;
function Point() {
}
return Point;
})();
}());
A.Point = Point;
var Line = (function () {
function Line(start, end) {
@@ -30,7 +30,7 @@ var A;
this.end = end;
}
return Line;
})();
}());
A.Line = Line;
function fromOrigin(p) {
return new Line({ x: 0, y: 0 }, p);
@@ -22,14 +22,14 @@ var A;
function Point() {
}
return Point;
})();
}());
var Line = (function () {
function Line(start, end) {
this.start = start;
this.end = end;
}
return Line;
})();
}());
A.Line = Line;
function fromOrigin(p) {
return new Line({ x: 0, y: 0 }, p);
@@ -22,7 +22,7 @@ var A;
function Point() {
}
return Point;
})();
}());
A.Point = Point;
var Line = (function () {
function Line(start, end) {
@@ -30,7 +30,7 @@ var A;
this.end = end;
}
return Line;
})();
}());
function fromOrigin(p) {
return new Line({ x: 0, y: 0 }, p);
}
@@ -29,7 +29,7 @@ var A;
this.y = y;
}
return Point;
})();
}());
A.Point = Point;
var B;
(function (B) {
@@ -41,7 +41,7 @@ var A;
return new Line({ x: 0, y: 0 }, p);
};
return Line;
})();
}());
B.Line = Line;
})(B = A.B || (A.B = {}));
})(A || (A = {}));
@@ -20,7 +20,7 @@ var A;
this.y = y;
}
return Point;
})();
}());
A.Origin = { x: 0, y: 0 };
A.Unity = { start: new Point(0, 0), end: new Point(1, 0) };
})(A || (A = {}));
@@ -20,6 +20,6 @@ var A;
this.y = y;
}
return Point;
})();
}());
A.UnitSquare = null;
})(A || (A = {}));
@@ -15,6 +15,6 @@ var A;
function B() {
}
return B;
})();
}());
A.beez2 = new Array();
})(A || (A = {}));
@@ -13,4 +13,4 @@ var C = (function () {
configurable: true
});
return C;
})();
}());
@@ -9,4 +9,4 @@ var C = (function () {
}
C.prototype.foo = function () { };
return C;
})();
}());
@@ -9,4 +9,4 @@ var C = (function () {
}
C.prototype.foo = function () { };
return C;
})();
}());
@@ -9,4 +9,4 @@ var C = (function () {
}
C.prototype[foo] = function () { };
return C;
})();
}());
@@ -9,4 +9,4 @@ var C = (function () {
}
C.prototype. = function () { };
return C;
})();
}());
@@ -8,4 +8,4 @@ var C = (function () {
function C() {
}
return C;
})();
}());
@@ -8,4 +8,4 @@ var C = (function () {
function C() {
}
return C;
})();
}());
@@ -9,4 +9,4 @@ var C = (function () {
}
C.prototype.foo = function () { };
return C;
})();
}());
@@ -19,4 +19,4 @@ var C = (function () {
return bar;
};
return C;
})();
}());
@@ -54,7 +54,7 @@ var X;
this.y = y;
}
return Point;
})();
}());
Y.Point = Point;
})(Y = X.Y || (X.Y = {}));
})(X || (X = {}));
@@ -68,4 +68,4 @@ var A = (function () {
function A() {
}
return A;
})();
}());
@@ -25,7 +25,7 @@ var enumdule;
this.y = y;
}
return Point;
})();
}());
enumdule.Point = Point;
})(enumdule || (enumdule = {}));
var enumdule;
@@ -40,24 +40,24 @@ var A;
function A() {
}
return A;
})();
}());
A_1.A = A;
var AG = (function () {
function AG() {
}
return AG;
})();
}());
A_1.AG = AG;
var A2 = (function () {
function A2() {
}
return A2;
})();
}());
var AG2 = (function () {
function AG2() {
}
return AG2;
})();
}());
})(A || (A = {}));
// no errors expected, these are all exported
var a;
@@ -48,7 +48,7 @@ var B;
this.end = end;
}
return Line;
})();
}());
B.Line = Line;
})(B || (B = {}));
var Geometry;
@@ -45,7 +45,7 @@ var Inner;
function A() {
}
return A;
})();
}());
var B;
(function (B) {
B.a = 1, B.c = 2;
@@ -63,7 +63,7 @@ var Inner;
function D() {
}
return D;
})();
}());
Inner.e1 = new D;
Inner.f1 = new D;
Inner.g1 = new D;
+1 -1
View File
@@ -9,4 +9,4 @@ var C = (function () {
function C(C) {
}
return C;
})();
}());
+1 -1
View File
@@ -11,4 +11,4 @@ var C1 = (function () {
this.p3 = p3;
} // OK
return C1;
})();
}());
+1 -1
View File
@@ -7,4 +7,4 @@ var C = (function () {
function C() {
}
return C;
})();
}());
+1 -1
View File
@@ -8,4 +8,4 @@ var C = (function () {
function C() {
}
return C;
})();
}());
+1 -1
View File
@@ -9,4 +9,4 @@ var C = (function () {
}
C.prototype.m = function () { };
return C;
})();
}());
+1 -1
View File
@@ -9,4 +9,4 @@ var C = (function () {
}
C.m = function () { };
return C;
})();
}());
+1 -1
View File
@@ -9,4 +9,4 @@ var C = (function () {
}
C.m = function () { };
return C;
})();
}());
+1 -1
View File
@@ -9,4 +9,4 @@ var C = (function () {
}
C.prototype.m = function () { };
return C;
})();
}());
+1 -1
View File
@@ -9,4 +9,4 @@ var C = (function () {
this.p = p;
}
return C;
})();
}());
@@ -47,7 +47,7 @@ var A;
function Point() {
}
return Point;
})();
}());
A.Point = Point;
})(A || (A = {}));
var A;
@@ -59,7 +59,7 @@ var A;
return { x: p.x, y: p.y };
};
return Point;
})();
}());
})(A || (A = {}));
// ensure merges as expected
var p;
@@ -74,7 +74,7 @@ var X;
function Line() {
}
return Line;
})();
}());
Z.Line = Line;
})(Z = Y.Z || (Y.Z = {}));
})(Y = X.Y || (X.Y = {}));
@@ -89,7 +89,7 @@ var X;
function Line() {
}
return Line;
})();
}());
})(Z = Y.Z || (Y.Z = {}));
})(Y = X.Y || (X.Y = {}));
})(X || (X = {}));
@@ -66,7 +66,7 @@ var A;
this.br = br;
}
return Plane;
})();
}());
Utils.Plane = Plane;
})(Utils = A.Utils || (A.Utils = {}));
})(A || (A = {}));
@@ -39,7 +39,7 @@ var A;
function Point() {
}
return Point;
})();
}());
A.Point = Point;
})(A || (A = {}));
var A;
@@ -49,7 +49,7 @@ var A;
function Point() {
}
return Point;
})();
}());
A.Point = Point;
})(A || (A = {}));
var X;
@@ -62,7 +62,7 @@ var X;
function Line() {
}
return Line;
})();
}());
Z.Line = Line;
})(Z = Y.Z || (Y.Z = {}));
})(Y = X.Y || (X.Y = {}));
@@ -78,7 +78,7 @@ var X;
function Line() {
}
return Line;
})();
}());
Z.Line = Line;
})(Z = Y.Z || (Y.Z = {}));
})(Y = X.Y || (X.Y = {}));
@@ -1,4 +1,4 @@
tests/cases/conformance/internalModules/DeclarationMerging/part1.ts(1,15): error TS1148: Cannot compile modules unless the '--module' flag is provided.
tests/cases/conformance/internalModules/DeclarationMerging/part1.ts(1,15): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file.
tests/cases/conformance/internalModules/DeclarationMerging/part2.ts(3,24): error TS2304: Cannot find name 'Point'.
tests/cases/conformance/internalModules/DeclarationMerging/part2.ts(7,36): error TS2304: Cannot find name 'Point'.
tests/cases/conformance/internalModules/DeclarationMerging/part2.ts(7,54): error TS2304: Cannot find name 'Point'.
@@ -7,7 +7,7 @@ tests/cases/conformance/internalModules/DeclarationMerging/part2.ts(7,54): error
==== tests/cases/conformance/internalModules/DeclarationMerging/part1.ts (1 errors) ====
export module A {
~
!!! error TS1148: Cannot compile modules unless the '--module' flag is provided.
!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file.
export interface Point {
x: number;
y: number;
@@ -56,7 +56,7 @@ var A;
this.br = br;
}
return Plane;
})();
}());
Utils.Plane = Plane;
})(Utils = A.Utils || (A.Utils = {}));
})(A = exports.A || (exports.A = {}));
@@ -60,7 +60,7 @@ var X;
function Line() {
}
return Line;
})();
}());
Z.Line = Line;
})(Z = Y.Z || (Y.Z = {}));
})(Y = X.Y || (X.Y = {}));
@@ -75,7 +75,7 @@ var X;
function Line() {
}
return Line;
})();
}());
Z.Line = Line;
})(Z || (Z = {}));
})(Y = X.Y || (X.Y = {}));
@@ -59,7 +59,7 @@ var otherRoot;
this.br = br;
}
return Plane;
})();
}());
Utils.Plane = Plane;
})(Utils = A.Utils || (A.Utils = {}));
})(A = otherRoot.A || (otherRoot.A = {}));
@@ -62,7 +62,7 @@ var A;
this.br = br;
}
return Plane;
})();
}());
Utils.Plane = Plane;
})(Utils = A.Utils || (A.Utils = {}));
})(A || (A = {}));
@@ -15,7 +15,7 @@ var Message = (function () {
function Message() {
}
return Message;
})();
}());
function saySize(message) {
if (message instanceof Array) {
return message.length; // Should have type Message[] here
@@ -13,4 +13,4 @@ var C = (function () {
yield (foo);
};
return C;
})();
}());
@@ -11,4 +11,4 @@ var C = (function () {
yield foo;
}
return C;
})();
}());
@@ -13,4 +13,4 @@ var C = (function () {
yield foo;
};
return C;
})();
}());
@@ -30,7 +30,7 @@ var Point = (function () {
return "x=" + this.x + " y=" + this.y;
};
return Point;
})();
}());
var ColoredPoint = (function (_super) {
__extends(ColoredPoint, _super);
function ColoredPoint(x, y, color) {
@@ -41,4 +41,4 @@ var ColoredPoint = (function (_super) {
return _super.prototype.toString.call(this) + " color=" + this.color;
};
return ColoredPoint;
})(Point);
}(Point));

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