Merge remote-tracking branch 'Microsoft/master'

This commit is contained in:
SaschaNaz
2015-08-28 20:08:14 +09:00
86 changed files with 3131 additions and 351 deletions
+19 -6
View File
@@ -6929,6 +6929,7 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec
webkitMatchesSelector(selectors: string): boolean;
webkitRequestFullScreen(): void;
webkitRequestFullscreen(): void;
getElementsByClassName(classNames: string): NodeListOf<Element>;
addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void;
addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void;
addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void;
@@ -7916,7 +7917,6 @@ interface HTMLElement extends Element {
contains(child: HTMLElement): boolean;
dragDrop(): boolean;
focus(): void;
getElementsByClassName(classNames: string): NodeListOf<Element>;
insertAdjacentElement(position: string, insertedElement: Element): Element;
insertAdjacentHTML(where: string, html: string): void;
insertAdjacentText(where: string, text: string): void;
@@ -11719,7 +11719,7 @@ interface MessageEvent extends Event {
declare var MessageEvent: {
prototype: MessageEvent;
new(): MessageEvent;
new(type: string, eventInitDict?: MessageEventInit): MessageEvent;
}
interface MessagePort extends EventTarget {
@@ -12461,7 +12461,7 @@ interface ProgressEvent extends Event {
declare var ProgressEvent: {
prototype: ProgressEvent;
new(): ProgressEvent;
new(type: string, eventInitDict?: ProgressEventInit): ProgressEvent;
}
interface Range {
@@ -16628,7 +16628,6 @@ interface NodeListOf<TNode extends Node> extends NodeList {
[index: number]: TNode;
}
interface BlobPropertyBag {
type?: string;
endings?: string;
@@ -16645,6 +16644,21 @@ interface EventListenerObject {
declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject;
interface MessageEventInit extends EventInit {
data?: any;
origin?: string;
lastEventId?: string;
channel?: string;
source?: any;
ports?: MessagePort[];
}
interface ProgressEventInit extends EventInit {
lengthComputable?: boolean;
loaded?: number;
total?: number;
}
interface ErrorEventHandler {
(message: string, filename?: string, lineno?: number, colno?: number, error?:Error): void;
}
@@ -16974,8 +16988,7 @@ declare function addEventListener(type: "unload", listener: (ev: Event) => any,
declare function addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void;
declare function addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void;
declare function addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void;
declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
/////////////////////////////
/// WorkerGlobalScope APIs
/////////////////////////////
+19 -5
View File
@@ -3105,6 +3105,7 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec
webkitMatchesSelector(selectors: string): boolean;
webkitRequestFullScreen(): void;
webkitRequestFullscreen(): void;
getElementsByClassName(classNames: string): NodeListOf<Element>;
addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void;
addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void;
addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void;
@@ -4092,7 +4093,6 @@ interface HTMLElement extends Element {
contains(child: HTMLElement): boolean;
dragDrop(): boolean;
focus(): void;
getElementsByClassName(classNames: string): NodeListOf<Element>;
insertAdjacentElement(position: string, insertedElement: Element): Element;
insertAdjacentHTML(where: string, html: string): void;
insertAdjacentText(where: string, text: string): void;
@@ -7895,7 +7895,7 @@ interface MessageEvent extends Event {
declare var MessageEvent: {
prototype: MessageEvent;
new(): MessageEvent;
new(type: string, eventInitDict?: MessageEventInit): MessageEvent;
}
interface MessagePort extends EventTarget {
@@ -8637,7 +8637,7 @@ interface ProgressEvent extends Event {
declare var ProgressEvent: {
prototype: ProgressEvent;
new(): ProgressEvent;
new(type: string, eventInitDict?: ProgressEventInit): ProgressEvent;
}
interface Range {
@@ -12804,7 +12804,6 @@ interface NodeListOf<TNode extends Node> extends NodeList {
[index: number]: TNode;
}
interface BlobPropertyBag {
type?: string;
endings?: string;
@@ -12821,6 +12820,21 @@ interface EventListenerObject {
declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject;
interface MessageEventInit extends EventInit {
data?: any;
origin?: string;
lastEventId?: string;
channel?: string;
source?: any;
ports?: MessagePort[];
}
interface ProgressEventInit extends EventInit {
lengthComputable?: boolean;
loaded?: number;
total?: number;
}
interface ErrorEventHandler {
(message: string, filename?: string, lineno?: number, colno?: number, error?:Error): void;
}
@@ -13150,4 +13164,4 @@ declare function addEventListener(type: "unload", listener: (ev: Event) => any,
declare function addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void;
declare function addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void;
declare function addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void;
declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
+19 -6
View File
@@ -8217,6 +8217,7 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec
webkitMatchesSelector(selectors: string): boolean;
webkitRequestFullScreen(): void;
webkitRequestFullscreen(): void;
getElementsByClassName(classNames: string): NodeListOf<Element>;
addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void;
addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void;
addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void;
@@ -9204,7 +9205,6 @@ interface HTMLElement extends Element {
contains(child: HTMLElement): boolean;
dragDrop(): boolean;
focus(): void;
getElementsByClassName(classNames: string): NodeListOf<Element>;
insertAdjacentElement(position: string, insertedElement: Element): Element;
insertAdjacentHTML(where: string, html: string): void;
insertAdjacentText(where: string, text: string): void;
@@ -13007,7 +13007,7 @@ interface MessageEvent extends Event {
declare var MessageEvent: {
prototype: MessageEvent;
new(): MessageEvent;
new(type: string, eventInitDict?: MessageEventInit): MessageEvent;
}
interface MessagePort extends EventTarget {
@@ -13749,7 +13749,7 @@ interface ProgressEvent extends Event {
declare var ProgressEvent: {
prototype: ProgressEvent;
new(): ProgressEvent;
new(type: string, eventInitDict?: ProgressEventInit): ProgressEvent;
}
interface Range {
@@ -17916,7 +17916,6 @@ interface NodeListOf<TNode extends Node> extends NodeList {
[index: number]: TNode;
}
interface BlobPropertyBag {
type?: string;
endings?: string;
@@ -17933,6 +17932,21 @@ interface EventListenerObject {
declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject;
interface MessageEventInit extends EventInit {
data?: any;
origin?: string;
lastEventId?: string;
channel?: string;
source?: any;
ports?: MessagePort[];
}
interface ProgressEventInit extends EventInit {
lengthComputable?: boolean;
loaded?: number;
total?: number;
}
interface ErrorEventHandler {
(message: string, filename?: string, lineno?: number, colno?: number, error?:Error): void;
}
@@ -18262,8 +18276,7 @@ declare function addEventListener(type: "unload", listener: (ev: Event) => any,
declare function addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void;
declare function addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void;
declare function addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void;
declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
interface DOMTokenList {
declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;interface DOMTokenList {
[Symbol.iterator](): IterableIterator<string>;
}
+18 -3
View File
@@ -776,7 +776,7 @@ interface MessageEvent extends Event {
declare var MessageEvent: {
prototype: MessageEvent;
new(): MessageEvent;
new(type: string, eventInitDict?: MessageEventInit): MessageEvent;
}
interface MessagePort extends EventTarget {
@@ -829,7 +829,7 @@ interface ProgressEvent extends Event {
declare var ProgressEvent: {
prototype: ProgressEvent;
new(): ProgressEvent;
new(type: string, eventInitDict?: ProgressEventInit): ProgressEvent;
}
interface WebSocket extends EventTarget {
@@ -1100,6 +1100,21 @@ interface EventListenerObject {
declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject;
interface MessageEventInit extends EventInit {
data?: any;
origin?: string;
lastEventId?: string;
channel?: string;
source?: any;
ports?: MessagePort[];
}
interface ProgressEventInit extends EventInit {
lengthComputable?: boolean;
loaded?: number;
total?: number;
}
interface ErrorEventHandler {
(message: string, filename?: string, lineno?: number, colno?: number, error?:Error): void;
}
@@ -1156,4 +1171,4 @@ declare function postMessage(data: any): void;
declare var console: Console;
declare function addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void;
declare function addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void;
declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
+259 -21
View File
@@ -1429,7 +1429,7 @@ var ts;
JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: { code: 2607, category: ts.DiagnosticCategory.Error, key: "JSX element class does not support attributes because it does not have a '{0}' property" },
The_global_type_JSX_0_may_not_have_more_than_one_property: { code: 2608, category: ts.DiagnosticCategory.Error, key: "The global type 'JSX.{0}' may not have more than one property" },
Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot emit namespaced JSX elements in React" },
A_member_initializer_in_a_const_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_const_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A member initializer in a 'const' enum declaration cannot reference members declared after it, including members defined in other 'const' enums." },
A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums." },
Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: ts.DiagnosticCategory.Error, key: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." },
Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." },
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." },
@@ -1515,6 +1515,7 @@ var ts;
Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: { code: 5051, category: ts.DiagnosticCategory.Error, key: "Option 'inlineSources' can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided." },
Option_0_cannot_be_specified_without_specifying_option_1: { code: 5052, category: ts.DiagnosticCategory.Error, key: "Option '{0}' cannot be specified without specifying option '{1}'." },
Option_0_cannot_be_specified_with_option_1: { code: 5053, category: ts.DiagnosticCategory.Error, key: "Option '{0}' cannot be specified with option '{1}'." },
A_tsconfig_json_file_is_already_defined_at_Colon_0: { code: 5053, category: ts.DiagnosticCategory.Error, key: "A 'tsconfig.json' file is already defined at: '{0}'." },
Concatenate_and_emit_output_to_single_file: { code: 6001, category: ts.DiagnosticCategory.Message, key: "Concatenate and emit output to single file." },
Generates_corresponding_d_ts_file: { code: 6002, category: ts.DiagnosticCategory.Message, key: "Generates corresponding '.d.ts' file." },
Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: { code: 6003, category: ts.DiagnosticCategory.Message, key: "Specifies the location where debugger should locate map files instead of generated locations." },
@@ -1569,6 +1570,9 @@ var ts;
Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for emitting type metadata for decorators." },
Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower: { code: 6067, category: ts.DiagnosticCategory.Message, key: "Option 'experimentalAsyncFunctions' cannot be specified when targeting ES5 or lower." },
Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 async functions." },
Specifies_module_resolution_strategy_Colon_node_Node_or_classic_TypeScript_pre_1_6: { code: 6069, category: ts.DiagnosticCategory.Message, key: "Specifies module resolution strategy: 'node' (Node) or 'classic' (TypeScript pre 1.6) ." },
Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: ts.DiagnosticCategory.Message, key: "Initializes a TypeScript project and creates a tsconfig.json file." },
Successfully_created_a_tsconfig_json_file: { code: 6071, category: ts.DiagnosticCategory.Message, key: "Successfully created a tsconfig.json file." },
Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." },
Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." },
Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." },
@@ -3629,6 +3633,9 @@ var ts;
else {
var bindingName = node.name ? node.name.text : "__class";
bindAnonymousDeclaration(node, 32, bindingName);
if (node.name) {
classifiableNames[node.name.text] = node.name.text;
}
}
var symbol = node.symbol;
var prototypeSymbol = createSymbol(4 | 134217728, "prototype");
@@ -4482,6 +4489,7 @@ var ts;
case 134:
return node === parent_2.expression;
case 137:
case 238:
return true;
case 186:
return parent_2.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_2);
@@ -9823,7 +9831,6 @@ var ts;
}
if (!name) {
parseErrorAtPosition(pos, 0, ts.Diagnostics.Identifier_expected);
return undefined;
}
var preName, postName;
if (typeExpression) {
@@ -11681,7 +11688,7 @@ var ts;
}
function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaraiton, flags) {
var targetSymbol = getTargetSymbol(symbol);
if (targetSymbol.flags & 32 || targetSymbol.flags & 64) {
if (targetSymbol.flags & 32 || targetSymbol.flags & 64 || targetSymbol.flags & 524288) {
buildDisplayForTypeParametersAndDelimiters(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), writer, enclosingDeclaraiton, flags);
}
}
@@ -13824,6 +13831,15 @@ var ts;
return result;
}
function instantiateAnonymousType(type, mapper) {
if (mapper.instantiations) {
var cachedType = mapper.instantiations[type.id];
if (cachedType) {
return cachedType;
}
}
else {
mapper.instantiations = [];
}
var result = createObjectType(65536 | 131072, type.symbol);
result.properties = instantiateList(getPropertiesOfObjectType(type), mapper, instantiateSymbol);
result.members = createSymbolTable(result.properties);
@@ -13835,6 +13851,7 @@ var ts;
result.stringIndexType = instantiateType(stringIndexType, mapper);
if (numberIndexType)
result.numberIndexType = instantiateType(numberIndexType, mapper);
mapper.instantiations[type.id] = result;
return result;
}
function instantiateType(type, mapper) {
@@ -18860,9 +18877,13 @@ var ts;
function checkTypeNodeAsExpression(node) {
if (node && node.kind === 149) {
var root = getFirstIdentifier(node.typeName);
var rootSymbol = resolveName(root, root.text, 107455, undefined, undefined);
if (rootSymbol && rootSymbol.flags & 8388608 && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) {
markAliasSymbolAsReferenced(rootSymbol);
var meaning = root.parent.kind === 149 ? 793056 : 1536;
var rootSymbol = resolveName(root, root.text, meaning | 8388608, undefined, undefined);
if (rootSymbol && rootSymbol.flags & 8388608) {
var aliasTarget = resolveAlias(rootSymbol);
if (aliasTarget.flags & 107455 && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) {
markAliasSymbolAsReferenced(rootSymbol);
}
}
}
}
@@ -20058,7 +20079,7 @@ var ts;
}
if (!isDefinedBefore(propertyDecl, member)) {
reportError = false;
error(e, ts.Diagnostics.A_member_initializer_in_a_const_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_const_enums);
error(e, ts.Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums);
return undefined;
}
return getNodeLinks(propertyDecl).enumMemberValue;
@@ -21147,6 +21168,9 @@ var ts;
return ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue;
}
var typeSymbol = resolveEntityName(typeName, 793056, true);
if (!typeSymbol) {
return ts.TypeReferenceSerializationKind.ObjectType;
}
var type = getDeclaredTypeOfSymbol(typeSymbol);
if (type === unknownType) {
return ts.TypeReferenceSerializationKind.Unknown;
@@ -23011,6 +23035,9 @@ var ts;
if (ts.isSupportedExpressionWithTypeArguments(node)) {
emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError);
}
else if (!isImplementsList && node.expression.kind === 91) {
write("null");
}
function getHeritageClauseVisibilityError(symbolAccesibilityResult) {
var diagnosticMessage;
if (node.parent.parent.kind === 212) {
@@ -23668,11 +23695,7 @@ var ts;
}
function emitJavaScript(jsFilePath, root) {
var writer = ts.createTextWriter(newLine);
var write = writer.write;
var writeTextOfNode = writer.writeTextOfNode;
var writeLine = writer.writeLine;
var increaseIndent = writer.increaseIndent;
var decreaseIndent = writer.decreaseIndent;
var write = writer.write, writeTextOfNode = writer.writeTextOfNode, writeLine = writer.writeLine, increaseIndent = writer.increaseIndent, decreaseIndent = writer.decreaseIndent;
var currentSourceFile;
var exportFunctionForFile;
var generatedNameSet = {};
@@ -24708,7 +24731,12 @@ var ts;
return;
}
}
writeTextOfNode(currentSourceFile, node);
if (ts.nodeIsSynthesized(node)) {
write(node.text);
}
else {
writeTextOfNode(currentSourceFile, node);
}
}
function isNameOfNestedRedeclaration(node) {
if (languageVersion < 2) {
@@ -24733,6 +24761,9 @@ var ts;
else if (isNameOfNestedRedeclaration(node)) {
write(getGeneratedNameForNode(node));
}
else if (ts.nodeIsSynthesized(node)) {
write(node.text);
}
else {
writeTextOfNode(currentSourceFile, node);
}
@@ -28558,7 +28589,7 @@ var ts;
}
function trimReactWhitespaceAndApplyEntities(node) {
var result = undefined;
var text = ts.getTextOfNode(node);
var text = ts.getTextOfNode(node, true);
var firstNonWhitespace = 0;
var lastNonWhitespace = -1;
for (var i = 0; i < text.length; i++) {
@@ -29331,6 +29362,7 @@ var ts;
})(ts || (ts = {}));
/// <reference path="sys.ts" />
/// <reference path="emitter.ts" />
/// <reference path="core.ts" />
var ts;
(function (ts) {
ts.programTime = 0;
@@ -29362,10 +29394,124 @@ var ts;
}
ts.resolveTripleslashReference = resolveTripleslashReference;
function resolveModuleName(moduleName, containingFile, compilerOptions, host) {
return legacyNameResolver(moduleName, containingFile, compilerOptions, host);
var moduleResolution = compilerOptions.moduleResolution !== undefined
? compilerOptions.moduleResolution
: compilerOptions.module === 1 ? 2 : 1;
switch (moduleResolution) {
case 2: return nodeModuleNameResolver(moduleName, containingFile, host);
case 1: return classicNameResolver(moduleName, containingFile, compilerOptions, host);
}
}
ts.resolveModuleName = resolveModuleName;
function legacyNameResolver(moduleName, containingFile, compilerOptions, host) {
function nodeModuleNameResolver(moduleName, containingFile, host) {
var containingDirectory = ts.getDirectoryPath(containingFile);
if (ts.getRootLength(moduleName) !== 0 || nameStartsWithDotSlashOrDotDotSlash(moduleName)) {
var failedLookupLocations = [];
var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName));
var resolvedFileName = loadNodeModuleFromFile(candidate, false, failedLookupLocations, host);
if (resolvedFileName) {
return { resolvedFileName: resolvedFileName, failedLookupLocations: failedLookupLocations };
}
resolvedFileName = loadNodeModuleFromDirectory(candidate, false, failedLookupLocations, host);
return { resolvedFileName: resolvedFileName, failedLookupLocations: failedLookupLocations };
}
else {
return loadModuleFromNodeModules(moduleName, containingDirectory, host);
}
}
ts.nodeModuleNameResolver = nodeModuleNameResolver;
function loadNodeModuleFromFile(candidate, loadOnlyDts, failedLookupLocation, host) {
if (loadOnlyDts) {
return tryLoad(".d.ts");
}
else {
return ts.forEach(ts.supportedExtensions, tryLoad);
}
function tryLoad(ext) {
var fileName = ts.fileExtensionIs(candidate, ext) ? candidate : candidate + ext;
if (host.fileExists(fileName)) {
return fileName;
}
else {
failedLookupLocation.push(fileName);
return undefined;
}
}
}
function loadNodeModuleFromDirectory(candidate, loadOnlyDts, failedLookupLocation, host) {
var packageJsonPath = ts.combinePaths(candidate, "package.json");
if (host.fileExists(packageJsonPath)) {
var jsonContent;
try {
var jsonText = host.readFile(packageJsonPath);
jsonContent = jsonText ? JSON.parse(jsonText) : { typings: undefined };
}
catch (e) {
jsonContent = { typings: undefined };
}
if (jsonContent.typings) {
var result = loadNodeModuleFromFile(ts.normalizePath(ts.combinePaths(candidate, jsonContent.typings)), loadOnlyDts, failedLookupLocation, host);
if (result) {
return result;
}
}
}
else {
failedLookupLocation.push(packageJsonPath);
}
return loadNodeModuleFromFile(ts.combinePaths(candidate, "index"), loadOnlyDts, failedLookupLocation, host);
}
function loadModuleFromNodeModules(moduleName, directory, host) {
var failedLookupLocations = [];
directory = ts.normalizeSlashes(directory);
while (true) {
var baseName = ts.getBaseFileName(directory);
if (baseName !== "node_modules") {
var nodeModulesFolder = ts.combinePaths(directory, "node_modules");
var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName));
var result = loadNodeModuleFromFile(candidate, true, failedLookupLocations, host);
if (result) {
return { resolvedFileName: result, failedLookupLocations: failedLookupLocations };
}
result = loadNodeModuleFromDirectory(candidate, true, failedLookupLocations, host);
if (result) {
return { resolvedFileName: result, failedLookupLocations: failedLookupLocations };
}
}
var parentPath = ts.getDirectoryPath(directory);
if (parentPath === directory) {
break;
}
directory = parentPath;
}
return { resolvedFileName: undefined, failedLookupLocations: failedLookupLocations };
}
function baseUrlModuleNameResolver(moduleName, containingFile, baseUrl, host) {
ts.Debug.assert(baseUrl !== undefined);
var normalizedModuleName = ts.normalizeSlashes(moduleName);
var basePart = useBaseUrl(moduleName) ? baseUrl : ts.getDirectoryPath(containingFile);
var candidate = ts.normalizePath(ts.combinePaths(basePart, moduleName));
var failedLookupLocations = [];
return ts.forEach(ts.supportedExtensions, function (ext) { return tryLoadFile(candidate + ext); }) || { resolvedFileName: undefined, failedLookupLocations: failedLookupLocations };
function tryLoadFile(location) {
if (host.fileExists(location)) {
return { resolvedFileName: location, failedLookupLocations: failedLookupLocations };
}
else {
failedLookupLocations.push(location);
return undefined;
}
}
}
ts.baseUrlModuleNameResolver = baseUrlModuleNameResolver;
function nameStartsWithDotSlashOrDotDotSlash(name) {
var i = name.lastIndexOf("./", 1);
return i === 0 || (i === 1 && name.charCodeAt(0) === 46);
}
function useBaseUrl(moduleName) {
return ts.getRootLength(moduleName) === 0 && !nameStartsWithDotSlashOrDotDotSlash(moduleName);
}
function classicNameResolver(moduleName, containingFile, compilerOptions, host) {
if (moduleName.indexOf('!') != -1) {
return { resolvedFileName: undefined, failedLookupLocations: [] };
}
@@ -29398,6 +29544,15 @@ var ts;
}
return { resolvedFileName: referencedSourceFile, failedLookupLocations: failedLookupLocations };
}
ts.classicNameResolver = classicNameResolver;
ts.defaultInitCompilerOptions = {
module: 1,
target: 0,
noImplicitAny: false,
outDir: "built",
rootDir: ".",
sourceMap: false
};
function createCompilerHost(options, setParentNodes) {
var currentDirectory;
var existingDirectories = {};
@@ -30068,6 +30223,11 @@ var ts;
type: "boolean",
description: ts.Diagnostics.Print_this_message
},
{
name: "init",
type: "boolean",
description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file
},
{
name: "inlineSourceMap",
type: "boolean"
@@ -30262,20 +30422,39 @@ var ts;
type: "boolean",
experimental: true,
description: ts.Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators
},
{
name: "moduleResolution",
type: {
"node": 2,
"classic": 1
},
experimental: true,
description: ts.Diagnostics.Specifies_module_resolution_strategy_Colon_node_Node_or_classic_TypeScript_pre_1_6
}
];
function parseCommandLine(commandLine) {
var options = {};
var fileNames = [];
var errors = [];
var shortOptionNames = {};
var optionNameMapCache;
function getOptionNameMap() {
if (optionNameMapCache) {
return optionNameMapCache;
}
var optionNameMap = {};
var shortOptionNames = {};
ts.forEach(ts.optionDeclarations, function (option) {
optionNameMap[option.name.toLowerCase()] = option;
if (option.shortName) {
shortOptionNames[option.shortName] = option.name;
}
});
optionNameMapCache = { optionNameMap: optionNameMap, shortOptionNames: shortOptionNames };
return optionNameMapCache;
}
ts.getOptionNameMap = getOptionNameMap;
function parseCommandLine(commandLine) {
var options = {};
var fileNames = [];
var errors = [];
var _a = getOptionNameMap(), optionNameMap = _a.optionNameMap, shortOptionNames = _a.shortOptionNames;
parseStrings(commandLine);
return {
options: options,
@@ -30591,6 +30770,10 @@ var ts;
reportDiagnostics(commandLine.errors);
return ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
}
if (commandLine.options.init) {
writeConfigFile(commandLine.options, commandLine.fileNames);
return ts.sys.exit(ts.ExitStatus.Success);
}
if (commandLine.options.version) {
reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Version_0, ts.version));
return ts.sys.exit(ts.ExitStatus.Success);
@@ -30832,5 +31015,60 @@ var ts;
return Array(paddingLength + 1).join(" ");
}
}
function writeConfigFile(options, fileNames) {
var currentDirectory = ts.sys.getCurrentDirectory();
var file = ts.combinePaths(currentDirectory, 'tsconfig.json');
if (ts.sys.fileExists(file)) {
reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.A_tsconfig_json_file_is_already_defined_at_Colon_0, file));
}
else {
var compilerOptions = ts.extend(options, ts.defaultInitCompilerOptions);
var configurations = {
compilerOptions: serializeCompilerOptions(compilerOptions),
exclude: ["node_modules"]
};
if (fileNames && fileNames.length) {
configurations.files = fileNames;
}
ts.sys.writeFile(file, JSON.stringify(configurations, undefined, 4));
reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Successfully_created_a_tsconfig_json_file));
}
return;
function serializeCompilerOptions(options) {
var result = {};
var optionsNameMap = ts.getOptionNameMap().optionNameMap;
for (var name_28 in options) {
if (ts.hasProperty(options, name_28)) {
var value = options[name_28];
switch (name_28) {
case "init":
case "watch":
case "version":
case "help":
case "project":
break;
default:
var optionDefinition = optionsNameMap[name_28.toLowerCase()];
if (optionDefinition) {
if (typeof optionDefinition.type === "string") {
result[name_28] = value;
}
else {
var typeMap = optionDefinition.type;
for (var key in typeMap) {
if (ts.hasProperty(typeMap, key)) {
if (typeMap[key] === value)
result[name_28] = key;
}
}
}
}
break;
}
}
}
return result;
}
}
})(ts || (ts = {}));
ts.executeCommandLine(ts.sys.args);
+378 -48
View File
@@ -1429,7 +1429,7 @@ var ts;
JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: { code: 2607, category: ts.DiagnosticCategory.Error, key: "JSX element class does not support attributes because it does not have a '{0}' property" },
The_global_type_JSX_0_may_not_have_more_than_one_property: { code: 2608, category: ts.DiagnosticCategory.Error, key: "The global type 'JSX.{0}' may not have more than one property" },
Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot emit namespaced JSX elements in React" },
A_member_initializer_in_a_const_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_const_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A member initializer in a 'const' enum declaration cannot reference members declared after it, including members defined in other 'const' enums." },
A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums." },
Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: ts.DiagnosticCategory.Error, key: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." },
Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." },
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." },
@@ -1515,6 +1515,7 @@ var ts;
Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: { code: 5051, category: ts.DiagnosticCategory.Error, key: "Option 'inlineSources' can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided." },
Option_0_cannot_be_specified_without_specifying_option_1: { code: 5052, category: ts.DiagnosticCategory.Error, key: "Option '{0}' cannot be specified without specifying option '{1}'." },
Option_0_cannot_be_specified_with_option_1: { code: 5053, category: ts.DiagnosticCategory.Error, key: "Option '{0}' cannot be specified with option '{1}'." },
A_tsconfig_json_file_is_already_defined_at_Colon_0: { code: 5053, category: ts.DiagnosticCategory.Error, key: "A 'tsconfig.json' file is already defined at: '{0}'." },
Concatenate_and_emit_output_to_single_file: { code: 6001, category: ts.DiagnosticCategory.Message, key: "Concatenate and emit output to single file." },
Generates_corresponding_d_ts_file: { code: 6002, category: ts.DiagnosticCategory.Message, key: "Generates corresponding '.d.ts' file." },
Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: { code: 6003, category: ts.DiagnosticCategory.Message, key: "Specifies the location where debugger should locate map files instead of generated locations." },
@@ -1569,6 +1570,9 @@ var ts;
Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for emitting type metadata for decorators." },
Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower: { code: 6067, category: ts.DiagnosticCategory.Message, key: "Option 'experimentalAsyncFunctions' cannot be specified when targeting ES5 or lower." },
Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 async functions." },
Specifies_module_resolution_strategy_Colon_node_Node_or_classic_TypeScript_pre_1_6: { code: 6069, category: ts.DiagnosticCategory.Message, key: "Specifies module resolution strategy: 'node' (Node) or 'classic' (TypeScript pre 1.6) ." },
Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: ts.DiagnosticCategory.Message, key: "Initializes a TypeScript project and creates a tsconfig.json file." },
Successfully_created_a_tsconfig_json_file: { code: 6071, category: ts.DiagnosticCategory.Message, key: "Successfully created a tsconfig.json file." },
Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." },
Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." },
Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." },
@@ -3006,6 +3010,11 @@ var ts;
type: "boolean",
description: ts.Diagnostics.Print_this_message
},
{
name: "init",
type: "boolean",
description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file
},
{
name: "inlineSourceMap",
type: "boolean"
@@ -3200,20 +3209,39 @@ var ts;
type: "boolean",
experimental: true,
description: ts.Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators
},
{
name: "moduleResolution",
type: {
"node": 2,
"classic": 1
},
experimental: true,
description: ts.Diagnostics.Specifies_module_resolution_strategy_Colon_node_Node_or_classic_TypeScript_pre_1_6
}
];
function parseCommandLine(commandLine) {
var options = {};
var fileNames = [];
var errors = [];
var shortOptionNames = {};
var optionNameMapCache;
function getOptionNameMap() {
if (optionNameMapCache) {
return optionNameMapCache;
}
var optionNameMap = {};
var shortOptionNames = {};
ts.forEach(ts.optionDeclarations, function (option) {
optionNameMap[option.name.toLowerCase()] = option;
if (option.shortName) {
shortOptionNames[option.shortName] = option.name;
}
});
optionNameMapCache = { optionNameMap: optionNameMap, shortOptionNames: shortOptionNames };
return optionNameMapCache;
}
ts.getOptionNameMap = getOptionNameMap;
function parseCommandLine(commandLine) {
var options = {};
var fileNames = [];
var errors = [];
var _a = getOptionNameMap(), optionNameMap = _a.optionNameMap, shortOptionNames = _a.shortOptionNames;
parseStrings(commandLine);
return {
options: options,
@@ -4203,6 +4231,7 @@ var ts;
case 134:
return node === parent_2.expression;
case 137:
case 238:
return true;
case 186:
return parent_2.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_2);
@@ -9544,7 +9573,6 @@ var ts;
}
if (!name) {
parseErrorAtPosition(pos, 0, ts.Diagnostics.Identifier_expected);
return undefined;
}
var preName, postName;
if (typeExpression) {
@@ -10575,6 +10603,9 @@ var ts;
else {
var bindingName = node.name ? node.name.text : "__class";
bindAnonymousDeclaration(node, 32, bindingName);
if (node.name) {
classifiableNames[node.name.text] = node.name.text;
}
}
var symbol = node.symbol;
var prototypeSymbol = createSymbol(4 | 134217728, "prototype");
@@ -12113,7 +12144,7 @@ var ts;
}
function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaraiton, flags) {
var targetSymbol = getTargetSymbol(symbol);
if (targetSymbol.flags & 32 || targetSymbol.flags & 64) {
if (targetSymbol.flags & 32 || targetSymbol.flags & 64 || targetSymbol.flags & 524288) {
buildDisplayForTypeParametersAndDelimiters(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), writer, enclosingDeclaraiton, flags);
}
}
@@ -14256,6 +14287,15 @@ var ts;
return result;
}
function instantiateAnonymousType(type, mapper) {
if (mapper.instantiations) {
var cachedType = mapper.instantiations[type.id];
if (cachedType) {
return cachedType;
}
}
else {
mapper.instantiations = [];
}
var result = createObjectType(65536 | 131072, type.symbol);
result.properties = instantiateList(getPropertiesOfObjectType(type), mapper, instantiateSymbol);
result.members = createSymbolTable(result.properties);
@@ -14267,6 +14307,7 @@ var ts;
result.stringIndexType = instantiateType(stringIndexType, mapper);
if (numberIndexType)
result.numberIndexType = instantiateType(numberIndexType, mapper);
mapper.instantiations[type.id] = result;
return result;
}
function instantiateType(type, mapper) {
@@ -19292,9 +19333,13 @@ var ts;
function checkTypeNodeAsExpression(node) {
if (node && node.kind === 149) {
var root = getFirstIdentifier(node.typeName);
var rootSymbol = resolveName(root, root.text, 107455, undefined, undefined);
if (rootSymbol && rootSymbol.flags & 8388608 && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) {
markAliasSymbolAsReferenced(rootSymbol);
var meaning = root.parent.kind === 149 ? 793056 : 1536;
var rootSymbol = resolveName(root, root.text, meaning | 8388608, undefined, undefined);
if (rootSymbol && rootSymbol.flags & 8388608) {
var aliasTarget = resolveAlias(rootSymbol);
if (aliasTarget.flags & 107455 && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) {
markAliasSymbolAsReferenced(rootSymbol);
}
}
}
}
@@ -20490,7 +20535,7 @@ var ts;
}
if (!isDefinedBefore(propertyDecl, member)) {
reportError = false;
error(e, ts.Diagnostics.A_member_initializer_in_a_const_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_const_enums);
error(e, ts.Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums);
return undefined;
}
return getNodeLinks(propertyDecl).enumMemberValue;
@@ -21579,6 +21624,9 @@ var ts;
return ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue;
}
var typeSymbol = resolveEntityName(typeName, 793056, true);
if (!typeSymbol) {
return ts.TypeReferenceSerializationKind.ObjectType;
}
var type = getDeclaredTypeOfSymbol(typeSymbol);
if (type === unknownType) {
return ts.TypeReferenceSerializationKind.Unknown;
@@ -23443,6 +23491,9 @@ var ts;
if (ts.isSupportedExpressionWithTypeArguments(node)) {
emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError);
}
else if (!isImplementsList && node.expression.kind === 91) {
write("null");
}
function getHeritageClauseVisibilityError(symbolAccesibilityResult) {
var diagnosticMessage;
if (node.parent.parent.kind === 212) {
@@ -24100,11 +24151,7 @@ var ts;
}
function emitJavaScript(jsFilePath, root) {
var writer = ts.createTextWriter(newLine);
var write = writer.write;
var writeTextOfNode = writer.writeTextOfNode;
var writeLine = writer.writeLine;
var increaseIndent = writer.increaseIndent;
var decreaseIndent = writer.decreaseIndent;
var write = writer.write, writeTextOfNode = writer.writeTextOfNode, writeLine = writer.writeLine, increaseIndent = writer.increaseIndent, decreaseIndent = writer.decreaseIndent;
var currentSourceFile;
var exportFunctionForFile;
var generatedNameSet = {};
@@ -25140,7 +25187,12 @@ var ts;
return;
}
}
writeTextOfNode(currentSourceFile, node);
if (ts.nodeIsSynthesized(node)) {
write(node.text);
}
else {
writeTextOfNode(currentSourceFile, node);
}
}
function isNameOfNestedRedeclaration(node) {
if (languageVersion < 2) {
@@ -25165,6 +25217,9 @@ var ts;
else if (isNameOfNestedRedeclaration(node)) {
write(getGeneratedNameForNode(node));
}
else if (ts.nodeIsSynthesized(node)) {
write(node.text);
}
else {
writeTextOfNode(currentSourceFile, node);
}
@@ -28990,7 +29045,7 @@ var ts;
}
function trimReactWhitespaceAndApplyEntities(node) {
var result = undefined;
var text = ts.getTextOfNode(node);
var text = ts.getTextOfNode(node, true);
var firstNonWhitespace = 0;
var lastNonWhitespace = -1;
for (var i = 0; i < text.length; i++) {
@@ -29763,6 +29818,7 @@ var ts;
})(ts || (ts = {}));
/// <reference path="sys.ts" />
/// <reference path="emitter.ts" />
/// <reference path="core.ts" />
var ts;
(function (ts) {
ts.programTime = 0;
@@ -29794,10 +29850,124 @@ var ts;
}
ts.resolveTripleslashReference = resolveTripleslashReference;
function resolveModuleName(moduleName, containingFile, compilerOptions, host) {
return legacyNameResolver(moduleName, containingFile, compilerOptions, host);
var moduleResolution = compilerOptions.moduleResolution !== undefined
? compilerOptions.moduleResolution
: compilerOptions.module === 1 ? 2 : 1;
switch (moduleResolution) {
case 2: return nodeModuleNameResolver(moduleName, containingFile, host);
case 1: return classicNameResolver(moduleName, containingFile, compilerOptions, host);
}
}
ts.resolveModuleName = resolveModuleName;
function legacyNameResolver(moduleName, containingFile, compilerOptions, host) {
function nodeModuleNameResolver(moduleName, containingFile, host) {
var containingDirectory = ts.getDirectoryPath(containingFile);
if (ts.getRootLength(moduleName) !== 0 || nameStartsWithDotSlashOrDotDotSlash(moduleName)) {
var failedLookupLocations = [];
var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName));
var resolvedFileName = loadNodeModuleFromFile(candidate, false, failedLookupLocations, host);
if (resolvedFileName) {
return { resolvedFileName: resolvedFileName, failedLookupLocations: failedLookupLocations };
}
resolvedFileName = loadNodeModuleFromDirectory(candidate, false, failedLookupLocations, host);
return { resolvedFileName: resolvedFileName, failedLookupLocations: failedLookupLocations };
}
else {
return loadModuleFromNodeModules(moduleName, containingDirectory, host);
}
}
ts.nodeModuleNameResolver = nodeModuleNameResolver;
function loadNodeModuleFromFile(candidate, loadOnlyDts, failedLookupLocation, host) {
if (loadOnlyDts) {
return tryLoad(".d.ts");
}
else {
return ts.forEach(ts.supportedExtensions, tryLoad);
}
function tryLoad(ext) {
var fileName = ts.fileExtensionIs(candidate, ext) ? candidate : candidate + ext;
if (host.fileExists(fileName)) {
return fileName;
}
else {
failedLookupLocation.push(fileName);
return undefined;
}
}
}
function loadNodeModuleFromDirectory(candidate, loadOnlyDts, failedLookupLocation, host) {
var packageJsonPath = ts.combinePaths(candidate, "package.json");
if (host.fileExists(packageJsonPath)) {
var jsonContent;
try {
var jsonText = host.readFile(packageJsonPath);
jsonContent = jsonText ? JSON.parse(jsonText) : { typings: undefined };
}
catch (e) {
jsonContent = { typings: undefined };
}
if (jsonContent.typings) {
var result = loadNodeModuleFromFile(ts.normalizePath(ts.combinePaths(candidate, jsonContent.typings)), loadOnlyDts, failedLookupLocation, host);
if (result) {
return result;
}
}
}
else {
failedLookupLocation.push(packageJsonPath);
}
return loadNodeModuleFromFile(ts.combinePaths(candidate, "index"), loadOnlyDts, failedLookupLocation, host);
}
function loadModuleFromNodeModules(moduleName, directory, host) {
var failedLookupLocations = [];
directory = ts.normalizeSlashes(directory);
while (true) {
var baseName = ts.getBaseFileName(directory);
if (baseName !== "node_modules") {
var nodeModulesFolder = ts.combinePaths(directory, "node_modules");
var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName));
var result = loadNodeModuleFromFile(candidate, true, failedLookupLocations, host);
if (result) {
return { resolvedFileName: result, failedLookupLocations: failedLookupLocations };
}
result = loadNodeModuleFromDirectory(candidate, true, failedLookupLocations, host);
if (result) {
return { resolvedFileName: result, failedLookupLocations: failedLookupLocations };
}
}
var parentPath = ts.getDirectoryPath(directory);
if (parentPath === directory) {
break;
}
directory = parentPath;
}
return { resolvedFileName: undefined, failedLookupLocations: failedLookupLocations };
}
function baseUrlModuleNameResolver(moduleName, containingFile, baseUrl, host) {
ts.Debug.assert(baseUrl !== undefined);
var normalizedModuleName = ts.normalizeSlashes(moduleName);
var basePart = useBaseUrl(moduleName) ? baseUrl : ts.getDirectoryPath(containingFile);
var candidate = ts.normalizePath(ts.combinePaths(basePart, moduleName));
var failedLookupLocations = [];
return ts.forEach(ts.supportedExtensions, function (ext) { return tryLoadFile(candidate + ext); }) || { resolvedFileName: undefined, failedLookupLocations: failedLookupLocations };
function tryLoadFile(location) {
if (host.fileExists(location)) {
return { resolvedFileName: location, failedLookupLocations: failedLookupLocations };
}
else {
failedLookupLocations.push(location);
return undefined;
}
}
}
ts.baseUrlModuleNameResolver = baseUrlModuleNameResolver;
function nameStartsWithDotSlashOrDotDotSlash(name) {
var i = name.lastIndexOf("./", 1);
return i === 0 || (i === 1 && name.charCodeAt(0) === 46);
}
function useBaseUrl(moduleName) {
return ts.getRootLength(moduleName) === 0 && !nameStartsWithDotSlashOrDotDotSlash(moduleName);
}
function classicNameResolver(moduleName, containingFile, compilerOptions, host) {
if (moduleName.indexOf('!') != -1) {
return { resolvedFileName: undefined, failedLookupLocations: [] };
}
@@ -29830,6 +30000,15 @@ var ts;
}
return { resolvedFileName: referencedSourceFile, failedLookupLocations: failedLookupLocations };
}
ts.classicNameResolver = classicNameResolver;
ts.defaultInitCompilerOptions = {
module: 1,
target: 0,
noImplicitAny: false,
outDir: "built",
rootDir: ".",
sourceMap: false
};
function createCompilerHost(options, setParentNodes) {
var currentDirectory;
var existingDirectories = {};
@@ -32608,6 +32787,34 @@ var ts;
}
}
ts.hasDocComment = hasDocComment;
function getJsDocTagAtPosition(sourceFile, position) {
var node = ts.getTokenAtPosition(sourceFile, position);
if (isToken(node)) {
switch (node.kind) {
case 100:
case 106:
case 72:
node = node.parent === undefined ? undefined : node.parent.parent;
break;
default:
node = node.parent;
break;
}
}
if (node) {
var jsDocComment = node.jsDocComment;
if (jsDocComment) {
for (var _i = 0, _a = jsDocComment.tags; _i < _a.length; _i++) {
var tag = _a[_i];
if (tag.pos <= position && position <= tag.end) {
return tag;
}
}
}
}
return undefined;
}
ts.getJsDocTagAtPosition = getJsDocTagAtPosition;
function nodeHasTokens(n) {
return n.getWidth() !== 0;
}
@@ -33349,6 +33556,18 @@ var ts;
this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(37, formatting.Shared.TokenRange.FromTokens([67, 17])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2));
this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(112, 37), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8));
this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([112, 37]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2));
this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(116, 85), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2));
this.NoSpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(116, 85), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8));
this.SpaceAfterAwaitKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(117, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2));
this.NoSpaceAfterAwaitKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(117, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8));
this.SpaceAfterTypeKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(130, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2));
this.NoSpaceAfterTypeKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(130, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8));
this.SpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(67, formatting.Shared.TokenRange.FromTokens([11, 12])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2));
this.NoSpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(67, formatting.Shared.TokenRange.FromTokens([11, 12])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8));
this.SpaceBeforeBar = new formatting.Rule(formatting.RuleDescriptor.create3(46, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2));
this.NoSpaceBeforeBar = new formatting.Rule(formatting.RuleDescriptor.create3(46, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8));
this.SpaceAfterBar = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 46), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2));
this.NoSpaceAfterBar = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 46), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8));
this.HighPriorityCommonRules =
[
this.IgnoreBeforeComment, this.IgnoreAfterLineComment,
@@ -33374,6 +33593,11 @@ var ts;
this.NoSpaceBeforeOpenParenInFuncCall,
this.SpaceBeforeBinaryKeywordOperator, this.SpaceAfterBinaryKeywordOperator,
this.SpaceAfterVoidOperator,
this.SpaceBetweenAsyncAndFunctionKeyword, this.NoSpaceBetweenAsyncAndFunctionKeyword,
this.SpaceAfterAwaitKeyword, this.NoSpaceAfterAwaitKeyword,
this.SpaceAfterTypeKeyword, this.NoSpaceAfterTypeKeyword,
this.SpaceBetweenTagAndTemplateString, this.NoSpaceBetweenTagAndTemplateString,
this.SpaceBeforeBar, this.NoSpaceBeforeBar, this.SpaceAfterBar, this.NoSpaceAfterBar,
this.NoSpaceAfterConstructor, this.NoSpaceAfterModuleImport,
this.SpaceAfterCertainTypeScriptKeywords, this.SpaceBeforeCertainTypeScriptKeywords,
this.SpaceAfterModuleName,
@@ -35076,6 +35300,7 @@ var ts;
case 212:
case 213:
case 215:
case 214:
case 162:
case 190:
case 217:
@@ -35097,6 +35322,16 @@ var ts;
case 160:
case 159:
case 231:
case 140:
case 145:
case 146:
case 136:
case 150:
case 151:
case 156:
case 158:
case 168:
case 176:
return true;
}
return false;
@@ -35115,8 +35350,6 @@ var ts;
case 211:
case 171:
case 141:
case 140:
case 145:
case 172:
case 142:
case 143:
@@ -35172,6 +35405,45 @@ var ts;
})(ScriptSnapshot = ts.ScriptSnapshot || (ts.ScriptSnapshot = {}));
var scanner = ts.createScanner(2, true);
var emptyArray = [];
var jsDocTagNames = [
"augments",
"author",
"argument",
"borrows",
"class",
"constant",
"constructor",
"constructs",
"default",
"deprecated",
"description",
"event",
"example",
"extends",
"field",
"fileOverview",
"function",
"ignore",
"inner",
"lends",
"link",
"memberOf",
"name",
"namespace",
"param",
"private",
"property",
"public",
"requires",
"returns",
"see",
"since",
"static",
"throws",
"type",
"version"
];
var jsDocCompletionEntries;
function createNode(kind, pos, end, flags, parent) {
var node = new (ts.getNodeConstructor(kind))();
node.pos = pos;
@@ -36883,6 +37155,7 @@ var ts;
var syntacticStart = new Date().getTime();
var sourceFile = getValidSourceFile(fileName);
var isJavaScriptFile = ts.isJavaScript(fileName);
var isJsDocTagName = false;
var start = new Date().getTime();
var currentToken = ts.getTokenAtPosition(sourceFile, position);
log("getCompletionData: Get current token: " + (new Date().getTime() - start));
@@ -36890,8 +37163,33 @@ var ts;
var insideComment = isInsideComment(sourceFile, currentToken, position);
log("getCompletionData: Is inside comment: " + (new Date().getTime() - start));
if (insideComment) {
log("Returning an empty list because completion was inside a comment.");
return undefined;
if (ts.hasDocComment(sourceFile, position) && sourceFile.text.charCodeAt(position - 1) === 64) {
isJsDocTagName = true;
}
var insideJsDocTagExpression = false;
var tag = ts.getJsDocTagAtPosition(sourceFile, position);
if (tag) {
if (tag.tagName.pos <= position && position <= tag.tagName.end) {
isJsDocTagName = true;
}
switch (tag.kind) {
case 267:
case 265:
case 266:
var tagWithExpression = tag;
if (tagWithExpression.typeExpression) {
insideJsDocTagExpression = tagWithExpression.typeExpression.pos < position && position < tagWithExpression.typeExpression.end;
}
break;
}
}
if (isJsDocTagName) {
return { symbols: undefined, isMemberCompletion: false, isNewIdentifierLocation: false, location: undefined, isRightOfDot: false, isJsDocTagName: isJsDocTagName };
}
if (!insideJsDocTagExpression) {
log("Returning an empty list because completion was inside a regular comment or plain text part of a JsDoc comment.");
return undefined;
}
}
start = new Date().getTime();
var previousToken = ts.findPrecedingToken(position, sourceFile);
@@ -36954,7 +37252,7 @@ var ts;
}
}
log("getCompletionData: Semantic work: " + (new Date().getTime() - semanticStart));
return { symbols: symbols, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: (isRightOfDot || isRightOfOpenTag) };
return { symbols: symbols, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), isJsDocTagName: isJsDocTagName };
function getTypeScriptMemberSymbols() {
isMemberCompletion = true;
isNewIdentifierLocation = false;
@@ -37247,9 +37545,10 @@ var ts;
containingNodeKind === 215 ||
isFunction(containingNodeKind) ||
containingNodeKind === 212 ||
containingNodeKind === 211 ||
containingNodeKind === 184 ||
containingNodeKind === 213 ||
containingNodeKind === 160;
containingNodeKind === 160 ||
containingNodeKind === 214;
case 21:
return containingNodeKind === 160;
case 53:
@@ -37270,8 +37569,9 @@ var ts;
contextToken.parent.parent.kind === 153);
case 25:
return containingNodeKind === 212 ||
containingNodeKind === 211 ||
containingNodeKind === 184 ||
containingNodeKind === 213 ||
containingNodeKind === 214 ||
isFunction(containingNodeKind);
case 111:
return containingNodeKind === 139;
@@ -37383,8 +37683,11 @@ var ts;
if (!completionData) {
return undefined;
}
var symbols = completionData.symbols, isMemberCompletion = completionData.isMemberCompletion, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, isRightOfDot = completionData.isRightOfDot;
var symbols = completionData.symbols, isMemberCompletion = completionData.isMemberCompletion, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, isRightOfDot = completionData.isRightOfDot, isJsDocTagName = completionData.isJsDocTagName;
var entries;
if (isJsDocTagName) {
return { isMemberCompletion: false, isNewIdentifierLocation: false, entries: getAllJsDocCompletionEntries() };
}
if (isRightOfDot && ts.isJavaScript(fileName)) {
entries = getCompletionEntriesFromSymbols(symbols);
ts.addRange(entries, getJavaScriptCompletionEntries());
@@ -37395,7 +37698,7 @@ var ts;
}
entries = getCompletionEntriesFromSymbols(symbols);
}
if (!isMemberCompletion) {
if (!isMemberCompletion && !isJsDocTagName) {
ts.addRange(entries, keywordCompletions);
}
return { isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, entries: entries };
@@ -37424,6 +37727,16 @@ var ts;
}
return entries;
}
function getAllJsDocCompletionEntries() {
return jsDocCompletionEntries || (jsDocCompletionEntries = ts.map(jsDocTagNames, function (tagName) {
return {
name: tagName,
kind: ScriptElementKind.keyword,
kindModifiers: "",
sortText: "0"
};
}));
}
function createCompletionEntry(symbol, location) {
var displayName = getCompletionEntryDisplayNameForSymbol(symbol, program.getCompilerOptions().target, true, location);
if (!displayName) {
@@ -37698,6 +38011,7 @@ var ts;
displayParts.push(ts.keywordPart(130));
displayParts.push(ts.spacePart());
addFullSymbolName(symbol);
writeTypeParametersOfSymbol(symbol, sourceFile);
displayParts.push(ts.spacePart());
displayParts.push(ts.operatorPart(55));
displayParts.push(ts.spacePart());
@@ -37736,16 +38050,26 @@ var ts;
writeTypeParametersOfSymbol(symbol.parent, enclosingDeclaration);
}
else {
var signatureDeclaration = ts.getDeclarationOfKind(symbol, 135).parent;
var signature = typeChecker.getSignatureFromDeclaration(signatureDeclaration);
if (signatureDeclaration.kind === 146) {
displayParts.push(ts.keywordPart(90));
var container = ts.getContainingFunction(location);
if (container) {
var signatureDeclaration = ts.getDeclarationOfKind(symbol, 135).parent;
var signature = typeChecker.getSignatureFromDeclaration(signatureDeclaration);
if (signatureDeclaration.kind === 146) {
displayParts.push(ts.keywordPart(90));
displayParts.push(ts.spacePart());
}
else if (signatureDeclaration.kind !== 145 && signatureDeclaration.name) {
addFullSymbolName(signatureDeclaration.symbol);
}
ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32));
}
else {
var declaration = ts.getDeclarationOfKind(symbol, 135).parent;
displayParts.push(ts.keywordPart(130));
displayParts.push(ts.spacePart());
addFullSymbolName(declaration.symbol);
writeTypeParametersOfSymbol(declaration.symbol, sourceFile);
}
else if (signatureDeclaration.kind !== 145 && signatureDeclaration.name) {
addFullSymbolName(signatureDeclaration.symbol);
}
ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32));
}
}
if (symbolFlags & 8) {
@@ -37951,9 +38275,13 @@ var ts;
function tryAddConstructSignature(symbol, location, symbolKind, symbolName, containerName, result) {
if (isNewExpressionTarget(location) || location.kind === 119) {
if (symbol.flags & 32) {
var classDeclaration = symbol.getDeclarations()[0];
ts.Debug.assert(classDeclaration && classDeclaration.kind === 212);
return tryAddSignature(classDeclaration.members, true, symbolKind, symbolName, containerName, result);
for (var _i = 0, _a = symbol.getDeclarations(); _i < _a.length; _i++) {
var declaration = _a[_i];
if (ts.isClassLike(declaration)) {
return tryAddSignature(declaration.members, true, symbolKind, symbolName, containerName, result);
}
}
ts.Debug.fail("Expected declaration to have at least one class-like declaration");
}
}
return false;
@@ -42229,13 +42557,15 @@ var ts;
info = this.openFile(fileName, false);
}
else {
if (this.openFileRoots.indexOf(info) >= 0) {
this.openFileRoots = copyListRemovingItem(info, this.openFileRoots);
if (info.isOpen) {
if (this.openFileRoots.indexOf(info) >= 0) {
this.openFileRoots = copyListRemovingItem(info, this.openFileRoots);
}
if (this.openFilesReferenced.indexOf(info) >= 0) {
this.openFilesReferenced = copyListRemovingItem(info, this.openFilesReferenced);
}
this.openFileRootsConfigured.push(info);
}
if (this.openFilesReferenced.indexOf(info) >= 0) {
this.openFilesReferenced = copyListRemovingItem(info, this.openFilesReferenced);
}
this.openFileRootsConfigured.push(info);
}
project.addRoot(info);
}
+9
View File
@@ -1293,6 +1293,10 @@ declare module "typescript" {
Error = 1,
Message = 2,
}
const enum ModuleResolutionKind {
Classic = 1,
NodeJs = 2,
}
interface CompilerOptions {
allowNonTsExtensions?: boolean;
charset?: string;
@@ -1300,6 +1304,7 @@ declare module "typescript" {
diagnostics?: boolean;
emitBOM?: boolean;
help?: boolean;
init?: boolean;
inlineSourceMap?: boolean;
inlineSources?: boolean;
jsx?: JsxEmit;
@@ -1332,6 +1337,7 @@ declare module "typescript" {
experimentalDecorators?: boolean;
experimentalAsyncFunctions?: boolean;
emitDecoratorMetadata?: boolean;
moduleResolution?: ModuleResolutionKind;
[option: string]: string | number | boolean;
}
const enum ModuleKind {
@@ -1509,6 +1515,9 @@ declare module "typescript" {
function findConfigFile(searchPath: string): string;
function resolveTripleslashReference(moduleName: string, containingFile: string): string;
function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModule;
function nodeModuleNameResolver(moduleName: string, containingFile: string, host: ModuleResolutionHost): ResolvedModule;
function baseUrlModuleNameResolver(moduleName: string, containingFile: string, baseUrl: string, host: ModuleResolutionHost): ResolvedModule;
function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModule;
function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost;
function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[];
function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string;
+412 -48
View File
@@ -644,6 +644,11 @@ var ts;
DiagnosticCategory[DiagnosticCategory["Message"] = 2] = "Message";
})(ts.DiagnosticCategory || (ts.DiagnosticCategory = {}));
var DiagnosticCategory = ts.DiagnosticCategory;
(function (ModuleResolutionKind) {
ModuleResolutionKind[ModuleResolutionKind["Classic"] = 1] = "Classic";
ModuleResolutionKind[ModuleResolutionKind["NodeJs"] = 2] = "NodeJs";
})(ts.ModuleResolutionKind || (ts.ModuleResolutionKind = {}));
var ModuleResolutionKind = ts.ModuleResolutionKind;
(function (ModuleKind) {
ModuleKind[ModuleKind["None"] = 0] = "None";
ModuleKind[ModuleKind["CommonJS"] = 1] = "CommonJS";
@@ -2293,7 +2298,7 @@ var ts;
JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: { code: 2607, category: ts.DiagnosticCategory.Error, key: "JSX element class does not support attributes because it does not have a '{0}' property" },
The_global_type_JSX_0_may_not_have_more_than_one_property: { code: 2608, category: ts.DiagnosticCategory.Error, key: "The global type 'JSX.{0}' may not have more than one property" },
Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot emit namespaced JSX elements in React" },
A_member_initializer_in_a_const_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_const_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A member initializer in a 'const' enum declaration cannot reference members declared after it, including members defined in other 'const' enums." },
A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums." },
Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: ts.DiagnosticCategory.Error, key: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." },
Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." },
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." },
@@ -2379,6 +2384,7 @@ var ts;
Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: { code: 5051, category: ts.DiagnosticCategory.Error, key: "Option 'inlineSources' can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided." },
Option_0_cannot_be_specified_without_specifying_option_1: { code: 5052, category: ts.DiagnosticCategory.Error, key: "Option '{0}' cannot be specified without specifying option '{1}'." },
Option_0_cannot_be_specified_with_option_1: { code: 5053, category: ts.DiagnosticCategory.Error, key: "Option '{0}' cannot be specified with option '{1}'." },
A_tsconfig_json_file_is_already_defined_at_Colon_0: { code: 5053, category: ts.DiagnosticCategory.Error, key: "A 'tsconfig.json' file is already defined at: '{0}'." },
Concatenate_and_emit_output_to_single_file: { code: 6001, category: ts.DiagnosticCategory.Message, key: "Concatenate and emit output to single file." },
Generates_corresponding_d_ts_file: { code: 6002, category: ts.DiagnosticCategory.Message, key: "Generates corresponding '.d.ts' file." },
Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: { code: 6003, category: ts.DiagnosticCategory.Message, key: "Specifies the location where debugger should locate map files instead of generated locations." },
@@ -2433,6 +2439,9 @@ var ts;
Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for emitting type metadata for decorators." },
Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower: { code: 6067, category: ts.DiagnosticCategory.Message, key: "Option 'experimentalAsyncFunctions' cannot be specified when targeting ES5 or lower." },
Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 async functions." },
Specifies_module_resolution_strategy_Colon_node_Node_or_classic_TypeScript_pre_1_6: { code: 6069, category: ts.DiagnosticCategory.Message, key: "Specifies module resolution strategy: 'node' (Node) or 'classic' (TypeScript pre 1.6) ." },
Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: ts.DiagnosticCategory.Message, key: "Initializes a TypeScript project and creates a tsconfig.json file." },
Successfully_created_a_tsconfig_json_file: { code: 6071, category: ts.DiagnosticCategory.Message, key: "Successfully created a tsconfig.json file." },
Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." },
Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." },
Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." },
@@ -4849,6 +4858,10 @@ var ts;
else {
var bindingName = node.name ? node.name.text : "__class";
bindAnonymousDeclaration(node, 32 /* Class */, bindingName);
// Add name of class expression into the map for semantic classifier
if (node.name) {
classifiableNames[node.name.text] = node.name.text;
}
}
var symbol = node.symbol;
// TypeScript 1.0 spec (April 2014): 8.4
@@ -5832,6 +5845,7 @@ var ts;
case 134 /* ComputedPropertyName */:
return node === parent_2.expression;
case 137 /* Decorator */:
case 238 /* JsxExpression */:
return true;
case 186 /* ExpressionWithTypeArguments */:
return parent_2.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_2);
@@ -12258,7 +12272,6 @@ var ts;
}
if (!name) {
parseErrorAtPosition(pos, 0, ts.Diagnostics.Identifier_expected);
return undefined;
}
var preName, postName;
if (typeExpression) {
@@ -14561,7 +14574,7 @@ var ts;
}
function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaraiton, flags) {
var targetSymbol = getTargetSymbol(symbol);
if (targetSymbol.flags & 32 /* Class */ || targetSymbol.flags & 64 /* Interface */) {
if (targetSymbol.flags & 32 /* Class */ || targetSymbol.flags & 64 /* Interface */ || targetSymbol.flags & 524288 /* TypeAlias */) {
buildDisplayForTypeParametersAndDelimiters(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), writer, enclosingDeclaraiton, flags);
}
}
@@ -16957,6 +16970,15 @@ var ts;
return result;
}
function instantiateAnonymousType(type, mapper) {
if (mapper.instantiations) {
var cachedType = mapper.instantiations[type.id];
if (cachedType) {
return cachedType;
}
}
else {
mapper.instantiations = [];
}
// Mark the anonymous type as instantiated such that our infinite instantiation detection logic can recognize it
var result = createObjectType(65536 /* Anonymous */ | 131072 /* Instantiated */, type.symbol);
result.properties = instantiateList(getPropertiesOfObjectType(type), mapper, instantiateSymbol);
@@ -16969,6 +16991,7 @@ var ts;
result.stringIndexType = instantiateType(stringIndexType, mapper);
if (numberIndexType)
result.numberIndexType = instantiateType(numberIndexType, mapper);
mapper.instantiations[type.id] = result;
return result;
}
function instantiateType(type, mapper) {
@@ -23164,9 +23187,16 @@ var ts;
// serialize the type metadata.
if (node && node.kind === 149 /* TypeReference */) {
var root = getFirstIdentifier(node.typeName);
var rootSymbol = resolveName(root, root.text, 107455 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined);
if (rootSymbol && rootSymbol.flags & 8388608 /* Alias */ && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) {
markAliasSymbolAsReferenced(rootSymbol);
var meaning = root.parent.kind === 149 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */;
// Resolve type so we know which symbol is referenced
var rootSymbol = resolveName(root, root.text, meaning | 8388608 /* Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined);
// Resolved symbol is alias
if (rootSymbol && rootSymbol.flags & 8388608 /* Alias */) {
var aliasTarget = resolveAlias(rootSymbol);
// If alias has value symbol - mark alias as referenced
if (aliasTarget.flags & 107455 /* Value */ && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) {
markAliasSymbolAsReferenced(rootSymbol);
}
}
}
}
@@ -24621,7 +24651,7 @@ var ts;
// illegal case: forward reference
if (!isDefinedBefore(propertyDecl, member)) {
reportError = false;
error(e, ts.Diagnostics.A_member_initializer_in_a_const_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_const_enums);
error(e, ts.Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums);
return undefined;
}
return getNodeLinks(propertyDecl).enumMemberValue;
@@ -25835,6 +25865,10 @@ var ts;
}
// Resolve the symbol as a type so that we can provide a more useful hint for the type serializer.
var typeSymbol = resolveEntityName(typeName, 793056 /* Type */, /*ignoreErrors*/ true);
// We might not be able to resolve type symbol so use unknown type in that case (eg error case)
if (!typeSymbol) {
return ts.TypeReferenceSerializationKind.ObjectType;
}
var type = getDeclaredTypeOfSymbol(typeSymbol);
if (type === unknownType) {
return ts.TypeReferenceSerializationKind.Unknown;
@@ -27820,6 +27854,9 @@ var ts;
if (ts.isSupportedExpressionWithTypeArguments(node)) {
emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError);
}
else if (!isImplementsList && node.expression.kind === 91 /* NullKeyword */) {
write("null");
}
function getHeritageClauseVisibilityError(symbolAccesibilityResult) {
var diagnosticMessage;
// Heritage clause is written by user so it can always be named
@@ -28561,11 +28598,7 @@ var ts;
}
function emitJavaScript(jsFilePath, root) {
var writer = ts.createTextWriter(newLine);
var write = writer.write;
var writeTextOfNode = writer.writeTextOfNode;
var writeLine = writer.writeLine;
var increaseIndent = writer.increaseIndent;
var decreaseIndent = writer.decreaseIndent;
var write = writer.write, writeTextOfNode = writer.writeTextOfNode, writeLine = writer.writeLine, increaseIndent = writer.increaseIndent, decreaseIndent = writer.decreaseIndent;
var currentSourceFile;
// name of an exporter function if file is a System external module
// System.register([...], function (<exporter>) {...})
@@ -29775,7 +29808,12 @@ var ts;
return;
}
}
writeTextOfNode(currentSourceFile, node);
if (ts.nodeIsSynthesized(node)) {
write(node.text);
}
else {
writeTextOfNode(currentSourceFile, node);
}
}
function isNameOfNestedRedeclaration(node) {
if (languageVersion < 2 /* ES6 */) {
@@ -29800,6 +29838,9 @@ var ts;
else if (isNameOfNestedRedeclaration(node)) {
write(getGeneratedNameForNode(node));
}
else if (ts.nodeIsSynthesized(node)) {
write(node.text);
}
else {
writeTextOfNode(currentSourceFile, node);
}
@@ -31141,7 +31182,7 @@ var ts;
if (compilerOptions.module === 1 /* CommonJS */ || compilerOptions.module === 2 /* AMD */ || compilerOptions.module === 3 /* UMD */) {
if (!currentSourceFile.symbol.exports["___esModule"]) {
if (languageVersion === 1 /* ES5 */) {
// default value of configurable, enumerable, writable are `false`.
// default value of configurable, enumerable, writable are `false`.
write("Object.defineProperty(exports, \"__esModule\", { value: true });");
writeLine();
}
@@ -32812,7 +32853,7 @@ var ts;
// * The serialized type of an AccessorDeclaration is the serialized type of the return type annotation of its getter or parameter type annotation of its setter.
// * The serialized type of any other FunctionLikeDeclaration is "Function".
// * The serialized type of any other node is "void 0".
//
//
// For rules on serializing type annotations, see `serializeTypeNode`.
switch (node.kind) {
case 212 /* ClassDeclaration */:
@@ -32946,7 +32987,7 @@ var ts;
//
// * If the declaration is a class, the parameters of the first constructor with a body are used.
// * If the declaration is function-like and has a body, the parameters of the function are used.
//
//
// For the rules on serializing the type of each parameter declaration, see `serializeTypeOfDeclaration`.
if (node) {
var valueDeclaration;
@@ -34261,7 +34302,7 @@ var ts;
}
function trimReactWhitespaceAndApplyEntities(node) {
var result = undefined;
var text = ts.getTextOfNode(node);
var text = ts.getTextOfNode(node, /*includeTrivia*/ true);
var firstNonWhitespace = 0;
var lastNonWhitespace = -1;
// JSX trims whitespace at the end and beginning of lines, except that the
@@ -34312,7 +34353,7 @@ var ts;
}
case 1 /* Preserve */:
default:
return ts.getTextOfNode(node, true);
return ts.getTextOfNode(node, /*includeTrivia*/ true);
}
}
function emitJsxText(node) {
@@ -34324,7 +34365,7 @@ var ts;
break;
case 1 /* Preserve */:
default:
writer.writeLiteral(ts.getTextOfNode(node, true));
writer.writeLiteral(ts.getTextOfNode(node, /*includeTrivia*/ true));
break;
}
}
@@ -35092,6 +35133,7 @@ var ts;
})(ts || (ts = {}));
/// <reference path="sys.ts" />
/// <reference path="emitter.ts" />
/// <reference path="core.ts" />
var ts;
(function (ts) {
/* @internal */ ts.programTime = 0;
@@ -35124,11 +35166,128 @@ var ts;
}
ts.resolveTripleslashReference = resolveTripleslashReference;
function resolveModuleName(moduleName, containingFile, compilerOptions, host) {
// TODO: use different resolution strategy based on compiler options
return legacyNameResolver(moduleName, containingFile, compilerOptions, host);
var moduleResolution = compilerOptions.moduleResolution !== undefined
? compilerOptions.moduleResolution
: compilerOptions.module === 1 /* CommonJS */ ? 2 /* NodeJs */ : 1 /* Classic */;
switch (moduleResolution) {
case 2 /* NodeJs */: return nodeModuleNameResolver(moduleName, containingFile, host);
case 1 /* Classic */: return classicNameResolver(moduleName, containingFile, compilerOptions, host);
}
}
ts.resolveModuleName = resolveModuleName;
function legacyNameResolver(moduleName, containingFile, compilerOptions, host) {
function nodeModuleNameResolver(moduleName, containingFile, host) {
var containingDirectory = ts.getDirectoryPath(containingFile);
if (ts.getRootLength(moduleName) !== 0 || nameStartsWithDotSlashOrDotDotSlash(moduleName)) {
var failedLookupLocations = [];
var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName));
var resolvedFileName = loadNodeModuleFromFile(candidate, /* loadOnlyDts */ false, failedLookupLocations, host);
if (resolvedFileName) {
return { resolvedFileName: resolvedFileName, failedLookupLocations: failedLookupLocations };
}
resolvedFileName = loadNodeModuleFromDirectory(candidate, /* loadOnlyDts */ false, failedLookupLocations, host);
return { resolvedFileName: resolvedFileName, failedLookupLocations: failedLookupLocations };
}
else {
return loadModuleFromNodeModules(moduleName, containingDirectory, host);
}
}
ts.nodeModuleNameResolver = nodeModuleNameResolver;
function loadNodeModuleFromFile(candidate, loadOnlyDts, failedLookupLocation, host) {
if (loadOnlyDts) {
return tryLoad(".d.ts");
}
else {
return ts.forEach(ts.supportedExtensions, tryLoad);
}
function tryLoad(ext) {
var fileName = ts.fileExtensionIs(candidate, ext) ? candidate : candidate + ext;
if (host.fileExists(fileName)) {
return fileName;
}
else {
failedLookupLocation.push(fileName);
return undefined;
}
}
}
function loadNodeModuleFromDirectory(candidate, loadOnlyDts, failedLookupLocation, host) {
var packageJsonPath = ts.combinePaths(candidate, "package.json");
if (host.fileExists(packageJsonPath)) {
var jsonContent;
try {
var jsonText = host.readFile(packageJsonPath);
jsonContent = jsonText ? JSON.parse(jsonText) : { typings: undefined };
}
catch (e) {
// gracefully handle if readFile fails or returns not JSON
jsonContent = { typings: undefined };
}
if (jsonContent.typings) {
var result = loadNodeModuleFromFile(ts.normalizePath(ts.combinePaths(candidate, jsonContent.typings)), loadOnlyDts, failedLookupLocation, host);
if (result) {
return result;
}
}
}
else {
// record package json as one of failed lookup locations - in the future if this file will appear it will invalidate resolution results
failedLookupLocation.push(packageJsonPath);
}
return loadNodeModuleFromFile(ts.combinePaths(candidate, "index"), loadOnlyDts, failedLookupLocation, host);
}
function loadModuleFromNodeModules(moduleName, directory, host) {
var failedLookupLocations = [];
directory = ts.normalizeSlashes(directory);
while (true) {
var baseName = ts.getBaseFileName(directory);
if (baseName !== "node_modules") {
var nodeModulesFolder = ts.combinePaths(directory, "node_modules");
var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName));
var result = loadNodeModuleFromFile(candidate, /* loadOnlyDts */ true, failedLookupLocations, host);
if (result) {
return { resolvedFileName: result, failedLookupLocations: failedLookupLocations };
}
result = loadNodeModuleFromDirectory(candidate, /* loadOnlyDts */ true, failedLookupLocations, host);
if (result) {
return { resolvedFileName: result, failedLookupLocations: failedLookupLocations };
}
}
var parentPath = ts.getDirectoryPath(directory);
if (parentPath === directory) {
break;
}
directory = parentPath;
}
return { resolvedFileName: undefined, failedLookupLocations: failedLookupLocations };
}
function baseUrlModuleNameResolver(moduleName, containingFile, baseUrl, host) {
ts.Debug.assert(baseUrl !== undefined);
var normalizedModuleName = ts.normalizeSlashes(moduleName);
var basePart = useBaseUrl(moduleName) ? baseUrl : ts.getDirectoryPath(containingFile);
var candidate = ts.normalizePath(ts.combinePaths(basePart, moduleName));
var failedLookupLocations = [];
return ts.forEach(ts.supportedExtensions, function (ext) { return tryLoadFile(candidate + ext); }) || { resolvedFileName: undefined, failedLookupLocations: failedLookupLocations };
function tryLoadFile(location) {
if (host.fileExists(location)) {
return { resolvedFileName: location, failedLookupLocations: failedLookupLocations };
}
else {
failedLookupLocations.push(location);
return undefined;
}
}
}
ts.baseUrlModuleNameResolver = baseUrlModuleNameResolver;
function nameStartsWithDotSlashOrDotDotSlash(name) {
var i = name.lastIndexOf("./", 1);
return i === 0 || (i === 1 && name.charCodeAt(0) === 46 /* dot */);
}
function useBaseUrl(moduleName) {
// path is not rooted
// module name does not start with './' or '../'
return ts.getRootLength(moduleName) === 0 && !nameStartsWithDotSlashOrDotDotSlash(moduleName);
}
function classicNameResolver(moduleName, containingFile, compilerOptions, host) {
// module names that contain '!' are used to reference resources and are not resolved to actual files on disk
if (moduleName.indexOf('!') != -1) {
return { resolvedFileName: undefined, failedLookupLocations: [] };
@@ -35164,6 +35323,16 @@ var ts;
}
return { resolvedFileName: referencedSourceFile, failedLookupLocations: failedLookupLocations };
}
ts.classicNameResolver = classicNameResolver;
/* @internal */
ts.defaultInitCompilerOptions = {
module: 1 /* CommonJS */,
target: 0 /* ES3 */,
noImplicitAny: false,
outDir: "built",
rootDir: ".",
sourceMap: false
};
function createCompilerHost(options, setParentNodes) {
var currentDirectory;
var existingDirectories = {};
@@ -35908,6 +36077,11 @@ var ts;
type: "boolean",
description: ts.Diagnostics.Print_this_message
},
{
name: "init",
type: "boolean",
description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file
},
{
name: "inlineSourceMap",
type: "boolean"
@@ -36103,20 +36277,40 @@ var ts;
type: "boolean",
experimental: true,
description: ts.Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators
},
{
name: "moduleResolution",
type: {
"node": 2 /* NodeJs */,
"classic": 1 /* Classic */
},
experimental: true,
description: ts.Diagnostics.Specifies_module_resolution_strategy_Colon_node_Node_or_classic_TypeScript_pre_1_6
}
];
function parseCommandLine(commandLine) {
var options = {};
var fileNames = [];
var errors = [];
var shortOptionNames = {};
var optionNameMapCache;
/* @internal */
function getOptionNameMap() {
if (optionNameMapCache) {
return optionNameMapCache;
}
var optionNameMap = {};
var shortOptionNames = {};
ts.forEach(ts.optionDeclarations, function (option) {
optionNameMap[option.name.toLowerCase()] = option;
if (option.shortName) {
shortOptionNames[option.shortName] = option.name;
}
});
optionNameMapCache = { optionNameMap: optionNameMap, shortOptionNames: shortOptionNames };
return optionNameMapCache;
}
ts.getOptionNameMap = getOptionNameMap;
function parseCommandLine(commandLine) {
var options = {};
var fileNames = [];
var errors = [];
var _a = getOptionNameMap(), optionNameMap = _a.optionNameMap, shortOptionNames = _a.shortOptionNames;
parseStrings(commandLine);
return {
options: options,
@@ -38656,6 +38850,38 @@ var ts;
}
}
ts.hasDocComment = hasDocComment;
/**
* Get the corresponding JSDocTag node if the position is in a jsDoc comment
*/
function getJsDocTagAtPosition(sourceFile, position) {
var node = ts.getTokenAtPosition(sourceFile, position);
if (isToken(node)) {
switch (node.kind) {
case 100 /* VarKeyword */:
case 106 /* LetKeyword */:
case 72 /* ConstKeyword */:
// if the current token is var, let or const, skip the VariableDeclarationList
node = node.parent === undefined ? undefined : node.parent.parent;
break;
default:
node = node.parent;
break;
}
}
if (node) {
var jsDocComment = node.jsDocComment;
if (jsDocComment) {
for (var _i = 0, _a = jsDocComment.tags; _i < _a.length; _i++) {
var tag = _a[_i];
if (tag.pos <= position && position <= tag.end) {
return tag;
}
}
}
}
return undefined;
}
ts.getJsDocTagAtPosition = getJsDocTagAtPosition;
function nodeHasTokens(n) {
// If we have a token or node that has a non-zero width, it must have tokens.
// Note, that getWidth() does not take trivia into account.
@@ -39523,6 +39749,22 @@ var ts;
this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(37 /* AsteriskToken */, formatting.Shared.TokenRange.FromTokens([67 /* Identifier */, 17 /* OpenParenToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2 /* Space */));
this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(112 /* YieldKeyword */, 37 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8 /* Delete */));
this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([112 /* YieldKeyword */, 37 /* AsteriskToken */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2 /* Space */));
// Async-await
this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(116 /* AsyncKeyword */, 85 /* FunctionKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
this.NoSpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(116 /* AsyncKeyword */, 85 /* FunctionKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
this.SpaceAfterAwaitKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(117 /* AwaitKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
this.NoSpaceAfterAwaitKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(117 /* AwaitKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
// Type alias declaration
this.SpaceAfterTypeKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(130 /* TypeKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
this.NoSpaceAfterTypeKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(130 /* TypeKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
// template string
this.SpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(67 /* Identifier */, formatting.Shared.TokenRange.FromTokens([11 /* NoSubstitutionTemplateLiteral */, 12 /* TemplateHead */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
this.NoSpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(67 /* Identifier */, formatting.Shared.TokenRange.FromTokens([11 /* NoSubstitutionTemplateLiteral */, 12 /* TemplateHead */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
// union type
this.SpaceBeforeBar = new formatting.Rule(formatting.RuleDescriptor.create3(46 /* BarToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
this.NoSpaceBeforeBar = new formatting.Rule(formatting.RuleDescriptor.create3(46 /* BarToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
this.SpaceAfterBar = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 46 /* BarToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
this.NoSpaceAfterBar = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 46 /* BarToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
// These rules are higher in priority than user-configurable rules.
this.HighPriorityCommonRules =
[
@@ -39549,6 +39791,11 @@ var ts;
this.NoSpaceBeforeOpenParenInFuncCall,
this.SpaceBeforeBinaryKeywordOperator, this.SpaceAfterBinaryKeywordOperator,
this.SpaceAfterVoidOperator,
this.SpaceBetweenAsyncAndFunctionKeyword, this.NoSpaceBetweenAsyncAndFunctionKeyword,
this.SpaceAfterAwaitKeyword, this.NoSpaceAfterAwaitKeyword,
this.SpaceAfterTypeKeyword, this.NoSpaceAfterTypeKeyword,
this.SpaceBetweenTagAndTemplateString, this.NoSpaceBetweenTagAndTemplateString,
this.SpaceBeforeBar, this.NoSpaceBeforeBar, this.SpaceAfterBar, this.NoSpaceAfterBar,
// TypeScript-specific rules
this.NoSpaceAfterConstructor, this.NoSpaceAfterModuleImport,
this.SpaceAfterCertainTypeScriptKeywords, this.SpaceBeforeCertainTypeScriptKeywords,
@@ -41492,6 +41739,7 @@ var ts;
case 212 /* ClassDeclaration */:
case 213 /* InterfaceDeclaration */:
case 215 /* EnumDeclaration */:
case 214 /* TypeAliasDeclaration */:
case 162 /* ArrayLiteralExpression */:
case 190 /* Block */:
case 217 /* ModuleBlock */:
@@ -41513,6 +41761,16 @@ var ts;
case 160 /* ArrayBindingPattern */:
case 159 /* ObjectBindingPattern */:
case 231 /* JsxElement */:
case 140 /* MethodSignature */:
case 145 /* CallSignature */:
case 146 /* ConstructSignature */:
case 136 /* Parameter */:
case 150 /* FunctionType */:
case 151 /* ConstructorType */:
case 156 /* UnionType */:
case 158 /* ParenthesizedType */:
case 168 /* TaggedTemplateExpression */:
case 176 /* AwaitExpression */:
return true;
}
return false;
@@ -41531,8 +41789,6 @@ var ts;
case 211 /* FunctionDeclaration */:
case 171 /* FunctionExpression */:
case 141 /* MethodDeclaration */:
case 140 /* MethodSignature */:
case 145 /* CallSignature */:
case 172 /* ArrowFunction */:
case 142 /* Constructor */:
case 143 /* GetAccessor */:
@@ -41591,6 +41847,45 @@ var ts;
})(ScriptSnapshot = ts.ScriptSnapshot || (ts.ScriptSnapshot = {}));
var scanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ true);
var emptyArray = [];
var jsDocTagNames = [
"augments",
"author",
"argument",
"borrows",
"class",
"constant",
"constructor",
"constructs",
"default",
"deprecated",
"description",
"event",
"example",
"extends",
"field",
"fileOverview",
"function",
"ignore",
"inner",
"lends",
"link",
"memberOf",
"name",
"namespace",
"param",
"private",
"property",
"public",
"requires",
"returns",
"see",
"since",
"static",
"throws",
"type",
"version"
];
var jsDocCompletionEntries;
function createNode(kind, pos, end, flags, parent) {
var node = new (ts.getNodeConstructor(kind))();
node.pos = pos;
@@ -43614,6 +43909,7 @@ var ts;
var syntacticStart = new Date().getTime();
var sourceFile = getValidSourceFile(fileName);
var isJavaScriptFile = ts.isJavaScript(fileName);
var isJsDocTagName = false;
var start = new Date().getTime();
var currentToken = ts.getTokenAtPosition(sourceFile, position);
log("getCompletionData: Get current token: " + (new Date().getTime() - start));
@@ -43622,8 +43918,40 @@ var ts;
var insideComment = isInsideComment(sourceFile, currentToken, position);
log("getCompletionData: Is inside comment: " + (new Date().getTime() - start));
if (insideComment) {
log("Returning an empty list because completion was inside a comment.");
return undefined;
// The current position is next to the '@' sign, when no tag name being provided yet.
// Provide a full list of tag names
if (ts.hasDocComment(sourceFile, position) && sourceFile.text.charCodeAt(position - 1) === 64 /* at */) {
isJsDocTagName = true;
}
// Completion should work inside certain JsDoc tags. For example:
// /** @type {number | string} */
// Completion should work in the brackets
var insideJsDocTagExpression = false;
var tag = ts.getJsDocTagAtPosition(sourceFile, position);
if (tag) {
if (tag.tagName.pos <= position && position <= tag.tagName.end) {
isJsDocTagName = true;
}
switch (tag.kind) {
case 267 /* JSDocTypeTag */:
case 265 /* JSDocParameterTag */:
case 266 /* JSDocReturnTag */:
var tagWithExpression = tag;
if (tagWithExpression.typeExpression) {
insideJsDocTagExpression = tagWithExpression.typeExpression.pos < position && position < tagWithExpression.typeExpression.end;
}
break;
}
}
if (isJsDocTagName) {
return { symbols: undefined, isMemberCompletion: false, isNewIdentifierLocation: false, location: undefined, isRightOfDot: false, isJsDocTagName: isJsDocTagName };
}
if (!insideJsDocTagExpression) {
// Proceed if the current position is in jsDoc tag expression; otherwise it is a normal
// comment or the plain text part of a jsDoc comment, so no completion should be available
log("Returning an empty list because completion was inside a regular comment or plain text part of a JsDoc comment.");
return undefined;
}
}
start = new Date().getTime();
var previousToken = ts.findPrecedingToken(position, sourceFile);
@@ -43699,7 +44027,7 @@ var ts;
}
}
log("getCompletionData: Semantic work: " + (new Date().getTime() - semanticStart));
return { symbols: symbols, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: (isRightOfDot || isRightOfOpenTag) };
return { symbols: symbols, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), isJsDocTagName: isJsDocTagName };
function getTypeScriptMemberSymbols() {
// Right of dot member completion list
isMemberCompletion = true;
@@ -44083,9 +44411,10 @@ var ts;
containingNodeKind === 215 /* EnumDeclaration */ ||
isFunction(containingNodeKind) ||
containingNodeKind === 212 /* ClassDeclaration */ ||
containingNodeKind === 211 /* FunctionDeclaration */ ||
containingNodeKind === 184 /* ClassExpression */ ||
containingNodeKind === 213 /* InterfaceDeclaration */ ||
containingNodeKind === 160 /* ArrayBindingPattern */; // var [x, y|
containingNodeKind === 160 /* ArrayBindingPattern */ ||
containingNodeKind === 214 /* TypeAliasDeclaration */; // type Map, K, |
case 21 /* DotToken */:
return containingNodeKind === 160 /* ArrayBindingPattern */; // var [.|
case 53 /* ColonToken */:
@@ -44106,8 +44435,9 @@ var ts;
contextToken.parent.parent.kind === 153 /* TypeLiteral */); // let x : { a; |
case 25 /* LessThanToken */:
return containingNodeKind === 212 /* ClassDeclaration */ ||
containingNodeKind === 211 /* FunctionDeclaration */ ||
containingNodeKind === 184 /* ClassExpression */ ||
containingNodeKind === 213 /* InterfaceDeclaration */ ||
containingNodeKind === 214 /* TypeAliasDeclaration */ ||
isFunction(containingNodeKind);
case 111 /* StaticKeyword */:
return containingNodeKind === 139 /* PropertyDeclaration */;
@@ -44248,8 +44578,12 @@ var ts;
if (!completionData) {
return undefined;
}
var symbols = completionData.symbols, isMemberCompletion = completionData.isMemberCompletion, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, isRightOfDot = completionData.isRightOfDot;
var symbols = completionData.symbols, isMemberCompletion = completionData.isMemberCompletion, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, isRightOfDot = completionData.isRightOfDot, isJsDocTagName = completionData.isJsDocTagName;
var entries;
if (isJsDocTagName) {
// If the current position is a jsDoc tag name, only tag names should be provided for completion
return { isMemberCompletion: false, isNewIdentifierLocation: false, entries: getAllJsDocCompletionEntries() };
}
if (isRightOfDot && ts.isJavaScript(fileName)) {
entries = getCompletionEntriesFromSymbols(symbols);
ts.addRange(entries, getJavaScriptCompletionEntries());
@@ -44261,7 +44595,7 @@ var ts;
entries = getCompletionEntriesFromSymbols(symbols);
}
// Add keywords if this is not a member completion list
if (!isMemberCompletion) {
if (!isMemberCompletion && !isJsDocTagName) {
ts.addRange(entries, keywordCompletions);
}
return { isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, entries: entries };
@@ -44290,6 +44624,16 @@ var ts;
}
return entries;
}
function getAllJsDocCompletionEntries() {
return jsDocCompletionEntries || (jsDocCompletionEntries = ts.map(jsDocTagNames, function (tagName) {
return {
name: tagName,
kind: ScriptElementKind.keyword,
kindModifiers: "",
sortText: "0"
};
}));
}
function createCompletionEntry(symbol, location) {
// Try to get a valid display name for this symbol, if we could not find one, then ignore it.
// We would like to only show things that can be added after a dot, so for instance numeric properties can
@@ -44601,6 +44945,7 @@ var ts;
displayParts.push(ts.keywordPart(130 /* TypeKeyword */));
displayParts.push(ts.spacePart());
addFullSymbolName(symbol);
writeTypeParametersOfSymbol(symbol, sourceFile);
displayParts.push(ts.spacePart());
displayParts.push(ts.operatorPart(55 /* EqualsToken */));
displayParts.push(ts.spacePart());
@@ -44641,16 +44986,29 @@ var ts;
}
else {
// Method/function type parameter
var signatureDeclaration = ts.getDeclarationOfKind(symbol, 135 /* TypeParameter */).parent;
var signature = typeChecker.getSignatureFromDeclaration(signatureDeclaration);
if (signatureDeclaration.kind === 146 /* ConstructSignature */) {
displayParts.push(ts.keywordPart(90 /* NewKeyword */));
var container = ts.getContainingFunction(location);
if (container) {
var signatureDeclaration = ts.getDeclarationOfKind(symbol, 135 /* TypeParameter */).parent;
var signature = typeChecker.getSignatureFromDeclaration(signatureDeclaration);
if (signatureDeclaration.kind === 146 /* ConstructSignature */) {
displayParts.push(ts.keywordPart(90 /* NewKeyword */));
displayParts.push(ts.spacePart());
}
else if (signatureDeclaration.kind !== 145 /* CallSignature */ && signatureDeclaration.name) {
addFullSymbolName(signatureDeclaration.symbol);
}
ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */));
}
else {
// Type aliash type parameter
// For example
// type list<T> = T[]; // Both T will go through same code path
var declaration = ts.getDeclarationOfKind(symbol, 135 /* TypeParameter */).parent;
displayParts.push(ts.keywordPart(130 /* TypeKeyword */));
displayParts.push(ts.spacePart());
addFullSymbolName(declaration.symbol);
writeTypeParametersOfSymbol(declaration.symbol, sourceFile);
}
else if (signatureDeclaration.kind !== 145 /* CallSignature */ && signatureDeclaration.name) {
addFullSymbolName(signatureDeclaration.symbol);
}
ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */));
}
}
if (symbolFlags & 8 /* EnumMember */) {
@@ -44863,9 +45221,15 @@ var ts;
// and in either case the symbol has a construct signature definition, i.e. class
if (isNewExpressionTarget(location) || location.kind === 119 /* ConstructorKeyword */) {
if (symbol.flags & 32 /* Class */) {
var classDeclaration = symbol.getDeclarations()[0];
ts.Debug.assert(classDeclaration && classDeclaration.kind === 212 /* ClassDeclaration */);
return tryAddSignature(classDeclaration.members, /*selectConstructors*/ true, symbolKind, symbolName, containerName, result);
// Find the first class-like declaration and try to get the construct signature.
for (var _i = 0, _a = symbol.getDeclarations(); _i < _a.length; _i++) {
var declaration = _a[_i];
if (ts.isClassLike(declaration)) {
return tryAddSignature(declaration.members,
/*selectConstructors*/ true, symbolKind, symbolName, containerName, result);
}
}
ts.Debug.fail("Expected declaration to have at least one class-like declaration");
}
}
return false;
+9
View File
@@ -1293,6 +1293,10 @@ declare namespace ts {
Error = 1,
Message = 2,
}
const enum ModuleResolutionKind {
Classic = 1,
NodeJs = 2,
}
interface CompilerOptions {
allowNonTsExtensions?: boolean;
charset?: string;
@@ -1300,6 +1304,7 @@ declare namespace ts {
diagnostics?: boolean;
emitBOM?: boolean;
help?: boolean;
init?: boolean;
inlineSourceMap?: boolean;
inlineSources?: boolean;
jsx?: JsxEmit;
@@ -1332,6 +1337,7 @@ declare namespace ts {
experimentalDecorators?: boolean;
experimentalAsyncFunctions?: boolean;
emitDecoratorMetadata?: boolean;
moduleResolution?: ModuleResolutionKind;
[option: string]: string | number | boolean;
}
const enum ModuleKind {
@@ -1509,6 +1515,9 @@ declare namespace ts {
function findConfigFile(searchPath: string): string;
function resolveTripleslashReference(moduleName: string, containingFile: string): string;
function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModule;
function nodeModuleNameResolver(moduleName: string, containingFile: string, host: ModuleResolutionHost): ResolvedModule;
function baseUrlModuleNameResolver(moduleName: string, containingFile: string, baseUrl: string, host: ModuleResolutionHost): ResolvedModule;
function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModule;
function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost;
function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[];
function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string;
+412 -48
View File
@@ -644,6 +644,11 @@ var ts;
DiagnosticCategory[DiagnosticCategory["Message"] = 2] = "Message";
})(ts.DiagnosticCategory || (ts.DiagnosticCategory = {}));
var DiagnosticCategory = ts.DiagnosticCategory;
(function (ModuleResolutionKind) {
ModuleResolutionKind[ModuleResolutionKind["Classic"] = 1] = "Classic";
ModuleResolutionKind[ModuleResolutionKind["NodeJs"] = 2] = "NodeJs";
})(ts.ModuleResolutionKind || (ts.ModuleResolutionKind = {}));
var ModuleResolutionKind = ts.ModuleResolutionKind;
(function (ModuleKind) {
ModuleKind[ModuleKind["None"] = 0] = "None";
ModuleKind[ModuleKind["CommonJS"] = 1] = "CommonJS";
@@ -2293,7 +2298,7 @@ var ts;
JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: { code: 2607, category: ts.DiagnosticCategory.Error, key: "JSX element class does not support attributes because it does not have a '{0}' property" },
The_global_type_JSX_0_may_not_have_more_than_one_property: { code: 2608, category: ts.DiagnosticCategory.Error, key: "The global type 'JSX.{0}' may not have more than one property" },
Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot emit namespaced JSX elements in React" },
A_member_initializer_in_a_const_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_const_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A member initializer in a 'const' enum declaration cannot reference members declared after it, including members defined in other 'const' enums." },
A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums." },
Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: ts.DiagnosticCategory.Error, key: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." },
Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." },
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." },
@@ -2379,6 +2384,7 @@ var ts;
Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: { code: 5051, category: ts.DiagnosticCategory.Error, key: "Option 'inlineSources' can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided." },
Option_0_cannot_be_specified_without_specifying_option_1: { code: 5052, category: ts.DiagnosticCategory.Error, key: "Option '{0}' cannot be specified without specifying option '{1}'." },
Option_0_cannot_be_specified_with_option_1: { code: 5053, category: ts.DiagnosticCategory.Error, key: "Option '{0}' cannot be specified with option '{1}'." },
A_tsconfig_json_file_is_already_defined_at_Colon_0: { code: 5053, category: ts.DiagnosticCategory.Error, key: "A 'tsconfig.json' file is already defined at: '{0}'." },
Concatenate_and_emit_output_to_single_file: { code: 6001, category: ts.DiagnosticCategory.Message, key: "Concatenate and emit output to single file." },
Generates_corresponding_d_ts_file: { code: 6002, category: ts.DiagnosticCategory.Message, key: "Generates corresponding '.d.ts' file." },
Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: { code: 6003, category: ts.DiagnosticCategory.Message, key: "Specifies the location where debugger should locate map files instead of generated locations." },
@@ -2433,6 +2439,9 @@ var ts;
Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for emitting type metadata for decorators." },
Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower: { code: 6067, category: ts.DiagnosticCategory.Message, key: "Option 'experimentalAsyncFunctions' cannot be specified when targeting ES5 or lower." },
Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 async functions." },
Specifies_module_resolution_strategy_Colon_node_Node_or_classic_TypeScript_pre_1_6: { code: 6069, category: ts.DiagnosticCategory.Message, key: "Specifies module resolution strategy: 'node' (Node) or 'classic' (TypeScript pre 1.6) ." },
Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: ts.DiagnosticCategory.Message, key: "Initializes a TypeScript project and creates a tsconfig.json file." },
Successfully_created_a_tsconfig_json_file: { code: 6071, category: ts.DiagnosticCategory.Message, key: "Successfully created a tsconfig.json file." },
Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." },
Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." },
Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." },
@@ -4849,6 +4858,10 @@ var ts;
else {
var bindingName = node.name ? node.name.text : "__class";
bindAnonymousDeclaration(node, 32 /* Class */, bindingName);
// Add name of class expression into the map for semantic classifier
if (node.name) {
classifiableNames[node.name.text] = node.name.text;
}
}
var symbol = node.symbol;
// TypeScript 1.0 spec (April 2014): 8.4
@@ -5832,6 +5845,7 @@ var ts;
case 134 /* ComputedPropertyName */:
return node === parent_2.expression;
case 137 /* Decorator */:
case 238 /* JsxExpression */:
return true;
case 186 /* ExpressionWithTypeArguments */:
return parent_2.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_2);
@@ -12258,7 +12272,6 @@ var ts;
}
if (!name) {
parseErrorAtPosition(pos, 0, ts.Diagnostics.Identifier_expected);
return undefined;
}
var preName, postName;
if (typeExpression) {
@@ -14561,7 +14574,7 @@ var ts;
}
function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaraiton, flags) {
var targetSymbol = getTargetSymbol(symbol);
if (targetSymbol.flags & 32 /* Class */ || targetSymbol.flags & 64 /* Interface */) {
if (targetSymbol.flags & 32 /* Class */ || targetSymbol.flags & 64 /* Interface */ || targetSymbol.flags & 524288 /* TypeAlias */) {
buildDisplayForTypeParametersAndDelimiters(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), writer, enclosingDeclaraiton, flags);
}
}
@@ -16957,6 +16970,15 @@ var ts;
return result;
}
function instantiateAnonymousType(type, mapper) {
if (mapper.instantiations) {
var cachedType = mapper.instantiations[type.id];
if (cachedType) {
return cachedType;
}
}
else {
mapper.instantiations = [];
}
// Mark the anonymous type as instantiated such that our infinite instantiation detection logic can recognize it
var result = createObjectType(65536 /* Anonymous */ | 131072 /* Instantiated */, type.symbol);
result.properties = instantiateList(getPropertiesOfObjectType(type), mapper, instantiateSymbol);
@@ -16969,6 +16991,7 @@ var ts;
result.stringIndexType = instantiateType(stringIndexType, mapper);
if (numberIndexType)
result.numberIndexType = instantiateType(numberIndexType, mapper);
mapper.instantiations[type.id] = result;
return result;
}
function instantiateType(type, mapper) {
@@ -23164,9 +23187,16 @@ var ts;
// serialize the type metadata.
if (node && node.kind === 149 /* TypeReference */) {
var root = getFirstIdentifier(node.typeName);
var rootSymbol = resolveName(root, root.text, 107455 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined);
if (rootSymbol && rootSymbol.flags & 8388608 /* Alias */ && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) {
markAliasSymbolAsReferenced(rootSymbol);
var meaning = root.parent.kind === 149 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */;
// Resolve type so we know which symbol is referenced
var rootSymbol = resolveName(root, root.text, meaning | 8388608 /* Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined);
// Resolved symbol is alias
if (rootSymbol && rootSymbol.flags & 8388608 /* Alias */) {
var aliasTarget = resolveAlias(rootSymbol);
// If alias has value symbol - mark alias as referenced
if (aliasTarget.flags & 107455 /* Value */ && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) {
markAliasSymbolAsReferenced(rootSymbol);
}
}
}
}
@@ -24621,7 +24651,7 @@ var ts;
// illegal case: forward reference
if (!isDefinedBefore(propertyDecl, member)) {
reportError = false;
error(e, ts.Diagnostics.A_member_initializer_in_a_const_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_const_enums);
error(e, ts.Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums);
return undefined;
}
return getNodeLinks(propertyDecl).enumMemberValue;
@@ -25835,6 +25865,10 @@ var ts;
}
// Resolve the symbol as a type so that we can provide a more useful hint for the type serializer.
var typeSymbol = resolveEntityName(typeName, 793056 /* Type */, /*ignoreErrors*/ true);
// We might not be able to resolve type symbol so use unknown type in that case (eg error case)
if (!typeSymbol) {
return ts.TypeReferenceSerializationKind.ObjectType;
}
var type = getDeclaredTypeOfSymbol(typeSymbol);
if (type === unknownType) {
return ts.TypeReferenceSerializationKind.Unknown;
@@ -27820,6 +27854,9 @@ var ts;
if (ts.isSupportedExpressionWithTypeArguments(node)) {
emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError);
}
else if (!isImplementsList && node.expression.kind === 91 /* NullKeyword */) {
write("null");
}
function getHeritageClauseVisibilityError(symbolAccesibilityResult) {
var diagnosticMessage;
// Heritage clause is written by user so it can always be named
@@ -28561,11 +28598,7 @@ var ts;
}
function emitJavaScript(jsFilePath, root) {
var writer = ts.createTextWriter(newLine);
var write = writer.write;
var writeTextOfNode = writer.writeTextOfNode;
var writeLine = writer.writeLine;
var increaseIndent = writer.increaseIndent;
var decreaseIndent = writer.decreaseIndent;
var write = writer.write, writeTextOfNode = writer.writeTextOfNode, writeLine = writer.writeLine, increaseIndent = writer.increaseIndent, decreaseIndent = writer.decreaseIndent;
var currentSourceFile;
// name of an exporter function if file is a System external module
// System.register([...], function (<exporter>) {...})
@@ -29775,7 +29808,12 @@ var ts;
return;
}
}
writeTextOfNode(currentSourceFile, node);
if (ts.nodeIsSynthesized(node)) {
write(node.text);
}
else {
writeTextOfNode(currentSourceFile, node);
}
}
function isNameOfNestedRedeclaration(node) {
if (languageVersion < 2 /* ES6 */) {
@@ -29800,6 +29838,9 @@ var ts;
else if (isNameOfNestedRedeclaration(node)) {
write(getGeneratedNameForNode(node));
}
else if (ts.nodeIsSynthesized(node)) {
write(node.text);
}
else {
writeTextOfNode(currentSourceFile, node);
}
@@ -31141,7 +31182,7 @@ var ts;
if (compilerOptions.module === 1 /* CommonJS */ || compilerOptions.module === 2 /* AMD */ || compilerOptions.module === 3 /* UMD */) {
if (!currentSourceFile.symbol.exports["___esModule"]) {
if (languageVersion === 1 /* ES5 */) {
// default value of configurable, enumerable, writable are `false`.
// default value of configurable, enumerable, writable are `false`.
write("Object.defineProperty(exports, \"__esModule\", { value: true });");
writeLine();
}
@@ -32812,7 +32853,7 @@ var ts;
// * The serialized type of an AccessorDeclaration is the serialized type of the return type annotation of its getter or parameter type annotation of its setter.
// * The serialized type of any other FunctionLikeDeclaration is "Function".
// * The serialized type of any other node is "void 0".
//
//
// For rules on serializing type annotations, see `serializeTypeNode`.
switch (node.kind) {
case 212 /* ClassDeclaration */:
@@ -32946,7 +32987,7 @@ var ts;
//
// * If the declaration is a class, the parameters of the first constructor with a body are used.
// * If the declaration is function-like and has a body, the parameters of the function are used.
//
//
// For the rules on serializing the type of each parameter declaration, see `serializeTypeOfDeclaration`.
if (node) {
var valueDeclaration;
@@ -34261,7 +34302,7 @@ var ts;
}
function trimReactWhitespaceAndApplyEntities(node) {
var result = undefined;
var text = ts.getTextOfNode(node);
var text = ts.getTextOfNode(node, /*includeTrivia*/ true);
var firstNonWhitespace = 0;
var lastNonWhitespace = -1;
// JSX trims whitespace at the end and beginning of lines, except that the
@@ -34312,7 +34353,7 @@ var ts;
}
case 1 /* Preserve */:
default:
return ts.getTextOfNode(node, true);
return ts.getTextOfNode(node, /*includeTrivia*/ true);
}
}
function emitJsxText(node) {
@@ -34324,7 +34365,7 @@ var ts;
break;
case 1 /* Preserve */:
default:
writer.writeLiteral(ts.getTextOfNode(node, true));
writer.writeLiteral(ts.getTextOfNode(node, /*includeTrivia*/ true));
break;
}
}
@@ -35092,6 +35133,7 @@ var ts;
})(ts || (ts = {}));
/// <reference path="sys.ts" />
/// <reference path="emitter.ts" />
/// <reference path="core.ts" />
var ts;
(function (ts) {
/* @internal */ ts.programTime = 0;
@@ -35124,11 +35166,128 @@ var ts;
}
ts.resolveTripleslashReference = resolveTripleslashReference;
function resolveModuleName(moduleName, containingFile, compilerOptions, host) {
// TODO: use different resolution strategy based on compiler options
return legacyNameResolver(moduleName, containingFile, compilerOptions, host);
var moduleResolution = compilerOptions.moduleResolution !== undefined
? compilerOptions.moduleResolution
: compilerOptions.module === 1 /* CommonJS */ ? 2 /* NodeJs */ : 1 /* Classic */;
switch (moduleResolution) {
case 2 /* NodeJs */: return nodeModuleNameResolver(moduleName, containingFile, host);
case 1 /* Classic */: return classicNameResolver(moduleName, containingFile, compilerOptions, host);
}
}
ts.resolveModuleName = resolveModuleName;
function legacyNameResolver(moduleName, containingFile, compilerOptions, host) {
function nodeModuleNameResolver(moduleName, containingFile, host) {
var containingDirectory = ts.getDirectoryPath(containingFile);
if (ts.getRootLength(moduleName) !== 0 || nameStartsWithDotSlashOrDotDotSlash(moduleName)) {
var failedLookupLocations = [];
var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName));
var resolvedFileName = loadNodeModuleFromFile(candidate, /* loadOnlyDts */ false, failedLookupLocations, host);
if (resolvedFileName) {
return { resolvedFileName: resolvedFileName, failedLookupLocations: failedLookupLocations };
}
resolvedFileName = loadNodeModuleFromDirectory(candidate, /* loadOnlyDts */ false, failedLookupLocations, host);
return { resolvedFileName: resolvedFileName, failedLookupLocations: failedLookupLocations };
}
else {
return loadModuleFromNodeModules(moduleName, containingDirectory, host);
}
}
ts.nodeModuleNameResolver = nodeModuleNameResolver;
function loadNodeModuleFromFile(candidate, loadOnlyDts, failedLookupLocation, host) {
if (loadOnlyDts) {
return tryLoad(".d.ts");
}
else {
return ts.forEach(ts.supportedExtensions, tryLoad);
}
function tryLoad(ext) {
var fileName = ts.fileExtensionIs(candidate, ext) ? candidate : candidate + ext;
if (host.fileExists(fileName)) {
return fileName;
}
else {
failedLookupLocation.push(fileName);
return undefined;
}
}
}
function loadNodeModuleFromDirectory(candidate, loadOnlyDts, failedLookupLocation, host) {
var packageJsonPath = ts.combinePaths(candidate, "package.json");
if (host.fileExists(packageJsonPath)) {
var jsonContent;
try {
var jsonText = host.readFile(packageJsonPath);
jsonContent = jsonText ? JSON.parse(jsonText) : { typings: undefined };
}
catch (e) {
// gracefully handle if readFile fails or returns not JSON
jsonContent = { typings: undefined };
}
if (jsonContent.typings) {
var result = loadNodeModuleFromFile(ts.normalizePath(ts.combinePaths(candidate, jsonContent.typings)), loadOnlyDts, failedLookupLocation, host);
if (result) {
return result;
}
}
}
else {
// record package json as one of failed lookup locations - in the future if this file will appear it will invalidate resolution results
failedLookupLocation.push(packageJsonPath);
}
return loadNodeModuleFromFile(ts.combinePaths(candidate, "index"), loadOnlyDts, failedLookupLocation, host);
}
function loadModuleFromNodeModules(moduleName, directory, host) {
var failedLookupLocations = [];
directory = ts.normalizeSlashes(directory);
while (true) {
var baseName = ts.getBaseFileName(directory);
if (baseName !== "node_modules") {
var nodeModulesFolder = ts.combinePaths(directory, "node_modules");
var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName));
var result = loadNodeModuleFromFile(candidate, /* loadOnlyDts */ true, failedLookupLocations, host);
if (result) {
return { resolvedFileName: result, failedLookupLocations: failedLookupLocations };
}
result = loadNodeModuleFromDirectory(candidate, /* loadOnlyDts */ true, failedLookupLocations, host);
if (result) {
return { resolvedFileName: result, failedLookupLocations: failedLookupLocations };
}
}
var parentPath = ts.getDirectoryPath(directory);
if (parentPath === directory) {
break;
}
directory = parentPath;
}
return { resolvedFileName: undefined, failedLookupLocations: failedLookupLocations };
}
function baseUrlModuleNameResolver(moduleName, containingFile, baseUrl, host) {
ts.Debug.assert(baseUrl !== undefined);
var normalizedModuleName = ts.normalizeSlashes(moduleName);
var basePart = useBaseUrl(moduleName) ? baseUrl : ts.getDirectoryPath(containingFile);
var candidate = ts.normalizePath(ts.combinePaths(basePart, moduleName));
var failedLookupLocations = [];
return ts.forEach(ts.supportedExtensions, function (ext) { return tryLoadFile(candidate + ext); }) || { resolvedFileName: undefined, failedLookupLocations: failedLookupLocations };
function tryLoadFile(location) {
if (host.fileExists(location)) {
return { resolvedFileName: location, failedLookupLocations: failedLookupLocations };
}
else {
failedLookupLocations.push(location);
return undefined;
}
}
}
ts.baseUrlModuleNameResolver = baseUrlModuleNameResolver;
function nameStartsWithDotSlashOrDotDotSlash(name) {
var i = name.lastIndexOf("./", 1);
return i === 0 || (i === 1 && name.charCodeAt(0) === 46 /* dot */);
}
function useBaseUrl(moduleName) {
// path is not rooted
// module name does not start with './' or '../'
return ts.getRootLength(moduleName) === 0 && !nameStartsWithDotSlashOrDotDotSlash(moduleName);
}
function classicNameResolver(moduleName, containingFile, compilerOptions, host) {
// module names that contain '!' are used to reference resources and are not resolved to actual files on disk
if (moduleName.indexOf('!') != -1) {
return { resolvedFileName: undefined, failedLookupLocations: [] };
@@ -35164,6 +35323,16 @@ var ts;
}
return { resolvedFileName: referencedSourceFile, failedLookupLocations: failedLookupLocations };
}
ts.classicNameResolver = classicNameResolver;
/* @internal */
ts.defaultInitCompilerOptions = {
module: 1 /* CommonJS */,
target: 0 /* ES3 */,
noImplicitAny: false,
outDir: "built",
rootDir: ".",
sourceMap: false
};
function createCompilerHost(options, setParentNodes) {
var currentDirectory;
var existingDirectories = {};
@@ -35908,6 +36077,11 @@ var ts;
type: "boolean",
description: ts.Diagnostics.Print_this_message
},
{
name: "init",
type: "boolean",
description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file
},
{
name: "inlineSourceMap",
type: "boolean"
@@ -36103,20 +36277,40 @@ var ts;
type: "boolean",
experimental: true,
description: ts.Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators
},
{
name: "moduleResolution",
type: {
"node": 2 /* NodeJs */,
"classic": 1 /* Classic */
},
experimental: true,
description: ts.Diagnostics.Specifies_module_resolution_strategy_Colon_node_Node_or_classic_TypeScript_pre_1_6
}
];
function parseCommandLine(commandLine) {
var options = {};
var fileNames = [];
var errors = [];
var shortOptionNames = {};
var optionNameMapCache;
/* @internal */
function getOptionNameMap() {
if (optionNameMapCache) {
return optionNameMapCache;
}
var optionNameMap = {};
var shortOptionNames = {};
ts.forEach(ts.optionDeclarations, function (option) {
optionNameMap[option.name.toLowerCase()] = option;
if (option.shortName) {
shortOptionNames[option.shortName] = option.name;
}
});
optionNameMapCache = { optionNameMap: optionNameMap, shortOptionNames: shortOptionNames };
return optionNameMapCache;
}
ts.getOptionNameMap = getOptionNameMap;
function parseCommandLine(commandLine) {
var options = {};
var fileNames = [];
var errors = [];
var _a = getOptionNameMap(), optionNameMap = _a.optionNameMap, shortOptionNames = _a.shortOptionNames;
parseStrings(commandLine);
return {
options: options,
@@ -38656,6 +38850,38 @@ var ts;
}
}
ts.hasDocComment = hasDocComment;
/**
* Get the corresponding JSDocTag node if the position is in a jsDoc comment
*/
function getJsDocTagAtPosition(sourceFile, position) {
var node = ts.getTokenAtPosition(sourceFile, position);
if (isToken(node)) {
switch (node.kind) {
case 100 /* VarKeyword */:
case 106 /* LetKeyword */:
case 72 /* ConstKeyword */:
// if the current token is var, let or const, skip the VariableDeclarationList
node = node.parent === undefined ? undefined : node.parent.parent;
break;
default:
node = node.parent;
break;
}
}
if (node) {
var jsDocComment = node.jsDocComment;
if (jsDocComment) {
for (var _i = 0, _a = jsDocComment.tags; _i < _a.length; _i++) {
var tag = _a[_i];
if (tag.pos <= position && position <= tag.end) {
return tag;
}
}
}
}
return undefined;
}
ts.getJsDocTagAtPosition = getJsDocTagAtPosition;
function nodeHasTokens(n) {
// If we have a token or node that has a non-zero width, it must have tokens.
// Note, that getWidth() does not take trivia into account.
@@ -39523,6 +39749,22 @@ var ts;
this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(37 /* AsteriskToken */, formatting.Shared.TokenRange.FromTokens([67 /* Identifier */, 17 /* OpenParenToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2 /* Space */));
this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(112 /* YieldKeyword */, 37 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8 /* Delete */));
this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([112 /* YieldKeyword */, 37 /* AsteriskToken */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2 /* Space */));
// Async-await
this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(116 /* AsyncKeyword */, 85 /* FunctionKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
this.NoSpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(116 /* AsyncKeyword */, 85 /* FunctionKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
this.SpaceAfterAwaitKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(117 /* AwaitKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
this.NoSpaceAfterAwaitKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(117 /* AwaitKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
// Type alias declaration
this.SpaceAfterTypeKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(130 /* TypeKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
this.NoSpaceAfterTypeKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(130 /* TypeKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
// template string
this.SpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(67 /* Identifier */, formatting.Shared.TokenRange.FromTokens([11 /* NoSubstitutionTemplateLiteral */, 12 /* TemplateHead */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
this.NoSpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(67 /* Identifier */, formatting.Shared.TokenRange.FromTokens([11 /* NoSubstitutionTemplateLiteral */, 12 /* TemplateHead */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
// union type
this.SpaceBeforeBar = new formatting.Rule(formatting.RuleDescriptor.create3(46 /* BarToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
this.NoSpaceBeforeBar = new formatting.Rule(formatting.RuleDescriptor.create3(46 /* BarToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
this.SpaceAfterBar = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 46 /* BarToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
this.NoSpaceAfterBar = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 46 /* BarToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
// These rules are higher in priority than user-configurable rules.
this.HighPriorityCommonRules =
[
@@ -39549,6 +39791,11 @@ var ts;
this.NoSpaceBeforeOpenParenInFuncCall,
this.SpaceBeforeBinaryKeywordOperator, this.SpaceAfterBinaryKeywordOperator,
this.SpaceAfterVoidOperator,
this.SpaceBetweenAsyncAndFunctionKeyword, this.NoSpaceBetweenAsyncAndFunctionKeyword,
this.SpaceAfterAwaitKeyword, this.NoSpaceAfterAwaitKeyword,
this.SpaceAfterTypeKeyword, this.NoSpaceAfterTypeKeyword,
this.SpaceBetweenTagAndTemplateString, this.NoSpaceBetweenTagAndTemplateString,
this.SpaceBeforeBar, this.NoSpaceBeforeBar, this.SpaceAfterBar, this.NoSpaceAfterBar,
// TypeScript-specific rules
this.NoSpaceAfterConstructor, this.NoSpaceAfterModuleImport,
this.SpaceAfterCertainTypeScriptKeywords, this.SpaceBeforeCertainTypeScriptKeywords,
@@ -41492,6 +41739,7 @@ var ts;
case 212 /* ClassDeclaration */:
case 213 /* InterfaceDeclaration */:
case 215 /* EnumDeclaration */:
case 214 /* TypeAliasDeclaration */:
case 162 /* ArrayLiteralExpression */:
case 190 /* Block */:
case 217 /* ModuleBlock */:
@@ -41513,6 +41761,16 @@ var ts;
case 160 /* ArrayBindingPattern */:
case 159 /* ObjectBindingPattern */:
case 231 /* JsxElement */:
case 140 /* MethodSignature */:
case 145 /* CallSignature */:
case 146 /* ConstructSignature */:
case 136 /* Parameter */:
case 150 /* FunctionType */:
case 151 /* ConstructorType */:
case 156 /* UnionType */:
case 158 /* ParenthesizedType */:
case 168 /* TaggedTemplateExpression */:
case 176 /* AwaitExpression */:
return true;
}
return false;
@@ -41531,8 +41789,6 @@ var ts;
case 211 /* FunctionDeclaration */:
case 171 /* FunctionExpression */:
case 141 /* MethodDeclaration */:
case 140 /* MethodSignature */:
case 145 /* CallSignature */:
case 172 /* ArrowFunction */:
case 142 /* Constructor */:
case 143 /* GetAccessor */:
@@ -41591,6 +41847,45 @@ var ts;
})(ScriptSnapshot = ts.ScriptSnapshot || (ts.ScriptSnapshot = {}));
var scanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ true);
var emptyArray = [];
var jsDocTagNames = [
"augments",
"author",
"argument",
"borrows",
"class",
"constant",
"constructor",
"constructs",
"default",
"deprecated",
"description",
"event",
"example",
"extends",
"field",
"fileOverview",
"function",
"ignore",
"inner",
"lends",
"link",
"memberOf",
"name",
"namespace",
"param",
"private",
"property",
"public",
"requires",
"returns",
"see",
"since",
"static",
"throws",
"type",
"version"
];
var jsDocCompletionEntries;
function createNode(kind, pos, end, flags, parent) {
var node = new (ts.getNodeConstructor(kind))();
node.pos = pos;
@@ -43614,6 +43909,7 @@ var ts;
var syntacticStart = new Date().getTime();
var sourceFile = getValidSourceFile(fileName);
var isJavaScriptFile = ts.isJavaScript(fileName);
var isJsDocTagName = false;
var start = new Date().getTime();
var currentToken = ts.getTokenAtPosition(sourceFile, position);
log("getCompletionData: Get current token: " + (new Date().getTime() - start));
@@ -43622,8 +43918,40 @@ var ts;
var insideComment = isInsideComment(sourceFile, currentToken, position);
log("getCompletionData: Is inside comment: " + (new Date().getTime() - start));
if (insideComment) {
log("Returning an empty list because completion was inside a comment.");
return undefined;
// The current position is next to the '@' sign, when no tag name being provided yet.
// Provide a full list of tag names
if (ts.hasDocComment(sourceFile, position) && sourceFile.text.charCodeAt(position - 1) === 64 /* at */) {
isJsDocTagName = true;
}
// Completion should work inside certain JsDoc tags. For example:
// /** @type {number | string} */
// Completion should work in the brackets
var insideJsDocTagExpression = false;
var tag = ts.getJsDocTagAtPosition(sourceFile, position);
if (tag) {
if (tag.tagName.pos <= position && position <= tag.tagName.end) {
isJsDocTagName = true;
}
switch (tag.kind) {
case 267 /* JSDocTypeTag */:
case 265 /* JSDocParameterTag */:
case 266 /* JSDocReturnTag */:
var tagWithExpression = tag;
if (tagWithExpression.typeExpression) {
insideJsDocTagExpression = tagWithExpression.typeExpression.pos < position && position < tagWithExpression.typeExpression.end;
}
break;
}
}
if (isJsDocTagName) {
return { symbols: undefined, isMemberCompletion: false, isNewIdentifierLocation: false, location: undefined, isRightOfDot: false, isJsDocTagName: isJsDocTagName };
}
if (!insideJsDocTagExpression) {
// Proceed if the current position is in jsDoc tag expression; otherwise it is a normal
// comment or the plain text part of a jsDoc comment, so no completion should be available
log("Returning an empty list because completion was inside a regular comment or plain text part of a JsDoc comment.");
return undefined;
}
}
start = new Date().getTime();
var previousToken = ts.findPrecedingToken(position, sourceFile);
@@ -43699,7 +44027,7 @@ var ts;
}
}
log("getCompletionData: Semantic work: " + (new Date().getTime() - semanticStart));
return { symbols: symbols, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: (isRightOfDot || isRightOfOpenTag) };
return { symbols: symbols, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), isJsDocTagName: isJsDocTagName };
function getTypeScriptMemberSymbols() {
// Right of dot member completion list
isMemberCompletion = true;
@@ -44083,9 +44411,10 @@ var ts;
containingNodeKind === 215 /* EnumDeclaration */ ||
isFunction(containingNodeKind) ||
containingNodeKind === 212 /* ClassDeclaration */ ||
containingNodeKind === 211 /* FunctionDeclaration */ ||
containingNodeKind === 184 /* ClassExpression */ ||
containingNodeKind === 213 /* InterfaceDeclaration */ ||
containingNodeKind === 160 /* ArrayBindingPattern */; // var [x, y|
containingNodeKind === 160 /* ArrayBindingPattern */ ||
containingNodeKind === 214 /* TypeAliasDeclaration */; // type Map, K, |
case 21 /* DotToken */:
return containingNodeKind === 160 /* ArrayBindingPattern */; // var [.|
case 53 /* ColonToken */:
@@ -44106,8 +44435,9 @@ var ts;
contextToken.parent.parent.kind === 153 /* TypeLiteral */); // let x : { a; |
case 25 /* LessThanToken */:
return containingNodeKind === 212 /* ClassDeclaration */ ||
containingNodeKind === 211 /* FunctionDeclaration */ ||
containingNodeKind === 184 /* ClassExpression */ ||
containingNodeKind === 213 /* InterfaceDeclaration */ ||
containingNodeKind === 214 /* TypeAliasDeclaration */ ||
isFunction(containingNodeKind);
case 111 /* StaticKeyword */:
return containingNodeKind === 139 /* PropertyDeclaration */;
@@ -44248,8 +44578,12 @@ var ts;
if (!completionData) {
return undefined;
}
var symbols = completionData.symbols, isMemberCompletion = completionData.isMemberCompletion, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, isRightOfDot = completionData.isRightOfDot;
var symbols = completionData.symbols, isMemberCompletion = completionData.isMemberCompletion, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, isRightOfDot = completionData.isRightOfDot, isJsDocTagName = completionData.isJsDocTagName;
var entries;
if (isJsDocTagName) {
// If the current position is a jsDoc tag name, only tag names should be provided for completion
return { isMemberCompletion: false, isNewIdentifierLocation: false, entries: getAllJsDocCompletionEntries() };
}
if (isRightOfDot && ts.isJavaScript(fileName)) {
entries = getCompletionEntriesFromSymbols(symbols);
ts.addRange(entries, getJavaScriptCompletionEntries());
@@ -44261,7 +44595,7 @@ var ts;
entries = getCompletionEntriesFromSymbols(symbols);
}
// Add keywords if this is not a member completion list
if (!isMemberCompletion) {
if (!isMemberCompletion && !isJsDocTagName) {
ts.addRange(entries, keywordCompletions);
}
return { isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, entries: entries };
@@ -44290,6 +44624,16 @@ var ts;
}
return entries;
}
function getAllJsDocCompletionEntries() {
return jsDocCompletionEntries || (jsDocCompletionEntries = ts.map(jsDocTagNames, function (tagName) {
return {
name: tagName,
kind: ScriptElementKind.keyword,
kindModifiers: "",
sortText: "0"
};
}));
}
function createCompletionEntry(symbol, location) {
// Try to get a valid display name for this symbol, if we could not find one, then ignore it.
// We would like to only show things that can be added after a dot, so for instance numeric properties can
@@ -44601,6 +44945,7 @@ var ts;
displayParts.push(ts.keywordPart(130 /* TypeKeyword */));
displayParts.push(ts.spacePart());
addFullSymbolName(symbol);
writeTypeParametersOfSymbol(symbol, sourceFile);
displayParts.push(ts.spacePart());
displayParts.push(ts.operatorPart(55 /* EqualsToken */));
displayParts.push(ts.spacePart());
@@ -44641,16 +44986,29 @@ var ts;
}
else {
// Method/function type parameter
var signatureDeclaration = ts.getDeclarationOfKind(symbol, 135 /* TypeParameter */).parent;
var signature = typeChecker.getSignatureFromDeclaration(signatureDeclaration);
if (signatureDeclaration.kind === 146 /* ConstructSignature */) {
displayParts.push(ts.keywordPart(90 /* NewKeyword */));
var container = ts.getContainingFunction(location);
if (container) {
var signatureDeclaration = ts.getDeclarationOfKind(symbol, 135 /* TypeParameter */).parent;
var signature = typeChecker.getSignatureFromDeclaration(signatureDeclaration);
if (signatureDeclaration.kind === 146 /* ConstructSignature */) {
displayParts.push(ts.keywordPart(90 /* NewKeyword */));
displayParts.push(ts.spacePart());
}
else if (signatureDeclaration.kind !== 145 /* CallSignature */ && signatureDeclaration.name) {
addFullSymbolName(signatureDeclaration.symbol);
}
ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */));
}
else {
// Type aliash type parameter
// For example
// type list<T> = T[]; // Both T will go through same code path
var declaration = ts.getDeclarationOfKind(symbol, 135 /* TypeParameter */).parent;
displayParts.push(ts.keywordPart(130 /* TypeKeyword */));
displayParts.push(ts.spacePart());
addFullSymbolName(declaration.symbol);
writeTypeParametersOfSymbol(declaration.symbol, sourceFile);
}
else if (signatureDeclaration.kind !== 145 /* CallSignature */ && signatureDeclaration.name) {
addFullSymbolName(signatureDeclaration.symbol);
}
ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */));
}
}
if (symbolFlags & 8 /* EnumMember */) {
@@ -44863,9 +45221,15 @@ var ts;
// and in either case the symbol has a construct signature definition, i.e. class
if (isNewExpressionTarget(location) || location.kind === 119 /* ConstructorKeyword */) {
if (symbol.flags & 32 /* Class */) {
var classDeclaration = symbol.getDeclarations()[0];
ts.Debug.assert(classDeclaration && classDeclaration.kind === 212 /* ClassDeclaration */);
return tryAddSignature(classDeclaration.members, /*selectConstructors*/ true, symbolKind, symbolName, containerName, result);
// Find the first class-like declaration and try to get the construct signature.
for (var _i = 0, _a = symbol.getDeclarations(); _i < _a.length; _i++) {
var declaration = _a[_i];
if (ts.isClassLike(declaration)) {
return tryAddSignature(declaration.members,
/*selectConstructors*/ true, symbolKind, symbolName, containerName, result);
}
}
ts.Debug.fail("Expected declaration to have at least one class-like declaration");
}
}
return false;
+2 -1
View File
@@ -2,7 +2,7 @@
"name": "typescript",
"author": "Microsoft Corp.",
"homepage": "http://typescriptlang.org/",
"version": "1.6.0",
"version": "1.7.0",
"license": "Apache-2.0",
"description": "TypeScript is a language for application scale JavaScript development",
"keywords": [
@@ -20,6 +20,7 @@
"url": "https://github.com/Microsoft/TypeScript.git"
},
"main": "./lib/typescript.js",
"typings": "./lib/typescript.d.ts",
"bin": {
"tsc": "./bin/tsc",
"tsserver": "./bin/tsserver"
+5 -1
View File
@@ -973,6 +973,10 @@ namespace ts {
else {
let bindingName = node.name ? node.name.text : "__class";
bindAnonymousDeclaration(node, SymbolFlags.Class, bindingName);
// Add name of class expression into the map for semantic classifier
if (node.name) {
classifiableNames[node.name.text] = node.name.text;
}
}
let symbol = node.symbol;
@@ -1062,4 +1066,4 @@ namespace ts {
: declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes);
}
}
}
}
+19 -5
View File
@@ -1893,7 +1893,7 @@ namespace ts {
function buildTypeParameterDisplayFromSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaraiton?: Node, flags?: TypeFormatFlags) {
let targetSymbol = getTargetSymbol(symbol);
if (targetSymbol.flags & SymbolFlags.Class || targetSymbol.flags & SymbolFlags.Interface) {
if (targetSymbol.flags & SymbolFlags.Class || targetSymbol.flags & SymbolFlags.Interface || targetSymbol.flags & SymbolFlags.TypeAlias) {
buildDisplayForTypeParametersAndDelimiters(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), writer, enclosingDeclaraiton, flags);
}
}
@@ -3119,7 +3119,7 @@ namespace ts {
}
function resolveTupleTypeMembers(type: TupleType) {
let arrayType = resolveStructuredTypeMembers(createArrayType(getUnionType(type.elementTypes)));
let arrayType = resolveStructuredTypeMembers(createArrayType(getUnionType(type.elementTypes, /*noDeduplication*/ true)));
let members = createTupleTypeMemberSymbols(type.elementTypes);
addInheritedMembers(members, arrayType.properties);
setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType);
@@ -4487,6 +4487,15 @@ namespace ts {
}
function instantiateAnonymousType(type: ObjectType, mapper: TypeMapper): ObjectType {
if (mapper.instantiations) {
let cachedType = mapper.instantiations[type.id];
if (cachedType) {
return cachedType;
}
}
else {
mapper.instantiations = [];
}
// Mark the anonymous type as instantiated such that our infinite instantiation detection logic can recognize it
let result = <ResolvedType>createObjectType(TypeFlags.Anonymous | TypeFlags.Instantiated, type.symbol);
result.properties = instantiateList(getPropertiesOfObjectType(type), mapper, instantiateSymbol);
@@ -4497,6 +4506,7 @@ namespace ts {
let numberIndexType = getIndexTypeOfType(type, IndexKind.Number);
if (stringIndexType) result.stringIndexType = instantiateType(stringIndexType, mapper);
if (numberIndexType) result.numberIndexType = instantiateType(numberIndexType, mapper);
mapper.instantiations[type.id] = result;
return result;
}
@@ -7151,7 +7161,7 @@ namespace ts {
let propertiesTable: SymbolTable = {};
let propertiesArray: Symbol[] = [];
let contextualType = getContextualType(node);
let typeFlags: TypeFlags;
let typeFlags: TypeFlags = 0;
for (let memberDecl of node.properties) {
let member = memberDecl.symbol;
@@ -7200,7 +7210,8 @@ namespace ts {
let stringIndexType = getIndexType(IndexKind.String);
let numberIndexType = getIndexType(IndexKind.Number);
let result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType);
result.flags |= TypeFlags.ObjectLiteral | TypeFlags.FreshObjectLiteral | TypeFlags.ContainsObjectLiteral | (typeFlags & TypeFlags.PropagatingFlags);
let freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : TypeFlags.FreshObjectLiteral;
result.flags |= TypeFlags.ObjectLiteral | TypeFlags.ContainsObjectLiteral | freshObjectLiteralFlag | (typeFlags & TypeFlags.PropagatingFlags);
return result;
function getIndexType(kind: IndexKind) {
@@ -12603,6 +12614,7 @@ namespace ts {
if (baseTypes.length && produceDiagnostics) {
let baseType = baseTypes[0];
let staticBaseType = getBaseConstructorTypeOfClass(type);
checkSourceElement(baseTypeNode.expression);
if (baseTypeNode.typeArguments) {
forEach(baseTypeNode.typeArguments, checkSourceElement);
for (let constructor of getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments)) {
@@ -13053,7 +13065,7 @@ namespace ts {
// illegal case: forward reference
if (!isDefinedBefore(propertyDecl, member)) {
reportError = false;
error(e, Diagnostics.A_member_initializer_in_a_const_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_const_enums);
error(e, Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums);
return undefined;
}
@@ -13672,6 +13684,8 @@ namespace ts {
case SyntaxKind.VariableDeclaration:
case SyntaxKind.VariableDeclarationList:
case SyntaxKind.ClassDeclaration:
case SyntaxKind.HeritageClause:
case SyntaxKind.ExpressionWithTypeArguments:
case SyntaxKind.EnumDeclaration:
case SyntaxKind.EnumMember:
case SyntaxKind.ExportAssignment:
+38 -8
View File
@@ -30,6 +30,11 @@ namespace ts {
type: "boolean",
description: Diagnostics.Print_this_message,
},
{
name: "init",
type: "boolean",
description: Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file,
},
{
name: "inlineSourceMap",
type: "boolean",
@@ -179,6 +184,12 @@ namespace ts {
description: Diagnostics.Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations,
paramType: Diagnostics.LOCATION,
},
{
name: "suppressExcessPropertyErrors",
type: "boolean",
description: Diagnostics.Suppress_excess_property_checks_for_object_literals,
experimental: true
},
{
name: "suppressImplicitAnyIndexErrors",
type: "boolean",
@@ -237,19 +248,38 @@ namespace ts {
}
];
export function parseCommandLine(commandLine: string[]): ParsedCommandLine {
let options: CompilerOptions = {};
let fileNames: string[] = [];
let errors: Diagnostic[] = [];
let shortOptionNames: Map<string> = {};
let optionNameMap: Map<CommandLineOption> = {};
/* @internal */
export interface OptionNameMap {
optionNameMap: Map<CommandLineOption>;
shortOptionNames: Map<string>;
}
let optionNameMapCache: OptionNameMap;
/* @internal */
export function getOptionNameMap(): OptionNameMap {
if (optionNameMapCache) {
return optionNameMapCache;
}
let optionNameMap: Map<CommandLineOption> = {};
let shortOptionNames: Map<string> = {};
forEach(optionDeclarations, option => {
optionNameMap[option.name.toLowerCase()] = option;
if (option.shortName) {
shortOptionNames[option.shortName] = option.name;
}
});
optionNameMapCache = { optionNameMap, shortOptionNames };
return optionNameMapCache;
}
export function parseCommandLine(commandLine: string[], readFile?: (path: string) => string): ParsedCommandLine {
let options: CompilerOptions = {};
let fileNames: string[] = [];
let errors: Diagnostic[] = [];
let { optionNameMap, shortOptionNames } = getOptionNameMap();
parseStrings(commandLine);
return {
options,
@@ -313,7 +343,7 @@ namespace ts {
}
function parseResponseFile(fileName: string) {
let text = sys.readFile(fileName);
let text = readFile ? readFile(fileName) : sys.readFile(fileName);
if (!text) {
errors.push(createCompilerDiagnostic(Diagnostics.File_0_not_found, fileName));
@@ -466,4 +496,4 @@ namespace ts {
return fileNames;
}
}
}
}
+4 -4
View File
@@ -287,14 +287,14 @@ namespace ts {
return <T>result;
}
export function extend<T>(first: Map<T>, second: Map<T>): Map<T> {
let result: Map<T> = {};
export function extend<T1, T2>(first: Map<T1>, second: Map<T2>): Map<T1 & T2> {
let result: Map<T1 & T2> = {};
for (let id in first) {
result[id] = first[id];
(result as any)[id] = first[id];
}
for (let id in second) {
if (!hasProperty(result, id)) {
result[id] = second[id];
(result as any)[id] = second[id];
}
}
return result;
+3
View File
@@ -896,6 +896,9 @@ namespace ts {
if (isSupportedExpressionWithTypeArguments(node)) {
emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError);
}
else if (!isImplementsList && node.expression.kind === SyntaxKind.NullKeyword) {
write("null");
}
function getHeritageClauseVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult): SymbolAccessibilityDiagnostic {
let diagnosticMessage: DiagnosticMessage;
@@ -425,7 +425,7 @@ namespace ts {
JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: { code: 2607, category: DiagnosticCategory.Error, key: "JSX element class does not support attributes because it does not have a '{0}' property" },
The_global_type_JSX_0_may_not_have_more_than_one_property: { code: 2608, category: DiagnosticCategory.Error, key: "The global type 'JSX.{0}' may not have more than one property" },
Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: DiagnosticCategory.Error, key: "Cannot emit namespaced JSX elements in React" },
A_member_initializer_in_a_const_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_const_enums: { code: 2651, category: DiagnosticCategory.Error, key: "A member initializer in a 'const' enum declaration cannot reference members declared after it, including members defined in other 'const' enums." },
A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: DiagnosticCategory.Error, key: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums." },
Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: DiagnosticCategory.Error, key: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." },
Import_declaration_0_is_using_private_name_1: { code: 4000, category: DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." },
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." },
@@ -511,6 +511,7 @@ namespace ts {
Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: { code: 5051, category: DiagnosticCategory.Error, key: "Option 'inlineSources' can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided." },
Option_0_cannot_be_specified_without_specifying_option_1: { code: 5052, category: DiagnosticCategory.Error, key: "Option '{0}' cannot be specified without specifying option '{1}'." },
Option_0_cannot_be_specified_with_option_1: { code: 5053, category: DiagnosticCategory.Error, key: "Option '{0}' cannot be specified with option '{1}'." },
A_tsconfig_json_file_is_already_defined_at_Colon_0: { code: 5053, category: DiagnosticCategory.Error, key: "A 'tsconfig.json' file is already defined at: '{0}'." },
Concatenate_and_emit_output_to_single_file: { code: 6001, category: DiagnosticCategory.Message, key: "Concatenate and emit output to single file." },
Generates_corresponding_d_ts_file: { code: 6002, category: DiagnosticCategory.Message, key: "Generates corresponding '.d.ts' file." },
Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: { code: 6003, category: DiagnosticCategory.Message, key: "Specifies the location where debugger should locate map files instead of generated locations." },
@@ -566,6 +567,9 @@ namespace ts {
Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower: { code: 6067, category: DiagnosticCategory.Message, key: "Option 'experimentalAsyncFunctions' cannot be specified when targeting ES5 or lower." },
Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: DiagnosticCategory.Message, key: "Enables experimental support for ES7 async functions." },
Specifies_module_resolution_strategy_Colon_node_Node_or_classic_TypeScript_pre_1_6: { code: 6069, category: DiagnosticCategory.Message, key: "Specifies module resolution strategy: 'node' (Node) or 'classic' (TypeScript pre 1.6) ." },
Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: DiagnosticCategory.Message, key: "Initializes a TypeScript project and creates a tsconfig.json file." },
Successfully_created_a_tsconfig_json_file: { code: 6071, category: DiagnosticCategory.Message, key: "Successfully created a tsconfig.json file." },
Suppress_excess_property_checks_for_object_literals: { code: 6072, category: DiagnosticCategory.Message, key: "Suppress excess property checks for object literals." },
Variable_0_implicitly_has_an_1_type: { code: 7005, category: DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." },
Parameter_0_implicitly_has_an_1_type: { code: 7006, category: DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." },
Member_0_implicitly_has_an_1_type: { code: 7008, category: DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." },
+19 -3
View File
@@ -161,7 +161,7 @@
},
"Type '{0}' is not a valid async function return type.": {
"category": "Error",
"code": 1055
"code": 1055
},
"Accessors are only available when targeting ECMAScript 5 and higher.": {
"category": "Error",
@@ -1689,7 +1689,7 @@
"category": "Error",
"code": 2650
},
"A member initializer in a 'const' enum declaration cannot reference members declared after it, including members defined in other 'const' enums.": {
"A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums.": {
"category": "Error",
"code": 2651
},
@@ -2033,7 +2033,11 @@
"category": "Error",
"code": 5053
},
"A 'tsconfig.json' file is already defined at: '{0}'.": {
"category": "Error",
"code": 5053
},
"Concatenate and emit output to single file.": {
"category": "Message",
"code": 6001
@@ -2254,6 +2258,18 @@
"category": "Message",
"code": 6069
},
"Initializes a TypeScript project and creates a tsconfig.json file.": {
"category": "Message",
"code": 6070
},
"Successfully created a tsconfig.json file.": {
"category": "Message",
"code": 6071
},
"Suppress excess property checks for object literals.": {
"category": "Message",
"code": 6072
},
"Variable '{0}' implicitly has an '{1}' type.": {
"category": "Error",
+70 -68
View File
@@ -124,11 +124,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
function emitJavaScript(jsFilePath: string, root?: SourceFile) {
let writer = createTextWriter(newLine);
let write = writer.write;
let writeTextOfNode = writer.writeTextOfNode;
let writeLine = writer.writeLine;
let increaseIndent = writer.increaseIndent;
let decreaseIndent = writer.decreaseIndent;
let { write, writeTextOfNode, writeLine, increaseIndent, decreaseIndent } = writer;
let currentSourceFile: SourceFile;
// name of an exporter function if file is a System external module
@@ -1181,9 +1177,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
}
function emitJsxElement(openingNode: JsxOpeningLikeElement, children?: JsxChild[]) {
let syntheticReactRef = <Identifier>createSynthesizedNode(SyntaxKind.Identifier);
syntheticReactRef.text = 'React';
syntheticReactRef.parent = openingNode;
// Call React.createElement(tag, ...
emitLeadingComments(openingNode);
write("React.createElement(");
emitExpressionIdentifier(syntheticReactRef);
write(".createElement(");
emitTagName(openingNode.tagName);
write(", ");
@@ -1197,7 +1198,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
// a call to React.__spread
let attrs = openingNode.attributes;
if (forEach(attrs, attr => attr.kind === SyntaxKind.JsxSpreadAttribute)) {
write("React.__spread(");
emitExpressionIdentifier(syntheticReactRef);
write(".__spread(");
let haveOpenedObjectLiteral = false;
for (let i = 0; i < attrs.length; i++) {
@@ -2114,7 +2116,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
emit(node.name);
decreaseIndentIf(indentedBeforeDot, indentedAfterDot);
}
function emitQualifiedName(node: QualifiedName) {
emit(node.left);
write(".");
@@ -2137,12 +2139,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
else {
emitEntityNameAsExpression(node.left, /*useFallback*/ false);
}
write(".");
emit(node.right);
}
function emitEntityNameAsExpression(node: EntityName, useFallback: boolean) {
function emitEntityNameAsExpression(node: EntityName, useFallback: boolean) {
switch (node.kind) {
case SyntaxKind.Identifier:
if (useFallback) {
@@ -2150,10 +2152,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
emitExpressionIdentifier(<Identifier>node);
write(" !== 'undefined' && ");
}
emitExpressionIdentifier(<Identifier>node);
break;
case SyntaxKind.QualifiedName:
emitQualifiedNameAsExpression(<QualifiedName>node, useFallback);
break;
@@ -3064,7 +3066,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
if (compilerOptions.module === ModuleKind.CommonJS || compilerOptions.module === ModuleKind.AMD || compilerOptions.module === ModuleKind.UMD) {
if (!currentSourceFile.symbol.exports["___esModule"]) {
if (languageVersion === ScriptTarget.ES5) {
// default value of configurable, enumerable, writable are `false`.
// default value of configurable, enumerable, writable are `false`.
write("Object.defineProperty(exports, \"__esModule\", { value: true });");
writeLine();
}
@@ -4320,7 +4322,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
if (ctor) {
// Emit all the directive prologues (like "use strict"). These have to come before
// any other preamble code we write (like parameter initializers).
startIndex = emitDirectivePrologues(ctor.body.statements, /*startWithNewLine*/ true);
startIndex = emitDirectivePrologues(ctor.body.statements, /*startWithNewLine*/ true);
emitDetachedComments(ctor.body.statements);
}
emitCaptureThisForNodeIfNecessary(node);
@@ -4892,7 +4894,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
}
return false;
}
/** Serializes the type of a declaration to an appropriate JS constructor value. Used by the __metadata decorator for a class member. */
function emitSerializedTypeOfNode(node: Node) {
// serialization of the type of a declaration uses the following rules:
@@ -4903,39 +4905,39 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
// * The serialized type of an AccessorDeclaration is the serialized type of the return type annotation of its getter or parameter type annotation of its setter.
// * The serialized type of any other FunctionLikeDeclaration is "Function".
// * The serialized type of any other node is "void 0".
//
//
// For rules on serializing type annotations, see `serializeTypeNode`.
switch (node.kind) {
case SyntaxKind.ClassDeclaration:
write("Function");
return;
case SyntaxKind.PropertyDeclaration:
case SyntaxKind.PropertyDeclaration:
emitSerializedTypeNode((<PropertyDeclaration>node).type);
return;
case SyntaxKind.Parameter:
case SyntaxKind.Parameter:
emitSerializedTypeNode((<ParameterDeclaration>node).type);
return;
case SyntaxKind.GetAccessor:
case SyntaxKind.GetAccessor:
emitSerializedTypeNode((<AccessorDeclaration>node).type);
return;
case SyntaxKind.SetAccessor:
case SyntaxKind.SetAccessor:
emitSerializedTypeNode(getSetAccessorTypeAnnotationNode(<AccessorDeclaration>node));
return;
}
if (isFunctionLike(node)) {
write("Function");
return;
}
write("void 0");
}
function emitSerializedTypeNode(node: TypeNode) {
if (!node) {
return;
@@ -4949,17 +4951,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
case SyntaxKind.ParenthesizedType:
emitSerializedTypeNode((<ParenthesizedTypeNode>node).type);
return;
case SyntaxKind.FunctionType:
case SyntaxKind.ConstructorType:
write("Function");
return;
case SyntaxKind.ArrayType:
case SyntaxKind.TupleType:
write("Array");
return;
case SyntaxKind.TypePredicate:
case SyntaxKind.BooleanKeyword:
write("Boolean");
@@ -4969,11 +4971,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
case SyntaxKind.StringLiteral:
write("String");
return;
case SyntaxKind.NumberKeyword:
write("Number");
return;
case SyntaxKind.SymbolKeyword:
write("Symbol");
return;
@@ -4981,22 +4983,22 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
case SyntaxKind.TypeReference:
emitSerializedTypeReferenceNode(<TypeReferenceNode>node);
return;
case SyntaxKind.TypeQuery:
case SyntaxKind.TypeLiteral:
case SyntaxKind.UnionType:
case SyntaxKind.IntersectionType:
case SyntaxKind.AnyKeyword:
break;
default:
Debug.fail("Cannot serialize unexpected type node.");
break;
}
write("Object");
}
/** Serializes a TypeReferenceNode to an appropriate JS constructor value. Used by the __metadata decorator. */
function emitSerializedTypeReferenceNode(node: TypeReferenceNode) {
let location: Node = node.parent;
@@ -5024,27 +5026,27 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
case TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue:
emitEntityNameAsExpression(typeName, /*useFallback*/ false);
break;
case TypeReferenceSerializationKind.VoidType:
write("void 0");
break;
case TypeReferenceSerializationKind.BooleanType:
write("Boolean");
break;
case TypeReferenceSerializationKind.NumberLikeType:
write("Number");
break;
case TypeReferenceSerializationKind.StringLikeType:
write("String");
break;
case TypeReferenceSerializationKind.ArrayLikeType:
write("Array");
break;
case TypeReferenceSerializationKind.ESSymbolType:
if (languageVersion < ScriptTarget.ES6) {
write("typeof Symbol === 'function' ? Symbol : Object");
@@ -5053,24 +5055,24 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
write("Symbol");
}
break;
case TypeReferenceSerializationKind.TypeWithCallSignature:
write("Function");
break;
case TypeReferenceSerializationKind.ObjectType:
write("Object");
break;
}
}
/** Serializes the parameter types of a function or the constructor of a class. Used by the __metadata decorator for a method or set accessor. */
function emitSerializedParameterTypesOfNode(node: Node) {
// serialization of parameter types uses the following rules:
//
// * If the declaration is a class, the parameters of the first constructor with a body are used.
// * If the declaration is function-like and has a body, the parameters of the function are used.
//
//
// For the rules on serializing the type of each parameter declaration, see `serializeTypeOfDeclaration`.
if (node) {
let valueDeclaration: FunctionLikeDeclaration;
@@ -5080,7 +5082,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
else if (isFunctionLike(node) && nodeIsPresent((<FunctionLikeDeclaration>node).body)) {
valueDeclaration = <FunctionLikeDeclaration>node;
}
if (valueDeclaration) {
const parameters = valueDeclaration.parameters;
const parameterCount = parameters.length;
@@ -5089,7 +5091,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
if (i > 0) {
write(", ");
}
if (parameters[i].dotDotDotToken) {
let parameterType = parameters[i].type;
if (parameterType.kind === SyntaxKind.ArrayType) {
@@ -5101,7 +5103,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
else {
parameterType = undefined;
}
emitSerializedTypeNode(parameterType);
}
else {
@@ -5112,18 +5114,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
}
}
}
/** Serializes the return type of function. Used by the __metadata decorator for a method. */
function emitSerializedReturnTypeOfNode(node: Node): string | string[] {
if (node && isFunctionLike(node) && (<FunctionLikeDeclaration>node).type) {
emitSerializedTypeNode((<FunctionLikeDeclaration>node).type);
return;
}
write("void 0");
}
function emitSerializedTypeMetadata(node: Declaration, writeComma: boolean): number {
// This method emits the serialized type metadata for a decorator target.
// The caller should have already tested whether the node has decorators.
@@ -5153,7 +5155,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
if (writeComma || argumentsWritten) {
write(", ");
}
writeLine();
write("__metadata('design:returntype', ");
emitSerializedReturnTypeOfNode(node);
@@ -5161,10 +5163,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
argumentsWritten++;
}
}
return argumentsWritten;
}
function emitInterfaceDeclaration(node: InterfaceDeclaration) {
emitOnlyPinnedOrTripleSlashComments(node);
}
@@ -5530,18 +5532,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
(!isExternalModule(currentSourceFile) && resolver.isTopLevelValueImportEqualsWithEntityName(node))) {
emitLeadingComments(node);
emitStart(node);
// variable declaration for import-equals declaration can be hoisted in system modules
// in this case 'var' should be omitted and emit should contain only initialization
let variableDeclarationIsHoisted = shouldHoistVariable(node, /*checkIfSourceFileLevelDecl*/ true);
// is it top level export import v = a.b.c in system module?
// if yes - it needs to be rewritten as exporter('v', v = a.b.c)
let isExported = isSourceFileLevelDeclarationInSystemJsModule(node, /*isExported*/ true);
if (!variableDeclarationIsHoisted) {
Debug.assert(!isExported);
if (isES6ExportedDeclaration(node)) {
write("export ");
write("var ");
@@ -5550,8 +5552,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
write("var ");
}
}
if (isExported) {
write(`${exportFunctionForFile}("`);
emitNodeWithoutSourceMap(node.name);
@@ -5565,8 +5567,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
if (isExported) {
write(")");
}
write(";");
write(";");
emitEnd(node);
emitExportImportAssignments(node);
emitTrailingComments(node);
@@ -6088,12 +6090,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
}
return;
}
if (isInternalModuleImportEqualsDeclaration(node)) {
if (!hoistedVars) {
hoistedVars = [];
}
hoistedVars.push(node.name);
return;
}
+4 -1
View File
@@ -4941,12 +4941,15 @@ namespace ts {
function parseModuleOrNamespaceDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray, flags: NodeFlags): ModuleDeclaration {
let node = <ModuleDeclaration>createNode(SyntaxKind.ModuleDeclaration, fullStart);
// If we are parsing a dotted namespace name, we want to
// propagate the 'Namespace' flag across the names if set.
let namespaceFlag = flags & NodeFlags.Namespace;
node.decorators = decorators;
setModifiers(node, modifiers);
node.flags |= flags;
node.name = parseIdentifier();
node.body = parseOptional(SyntaxKind.DotToken)
? parseModuleOrNamespaceDeclaration(getNodePos(), /*decorators*/ undefined, /*modifiers*/ undefined, NodeFlags.Export)
? parseModuleOrNamespaceDeclaration(getNodePos(), /*decorators*/ undefined, /*modifiers*/ undefined, NodeFlags.Export | namespaceFlag)
: parseModuleBlock();
return finishNode(node);
}
+12 -1
View File
@@ -1,5 +1,6 @@
/// <reference path="sys.ts" />
/// <reference path="emitter.ts" />
/// <reference path="core.ts" />
namespace ts {
/* @internal */ export let programTime = 0;
@@ -11,7 +12,7 @@ namespace ts {
let emptyArray: any[] = [];
export const version = "1.6.0";
export const version = "1.7.0";
export function findConfigFile(searchPath: string): string {
let fileName = "tsconfig.json";
@@ -224,6 +225,16 @@ namespace ts {
return { resolvedFileName: referencedSourceFile, failedLookupLocations };
}
/* @internal */
export const defaultInitCompilerOptions: CompilerOptions = {
module: ModuleKind.CommonJS,
target: ScriptTarget.ES3,
noImplicitAny: false,
outDir: "built",
rootDir: ".",
sourceMap: false,
};
export function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost {
let currentDirectory: string;
let existingDirectories: Map<boolean> = {};
+69
View File
@@ -159,6 +159,11 @@ namespace ts {
return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
}
if (commandLine.options.init) {
writeConfigFile(commandLine.options, commandLine.fileNames);
return sys.exit(ExitStatus.Success);
}
if (commandLine.options.version) {
reportDiagnostic(createCompilerDiagnostic(Diagnostics.Version_0, ts.version));
return sys.exit(ExitStatus.Success);
@@ -489,6 +494,70 @@ namespace ts {
return Array(paddingLength + 1).join(" ");
}
}
function writeConfigFile(options: CompilerOptions, fileNames: string[]) {
let currentDirectory = sys.getCurrentDirectory();
let file = combinePaths(currentDirectory, 'tsconfig.json');
if (sys.fileExists(file)) {
reportDiagnostic(createCompilerDiagnostic(Diagnostics.A_tsconfig_json_file_is_already_defined_at_Colon_0, file));
}
else {
let compilerOptions = extend(options, defaultInitCompilerOptions);
let configurations: any = {
compilerOptions: serializeCompilerOptions(compilerOptions),
exclude: ["node_modules"]
};
if (fileNames && fileNames.length) {
// only set the files property if we have at least one file
configurations.files = fileNames;
}
sys.writeFile(file, JSON.stringify(configurations, undefined, 4));
reportDiagnostic(createCompilerDiagnostic(Diagnostics.Successfully_created_a_tsconfig_json_file));
}
return;
function serializeCompilerOptions(options: CompilerOptions): Map<string|number|boolean> {
let result: Map<string|number|boolean> = {};
let optionsNameMap = getOptionNameMap().optionNameMap;
for (let name in options) {
if (hasProperty(options, name)) {
let value = options[name];
switch (name) {
case "init":
case "watch":
case "version":
case "help":
case "project":
break;
default:
let optionDefinition = optionsNameMap[name.toLowerCase()];
if (optionDefinition) {
if (typeof optionDefinition.type === "string") {
// string, number or boolean
result[name] = value;
}
else {
// Enum
let typeMap = <Map<number>>optionDefinition.type;
for (let key in typeMap) {
if (hasProperty(typeMap, key)) {
if (typeMap[key] === value)
result[name] = key;
}
}
}
}
break;
}
}
}
return result;
}
}
}
ts.executeCommandLine(ts.sys.args);
+5 -2
View File
@@ -1552,8 +1552,8 @@ namespace ts {
export interface SymbolAccessiblityResult extends SymbolVisibilityResult {
errorModuleName?: string; // If the symbol is not visible from module, module's name
}
/** Indicates how to serialize the name for a TypeReferenceNode when emitting decorator
/** Indicates how to serialize the name for a TypeReferenceNode when emitting decorator
* metadata */
/* @internal */
export enum TypeReferenceSerializationKind {
@@ -1953,6 +1953,7 @@ namespace ts {
/* @internal */
export interface TypeMapper {
(t: TypeParameter): Type;
instantiations?: Type[]; // Cache of instantiations created using this type mapper.
context?: InferenceContext; // The inference context this mapper was created from.
// Only inference mappers have this set (in createInferenceMapper).
// The identity mapper and regular instantiation mappers do not need it.
@@ -2022,6 +2023,7 @@ namespace ts {
diagnostics?: boolean;
emitBOM?: boolean;
help?: boolean;
init?: boolean;
inlineSourceMap?: boolean;
inlineSources?: boolean;
jsx?: JsxEmit;
@@ -2046,6 +2048,7 @@ namespace ts {
rootDir?: string;
sourceMap?: boolean;
sourceRoot?: string;
suppressExcessPropertyErrors?: boolean;
suppressImplicitAnyIndexErrors?: boolean;
target?: ScriptTarget;
version?: boolean;
+2 -2
View File
@@ -611,11 +611,11 @@ namespace ts {
return false;
}
export function isAccessor(node: Node): boolean {
export function isAccessor(node: Node): node is AccessorDeclaration {
return node && (node.kind === SyntaxKind.GetAccessor || node.kind === SyntaxKind.SetAccessor);
}
export function isClassLike(node: Node): boolean {
export function isClassLike(node: Node): node is ClassLikeDeclaration {
return node && (node.kind === SyntaxKind.ClassDeclaration || node.kind === SyntaxKind.ClassExpression);
}
+34 -10
View File
@@ -425,6 +425,9 @@ module Harness {
listFiles(path: string, filter: RegExp, options?: { recursive?: boolean }): string[];
log(text: string): void;
getMemoryUsage?(): number;
args(): string[];
getExecutingFilePath(): string;
exit(exitCode?: number): void;
}
export var IO: IO;
@@ -446,7 +449,10 @@ module Harness {
} else {
fso = {};
}
export const args = () => ts.sys.args;
export const getExecutingFilePath = () => ts.sys.getExecutingFilePath();
export const exit = (exitCode: number) => ts.sys.exit(exitCode);
export const resolvePath = (path: string) => ts.sys.resolvePath(path);
export const getCurrentDirectory = () => ts.sys.getCurrentDirectory();
export const newLine = () => harnessNewLine;
@@ -517,6 +523,9 @@ module Harness {
export const getCurrentDirectory = () => ts.sys.getCurrentDirectory();
export const newLine = () => harnessNewLine;
export const useCaseSensitiveFileNames = () => ts.sys.useCaseSensitiveFileNames;
export const args = () => ts.sys.args;
export const getExecutingFilePath = () => ts.sys.getExecutingFilePath();
export const exit = (exitCode: number) => ts.sys.exit(exitCode);
export const readFile: typeof IO.readFile = path => ts.sys.readFile(path);
export const writeFile: typeof IO.writeFile = (path, content) => ts.sys.writeFile(path, content);
@@ -589,6 +598,10 @@ module Harness {
export const newLine = () => harnessNewLine;
export const useCaseSensitiveFileNames = () => false;
export const getCurrentDirectory = () => "";
export const args = () => <string[]>[];
export const getExecutingFilePath = () => "";
export const exit = (exitCode: number) => {};
let supportsCodePage = () => false;
module Http {
@@ -1203,6 +1216,10 @@ module Harness {
options.isolatedModules = setting.value === "true";
break;
case "suppressexcesspropertyerrors":
options.suppressExcessPropertyErrors = setting.value === "true";
break;
case "suppressimplicitanyindexerrors":
options.suppressImplicitAnyIndexErrors = setting.value === "true";
break;
@@ -1327,8 +1344,8 @@ module Harness {
export function getErrorBaseline(inputFiles: { unitName: string; content: string }[], diagnostics: ts.Diagnostic[]) {
diagnostics.sort(ts.compareDiagnostics);
let outputLines: string[] = [];
// Count up all the errors we find so we don't miss any
let totalErrorsReported = 0;
// Count up all errors that were found in files other than lib.d.ts so we don't miss any
let totalErrorsReportedInNonLibraryFiles = 0;
function outputErrorText(error: ts.Diagnostic) {
let message = ts.flattenDiagnosticMessageText(error.messageText, Harness.IO.newLine());
@@ -1339,8 +1356,15 @@ module Harness {
.filter(s => s.length > 0)
.map(s => "!!! " + ts.DiagnosticCategory[error.category].toLowerCase() + " TS" + error.code + ": " + s);
errLines.forEach(e => outputLines.push(e));
totalErrorsReported++;
// do not count errors from lib.d.ts here, they are computed separately as numLibraryDiagnostics
// if lib.d.ts is explicitly included in input files and there are some errors in it (i.e. because of duplicate identifiers)
// then they will be added twice thus triggering 'total errors' assertion with condition
// 'totalErrorsReportedInNonLibraryFiles + numLibraryDiagnostics + numTest262HarnessDiagnostics, diagnostics.length
if (!error.file || !isLibraryFile(error.file.fileName)) {
totalErrorsReportedInNonLibraryFiles++;
}
}
// Report global errors
@@ -1425,7 +1449,7 @@ module Harness {
});
// Verify we didn't miss any errors in total
assert.equal(totalErrorsReported + numLibraryDiagnostics + numTest262HarnessDiagnostics, diagnostics.length, "total number of errors");
assert.equal(totalErrorsReportedInNonLibraryFiles + numLibraryDiagnostics + numTest262HarnessDiagnostics, diagnostics.length, "total number of errors");
return minimalDiagnosticsToString(diagnostics) +
Harness.IO.newLine() + Harness.IO.newLine() + outputLines.join("\r\n");
@@ -1569,7 +1593,7 @@ module Harness {
"nolib", "sourcemap", "target", "out", "outdir", "noemithelpers", "noemitonerror",
"noimplicitany", "noresolve", "newline", "normalizenewline", "emitbom",
"errortruncation", "usecasesensitivefilenames", "preserveconstenums",
"includebuiltfile", "suppressimplicitanyindexerrors", "stripinternal",
"includebuiltfile", "suppressexcesspropertyerrors", "suppressimplicitanyindexerrors", "stripinternal",
"isolatedmodules", "inlinesourcemap", "maproot", "sourceroot",
"inlinesources", "emitdecoratormetadata", "experimentaldecorators",
"skipdefaultlibcheck", "jsx"];
@@ -1803,11 +1827,11 @@ module Harness {
return filePath.indexOf(Harness.libFolder) === 0;
}
export function getDefaultLibraryFile(): { unitName: string, content: string } {
let libFile = Harness.userSpecifiedRoot + Harness.libFolder + "/" + "lib.d.ts";
export function getDefaultLibraryFile(io: Harness.IO): { unitName: string, content: string } {
let libFile = Harness.userSpecifiedRoot + Harness.libFolder + "lib.d.ts";
return {
unitName: libFile,
content: IO.readFile(libFile)
content: io.readFile(libFile)
};
}
+20 -14
View File
@@ -93,7 +93,7 @@ module Playback {
return run;
}
export interface PlaybackSystem extends ts.System, PlaybackControl { }
export interface PlaybackIO extends Harness.IO, PlaybackControl { }
function createEmptyLog(): IOLog {
return {
@@ -223,8 +223,8 @@ module Playback {
// console.log("Swallowed write operation during replay: " + name);
}
export function wrapSystem(underlying: ts.System): PlaybackSystem {
let wrapper: PlaybackSystem = <any>{};
export function wrapIO(underlying: Harness.IO): PlaybackIO {
let wrapper: PlaybackIO = <any>{};
initWrapper(wrapper, underlying);
wrapper.startReplayFromFile = logFn => {
@@ -239,18 +239,24 @@ module Playback {
recordLog = undefined;
}
};
Object.defineProperty(wrapper, "args", {
get() {
if (replayLog !== undefined) {
return replayLog.arguments;
} else if (recordLog !== undefined) {
recordLog.arguments = underlying.args;
}
return underlying.args;
wrapper.args = () => {
if (replayLog !== undefined) {
return replayLog.arguments;
} else if (recordLog !== undefined) {
recordLog.arguments = underlying.args();
}
});
return underlying.args();
}
wrapper.newLine = () => underlying.newLine();
wrapper.useCaseSensitiveFileNames = () => underlying.useCaseSensitiveFileNames();
wrapper.directoryName = (path): string => { throw new Error("NotSupported"); };
wrapper.createDirectory = path => { throw new Error("NotSupported"); };
wrapper.directoryExists = (path): boolean => { throw new Error("NotSupported"); };
wrapper.deleteFile = path => { throw new Error("NotSupported"); };
wrapper.listFiles = (path, filter, options): string[] => { throw new Error("NotSupported"); };
wrapper.log = text => underlying.log(text);
wrapper.fileExists = recordReplay(wrapper.fileExists, underlying)(
(path) => callAndRecord(underlying.fileExists(path), recordLog.fileExists, { path: path }),
+17 -17
View File
@@ -4,18 +4,18 @@
/// <reference path="..\compiler\commandLineParser.ts"/>
module RWC {
function runWithIOLog(ioLog: IOLog, fn: () => void) {
let oldSys = ts.sys;
function runWithIOLog(ioLog: IOLog, fn: (oldIO: Harness.IO) => void) {
let oldIO = Harness.IO;
let wrappedSys = Playback.wrapSystem(ts.sys);
wrappedSys.startReplayFromData(ioLog);
ts.sys = wrappedSys;
let wrappedIO = Playback.wrapIO(oldIO);
wrappedIO.startReplayFromData(ioLog);
Harness.IO = wrappedIO;
try {
fn();
fn(oldIO);
} finally {
wrappedSys.endReplay();
ts.sys = oldSys;
wrappedIO.endReplay();
Harness.IO = oldIO;
}
}
@@ -32,7 +32,6 @@ module RWC {
let baseName = /(.*)\/(.*).json/.exec(ts.normalizeSlashes(jsonPath))[2];
let currentDirectory: string;
let useCustomLibraryFile: boolean;
after(() => {
// Mocha holds onto the closure environment of the describe callback even after the test is done.
// Therefore we have to clean out large objects after the test is done.
@@ -57,7 +56,7 @@ module RWC {
currentDirectory = ioLog.currentDirectory;
useCustomLibraryFile = ioLog.useCustomLibraryFile;
runWithIOLog(ioLog, () => {
opts = ts.parseCommandLine(ioLog.arguments);
opts = ts.parseCommandLine(ioLog.arguments, fileName => Harness.IO.readFile(fileName));
assert.equal(opts.errors.length, 0);
// To provide test coverage of output javascript file,
@@ -65,7 +64,7 @@ module RWC {
opts.options.noEmitOnError = false;
});
runWithIOLog(ioLog, () => {
runWithIOLog(ioLog, oldIO => {
harnessCompiler.reset();
// Load the files
@@ -77,7 +76,7 @@ module RWC {
let isInInputList = (resolvedPath: string) => (inputFile: { unitName: string; content: string; }) => inputFile.unitName === resolvedPath;
for (let fileRead of ioLog.filesRead) {
// Check if the file is already added into the set of input files.
const resolvedPath = ts.normalizeSlashes(ts.sys.resolvePath(fileRead.path));
const resolvedPath = ts.normalizeSlashes(Harness.IO.resolvePath(fileRead.path));
let inInputList = ts.forEach(inputFiles, isInInputList(resolvedPath));
if (!Harness.isLibraryFile(fileRead.path)) {
@@ -97,7 +96,8 @@ module RWC {
inputFiles.push(getHarnessCompilerInputUnit(fileRead.path));
}
else {
inputFiles.push(Harness.getDefaultLibraryFile());
// set the flag to put default library to the beginning of the list
inputFiles.unshift(Harness.getDefaultLibraryFile(oldIO));
}
}
}
@@ -118,13 +118,13 @@ module RWC {
});
function getHarnessCompilerInputUnit(fileName: string) {
let unitName = ts.normalizeSlashes(ts.sys.resolvePath(fileName));
let unitName = ts.normalizeSlashes(Harness.IO.resolvePath(fileName));
let content: string = null;
try {
content = ts.sys.readFile(unitName);
content = Harness.IO.readFile(unitName);
}
catch (e) {
content = ts.sys.readFile(fileName);
content = Harness.IO.readFile(fileName);
}
return { unitName, content };
}
@@ -187,7 +187,7 @@ module RWC {
}
return Harness.Compiler.minimalDiagnosticsToString(declFileCompilationResult.declResult.errors) +
ts.sys.newLine + ts.sys.newLine +
Harness.IO.newLine() + Harness.IO.newLine() +
Harness.Compiler.getErrorBaseline(declFileCompilationResult.declInputFiles.concat(declFileCompilationResult.declOtherFiles), declFileCompilationResult.declResult.errors);
}, false, baselineOpts);
}
+18 -4
View File
@@ -7706,7 +7706,7 @@ interface MessageEvent extends Event {
declare var MessageEvent: {
prototype: MessageEvent;
new(): MessageEvent;
new(type: string, eventInitDict?: MessageEventInit): MessageEvent;
}
interface MessagePort extends EventTarget {
@@ -8448,7 +8448,7 @@ interface ProgressEvent extends Event {
declare var ProgressEvent: {
prototype: ProgressEvent;
new(): ProgressEvent;
new(type: string, eventInitDict?: ProgressEventInit): ProgressEvent;
}
interface Range {
@@ -12615,7 +12615,6 @@ interface NodeListOf<TNode extends Node> extends NodeList {
[index: number]: TNode;
}
interface BlobPropertyBag {
type?: string;
endings?: string;
@@ -12632,6 +12631,21 @@ interface EventListenerObject {
declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject;
interface MessageEventInit extends EventInit {
data?: any;
origin?: string;
lastEventId?: string;
channel?: string;
source?: any;
ports?: MessagePort[];
}
interface ProgressEventInit extends EventInit {
lengthComputable?: boolean;
loaded?: number;
total?: number;
}
interface ErrorEventHandler {
(message: string, filename?: string, lineno?: number, colno?: number, error?:Error): void;
}
@@ -12961,4 +12975,4 @@ declare function addEventListener(type: "unload", listener: (ev: Event) => any,
declare function addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void;
declare function addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void;
declare function addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void;
declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
+18 -3
View File
@@ -587,7 +587,7 @@ interface MessageEvent extends Event {
declare var MessageEvent: {
prototype: MessageEvent;
new(): MessageEvent;
new(type: string, eventInitDict?: MessageEventInit): MessageEvent;
}
interface MessagePort extends EventTarget {
@@ -640,7 +640,7 @@ interface ProgressEvent extends Event {
declare var ProgressEvent: {
prototype: ProgressEvent;
new(): ProgressEvent;
new(type: string, eventInitDict?: ProgressEventInit): ProgressEvent;
}
interface WebSocket extends EventTarget {
@@ -911,6 +911,21 @@ interface EventListenerObject {
declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject;
interface MessageEventInit extends EventInit {
data?: any;
origin?: string;
lastEventId?: string;
channel?: string;
source?: any;
ports?: MessagePort[];
}
interface ProgressEventInit extends EventInit {
lengthComputable?: boolean;
loaded?: number;
total?: number;
}
interface ErrorEventHandler {
(message: string, filename?: string, lineno?: number, colno?: number, error?:Error): void;
}
@@ -967,4 +982,4 @@ declare function postMessage(data: any): void;
declare var console: Console;
declare function addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void;
declare function addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void;
declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
+46
View File
@@ -213,6 +213,26 @@ namespace ts.formatting {
public NoSpaceBetweenYieldKeywordAndStar: Rule;
public SpaceBetweenYieldOrYieldStarAndOperand: Rule;
// Async-await
public SpaceBetweenAsyncAndFunctionKeyword: Rule;
public NoSpaceBetweenAsyncAndFunctionKeyword: Rule;
public SpaceAfterAwaitKeyword: Rule;
public NoSpaceAfterAwaitKeyword: Rule;
// Type alias declaration
public SpaceAfterTypeKeyword: Rule;
public NoSpaceAfterTypeKeyword: Rule;
// Tagged template string
public SpaceBetweenTagAndTemplateString: Rule;
public NoSpaceBetweenTagAndTemplateString: Rule;
// Union type
public SpaceBeforeBar: Rule;
public NoSpaceBeforeBar: Rule;
public SpaceAfterBar: Rule;
public NoSpaceAfterBar: Rule;
constructor() {
///
/// Common Rules
@@ -360,6 +380,27 @@ namespace ts.formatting {
this.NoSpaceBetweenYieldKeywordAndStar = new Rule(RuleDescriptor.create1(SyntaxKind.YieldKeyword, SyntaxKind.AsteriskToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), RuleAction.Delete));
this.SpaceBetweenYieldOrYieldStarAndOperand = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.YieldKeyword, SyntaxKind.AsteriskToken]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), RuleAction.Space));
// Async-await
this.SpaceBetweenAsyncAndFunctionKeyword = new Rule(RuleDescriptor.create1(SyntaxKind.AsyncKeyword, SyntaxKind.FunctionKeyword), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
this.NoSpaceBetweenAsyncAndFunctionKeyword = new Rule(RuleDescriptor.create1(SyntaxKind.AsyncKeyword, SyntaxKind.FunctionKeyword), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
this.SpaceAfterAwaitKeyword = new Rule(RuleDescriptor.create3(SyntaxKind.AwaitKeyword, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
this.NoSpaceAfterAwaitKeyword = new Rule(RuleDescriptor.create3(SyntaxKind.AwaitKeyword, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
// Type alias declaration
this.SpaceAfterTypeKeyword = new Rule(RuleDescriptor.create3(SyntaxKind.TypeKeyword, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
this.NoSpaceAfterTypeKeyword = new Rule(RuleDescriptor.create3(SyntaxKind.TypeKeyword, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
// template string
this.SpaceBetweenTagAndTemplateString = new Rule(RuleDescriptor.create3(SyntaxKind.Identifier, Shared.TokenRange.FromTokens([SyntaxKind.NoSubstitutionTemplateLiteral, SyntaxKind.TemplateHead])), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
this.NoSpaceBetweenTagAndTemplateString = new Rule(RuleDescriptor.create3(SyntaxKind.Identifier, Shared.TokenRange.FromTokens([SyntaxKind.NoSubstitutionTemplateLiteral, SyntaxKind.TemplateHead])), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
// union type
this.SpaceBeforeBar = new Rule(RuleDescriptor.create3(SyntaxKind.BarToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
this.NoSpaceBeforeBar = new Rule(RuleDescriptor.create3(SyntaxKind.BarToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
this.SpaceAfterBar = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.BarToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
this.NoSpaceAfterBar = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.BarToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
// These rules are higher in priority than user-configurable rules.
this.HighPriorityCommonRules =
[
@@ -386,6 +427,11 @@ namespace ts.formatting {
this.NoSpaceBeforeOpenParenInFuncCall,
this.SpaceBeforeBinaryKeywordOperator, this.SpaceAfterBinaryKeywordOperator,
this.SpaceAfterVoidOperator,
this.SpaceBetweenAsyncAndFunctionKeyword, this.NoSpaceBetweenAsyncAndFunctionKeyword,
this.SpaceAfterAwaitKeyword, this.NoSpaceAfterAwaitKeyword,
this.SpaceAfterTypeKeyword, this.NoSpaceAfterTypeKeyword,
this.SpaceBetweenTagAndTemplateString, this.NoSpaceBetweenTagAndTemplateString,
this.SpaceBeforeBar, this.NoSpaceBeforeBar, this.SpaceAfterBar, this.NoSpaceAfterBar,
// TypeScript-specific rules
this.NoSpaceAfterConstructor, this.NoSpaceAfterModuleImport,
+11 -2
View File
@@ -408,6 +408,7 @@ namespace ts.formatting {
case SyntaxKind.ClassDeclaration:
case SyntaxKind.InterfaceDeclaration:
case SyntaxKind.EnumDeclaration:
case SyntaxKind.TypeAliasDeclaration:
case SyntaxKind.ArrayLiteralExpression:
case SyntaxKind.Block:
case SyntaxKind.ModuleBlock:
@@ -429,6 +430,16 @@ namespace ts.formatting {
case SyntaxKind.ArrayBindingPattern:
case SyntaxKind.ObjectBindingPattern:
case SyntaxKind.JsxElement:
case SyntaxKind.MethodSignature:
case SyntaxKind.CallSignature:
case SyntaxKind.ConstructSignature:
case SyntaxKind.Parameter:
case SyntaxKind.FunctionType:
case SyntaxKind.ConstructorType:
case SyntaxKind.UnionType:
case SyntaxKind.ParenthesizedType:
case SyntaxKind.TaggedTemplateExpression:
case SyntaxKind.AwaitExpression:
return true;
}
return false;
@@ -448,8 +459,6 @@ namespace ts.formatting {
case SyntaxKind.FunctionDeclaration:
case SyntaxKind.FunctionExpression:
case SyntaxKind.MethodDeclaration:
case SyntaxKind.MethodSignature:
case SyntaxKind.CallSignature:
case SyntaxKind.ArrowFunction:
case SyntaxKind.Constructor:
case SyntaxKind.GetAccessor:
+40 -15
View File
@@ -3589,10 +3589,11 @@ namespace ts {
containingNodeKind === SyntaxKind.EnumDeclaration || // enum a { foo, |
isFunction(containingNodeKind) ||
containingNodeKind === SyntaxKind.ClassDeclaration || // class A<T, |
containingNodeKind === SyntaxKind.FunctionDeclaration || // function A<T, |
containingNodeKind === SyntaxKind.ClassExpression || // var C = class D<T, |
containingNodeKind === SyntaxKind.InterfaceDeclaration || // interface A<T, |
containingNodeKind === SyntaxKind.ArrayBindingPattern; // var [x, y|
containingNodeKind === SyntaxKind.ArrayBindingPattern || // var [x, y|
containingNodeKind === SyntaxKind.TypeAliasDeclaration; // type Map, K, |
case SyntaxKind.DotToken:
return containingNodeKind === SyntaxKind.ArrayBindingPattern; // var [.|
@@ -3619,8 +3620,9 @@ namespace ts {
case SyntaxKind.LessThanToken:
return containingNodeKind === SyntaxKind.ClassDeclaration || // class A< |
containingNodeKind === SyntaxKind.FunctionDeclaration || // function A< |
containingNodeKind === SyntaxKind.ClassExpression || // var C = class D< |
containingNodeKind === SyntaxKind.InterfaceDeclaration || // interface A< |
containingNodeKind === SyntaxKind.TypeAliasDeclaration || // type List< |
isFunction(containingNodeKind);
case SyntaxKind.StaticKeyword:
@@ -4181,6 +4183,7 @@ namespace ts {
displayParts.push(keywordPart(SyntaxKind.TypeKeyword));
displayParts.push(spacePart());
addFullSymbolName(symbol);
writeTypeParametersOfSymbol(symbol, sourceFile);
displayParts.push(spacePart());
displayParts.push(operatorPart(SyntaxKind.EqualsToken));
displayParts.push(spacePart());
@@ -4221,16 +4224,29 @@ namespace ts {
}
else {
// Method/function type parameter
let signatureDeclaration = <SignatureDeclaration>getDeclarationOfKind(symbol, SyntaxKind.TypeParameter).parent;
let signature = typeChecker.getSignatureFromDeclaration(signatureDeclaration);
if (signatureDeclaration.kind === SyntaxKind.ConstructSignature) {
displayParts.push(keywordPart(SyntaxKind.NewKeyword));
let container = getContainingFunction(location);
if (container) {
let signatureDeclaration = <SignatureDeclaration>getDeclarationOfKind(symbol, SyntaxKind.TypeParameter).parent;
let signature = typeChecker.getSignatureFromDeclaration(signatureDeclaration);
if (signatureDeclaration.kind === SyntaxKind.ConstructSignature) {
displayParts.push(keywordPart(SyntaxKind.NewKeyword));
displayParts.push(spacePart());
}
else if (signatureDeclaration.kind !== SyntaxKind.CallSignature && signatureDeclaration.name) {
addFullSymbolName(signatureDeclaration.symbol);
}
addRange(displayParts, signatureToDisplayParts(typeChecker, signature, sourceFile, TypeFormatFlags.WriteTypeArgumentsOfSignature));
}
else {
// Type aliash type parameter
// For example
// type list<T> = T[]; // Both T will go through same code path
let declaration = <TypeAliasDeclaration>getDeclarationOfKind(symbol, SyntaxKind.TypeParameter).parent;
displayParts.push(keywordPart(SyntaxKind.TypeKeyword));
displayParts.push(spacePart());
addFullSymbolName(declaration.symbol);
writeTypeParametersOfSymbol(declaration.symbol, sourceFile);
}
else if (signatureDeclaration.kind !== SyntaxKind.CallSignature && signatureDeclaration.name) {
addFullSymbolName(signatureDeclaration.symbol);
}
addRange(displayParts, signatureToDisplayParts(typeChecker, signature, sourceFile, TypeFormatFlags.WriteTypeArgumentsOfSignature));
}
}
if (symbolFlags & SymbolFlags.EnumMember) {
@@ -4464,10 +4480,19 @@ namespace ts {
// and in either case the symbol has a construct signature definition, i.e. class
if (isNewExpressionTarget(location) || location.kind === SyntaxKind.ConstructorKeyword) {
if (symbol.flags & SymbolFlags.Class) {
let classDeclaration = <ClassDeclaration>symbol.getDeclarations()[0];
Debug.assert(classDeclaration && classDeclaration.kind === SyntaxKind.ClassDeclaration);
// Find the first class-like declaration and try to get the construct signature.
for (let declaration of symbol.getDeclarations()) {
if (isClassLike(declaration)) {
return tryAddSignature(declaration.members,
/*selectConstructors*/ true,
symbolKind,
symbolName,
containerName,
result);
}
}
return tryAddSignature(classDeclaration.members, /*selectConstructors*/ true, symbolKind, symbolName, containerName, result);
Debug.fail("Expected declaration to have at least one class-like declaration");
}
}
return false;
@@ -1,6 +1,6 @@
tests/cases/compiler/constEnumErrors.ts(1,12): error TS2300: Duplicate identifier 'E'.
tests/cases/compiler/constEnumErrors.ts(5,8): error TS2300: Duplicate identifier 'E'.
tests/cases/compiler/constEnumErrors.ts(12,9): error TS2651: A member initializer in a 'const' enum declaration cannot reference members declared after it, including members defined in other 'const' enums.
tests/cases/compiler/constEnumErrors.ts(12,9): error TS2651: A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums.
tests/cases/compiler/constEnumErrors.ts(14,9): error TS2474: In 'const' enum declarations member initializer must be constant expression.
tests/cases/compiler/constEnumErrors.ts(15,10): error TS2474: In 'const' enum declarations member initializer must be constant expression.
tests/cases/compiler/constEnumErrors.ts(22,13): error TS2476: A const enum member can only be accessed using a string literal.
@@ -31,7 +31,7 @@ tests/cases/compiler/constEnumErrors.ts(42,9): error TS2478: 'const' enum member
// forward reference to the element of the same enum
X = Y,
~
!!! error TS2651: A member initializer in a 'const' enum declaration cannot reference members declared after it, including members defined in other 'const' enums.
!!! error TS2651: A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums.
// forward reference to the element of the same enum
Y = E1.Z,
~~~~
@@ -0,0 +1,23 @@
//// [declFileClassExtendsNull.ts]
class ExtendsNull extends null {
}
//// [declFileClassExtendsNull.js]
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var ExtendsNull = (function (_super) {
__extends(ExtendsNull, _super);
function ExtendsNull() {
_super.apply(this, arguments);
}
return ExtendsNull;
})(null);
//// [declFileClassExtendsNull.d.ts]
declare class ExtendsNull extends null {
}
@@ -0,0 +1,5 @@
=== tests/cases/compiler/declFileClassExtendsNull.ts ===
class ExtendsNull extends null {
>ExtendsNull : Symbol(ExtendsNull, Decl(declFileClassExtendsNull.ts, 0, 0))
}
@@ -0,0 +1,6 @@
=== tests/cases/compiler/declFileClassExtendsNull.ts ===
class ExtendsNull extends null {
>ExtendsNull : ExtendsNull
>null : null
}
@@ -0,0 +1,7 @@
//// [excessPropertyErrorsSuppressed.ts]
var x: { a: string } = { a: "hello", b: 42 }; // No error
//// [excessPropertyErrorsSuppressed.js]
var x = { a: "hello", b: 42 }; // No error
@@ -0,0 +1,8 @@
=== tests/cases/compiler/excessPropertyErrorsSuppressed.ts ===
var x: { a: string } = { a: "hello", b: 42 }; // No error
>x : Symbol(x, Decl(excessPropertyErrorsSuppressed.ts, 1, 3))
>a : Symbol(a, Decl(excessPropertyErrorsSuppressed.ts, 1, 8))
>a : Symbol(a, Decl(excessPropertyErrorsSuppressed.ts, 1, 24))
>b : Symbol(b, Decl(excessPropertyErrorsSuppressed.ts, 1, 36))
@@ -0,0 +1,11 @@
=== tests/cases/compiler/excessPropertyErrorsSuppressed.ts ===
var x: { a: string } = { a: "hello", b: 42 }; // No error
>x : { a: string; }
>a : string
>{ a: "hello", b: 42 } : { a: string; b: number; }
>a : string
>"hello" : string
>b : number
>42 : number
@@ -0,0 +1,29 @@
tests/cases/compiler/forwardRefInEnum.ts(4,9): error TS2651: A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums.
tests/cases/compiler/forwardRefInEnum.ts(5,10): error TS2651: A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums.
tests/cases/compiler/forwardRefInEnum.ts(7,9): error TS2651: A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums.
tests/cases/compiler/forwardRefInEnum.ts(8,10): error TS2651: A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums.
==== tests/cases/compiler/forwardRefInEnum.ts (4 errors) ====
enum E1 {
// illegal case
// forward reference to the element of the same enum
X = Y,
~
!!! error TS2651: A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums.
X1 = E1["Y"],
~~~~~~~
!!! error TS2651: A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums.
// forward reference to the element of the same enum
Y = E1.Z,
~~~~
!!! error TS2651: A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums.
Y1 = E1["Z"]
~~~~~~~
!!! error TS2651: A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums.
}
enum E1 {
Z = 4
}
@@ -0,0 +1,31 @@
//// [forwardRefInEnum.ts]
enum E1 {
// illegal case
// forward reference to the element of the same enum
X = Y,
X1 = E1["Y"],
// forward reference to the element of the same enum
Y = E1.Z,
Y1 = E1["Z"]
}
enum E1 {
Z = 4
}
//// [forwardRefInEnum.js]
var E1;
(function (E1) {
// illegal case
// forward reference to the element of the same enum
E1[E1["X"] = E1.Y] = "X";
E1[E1["X1"] = E1["Y"]] = "X1";
// forward reference to the element of the same enum
E1[E1["Y"] = E1.Z] = "Y";
E1[E1["Y1"] = E1["Z"]] = "Y1";
})(E1 || (E1 = {}));
var E1;
(function (E1) {
E1[E1["Z"] = 4] = "Z";
})(E1 || (E1 = {}));
@@ -0,0 +1,12 @@
tests/cases/compiler/missingPropertiesOfClassExpression.ts(1,52): error TS2339: Property 'y' does not exist on type '(Anonymous class)'.
==== tests/cases/compiler/missingPropertiesOfClassExpression.ts (1 errors) ====
class George extends class { reset() { return this.y; } } {
~
!!! error TS2339: Property 'y' does not exist on type '(Anonymous class)'.
constructor() {
super();
}
}
@@ -0,0 +1,26 @@
//// [missingPropertiesOfClassExpression.ts]
class George extends class { reset() { return this.y; } } {
constructor() {
super();
}
}
//// [missingPropertiesOfClassExpression.js]
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var George = (function (_super) {
__extends(George, _super);
function George() {
_super.call(this);
}
return George;
})((function () {
function class_1() {
}
class_1.prototype.reset = function () { return this.y; };
return class_1;
})());
@@ -0,0 +1,20 @@
//// [recursiveTupleTypes1.ts]
interface Tree1 {
children: [Tree1, Tree2];
}
interface Tree2 {
children: [Tree2, Tree1];
}
let tree1: Tree1;
let tree2: Tree2;
tree1 = tree2;
tree2 = tree1;
//// [recursiveTupleTypes1.js]
var tree1;
var tree2;
tree1 = tree2;
tree2 = tree1;
@@ -0,0 +1,35 @@
=== tests/cases/compiler/recursiveTupleTypes1.ts ===
interface Tree1 {
>Tree1 : Symbol(Tree1, Decl(recursiveTupleTypes1.ts, 0, 0))
children: [Tree1, Tree2];
>children : Symbol(children, Decl(recursiveTupleTypes1.ts, 0, 17))
>Tree1 : Symbol(Tree1, Decl(recursiveTupleTypes1.ts, 0, 0))
>Tree2 : Symbol(Tree2, Decl(recursiveTupleTypes1.ts, 2, 1))
}
interface Tree2 {
>Tree2 : Symbol(Tree2, Decl(recursiveTupleTypes1.ts, 2, 1))
children: [Tree2, Tree1];
>children : Symbol(children, Decl(recursiveTupleTypes1.ts, 4, 17))
>Tree2 : Symbol(Tree2, Decl(recursiveTupleTypes1.ts, 2, 1))
>Tree1 : Symbol(Tree1, Decl(recursiveTupleTypes1.ts, 0, 0))
}
let tree1: Tree1;
>tree1 : Symbol(tree1, Decl(recursiveTupleTypes1.ts, 8, 3))
>Tree1 : Symbol(Tree1, Decl(recursiveTupleTypes1.ts, 0, 0))
let tree2: Tree2;
>tree2 : Symbol(tree2, Decl(recursiveTupleTypes1.ts, 9, 3))
>Tree2 : Symbol(Tree2, Decl(recursiveTupleTypes1.ts, 2, 1))
tree1 = tree2;
>tree1 : Symbol(tree1, Decl(recursiveTupleTypes1.ts, 8, 3))
>tree2 : Symbol(tree2, Decl(recursiveTupleTypes1.ts, 9, 3))
tree2 = tree1;
>tree2 : Symbol(tree2, Decl(recursiveTupleTypes1.ts, 9, 3))
>tree1 : Symbol(tree1, Decl(recursiveTupleTypes1.ts, 8, 3))
@@ -0,0 +1,37 @@
=== tests/cases/compiler/recursiveTupleTypes1.ts ===
interface Tree1 {
>Tree1 : Tree1
children: [Tree1, Tree2];
>children : [Tree1, Tree2]
>Tree1 : Tree1
>Tree2 : Tree2
}
interface Tree2 {
>Tree2 : Tree2
children: [Tree2, Tree1];
>children : [Tree2, Tree1]
>Tree2 : Tree2
>Tree1 : Tree1
}
let tree1: Tree1;
>tree1 : Tree1
>Tree1 : Tree1
let tree2: Tree2;
>tree2 : Tree2
>Tree2 : Tree2
tree1 = tree2;
>tree1 = tree2 : Tree2
>tree1 : Tree1
>tree2 : Tree2
tree2 = tree1;
>tree2 = tree1 : Tree1
>tree2 : Tree2
>tree1 : Tree1
@@ -0,0 +1,20 @@
//// [recursiveTupleTypes2.ts]
interface Tree1 {
children: [Tree1, Tree2];
}
interface Tree2 {
children: [Tree2, Tree2];
}
let tree1: Tree1;
let tree2: Tree2;
tree1 = tree2;
tree2 = tree1;
//// [recursiveTupleTypes2.js]
var tree1;
var tree2;
tree1 = tree2;
tree2 = tree1;
@@ -0,0 +1,35 @@
=== tests/cases/compiler/recursiveTupleTypes2.ts ===
interface Tree1 {
>Tree1 : Symbol(Tree1, Decl(recursiveTupleTypes2.ts, 0, 0))
children: [Tree1, Tree2];
>children : Symbol(children, Decl(recursiveTupleTypes2.ts, 0, 17))
>Tree1 : Symbol(Tree1, Decl(recursiveTupleTypes2.ts, 0, 0))
>Tree2 : Symbol(Tree2, Decl(recursiveTupleTypes2.ts, 2, 1))
}
interface Tree2 {
>Tree2 : Symbol(Tree2, Decl(recursiveTupleTypes2.ts, 2, 1))
children: [Tree2, Tree2];
>children : Symbol(children, Decl(recursiveTupleTypes2.ts, 4, 17))
>Tree2 : Symbol(Tree2, Decl(recursiveTupleTypes2.ts, 2, 1))
>Tree2 : Symbol(Tree2, Decl(recursiveTupleTypes2.ts, 2, 1))
}
let tree1: Tree1;
>tree1 : Symbol(tree1, Decl(recursiveTupleTypes2.ts, 8, 3))
>Tree1 : Symbol(Tree1, Decl(recursiveTupleTypes2.ts, 0, 0))
let tree2: Tree2;
>tree2 : Symbol(tree2, Decl(recursiveTupleTypes2.ts, 9, 3))
>Tree2 : Symbol(Tree2, Decl(recursiveTupleTypes2.ts, 2, 1))
tree1 = tree2;
>tree1 : Symbol(tree1, Decl(recursiveTupleTypes2.ts, 8, 3))
>tree2 : Symbol(tree2, Decl(recursiveTupleTypes2.ts, 9, 3))
tree2 = tree1;
>tree2 : Symbol(tree2, Decl(recursiveTupleTypes2.ts, 9, 3))
>tree1 : Symbol(tree1, Decl(recursiveTupleTypes2.ts, 8, 3))
@@ -0,0 +1,37 @@
=== tests/cases/compiler/recursiveTupleTypes2.ts ===
interface Tree1 {
>Tree1 : Tree1
children: [Tree1, Tree2];
>children : [Tree1, Tree2]
>Tree1 : Tree1
>Tree2 : Tree2
}
interface Tree2 {
>Tree2 : Tree2
children: [Tree2, Tree2];
>children : [Tree2, Tree2]
>Tree2 : Tree2
>Tree2 : Tree2
}
let tree1: Tree1;
>tree1 : Tree1
>Tree1 : Tree1
let tree2: Tree2;
>tree2 : Tree2
>Tree2 : Tree2
tree1 = tree2;
>tree1 = tree2 : Tree2
>tree1 : Tree1
>tree2 : Tree2
tree2 = tree1;
>tree2 = tree1 : Tree1
>tree2 : Tree2
>tree1 : Tree1
@@ -0,0 +1,29 @@
//// [tests/cases/conformance/jsx/tsxReactEmit5.tsx] ////
//// [file.tsx]
declare module JSX {
interface Element { }
interface IntrinsicElements {
[s: string]: any;
}
}
//// [test.d.ts]
export var React;
//// [react-consumer.tsx]
import {React} from "./test";
// Should emit test_1.React.createElement
// and React.__spread
var foo;
var spread1 = <div x='' {...foo} y='' />;
//// [file.js]
//// [react-consumer.js]
var test_1 = require("./test");
// Should emit test_1.React.createElement
// and React.__spread
var foo;
var spread1 = test_1.React.createElement("div", test_1.React.__spread({x: ''}, foo, {y: ''}));
@@ -0,0 +1,35 @@
=== tests/cases/conformance/jsx/file.tsx ===
declare module JSX {
>JSX : Symbol(JSX, Decl(file.tsx, 0, 0))
interface Element { }
>Element : Symbol(Element, Decl(file.tsx, 1, 20))
interface IntrinsicElements {
>IntrinsicElements : Symbol(IntrinsicElements, Decl(file.tsx, 2, 22))
[s: string]: any;
>s : Symbol(s, Decl(file.tsx, 4, 3))
}
}
=== tests/cases/conformance/jsx/test.d.ts ===
export var React;
>React : Symbol(React, Decl(test.d.ts, 0, 10))
=== tests/cases/conformance/jsx/react-consumer.tsx ===
import {React} from "./test";
>React : Symbol(React, Decl(react-consumer.tsx, 0, 8))
// Should emit test_1.React.createElement
// and React.__spread
var foo;
>foo : Symbol(foo, Decl(react-consumer.tsx, 3, 3))
var spread1 = <div x='' {...foo} y='' />;
>spread1 : Symbol(spread1, Decl(react-consumer.tsx, 4, 3))
>div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 2, 22))
>x : Symbol(unknown)
>y : Symbol(unknown)
@@ -0,0 +1,37 @@
=== tests/cases/conformance/jsx/file.tsx ===
declare module JSX {
>JSX : any
interface Element { }
>Element : Element
interface IntrinsicElements {
>IntrinsicElements : IntrinsicElements
[s: string]: any;
>s : string
}
}
=== tests/cases/conformance/jsx/test.d.ts ===
export var React;
>React : any
=== tests/cases/conformance/jsx/react-consumer.tsx ===
import {React} from "./test";
>React : any
// Should emit test_1.React.createElement
// and React.__spread
var foo;
>foo : any
var spread1 = <div x='' {...foo} y='' />;
>spread1 : JSX.Element
><div x='' {...foo} y='' /> : JSX.Element
>div : any
>x : any
>foo : any
>y : any
@@ -0,0 +1,36 @@
//// [tests/cases/conformance/jsx/tsxReactEmit6.tsx] ////
//// [file.tsx]
declare module JSX {
interface Element { }
interface IntrinsicElements {
[s: string]: any;
}
}
//// [react-consumer.tsx]
namespace M {
export var React: any;
}
namespace M {
// Should emit M.React.createElement
// and M.React.__spread
var foo;
var spread1 = <div x='' {...foo} y='' />;
}
//// [file.js]
//// [react-consumer.js]
var M;
(function (M) {
})(M || (M = {}));
var M;
(function (M) {
// Should emit M.React.createElement
// and M.React.__spread
var foo;
var spread1 = M.React.createElement("div", M.React.__spread({x: ''}, foo, {y: ''}));
})(M || (M = {}));
@@ -0,0 +1,39 @@
=== tests/cases/conformance/jsx/file.tsx ===
declare module JSX {
>JSX : Symbol(JSX, Decl(file.tsx, 0, 0))
interface Element { }
>Element : Symbol(Element, Decl(file.tsx, 1, 20))
interface IntrinsicElements {
>IntrinsicElements : Symbol(IntrinsicElements, Decl(file.tsx, 2, 22))
[s: string]: any;
>s : Symbol(s, Decl(file.tsx, 4, 3))
}
}
=== tests/cases/conformance/jsx/react-consumer.tsx ===
namespace M {
>M : Symbol(M, Decl(react-consumer.tsx, 0, 0), Decl(react-consumer.tsx, 2, 1))
export var React: any;
>React : Symbol(React, Decl(react-consumer.tsx, 1, 11))
}
namespace M {
>M : Symbol(M, Decl(react-consumer.tsx, 0, 0), Decl(react-consumer.tsx, 2, 1))
// Should emit M.React.createElement
// and M.React.__spread
var foo;
>foo : Symbol(foo, Decl(react-consumer.tsx, 7, 4))
var spread1 = <div x='' {...foo} y='' />;
>spread1 : Symbol(spread1, Decl(react-consumer.tsx, 8, 4))
>div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 2, 22))
>x : Symbol(unknown)
>y : Symbol(unknown)
}
@@ -0,0 +1,41 @@
=== tests/cases/conformance/jsx/file.tsx ===
declare module JSX {
>JSX : any
interface Element { }
>Element : Element
interface IntrinsicElements {
>IntrinsicElements : IntrinsicElements
[s: string]: any;
>s : string
}
}
=== tests/cases/conformance/jsx/react-consumer.tsx ===
namespace M {
>M : typeof M
export var React: any;
>React : any
}
namespace M {
>M : typeof M
// Should emit M.React.createElement
// and M.React.__spread
var foo;
>foo : any
var spread1 = <div x='' {...foo} y='' />;
>spread1 : JSX.Element
><div x='' {...foo} y='' /> : JSX.Element
>div : any
>x : any
>foo : any
>y : any
}
@@ -0,0 +1,13 @@
//// [typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts]
type TreeNode = {
name: string;
parent: TreeNode;
}
var nodes: TreeNode[];
nodes.map(n => n.name);
//// [typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.js]
var nodes;
nodes.map(function (n) { return n.name; });
@@ -0,0 +1,25 @@
=== tests/cases/compiler/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts ===
type TreeNode = {
>TreeNode : Symbol(TreeNode, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 0, 0))
name: string;
>name : Symbol(name, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 0, 17))
parent: TreeNode;
>parent : Symbol(parent, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 1, 17))
>TreeNode : Symbol(TreeNode, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 0, 0))
}
var nodes: TreeNode[];
>nodes : Symbol(nodes, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 5, 3))
>TreeNode : Symbol(TreeNode, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 0, 0))
nodes.map(n => n.name);
>nodes.map : Symbol(Array.map, Decl(lib.d.ts, 1115, 92))
>nodes : Symbol(nodes, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 5, 3))
>map : Symbol(Array.map, Decl(lib.d.ts, 1115, 92))
>n : Symbol(n, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 6, 10))
>n.name : Symbol(name, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 0, 17))
>n : Symbol(n, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 6, 10))
>name : Symbol(name, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 0, 17))
@@ -0,0 +1,27 @@
=== tests/cases/compiler/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts ===
type TreeNode = {
>TreeNode : { name: string; parent: TreeNode; }
name: string;
>name : string
parent: TreeNode;
>parent : { name: string; parent: TreeNode; }
>TreeNode : { name: string; parent: TreeNode; }
}
var nodes: TreeNode[];
>nodes : { name: string; parent: TreeNode; }[]
>TreeNode : { name: string; parent: TreeNode; }
nodes.map(n => n.name);
>nodes.map(n => n.name) : string[]
>nodes.map : <U>(callbackfn: (value: { name: string; parent: TreeNode; }, index: number, array: { name: string; parent: TreeNode; }[]) => U, thisArg?: any) => U[]
>nodes : { name: string; parent: TreeNode; }[]
>map : <U>(callbackfn: (value: { name: string; parent: TreeNode; }, index: number, array: { name: string; parent: TreeNode; }[]) => U, thisArg?: any) => U[]
>n => n.name : (n: { name: string; parent: TreeNode; }) => string
>n : { name: string; parent: TreeNode; }
>n.name : string
>n : { name: string; parent: TreeNode; }
>name : string
@@ -0,0 +1,18 @@
//// [typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts]
type TreeNode = {
name: string;
parent: TreeNode;
}
type TreeNodeMiddleman = {
name: string;
parent: TreeNode;
}
var nodes: TreeNodeMiddleman[];
nodes.map(n => n.name);
//// [typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.js]
var nodes;
nodes.map(function (n) { return n.name; });
@@ -0,0 +1,36 @@
=== tests/cases/compiler/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts ===
type TreeNode = {
>TreeNode : Symbol(TreeNode, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 0, 0))
name: string;
>name : Symbol(name, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 0, 17))
parent: TreeNode;
>parent : Symbol(parent, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 1, 17))
>TreeNode : Symbol(TreeNode, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 0, 0))
}
type TreeNodeMiddleman = {
>TreeNodeMiddleman : Symbol(TreeNodeMiddleman, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 3, 1))
name: string;
>name : Symbol(name, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 5, 26))
parent: TreeNode;
>parent : Symbol(parent, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 6, 17))
>TreeNode : Symbol(TreeNode, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 0, 0))
}
var nodes: TreeNodeMiddleman[];
>nodes : Symbol(nodes, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 10, 3))
>TreeNodeMiddleman : Symbol(TreeNodeMiddleman, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 3, 1))
nodes.map(n => n.name);
>nodes.map : Symbol(Array.map, Decl(lib.d.ts, 1115, 92))
>nodes : Symbol(nodes, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 10, 3))
>map : Symbol(Array.map, Decl(lib.d.ts, 1115, 92))
>n : Symbol(n, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 11, 10))
>n.name : Symbol(name, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 5, 26))
>n : Symbol(n, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 11, 10))
>name : Symbol(name, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 5, 26))
@@ -0,0 +1,38 @@
=== tests/cases/compiler/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts ===
type TreeNode = {
>TreeNode : { name: string; parent: TreeNode; }
name: string;
>name : string
parent: TreeNode;
>parent : { name: string; parent: TreeNode; }
>TreeNode : { name: string; parent: TreeNode; }
}
type TreeNodeMiddleman = {
>TreeNodeMiddleman : { name: string; parent: { name: string; parent: TreeNode; }; }
name: string;
>name : string
parent: TreeNode;
>parent : { name: string; parent: TreeNode; }
>TreeNode : { name: string; parent: TreeNode; }
}
var nodes: TreeNodeMiddleman[];
>nodes : { name: string; parent: { name: string; parent: TreeNode; }; }[]
>TreeNodeMiddleman : { name: string; parent: { name: string; parent: TreeNode; }; }
nodes.map(n => n.name);
>nodes.map(n => n.name) : string[]
>nodes.map : <U>(callbackfn: (value: { name: string; parent: { name: string; parent: TreeNode; }; }, index: number, array: { name: string; parent: { name: string; parent: TreeNode; }; }[]) => U, thisArg?: any) => U[]
>nodes : { name: string; parent: { name: string; parent: TreeNode; }; }[]
>map : <U>(callbackfn: (value: { name: string; parent: { name: string; parent: TreeNode; }; }, index: number, array: { name: string; parent: { name: string; parent: TreeNode; }; }[]) => U, thisArg?: any) => U[]
>n => n.name : (n: { name: string; parent: { name: string; parent: TreeNode; }; }) => string
>n : { name: string; parent: { name: string; parent: TreeNode; }; }
>n.name : string
>n : { name: string; parent: { name: string; parent: TreeNode; }; }
>name : string
@@ -0,0 +1,5 @@
// @target: ES5
// @declaration: true
class ExtendsNull extends null {
}
@@ -0,0 +1,3 @@
//@suppressExcessPropertyErrors: true
var x: { a: string } = { a: "hello", b: 42 }; // No error
+13
View File
@@ -0,0 +1,13 @@
enum E1 {
// illegal case
// forward reference to the element of the same enum
X = Y,
X1 = E1["Y"],
// forward reference to the element of the same enum
Y = E1.Z,
Y1 = E1["Z"]
}
enum E1 {
Z = 4
}
@@ -0,0 +1,5 @@
class George extends class { reset() { return this.y; } } {
constructor() {
super();
}
}
@@ -0,0 +1,12 @@
interface Tree1 {
children: [Tree1, Tree2];
}
interface Tree2 {
children: [Tree2, Tree1];
}
let tree1: Tree1;
let tree2: Tree2;
tree1 = tree2;
tree2 = tree1;
@@ -0,0 +1,12 @@
interface Tree1 {
children: [Tree1, Tree2];
}
interface Tree2 {
children: [Tree2, Tree2];
}
let tree1: Tree1;
let tree2: Tree2;
tree1 = tree2;
tree2 = tree1;
@@ -0,0 +1,7 @@
type TreeNode = {
name: string;
parent: TreeNode;
}
var nodes: TreeNode[];
nodes.map(n => n.name);
@@ -0,0 +1,12 @@
type TreeNode = {
name: string;
parent: TreeNode;
}
type TreeNodeMiddleman = {
name: string;
parent: TreeNode;
}
var nodes: TreeNodeMiddleman[];
nodes.map(n => n.name);
@@ -0,0 +1,20 @@
//@jsx: react
//@module: commonjs
//@filename: file.tsx
declare module JSX {
interface Element { }
interface IntrinsicElements {
[s: string]: any;
}
}
//@filename: test.d.ts
export var React;
//@filename: react-consumer.tsx
import {React} from "./test";
// Should emit test_1.React.createElement
// and React.__spread
var foo;
var spread1 = <div x='' {...foo} y='' />;
@@ -0,0 +1,22 @@
//@jsx: react
//@module: commonjs
//@filename: file.tsx
declare module JSX {
interface Element { }
interface IntrinsicElements {
[s: string]: any;
}
}
//@filename: react-consumer.tsx
namespace M {
export var React: any;
}
namespace M {
// Should emit M.React.createElement
// and M.React.__spread
var foo;
var spread1 = <div x='' {...foo} y='' />;
}
@@ -0,0 +1,18 @@
/// <reference path='fourslash.ts'/>
////var C0 = class D</*0*/
////var C1 = class D</*1*/T> {}
////var C3 = class D<T, /*2*/
////var C4 = class D<T, /*3*/U>{}
////var C5 = class D<T extends /*4*/>{}
goTo.marker("0");
verify.completionListIsEmpty();
goTo.marker("1");
verify.completionListIsEmpty();
goTo.marker("2");
verify.completionListIsEmpty();
goTo.marker("3");
verify.completionListIsEmpty();
goTo.marker("4");
verify.not.completionListIsEmpty();
@@ -0,0 +1,17 @@
/// <reference path='fourslash.ts'/>
////type List1</*0*/
////type List2</*1*/T> = T[];
////type List4<T> = /*2*/T[];
////type List3<T1> = /*3*/;
goTo.marker("0");
verify.completionListIsEmpty();
goTo.marker("1");
verify.not.completionListIsEmpty();
goTo.marker("2");
verify.completionListContains("T");
goTo.marker("3");
verify.not.completionListIsEmpty();
verify.not.completionListContains("T");
verify.completionListContains("T1");
@@ -0,0 +1,19 @@
/// <reference path='fourslash.ts'/>
////type Map1<K, /*0*/
////type Map1<K, /*1*/V> = [];
////type Map1<K,V> = /*2*/[];
////type Map1<K1, V1> = </*3*/
goTo.marker("0");
verify.completionListIsEmpty();
goTo.marker("1");
verify.completionListContains("V");
goTo.marker("2");
verify.completionListContains("K");
verify.completionListContains("V");
goTo.marker("3");
verify.not.completionListContains("K");
verify.not.completionListContains("V");
verify.completionListContains("K1");
verify.completionListContains("V1");
+19
View File
@@ -0,0 +1,19 @@
/// <reference path="fourslash.ts"/>
////async function asyncFunction() {/*asyncKeyword*/
//// await
/////*awaitExpressionIndent*/
//// Promise.resolve("await");/*awaitExpressionAutoformat*/
//// return await Promise.resolve("completed");/*awaitKeyword*/
////}
format.document();
goTo.marker("asyncKeyword");
verify.currentLineContentIs("async function asyncFunction() {");
goTo.marker("awaitExpressionIndent");
verify.indentationIs(8);
goTo.marker("awaitExpressionAutoformat");
verify.currentLineContentIs(' Promise.resolve("await");');
goTo.marker("awaitKeyword");
verify.currentLineContentIs(' return await Promise.resolve("completed");');
@@ -0,0 +1,32 @@
/// <reference path='fourslash.ts' />
////function renderElement(
//// element: Element,
//// renderNode:
////(/*funcAutoformat*/
//// node: Node/*funcParamAutoformat*/
/////*funcIndent*/
//// ) => void,
////newNode:
////new(/*constrAutoformat*/
//// name: string/*constrParamAutoformat*/
/////*constrIndent*/
////) => Node
////): void {
////}
format.document();
goTo.marker("funcAutoformat");
verify.currentLineContentIs(" (");
goTo.marker("funcParamAutoformat");
verify.currentLineContentIs(" node: Node");
goTo.marker("funcIndent");
verify.indentationIs(12);
goTo.marker("constrAutoformat");
verify.currentLineContentIs(" new (");
goTo.marker("constrParamAutoformat");
verify.currentLineContentIs(" name: string");
goTo.marker("constrIndent");
verify.indentationIs(12);
+23
View File
@@ -0,0 +1,23 @@
/// <reference path='fourslash.ts' />
////function foo(
//// first:
//// number,/*first*/
//// second: (
//// string/*second*/
//// ),
//// third:
//// (
//// boolean/*third*/
//// )
////) {
////}
format.document();
goTo.marker("first");
verify.currentLineContentIs(" number,");
goTo.marker("second");
verify.currentLineContentIs(" string");
goTo.marker("third");
verify.currentLineContentIs(" boolean");
+31
View File
@@ -0,0 +1,31 @@
/// <reference path="fourslash.ts"/>
////type Foo = {
//// (
//// call: any/*callAutoformat*/
/////*callIndent*/
//// ): void;
//// new (
//// constr: any/*constrAutoformat*/
/////*constrIndent*/
//// ): void;
//// method(
//// whatever: any/*methodAutoformat*/
/////*methodIndent*/
//// ): void;
////};
format.document();
goTo.marker("callAutoformat");
verify.currentLineContentIs(" call: any");
goTo.marker("callIndent");
verify.indentationIs(8);
goTo.marker("constrAutoformat");
verify.currentLineContentIs(" constr: any");
goTo.marker("constrIndent");
verify.indentationIs(8);
goTo.marker("methodAutoformat");
verify.currentLineContentIs(" whatever: any");
goTo.marker("methodIndent");
verify.indentationIs(8);
+16 -1
View File
@@ -2,6 +2,10 @@
////var x = `sadasdasdasdasfegsfd
/////*1*/rasdesgeryt35t35y35 e4 ergt er 35t 3535 `;
////var y = `1${2}/*2*/3`;
////let z= `foo`/*3*/
////let w= `bar${3}`/*4*/
////String.raw
//// `template`/*5*/
goTo.marker("1");
@@ -10,4 +14,15 @@ edit.insert("\r\n"); // edit will trigger formatting - should succeeed
goTo.marker("2");
edit.insert("\r\n");
verify.indentationIs(0);
verify.currentLineContentIs("3`;")
verify.currentLineContentIs("3`;")
goTo.marker("3");
edit.insert(";");
verify.currentLineContentIs("let z = `foo`;");
goTo.marker("4");
edit.insert(";");
verify.currentLineContentIs("let w = `bar${3}`;");
goTo.marker("5");
edit.insert(";");
verify.currentLineContentIs(" `template`;");
+14
View File
@@ -0,0 +1,14 @@
/// <reference path="fourslash.ts"/>
////type Alias = /*typeKeyword*/
/////*indent*/
////number;/*autoformat*/
format.document();
goTo.marker("typeKeyword");
verify.currentLineContentIs("type Alias =");
goTo.marker("indent");
verify.indentationIs(4);
goTo.marker("autoformat");
verify.currentLineContentIs(" number;");
+14
View File
@@ -0,0 +1,14 @@
/// <reference path="fourslash.ts"/>
////type Union = number | {}/*formatOperator*/
/////*indent*/
////|string/*autoformat*/
format.document();
goTo.marker("formatOperator");
verify.currentLineContentIs("type Union = number | {}");
goTo.marker("indent");
verify.indentationIs(4);
goTo.marker("autoformat");
verify.currentLineContentIs(" | string");
@@ -0,0 +1,11 @@
/// <reference path='fourslash.ts' />
////var x = class C {
//// /*definition*/constructor() {
//// var other = new /*usage*/C;
//// }
////}
goTo.marker("usage");
goTo.definition();
verify.caretAtMarker("definition");
@@ -0,0 +1,16 @@
/// <reference path='fourslash.ts' />
////namespace Foo {
//// export var x;
////}
////
////class Foo {
//// /*definition*/constructor() {
//// }
////}
////
////var x = new /*usage*/Foo();
goTo.marker("usage");
goTo.definition();
verify.caretAtMarker("definition");
@@ -0,0 +1,44 @@
/// <reference path='fourslash.ts'/>
////type /*0*/List</*1*/T> = /*2*/T[]
////type /*3*/List2</*4*/T extends string> = /*5*/T[];
type List2<T extends string> = T[];
type L<T> = T[]
let typeAliashDisplayParts = [{ text: "type", kind: "keyword" }, { text: " ", kind: "space" }, { text: "List", kind: "aliasName" },
{ text: "<", kind: "punctuation" }, { text: "T", kind: "typeParameterName" }, { text: ">", kind: "punctuation" }];
let typeAliashDisplayParts2 = [{ text: "type", kind: "keyword" }, { text: " ", kind: "space" }, { text: "List2", kind: "aliasName" },
{ text: "<", kind: "punctuation" }, { text: "T", kind: "typeParameterName" }, { text: " ", kind: "space" }, { text: "extends", kind: "keyword" },
{ text: " ", kind: "space" }, { text: "string", kind: "keyword" }, { text: ">", kind: "punctuation" }];
let typeParameterDisplayParts = [{ text: "(", kind: "punctuation" }, { text: "type parameter", kind: "text" }, { text: ")", kind: "punctuation" }, { text: " ", kind: "space" },
{ text: "T", kind: "typeParameterName" }, { text: " ", kind: "space" }, { text: "in", kind: "keyword" }, { text: " ", kind: "space" } ]
goTo.marker('0');
verify.verifyQuickInfoDisplayParts("type", "", { start: test.markerByName("0").position, length: "List".length },
typeAliashDisplayParts.concat([{ text: " ", kind: "space" }, { text: "=", kind: "operator" }, { "text": " ", "kind": "space" }, { text: "T", kind: "typeParameterName" },
{ text: "[", kind: "punctuation" }, { text: "]", kind: "punctuation" }]), []);
goTo.marker('1');
verify.verifyQuickInfoDisplayParts("type parameter", "", { start: test.markerByName("1").position, length: "T".length },
typeParameterDisplayParts.concat(typeAliashDisplayParts), []);
goTo.marker('2');
verify.verifyQuickInfoDisplayParts("type parameter", "", { start: test.markerByName("2").position, length: "T".length },
typeParameterDisplayParts.concat(typeAliashDisplayParts), []);
goTo.marker('3');
verify.verifyQuickInfoDisplayParts("type", "", { start: test.markerByName("3").position, length: "List2".length },
typeAliashDisplayParts2.concat([{ text: " ", kind: "space" }, { text: "=", kind: "operator" }, { "text": " ", "kind": "space" }, { text: "T", kind: "typeParameterName" },
{ text: "[", kind: "punctuation" }, { text: "]", kind: "punctuation" }]), []);
goTo.marker('4');
verify.verifyQuickInfoDisplayParts("type parameter", "", { start: test.markerByName("4").position, length: "T".length },
typeParameterDisplayParts.concat(typeAliashDisplayParts2), []);
goTo.marker('5');
verify.verifyQuickInfoDisplayParts("type parameter", "", { start: test.markerByName("5").position, length: "T".length },
typeParameterDisplayParts.concat(typeAliashDisplayParts2), []);
@@ -0,0 +1,12 @@
/// <reference path="fourslash.ts"/>
//// var x = class /*0*/C {}
//// class /*1*/C {}
//// class /*2*/D extends class /*3*/B{} { }
var c = classification;
verify.semanticClassificationsAre(
c.className("C", test.marker("0").position),
c.className("C", test.marker("1").position),
c.className("D", test.marker("2").position),
c.className("B", test.marker("3").position)
);
@@ -12,6 +12,6 @@ function verifyIndentationAfterNewLine(marker: string, indentation: number): voi
verifyIndentationAfterNewLine("1", 4);
verifyIndentationAfterNewLine("2", 4);
verifyIndentationAfterNewLine("3", 4);
verifyIndentationAfterNewLine("4", 4);
verifyIndentationAfterNewLine("4", 8);
verifyIndentationAfterNewLine("5", 4);
verifyIndentationAfterNewLine("6", 4);