Merge branch 'master' into cleanHarnessOptionLoading

Conflicts:
	src/harness/harness.ts
This commit is contained in:
Mohamed Hegazy
2015-09-14 16:53:08 -07:00
241 changed files with 6819 additions and 1563 deletions
+5 -3
View File
@@ -143,7 +143,8 @@ var harnessSources = harnessCoreSources.concat([
"convertToBase64.ts",
"transpile.ts",
"reuseProgramStructure.ts",
"cachingInServerLSHost.ts"
"cachingInServerLSHost.ts",
"moduleResolution.ts"
].map(function (f) {
return path.join(unittestsDirectory, f);
})).concat([
@@ -587,9 +588,10 @@ function deleteTemporaryProjectOutput() {
}
var testTimeout = 20000;
desc("Runs the tests using the built run.js file. Syntax is jake runtests. Optional parameters 'host=', 'tests=[regex], reporter=[list|spec|json|<more>]'.");
desc("Runs the tests using the built run.js file. Syntax is jake runtests. Optional parameters 'host=', 'tests=[regex], reporter=[list|spec|json|<more>]', debug=true.");
task("runtests", ["tests", builtLocalDirectory], function() {
cleanTestDirs();
var debug = process.env.debug || process.env.d;
host = "mocha"
tests = process.env.test || process.env.tests || process.env.t;
var light = process.env.light || false;
@@ -612,7 +614,7 @@ task("runtests", ["tests", builtLocalDirectory], function() {
reporter = process.env.reporter || process.env.r || 'mocha-fivemat-progress-reporter';
// timeout normally isn't necessary but Travis-CI has been timing out on compiler baselines occasionally
// default timeout is 2sec which really should be enough, but maybe we just need a small amount longer
var cmd = host + " -R " + reporter + tests + colors + ' -t ' + testTimeout + ' ' + run;
var cmd = host + (debug ? " --debug-brk" : "") + " -R " + reporter + tests + colors + ' -t ' + testTimeout + ' ' + run;
console.log(cmd);
exec(cmd, deleteTemporaryProjectOutput);
}, {async: true});
+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;
+313 -107
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,10 @@ 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." },
Suppress_excess_property_checks_for_object_literals: { code: 6072, category: ts.DiagnosticCategory.Message, key: "Suppress excess property checks for object literals." },
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 +3634,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 +4490,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 +9832,6 @@ var ts;
}
if (!name) {
parseErrorAtPosition(pos, 0, ts.Diagnostics.Identifier_expected);
return undefined;
}
var preName, postName;
if (typeExpression) {
@@ -11681,7 +11689,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);
}
}
@@ -12673,7 +12681,7 @@ var ts;
return members;
}
function resolveTupleTypeMembers(type) {
var arrayType = resolveStructuredTypeMembers(createArrayType(getUnionType(type.elementTypes)));
var arrayType = resolveStructuredTypeMembers(createArrayType(getUnionType(type.elementTypes, true)));
var members = createTupleTypeMemberSymbols(type.elementTypes);
addInheritedMembers(members, arrayType.properties);
setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType);
@@ -12965,25 +12973,6 @@ var ts;
}
return undefined;
}
function isKnownProperty(type, name) {
if (type.flags & 80896 && type !== globalObjectType) {
var resolved = resolveStructuredTypeMembers(type);
return !!(resolved.properties.length === 0 ||
resolved.stringIndexType ||
resolved.numberIndexType ||
getPropertyOfType(type, name));
}
if (type.flags & 49152) {
for (var _i = 0, _a = type.types; _i < _a.length; _i++) {
var t = _a[_i];
if (isKnownProperty(t, name)) {
return true;
}
}
return false;
}
return true;
}
function getSignaturesOfStructuredType(type, kind) {
if (type.flags & 130048) {
var resolved = resolveStructuredTypeMembers(type);
@@ -13439,7 +13428,7 @@ var ts;
}
function createTypedPropertyDescriptorType(propertyType) {
var globalTypedPropertyDescriptorType = getGlobalTypedPropertyDescriptorType();
return globalTypedPropertyDescriptorType !== emptyObjectType
return globalTypedPropertyDescriptorType !== emptyGenericType
? createTypeReference(globalTypedPropertyDescriptorType, [propertyType])
: emptyObjectType;
}
@@ -13492,68 +13481,19 @@ var ts;
addTypeToSet(typeSet, type, typeSetKind);
}
}
function isObjectLiteralTypeDuplicateOf(source, target) {
var sourceProperties = getPropertiesOfObjectType(source);
var targetProperties = getPropertiesOfObjectType(target);
if (sourceProperties.length !== targetProperties.length) {
return false;
}
for (var _i = 0; _i < sourceProperties.length; _i++) {
var sourceProp = sourceProperties[_i];
var targetProp = getPropertyOfObjectType(target, sourceProp.name);
if (!targetProp ||
getDeclarationFlagsFromSymbol(targetProp) & (32 | 64) ||
!isTypeDuplicateOf(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp))) {
return false;
}
}
return true;
}
function isTupleTypeDuplicateOf(source, target) {
var sourceTypes = source.elementTypes;
var targetTypes = target.elementTypes;
if (sourceTypes.length !== targetTypes.length) {
return false;
}
for (var i = 0; i < sourceTypes.length; i++) {
if (!isTypeDuplicateOf(sourceTypes[i], targetTypes[i])) {
return false;
}
}
return true;
}
function isTypeDuplicateOf(source, target) {
if (source === target) {
return true;
}
if (source.flags & 32 || source.flags & 64 && !(target.flags & 32)) {
return true;
}
if (source.flags & 524288 && target.flags & 80896) {
return isObjectLiteralTypeDuplicateOf(source, target);
}
if (isArrayType(source) && isArrayType(target)) {
return isTypeDuplicateOf(source.typeArguments[0], target.typeArguments[0]);
}
if (isTupleType(source) && isTupleType(target)) {
return isTupleTypeDuplicateOf(source, target);
}
return isTypeIdenticalTo(source, target);
}
function isTypeDuplicateOfSomeType(candidate, types) {
for (var _i = 0; _i < types.length; _i++) {
var type = types[_i];
if (candidate !== type && isTypeDuplicateOf(candidate, type)) {
function isSubtypeOfAny(candidate, types) {
for (var i = 0, len = types.length; i < len; i++) {
if (candidate !== types[i] && isTypeSubtypeOf(candidate, types[i])) {
return true;
}
}
return false;
}
function removeDuplicateTypes(types) {
function removeSubtypes(types) {
var i = types.length;
while (i > 0) {
i--;
if (isTypeDuplicateOfSomeType(types[i], types)) {
if (isSubtypeOfAny(types[i], types)) {
types.splice(i, 1);
}
}
@@ -13576,7 +13516,7 @@ var ts;
}
}
}
function getUnionType(types, noDeduplication) {
function getUnionType(types, noSubtypeReduction) {
if (types.length === 0) {
return emptyObjectType;
}
@@ -13585,12 +13525,12 @@ var ts;
if (containsTypeAny(typeSet)) {
return anyType;
}
if (noDeduplication) {
if (noSubtypeReduction) {
removeAllButLast(typeSet, undefinedType);
removeAllButLast(typeSet, nullType);
}
else {
removeDuplicateTypes(typeSet);
removeSubtypes(typeSet);
}
if (typeSet.length === 1) {
return typeSet[0];
@@ -13824,6 +13764,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 +13784,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) {
@@ -14074,6 +14024,26 @@ var ts;
}
return 0;
}
function isKnownProperty(type, name) {
if (type.flags & 80896) {
var resolved = resolveStructuredTypeMembers(type);
if (relation === assignableRelation && (type === globalObjectType || resolved.properties.length === 0) ||
resolved.stringIndexType || resolved.numberIndexType || getPropertyOfType(type, name)) {
return true;
}
return false;
}
if (type.flags & 49152) {
for (var _i = 0, _a = type.types; _i < _a.length; _i++) {
var t = _a[_i];
if (isKnownProperty(t, name)) {
return true;
}
}
return false;
}
return true;
}
function hasExcessProperties(source, target, reportErrors) {
for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) {
var prop = _a[_i];
@@ -14746,7 +14716,7 @@ var ts;
return getWidenedTypeOfObjectLiteral(type);
}
if (type.flags & 16384) {
return getUnionType(ts.map(type.types, getWidenedType));
return getUnionType(ts.map(type.types, getWidenedType), true);
}
if (isArrayType(type)) {
return createArrayType(getWidenedType(type.typeArguments[0]));
@@ -15956,7 +15926,7 @@ var ts;
var propertiesTable = {};
var propertiesArray = [];
var contextualType = getContextualType(node);
var typeFlags;
var typeFlags = 0;
for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
var memberDecl = _a[_i];
var member = memberDecl.symbol;
@@ -15997,7 +15967,8 @@ var ts;
var stringIndexType = getIndexType(0);
var numberIndexType = getIndexType(1);
var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType);
result.flags |= 524288 | 1048576 | 4194304 | (typeFlags & 14680064);
var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 1048576;
result.flags |= 524288 | 4194304 | freshObjectLiteralFlag | (typeFlags & 14680064);
return result;
function getIndexType(kind) {
if (contextualType && contextualTypeHasIndexSignature(contextualType, kind)) {
@@ -17243,7 +17214,7 @@ var ts;
}
function createPromiseType(promisedType) {
var globalPromiseType = getGlobalPromiseType();
if (globalPromiseType !== emptyObjectType) {
if (globalPromiseType !== emptyGenericType) {
promisedType = getAwaitedType(promisedType);
return createTypeReference(globalPromiseType, [promisedType]);
}
@@ -18860,9 +18831,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);
}
}
}
}
@@ -19693,6 +19668,7 @@ var ts;
if (baseTypes.length && produceDiagnostics) {
var baseType = baseTypes[0];
var staticBaseType = getBaseConstructorTypeOfClass(type);
checkSourceElement(baseTypeNode.expression);
if (baseTypeNode.typeArguments) {
ts.forEach(baseTypeNode.typeArguments, checkSourceElement);
for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); _i < _a.length; _i++) {
@@ -20058,7 +20034,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;
@@ -20592,6 +20568,8 @@ var ts;
case 209:
case 210:
case 212:
case 241:
case 186:
case 215:
case 245:
case 225:
@@ -21147,6 +21125,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;
@@ -21314,7 +21295,7 @@ var ts;
}
function createInstantiatedPromiseLikeType() {
var promiseLikeType = getGlobalPromiseLikeType();
if (promiseLikeType !== emptyObjectType) {
if (promiseLikeType !== emptyGenericType) {
return createTypeReference(promiseLikeType, [anyType]);
}
return emptyObjectType;
@@ -23011,6 +22992,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 +23652,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 = {};
@@ -24431,8 +24411,12 @@ var ts;
}
}
function emitJsxElement(openingNode, children) {
var syntheticReactRef = ts.createSynthesizedNode(67);
syntheticReactRef.text = 'React';
syntheticReactRef.parent = openingNode;
emitLeadingComments(openingNode);
write("React.createElement(");
emitExpressionIdentifier(syntheticReactRef);
write(".createElement(");
emitTagName(openingNode.tagName);
write(", ");
if (openingNode.attributes.length === 0) {
@@ -24441,7 +24425,8 @@ var ts;
else {
var attrs = openingNode.attributes;
if (ts.forEach(attrs, function (attr) { return attr.kind === 237; })) {
write("React.__spread(");
emitExpressionIdentifier(syntheticReactRef);
write(".__spread(");
var haveOpenedObjectLiteral = false;
for (var i_1 = 0; i_1 < attrs.length; i_1++) {
if (attrs[i_1].kind === 237) {
@@ -24708,7 +24693,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 +24723,9 @@ var ts;
else if (isNameOfNestedRedeclaration(node)) {
write(getGeneratedNameForNode(node));
}
else if (ts.nodeIsSynthesized(node)) {
write(node.text);
}
else {
writeTextOfNode(currentSourceFile, node);
}
@@ -28558,7 +28551,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 +29324,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 +29356,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 +29506,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 +30185,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"
@@ -30216,6 +30338,12 @@ var ts;
description: ts.Diagnostics.Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations,
paramType: ts.Diagnostics.LOCATION
},
{
name: "suppressExcessPropertyErrors",
type: "boolean",
description: ts.Diagnostics.Suppress_excess_property_checks_for_object_literals,
experimental: true
},
{
name: "suppressImplicitAnyIndexErrors",
type: "boolean",
@@ -30262,20 +30390,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, readFile) {
var options = {};
var fileNames = [];
var errors = [];
var _a = getOptionNameMap(), optionNameMap = _a.optionNameMap, shortOptionNames = _a.shortOptionNames;
parseStrings(commandLine);
return {
options: options,
@@ -30330,7 +30477,7 @@ var ts;
}
}
function parseResponseFile(fileName) {
var text = ts.sys.readFile(fileName);
var text = readFile ? readFile(fileName) : ts.sys.readFile(fileName);
if (!text) {
errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_not_found, fileName));
return;
@@ -30591,6 +30738,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 +30983,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);
+432 -134
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,10 @@ 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." },
Suppress_excess_property_checks_for_object_literals: { code: 6072, category: ts.DiagnosticCategory.Message, key: "Suppress excess property checks for object literals." },
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 +3011,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"
@@ -3154,6 +3164,12 @@ var ts;
description: ts.Diagnostics.Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations,
paramType: ts.Diagnostics.LOCATION
},
{
name: "suppressExcessPropertyErrors",
type: "boolean",
description: ts.Diagnostics.Suppress_excess_property_checks_for_object_literals,
experimental: true
},
{
name: "suppressImplicitAnyIndexErrors",
type: "boolean",
@@ -3200,20 +3216,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, readFile) {
var options = {};
var fileNames = [];
var errors = [];
var _a = getOptionNameMap(), optionNameMap = _a.optionNameMap, shortOptionNames = _a.shortOptionNames;
parseStrings(commandLine);
return {
options: options,
@@ -3268,7 +3303,7 @@ var ts;
}
}
function parseResponseFile(fileName) {
var text = ts.sys.readFile(fileName);
var text = readFile ? readFile(fileName) : ts.sys.readFile(fileName);
if (!text) {
errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_not_found, fileName));
return;
@@ -4203,6 +4238,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 +9580,6 @@ var ts;
}
if (!name) {
parseErrorAtPosition(pos, 0, ts.Diagnostics.Identifier_expected);
return undefined;
}
var preName, postName;
if (typeExpression) {
@@ -10575,6 +10610,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 +12151,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);
}
}
@@ -13105,7 +13143,7 @@ var ts;
return members;
}
function resolveTupleTypeMembers(type) {
var arrayType = resolveStructuredTypeMembers(createArrayType(getUnionType(type.elementTypes)));
var arrayType = resolveStructuredTypeMembers(createArrayType(getUnionType(type.elementTypes, true)));
var members = createTupleTypeMemberSymbols(type.elementTypes);
addInheritedMembers(members, arrayType.properties);
setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType);
@@ -13397,25 +13435,6 @@ var ts;
}
return undefined;
}
function isKnownProperty(type, name) {
if (type.flags & 80896 && type !== globalObjectType) {
var resolved = resolveStructuredTypeMembers(type);
return !!(resolved.properties.length === 0 ||
resolved.stringIndexType ||
resolved.numberIndexType ||
getPropertyOfType(type, name));
}
if (type.flags & 49152) {
for (var _i = 0, _a = type.types; _i < _a.length; _i++) {
var t = _a[_i];
if (isKnownProperty(t, name)) {
return true;
}
}
return false;
}
return true;
}
function getSignaturesOfStructuredType(type, kind) {
if (type.flags & 130048) {
var resolved = resolveStructuredTypeMembers(type);
@@ -13871,7 +13890,7 @@ var ts;
}
function createTypedPropertyDescriptorType(propertyType) {
var globalTypedPropertyDescriptorType = getGlobalTypedPropertyDescriptorType();
return globalTypedPropertyDescriptorType !== emptyObjectType
return globalTypedPropertyDescriptorType !== emptyGenericType
? createTypeReference(globalTypedPropertyDescriptorType, [propertyType])
: emptyObjectType;
}
@@ -13924,68 +13943,19 @@ var ts;
addTypeToSet(typeSet, type, typeSetKind);
}
}
function isObjectLiteralTypeDuplicateOf(source, target) {
var sourceProperties = getPropertiesOfObjectType(source);
var targetProperties = getPropertiesOfObjectType(target);
if (sourceProperties.length !== targetProperties.length) {
return false;
}
for (var _i = 0; _i < sourceProperties.length; _i++) {
var sourceProp = sourceProperties[_i];
var targetProp = getPropertyOfObjectType(target, sourceProp.name);
if (!targetProp ||
getDeclarationFlagsFromSymbol(targetProp) & (32 | 64) ||
!isTypeDuplicateOf(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp))) {
return false;
}
}
return true;
}
function isTupleTypeDuplicateOf(source, target) {
var sourceTypes = source.elementTypes;
var targetTypes = target.elementTypes;
if (sourceTypes.length !== targetTypes.length) {
return false;
}
for (var i = 0; i < sourceTypes.length; i++) {
if (!isTypeDuplicateOf(sourceTypes[i], targetTypes[i])) {
return false;
}
}
return true;
}
function isTypeDuplicateOf(source, target) {
if (source === target) {
return true;
}
if (source.flags & 32 || source.flags & 64 && !(target.flags & 32)) {
return true;
}
if (source.flags & 524288 && target.flags & 80896) {
return isObjectLiteralTypeDuplicateOf(source, target);
}
if (isArrayType(source) && isArrayType(target)) {
return isTypeDuplicateOf(source.typeArguments[0], target.typeArguments[0]);
}
if (isTupleType(source) && isTupleType(target)) {
return isTupleTypeDuplicateOf(source, target);
}
return isTypeIdenticalTo(source, target);
}
function isTypeDuplicateOfSomeType(candidate, types) {
for (var _i = 0; _i < types.length; _i++) {
var type = types[_i];
if (candidate !== type && isTypeDuplicateOf(candidate, type)) {
function isSubtypeOfAny(candidate, types) {
for (var i = 0, len = types.length; i < len; i++) {
if (candidate !== types[i] && isTypeSubtypeOf(candidate, types[i])) {
return true;
}
}
return false;
}
function removeDuplicateTypes(types) {
function removeSubtypes(types) {
var i = types.length;
while (i > 0) {
i--;
if (isTypeDuplicateOfSomeType(types[i], types)) {
if (isSubtypeOfAny(types[i], types)) {
types.splice(i, 1);
}
}
@@ -14008,7 +13978,7 @@ var ts;
}
}
}
function getUnionType(types, noDeduplication) {
function getUnionType(types, noSubtypeReduction) {
if (types.length === 0) {
return emptyObjectType;
}
@@ -14017,12 +13987,12 @@ var ts;
if (containsTypeAny(typeSet)) {
return anyType;
}
if (noDeduplication) {
if (noSubtypeReduction) {
removeAllButLast(typeSet, undefinedType);
removeAllButLast(typeSet, nullType);
}
else {
removeDuplicateTypes(typeSet);
removeSubtypes(typeSet);
}
if (typeSet.length === 1) {
return typeSet[0];
@@ -14256,6 +14226,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 +14246,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) {
@@ -14506,6 +14486,26 @@ var ts;
}
return 0;
}
function isKnownProperty(type, name) {
if (type.flags & 80896) {
var resolved = resolveStructuredTypeMembers(type);
if (relation === assignableRelation && (type === globalObjectType || resolved.properties.length === 0) ||
resolved.stringIndexType || resolved.numberIndexType || getPropertyOfType(type, name)) {
return true;
}
return false;
}
if (type.flags & 49152) {
for (var _i = 0, _a = type.types; _i < _a.length; _i++) {
var t = _a[_i];
if (isKnownProperty(t, name)) {
return true;
}
}
return false;
}
return true;
}
function hasExcessProperties(source, target, reportErrors) {
for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) {
var prop = _a[_i];
@@ -15178,7 +15178,7 @@ var ts;
return getWidenedTypeOfObjectLiteral(type);
}
if (type.flags & 16384) {
return getUnionType(ts.map(type.types, getWidenedType));
return getUnionType(ts.map(type.types, getWidenedType), true);
}
if (isArrayType(type)) {
return createArrayType(getWidenedType(type.typeArguments[0]));
@@ -16388,7 +16388,7 @@ var ts;
var propertiesTable = {};
var propertiesArray = [];
var contextualType = getContextualType(node);
var typeFlags;
var typeFlags = 0;
for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
var memberDecl = _a[_i];
var member = memberDecl.symbol;
@@ -16429,7 +16429,8 @@ var ts;
var stringIndexType = getIndexType(0);
var numberIndexType = getIndexType(1);
var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType);
result.flags |= 524288 | 1048576 | 4194304 | (typeFlags & 14680064);
var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 1048576;
result.flags |= 524288 | 4194304 | freshObjectLiteralFlag | (typeFlags & 14680064);
return result;
function getIndexType(kind) {
if (contextualType && contextualTypeHasIndexSignature(contextualType, kind)) {
@@ -17675,7 +17676,7 @@ var ts;
}
function createPromiseType(promisedType) {
var globalPromiseType = getGlobalPromiseType();
if (globalPromiseType !== emptyObjectType) {
if (globalPromiseType !== emptyGenericType) {
promisedType = getAwaitedType(promisedType);
return createTypeReference(globalPromiseType, [promisedType]);
}
@@ -19292,9 +19293,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);
}
}
}
}
@@ -20125,6 +20130,7 @@ var ts;
if (baseTypes.length && produceDiagnostics) {
var baseType = baseTypes[0];
var staticBaseType = getBaseConstructorTypeOfClass(type);
checkSourceElement(baseTypeNode.expression);
if (baseTypeNode.typeArguments) {
ts.forEach(baseTypeNode.typeArguments, checkSourceElement);
for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); _i < _a.length; _i++) {
@@ -20490,7 +20496,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;
@@ -21024,6 +21030,8 @@ var ts;
case 209:
case 210:
case 212:
case 241:
case 186:
case 215:
case 245:
case 225:
@@ -21579,6 +21587,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;
@@ -21746,7 +21757,7 @@ var ts;
}
function createInstantiatedPromiseLikeType() {
var promiseLikeType = getGlobalPromiseLikeType();
if (promiseLikeType !== emptyObjectType) {
if (promiseLikeType !== emptyGenericType) {
return createTypeReference(promiseLikeType, [anyType]);
}
return emptyObjectType;
@@ -23443,6 +23454,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 +24114,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 = {};
@@ -24863,8 +24873,12 @@ var ts;
}
}
function emitJsxElement(openingNode, children) {
var syntheticReactRef = ts.createSynthesizedNode(67);
syntheticReactRef.text = 'React';
syntheticReactRef.parent = openingNode;
emitLeadingComments(openingNode);
write("React.createElement(");
emitExpressionIdentifier(syntheticReactRef);
write(".createElement(");
emitTagName(openingNode.tagName);
write(", ");
if (openingNode.attributes.length === 0) {
@@ -24873,7 +24887,8 @@ var ts;
else {
var attrs = openingNode.attributes;
if (ts.forEach(attrs, function (attr) { return attr.kind === 237; })) {
write("React.__spread(");
emitExpressionIdentifier(syntheticReactRef);
write(".__spread(");
var haveOpenedObjectLiteral = false;
for (var i_1 = 0; i_1 < attrs.length; i_1++) {
if (attrs[i_1].kind === 237) {
@@ -25140,7 +25155,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 +25185,9 @@ var ts;
else if (isNameOfNestedRedeclaration(node)) {
write(getGeneratedNameForNode(node));
}
else if (ts.nodeIsSynthesized(node)) {
write(node.text);
}
else {
writeTextOfNode(currentSourceFile, node);
}
@@ -28990,7 +29013,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 +29786,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 +29818,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 +29968,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 +32755,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 +33524,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 +33561,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 +35268,7 @@ var ts;
case 212:
case 213:
case 215:
case 214:
case 162:
case 190:
case 217:
@@ -35097,6 +35290,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 +35318,6 @@ var ts;
case 211:
case 171:
case 141:
case 140:
case 145:
case 172:
case 142:
case 143:
@@ -35172,6 +35373,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 +37123,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 +37131,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 +37220,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 +37513,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 +37537,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 +37651,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 +37666,7 @@ var ts;
}
entries = getCompletionEntriesFromSymbols(symbols);
}
if (!isMemberCompletion) {
if (!isMemberCompletion && !isJsDocTagName) {
ts.addRange(entries, keywordCompletions);
}
return { isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, entries: entries };
@@ -37424,6 +37695,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 +37979,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 +38018,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 +38243,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 +42525,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);
}
+11 -1
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;
@@ -1324,6 +1329,7 @@ declare module "typescript" {
rootDir?: string;
sourceMap?: boolean;
sourceRoot?: string;
suppressExcessPropertyErrors?: boolean;
suppressImplicitAnyIndexErrors?: boolean;
target?: ScriptTarget;
version?: boolean;
@@ -1332,6 +1338,7 @@ declare module "typescript" {
experimentalDecorators?: boolean;
experimentalAsyncFunctions?: boolean;
emitDecoratorMetadata?: boolean;
moduleResolution?: ModuleResolutionKind;
[option: string]: string | number | boolean;
}
const enum ModuleKind {
@@ -1509,13 +1516,16 @@ 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;
function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program;
}
declare module "typescript" {
function parseCommandLine(commandLine: string[]): ParsedCommandLine;
function parseCommandLine(commandLine: string[], readFile?: (path: string) => string): ParsedCommandLine;
/**
* Read tsconfig.json file
* @param fileName The path to the config file
+479 -148
View File
File diff suppressed because it is too large Load Diff
+11 -1
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;
@@ -1324,6 +1329,7 @@ declare namespace ts {
rootDir?: string;
sourceMap?: boolean;
sourceRoot?: string;
suppressExcessPropertyErrors?: boolean;
suppressImplicitAnyIndexErrors?: boolean;
target?: ScriptTarget;
version?: boolean;
@@ -1332,6 +1338,7 @@ declare namespace ts {
experimentalDecorators?: boolean;
experimentalAsyncFunctions?: boolean;
emitDecoratorMetadata?: boolean;
moduleResolution?: ModuleResolutionKind;
[option: string]: string | number | boolean;
}
const enum ModuleKind {
@@ -1509,13 +1516,16 @@ 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;
function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program;
}
declare namespace ts {
function parseCommandLine(commandLine: string[]): ParsedCommandLine;
function parseCommandLine(commandLine: string[], readFile?: (path: string) => string): ParsedCommandLine;
/**
* Read tsconfig.json file
* @param fileName The path to the config file
+479 -148
View File
File diff suppressed because it is too large Load Diff
+1
View File
@@ -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);
}
}
}
}
+86 -105
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, /*noSubtypeReduction*/ true)));
let members = createTupleTypeMemberSymbols(type.elementTypes);
addInheritedMembers(members, arrayType.properties);
setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType);
@@ -3451,29 +3451,6 @@ namespace ts {
return undefined;
}
// Check if a property with the given name is known anywhere in the given type. In an object
// type, a property is considered known if the object type is empty, if it has any index
// signatures, or if the property is actually declared in the type. In a union or intersection
// type, a property is considered known if it is known in any constituent type.
function isKnownProperty(type: Type, name: string): boolean {
if (type.flags & TypeFlags.ObjectType && type !== globalObjectType) {
const resolved = resolveStructuredTypeMembers(type);
return !!(resolved.properties.length === 0 ||
resolved.stringIndexType ||
resolved.numberIndexType ||
getPropertyOfType(type, name));
}
if (type.flags & TypeFlags.UnionOrIntersection) {
for (let t of (<UnionOrIntersectionType>type).types) {
if (isKnownProperty(t, name)) {
return true;
}
}
return false;
}
return true;
}
function getSignaturesOfStructuredType(type: Type, kind: SignatureKind): Signature[] {
if (type.flags & TypeFlags.StructuredType) {
let resolved = resolveStructuredTypeMembers(<ObjectType>type);
@@ -4036,7 +4013,7 @@ namespace ts {
*/
function createTypedPropertyDescriptorType(propertyType: Type): Type {
let globalTypedPropertyDescriptorType = getGlobalTypedPropertyDescriptorType();
return globalTypedPropertyDescriptorType !== emptyObjectType
return globalTypedPropertyDescriptorType !== emptyGenericType
? createTypeReference(<GenericType>globalTypedPropertyDescriptorType, [propertyType])
: emptyObjectType;
}
@@ -4103,73 +4080,20 @@ namespace ts {
}
}
function isObjectLiteralTypeDuplicateOf(source: ObjectType, target: ObjectType): boolean {
let sourceProperties = getPropertiesOfObjectType(source);
let targetProperties = getPropertiesOfObjectType(target);
if (sourceProperties.length !== targetProperties.length) {
return false;
}
for (let sourceProp of sourceProperties) {
let targetProp = getPropertyOfObjectType(target, sourceProp.name);
if (!targetProp ||
getDeclarationFlagsFromSymbol(targetProp) & (NodeFlags.Private | NodeFlags.Protected) ||
!isTypeDuplicateOf(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp))) {
return false;
}
}
return true;
}
function isTupleTypeDuplicateOf(source: TupleType, target: TupleType): boolean {
let sourceTypes = source.elementTypes;
let targetTypes = target.elementTypes;
if (sourceTypes.length !== targetTypes.length) {
return false;
}
for (var i = 0; i < sourceTypes.length; i++) {
if (!isTypeDuplicateOf(sourceTypes[i], targetTypes[i])) {
return false;
}
}
return true;
}
// Returns true if the source type is a duplicate of the target type. A source type is a duplicate of
// a target type if the the two are identical, with the exception that the source type may have null or
// undefined in places where the target type doesn't. This is by design an asymmetric relationship.
function isTypeDuplicateOf(source: Type, target: Type): boolean {
if (source === target) {
return true;
}
if (source.flags & TypeFlags.Undefined || source.flags & TypeFlags.Null && !(target.flags & TypeFlags.Undefined)) {
return true;
}
if (source.flags & TypeFlags.ObjectLiteral && target.flags & TypeFlags.ObjectType) {
return isObjectLiteralTypeDuplicateOf(<ObjectType>source, <ObjectType>target);
}
if (isArrayType(source) && isArrayType(target)) {
return isTypeDuplicateOf((<TypeReference>source).typeArguments[0], (<TypeReference>target).typeArguments[0]);
}
if (isTupleType(source) && isTupleType(target)) {
return isTupleTypeDuplicateOf(<TupleType>source, <TupleType>target);
}
return isTypeIdenticalTo(source, target);
}
function isTypeDuplicateOfSomeType(candidate: Type, types: Type[]): boolean {
for (let type of types) {
if (candidate !== type && isTypeDuplicateOf(candidate, type)) {
function isSubtypeOfAny(candidate: Type, types: Type[]): boolean {
for (let i = 0, len = types.length; i < len; i++) {
if (candidate !== types[i] && isTypeSubtypeOf(candidate, types[i])) {
return true;
}
}
return false;
}
function removeDuplicateTypes(types: Type[]) {
function removeSubtypes(types: Type[]) {
let i = types.length;
while (i > 0) {
i--;
if (isTypeDuplicateOfSomeType(types[i], types)) {
if (isSubtypeOfAny(types[i], types)) {
types.splice(i, 1);
}
}
@@ -4194,12 +4118,14 @@ namespace ts {
}
}
// We always deduplicate the constituent type set based on object identity, but we'll also deduplicate
// based on the structure of the types unless the noDeduplication flag is true, which is the case when
// creating a union type from a type node and when instantiating a union type. In both of those cases,
// structural deduplication has to be deferred to properly support recursive union types. For example,
// a type of the form "type Item = string | (() => Item)" cannot be deduplicated during its declaration.
function getUnionType(types: Type[], noDeduplication?: boolean): Type {
// We reduce the constituent type set to only include types that aren't subtypes of other types, unless
// the noSubtypeReduction flag is specified, in which case we perform a simple deduplication based on
// object identity. Subtype reduction is possible only when union types are known not to circularly
// reference themselves (as is the case with union types created by expression constructs such as array
// literals and the || and ?: operators). Named types can circularly reference themselves and therefore
// cannot be deduplicated during their declaration. For example, "type Item = string | (() => Item" is
// a named type that circularly references itself.
function getUnionType(types: Type[], noSubtypeReduction?: boolean): Type {
if (types.length === 0) {
return emptyObjectType;
}
@@ -4208,12 +4134,12 @@ namespace ts {
if (containsTypeAny(typeSet)) {
return anyType;
}
if (noDeduplication) {
if (noSubtypeReduction) {
removeAllButLast(typeSet, undefinedType);
removeAllButLast(typeSet, nullType);
}
else {
removeDuplicateTypes(typeSet);
removeSubtypes(typeSet);
}
if (typeSet.length === 1) {
return typeSet[0];
@@ -4230,7 +4156,7 @@ namespace ts {
function getTypeFromUnionTypeNode(node: UnionTypeNode): Type {
let links = getNodeLinks(node);
if (!links.resolvedType) {
links.resolvedType = getUnionType(map(node.types, getTypeFromTypeNode), /*noDeduplication*/ true);
links.resolvedType = getUnionType(map(node.types, getTypeFromTypeNode), /*noSubtypeReduction*/ true);
}
return links.resolvedType;
}
@@ -4487,6 +4413,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 +4432,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;
}
@@ -4516,7 +4452,7 @@ namespace ts {
return createTupleType(instantiateList((<TupleType>type).elementTypes, mapper, instantiateType));
}
if (type.flags & TypeFlags.Union) {
return getUnionType(instantiateList((<UnionType>type).types, mapper, instantiateType), /*noDeduplication*/ true);
return getUnionType(instantiateList((<UnionType>type).types, mapper, instantiateType), /*noSubtypeReduction*/ true);
}
if (type.flags & TypeFlags.Intersection) {
return getIntersectionType(instantiateList((<IntersectionType>type).types, mapper, instantiateType));
@@ -4612,7 +4548,7 @@ namespace ts {
* @param target The right-hand-side of the relation.
* @param relation The relation considered. One of 'identityRelation', 'assignableRelation', or 'subTypeRelation'.
* Used as both to determine which checks are performed and as a cache of previously computed results.
* @param errorNode The node upon which all errors will be reported, if defined.
* @param errorNode The suggested node upon which all errors will be reported, if defined. This may or may not be the actual node used.
* @param headMessage If the error chain should be prepended by a head message, then headMessage will be used.
* @param containingMessageChain A chain of errors to prepend any new errors found.
*/
@@ -4803,11 +4739,41 @@ namespace ts {
return Ternary.False;
}
// Check if a property with the given name is known anywhere in the given type. In an object type, a property
// is considered known if the object type is empty and the check is for assignability, if the object type has
// index signatures, or if the property is actually declared in the object type. In a union or intersection
// type, a property is considered known if it is known in any constituent type.
function isKnownProperty(type: Type, name: string): boolean {
if (type.flags & TypeFlags.ObjectType) {
const resolved = resolveStructuredTypeMembers(type);
if (relation === assignableRelation && (type === globalObjectType || resolved.properties.length === 0) ||
resolved.stringIndexType || resolved.numberIndexType || getPropertyOfType(type, name)) {
return true;
}
return false;
}
if (type.flags & TypeFlags.UnionOrIntersection) {
for (let t of (<UnionOrIntersectionType>type).types) {
if (isKnownProperty(t, name)) {
return true;
}
}
return false;
}
return true;
}
function hasExcessProperties(source: FreshObjectLiteralType, target: Type, reportErrors: boolean): boolean {
for (let prop of getPropertiesOfObjectType(source)) {
if (!isKnownProperty(target, prop.name)) {
if (reportErrors) {
reportError(Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(prop), typeToString(target));
// We know *exactly* where things went wrong when comparing the types.
// Use this property as the error node as this will be more helpful in
// reasoning about what went wrong.
errorNode = prop.valueDeclaration
reportError(Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1,
symbolToString(prop),
typeToString(target));
}
return true;
}
@@ -5584,7 +5550,7 @@ namespace ts {
return getWidenedTypeOfObjectLiteral(type);
}
if (type.flags & TypeFlags.Union) {
return getUnionType(map((<UnionType>type).types, getWidenedType));
return getUnionType(map((<UnionType>type).types, getWidenedType), /*noSubtypeReduction*/ true);
}
if (isArrayType(type)) {
return createArrayType(getWidenedType((<TypeReference>type).typeArguments[0]));
@@ -7151,7 +7117,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 +7166,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) {
@@ -9165,7 +9132,7 @@ namespace ts {
function createPromiseType(promisedType: Type): Type {
// creates a `Promise<T>` type where `T` is the promisedType argument
let globalPromiseType = getGlobalPromiseType();
if (globalPromiseType !== emptyObjectType) {
if (globalPromiseType !== emptyGenericType) {
// if the promised type is itself a promise, get the underlying type; otherwise, fallback to the promised type
promisedType = getAwaitedType(promisedType);
return createTypeReference(<GenericType>globalPromiseType, [promisedType]);
@@ -11384,9 +11351,16 @@ namespace ts {
// serialize the type metadata.
if (node && node.kind === SyntaxKind.TypeReference) {
let root = getFirstIdentifier((<TypeReferenceNode>node).typeName);
let rootSymbol = resolveName(root, root.text, SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined);
if (rootSymbol && rootSymbol.flags & SymbolFlags.Alias && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) {
markAliasSymbolAsReferenced(rootSymbol);
let meaning = root.parent.kind === SyntaxKind.TypeReference ? SymbolFlags.Type : SymbolFlags.Namespace;
// Resolve type so we know which symbol is referenced
let rootSymbol = resolveName(root, root.text, meaning | SymbolFlags.Alias, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined);
// Resolved symbol is alias
if (rootSymbol && rootSymbol.flags & SymbolFlags.Alias) {
let aliasTarget = resolveAlias(rootSymbol);
// If alias has value symbol - mark alias as referenced
if (aliasTarget.flags & SymbolFlags.Value && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) {
markAliasSymbolAsReferenced(rootSymbol);
}
}
}
}
@@ -12596,6 +12570,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)) {
@@ -13046,7 +13021,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;
}
@@ -13665,6 +13640,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:
@@ -14402,6 +14379,10 @@ namespace ts {
// Resolve the symbol as a type so that we can provide a more useful hint for the type serializer.
let typeSymbol = resolveEntityName(typeName, SymbolFlags.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 TypeReferenceSerializationKind.ObjectType;
}
let type = getDeclaredTypeOfSymbol(typeSymbol);
if (type === unknownType) {
return TypeReferenceSerializationKind.Unknown;
@@ -14608,7 +14589,7 @@ namespace ts {
function createInstantiatedPromiseLikeType(): ObjectType {
let promiseLikeType = getGlobalPromiseLikeType();
if (promiseLikeType !== emptyObjectType) {
if (promiseLikeType !== emptyGenericType) {
return createTypeReference(<GenericType>promiseLikeType, [anyType]);
}
+49 -11
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",
@@ -225,22 +236,49 @@ namespace ts {
type: "boolean",
experimental: true,
description: Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators
}
},
{
name: "moduleResolution",
type: {
"node": ModuleResolutionKind.NodeJs,
"classic": ModuleResolutionKind.Classic
},
description: Diagnostics.Specifies_module_resolution_strategy_Colon_node_Node_or_classic_TypeScript_pre_1_6
}
];
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,
@@ -304,7 +342,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));
@@ -341,10 +379,10 @@ namespace ts {
* Read tsconfig.json file
* @param fileName The path to the config file
*/
export function readConfigFile(fileName: string): { config?: any; error?: Diagnostic } {
export function readConfigFile(fileName: string, readFile: (path: string) => string): { config?: any; error?: Diagnostic } {
let text = "";
try {
text = sys.readFile(fileName);
text = readFile(fileName);
}
catch (e) {
return { error: createCompilerDiagnostic(Diagnostics.Cannot_read_file_0_Colon_1, fileName, e.message) };
@@ -457,4 +495,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;
@@ -244,7 +244,7 @@ namespace ts {
Property_0_does_not_exist_on_type_1: { code: 2339, category: DiagnosticCategory.Error, key: "Property '{0}' does not exist on type '{1}'." },
Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: { code: 2340, category: DiagnosticCategory.Error, key: "Only public and protected methods of the base class are accessible via the 'super' keyword." },
Property_0_is_private_and_only_accessible_within_class_1: { code: 2341, category: DiagnosticCategory.Error, key: "Property '{0}' is private and only accessible within class '{1}'." },
An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: { code: 2342, category: DiagnosticCategory.Error, key: "An index expression argument must be of type 'string', 'number', 'symbol, or 'any'." },
An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: { code: 2342, category: DiagnosticCategory.Error, key: "An index expression argument must be of type 'string', 'number', 'symbol', or 'any'." },
Type_0_does_not_satisfy_the_constraint_1: { code: 2344, category: DiagnosticCategory.Error, key: "Type '{0}' does not satisfy the constraint '{1}'." },
Argument_of_type_0_is_not_assignable_to_parameter_of_type_1: { code: 2345, category: DiagnosticCategory.Error, key: "Argument of type '{0}' is not assignable to parameter of type '{1}'." },
Supplied_parameters_do_not_match_any_signature_of_call_target: { code: 2346, category: DiagnosticCategory.Error, key: "Supplied parameters do not match any signature of call target." },
@@ -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." },
@@ -565,6 +566,10 @@ namespace ts {
Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: 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: 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." },
+25 -5
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",
@@ -965,7 +965,7 @@
"category": "Error",
"code": 2341
},
"An index expression argument must be of type 'string', 'number', 'symbol, or 'any'.": {
"An index expression argument must be of type 'string', 'number', 'symbol', or 'any'.": {
"category": "Error",
"code": 2342
},
@@ -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
@@ -2250,7 +2254,23 @@
"category": "Message",
"code": 6068
},
"Specifies module resolution strategy: 'node' (Node) or 'classic' (TypeScript pre 1.6) .": {
"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",
"code": 7005
+126 -117
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++) {
@@ -1519,7 +1521,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
return;
}
}
writeTextOfNode(currentSourceFile, node);
if (nodeIsSynthesized(node)) {
write(node.text);
}
else {
writeTextOfNode(currentSourceFile, node);
}
}
function isNameOfNestedRedeclaration(node: Identifier) {
@@ -1546,6 +1554,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
else if (isNameOfNestedRedeclaration(node)) {
write(getGeneratedNameForNode(node));
}
else if (nodeIsSynthesized(node)) {
write(node.text);
}
else {
writeTextOfNode(currentSourceFile, node);
}
@@ -2105,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(".");
@@ -2128,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) {
@@ -2141,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;
@@ -3055,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();
}
@@ -4311,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);
@@ -4883,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:
@@ -4894,100 +4905,98 @@ 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;
if (node) {
switch (node.kind) {
case SyntaxKind.VoidKeyword:
write("void 0");
return;
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");
return;
case SyntaxKind.StringKeyword:
case SyntaxKind.StringLiteral:
write("String");
return;
case SyntaxKind.NumberKeyword:
write("Number");
return;
case SyntaxKind.SymbolKeyword:
write("Symbol");
return;
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;
}
}
switch (node.kind) {
case SyntaxKind.VoidKeyword:
write("void 0");
return;
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");
return;
case SyntaxKind.StringKeyword:
case SyntaxKind.StringLiteral:
write("String");
return;
case SyntaxKind.NumberKeyword:
write("Number");
return;
case SyntaxKind.SymbolKeyword:
write("Symbol");
return;
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;
@@ -5015,27 +5024,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");
@@ -5044,24 +5053,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;
@@ -5071,7 +5080,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;
@@ -5080,7 +5089,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) {
@@ -5092,7 +5101,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
else {
parameterType = undefined;
}
emitSerializedTypeNode(parameterType);
}
else {
@@ -5103,18 +5112,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.
@@ -5144,7 +5153,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
if (writeComma || argumentsWritten) {
write(", ");
}
writeLine();
write("__metadata('design:returntype', ");
emitSerializedReturnTypeOfNode(node);
@@ -5152,10 +5161,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
argumentsWritten++;
}
}
return argumentsWritten;
}
function emitInterfaceDeclaration(node: InterfaceDeclaration) {
emitOnlyPinnedOrTripleSlashComments(node);
}
@@ -5521,18 +5530,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 ");
@@ -5541,8 +5550,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
write("var ");
}
}
if (isExported) {
write(`${exportFunctionForFile}("`);
emitNodeWithoutSourceMap(node.name);
@@ -5556,8 +5565,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
if (isExported) {
write(")");
}
write(";");
write(";");
emitEnd(node);
emitExportImportAssignments(node);
emitTrailingComments(node);
@@ -6079,12 +6088,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);
}
+153 -3
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;
@@ -36,11 +37,150 @@ namespace ts {
}
export function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModule {
// TODO: use different resolution strategy based on compiler options
return legacyNameResolver(moduleName, containingFile, compilerOptions, host);
let moduleResolution = compilerOptions.moduleResolution !== undefined
? compilerOptions.moduleResolution
: compilerOptions.module === ModuleKind.CommonJS ? ModuleResolutionKind.NodeJs : ModuleResolutionKind.Classic;
switch (moduleResolution) {
case ModuleResolutionKind.NodeJs: return nodeModuleNameResolver(moduleName, containingFile, host);
case ModuleResolutionKind.Classic: return classicNameResolver(moduleName, containingFile, compilerOptions, host);
}
}
export function nodeModuleNameResolver(moduleName: string, containingFile: string, host: ModuleResolutionHost): ResolvedModule {
let containingDirectory = getDirectoryPath(containingFile);
if (getRootLength(moduleName) !== 0 || nameStartsWithDotSlashOrDotDotSlash(moduleName)) {
let failedLookupLocations: string[] = [];
let candidate = normalizePath(combinePaths(containingDirectory, moduleName));
let resolvedFileName = loadNodeModuleFromFile(candidate, /* loadOnlyDts */ false, failedLookupLocations, host);
if (resolvedFileName) {
return { resolvedFileName, failedLookupLocations };
}
resolvedFileName = loadNodeModuleFromDirectory(candidate, /* loadOnlyDts */ false, failedLookupLocations, host);
return { resolvedFileName, failedLookupLocations };
}
else {
return loadModuleFromNodeModules(moduleName, containingDirectory, host);
}
}
function loadNodeModuleFromFile(candidate: string, loadOnlyDts: boolean, failedLookupLocation: string[], host: ModuleResolutionHost): string {
if (loadOnlyDts) {
return tryLoad(".d.ts");
}
else {
return forEach(supportedExtensions, tryLoad);
}
function tryLoad(ext: string): string {
let fileName = fileExtensionIs(candidate, ext) ? candidate : candidate + ext;
if (host.fileExists(fileName)) {
return fileName;
}
else {
failedLookupLocation.push(fileName);
return undefined;
}
}
}
function loadNodeModuleFromDirectory(candidate: string, loadOnlyDts: boolean, failedLookupLocation: string[], host: ModuleResolutionHost): string {
let packageJsonPath = combinePaths(candidate, "package.json");
if (host.fileExists(packageJsonPath)) {
let jsonContent: { typings?: string };
try {
let jsonText = host.readFile(packageJsonPath);
jsonContent = jsonText ? <{ typings?: string }>JSON.parse(jsonText) : { typings: undefined };
}
catch (e) {
// gracefully handle if readFile fails or returns not JSON
jsonContent = { typings: undefined };
}
if (jsonContent.typings) {
let result = loadNodeModuleFromFile(normalizePath(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(combinePaths(candidate, "index"), loadOnlyDts, failedLookupLocation, host);
}
function loadModuleFromNodeModules(moduleName: string, directory: string, host: ModuleResolutionHost): ResolvedModule {
let failedLookupLocations: string[] = [];
directory = normalizeSlashes(directory);
while (true) {
let baseName = getBaseFileName(directory);
if (baseName !== "node_modules") {
let nodeModulesFolder = combinePaths(directory, "node_modules");
let candidate = normalizePath(combinePaths(nodeModulesFolder, moduleName));
let result = loadNodeModuleFromFile(candidate, /* loadOnlyDts */ true, failedLookupLocations, host);
if (result) {
return { resolvedFileName: result, failedLookupLocations };
}
result = loadNodeModuleFromDirectory(candidate, /* loadOnlyDts */ true, failedLookupLocations, host);
if (result) {
return { resolvedFileName: result, failedLookupLocations };
}
}
let parentPath = getDirectoryPath(directory);
if (parentPath === directory) {
break;
}
directory = parentPath;
}
return { resolvedFileName: undefined, failedLookupLocations };
}
export function baseUrlModuleNameResolver(moduleName: string, containingFile: string, baseUrl: string, host: ModuleResolutionHost): ResolvedModule {
Debug.assert(baseUrl !== undefined);
let normalizedModuleName = normalizeSlashes(moduleName);
let basePart = useBaseUrl(moduleName) ? baseUrl : getDirectoryPath(containingFile);
let candidate = normalizePath(combinePaths(basePart, moduleName));
let failedLookupLocations: string[] = [];
return forEach(supportedExtensions, ext => tryLoadFile(candidate + ext)) || { resolvedFileName: undefined, failedLookupLocations };
function tryLoadFile(location: string): ResolvedModule {
if (host.fileExists(location)) {
return { resolvedFileName: location, failedLookupLocations };
}
else {
failedLookupLocations.push(location);
return undefined;
}
}
}
function nameStartsWithDotSlashOrDotDotSlash(name: string) {
let i = name.lastIndexOf("./", 1);
return i === 0 || (i === 1 && name.charCodeAt(0) === CharacterCodes.dot);
}
function useBaseUrl(moduleName: string): boolean {
// path is not rooted
// module name does not start with './' or '../'
return getRootLength(moduleName) === 0 && !nameStartsWithDotSlashOrDotDotSlash(moduleName);
}
function legacyNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModule {
export function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModule {
// module names that contain '!' are used to reference resources and are not resolved to actual files on disk
if (moduleName.indexOf('!') != -1) {
@@ -85,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> = {};
+70 -1
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);
@@ -211,7 +216,7 @@ namespace ts {
if (!cachedProgram) {
if (configFileName) {
let result = readConfigFile(configFileName);
let result = readConfigFile(configFileName, sys.readFile);
if (result.error) {
reportDiagnostic(result.error);
return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
@@ -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);
+12 -3
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.
@@ -2009,7 +2010,12 @@ namespace ts {
Error,
Message,
}
export const enum ModuleResolutionKind {
Classic = 1,
NodeJs = 2
}
export interface CompilerOptions {
allowNonTsExtensions?: boolean;
charset?: string;
@@ -2017,6 +2023,7 @@ namespace ts {
diagnostics?: boolean;
emitBOM?: boolean;
help?: boolean;
init?: boolean;
inlineSourceMap?: boolean;
inlineSources?: boolean;
jsx?: JsxEmit;
@@ -2041,6 +2048,7 @@ namespace ts {
rootDir?: string;
sourceMap?: boolean;
sourceRoot?: string;
suppressExcessPropertyErrors?: boolean;
suppressImplicitAnyIndexErrors?: boolean;
target?: ScriptTarget;
version?: boolean;
@@ -2049,6 +2057,7 @@ namespace ts {
experimentalDecorators?: boolean;
experimentalAsyncFunctions?: boolean;
emitDecoratorMetadata?: boolean;
moduleResolution?: ModuleResolutionKind
/* @internal */ stripInternal?: boolean;
// Skip checking lib.d.ts to help speed up tests.
+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);
}
+29 -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 {
@@ -1195,8 +1208,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());
@@ -1207,8 +1220,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
@@ -1293,7 +1313,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");
@@ -1432,7 +1452,6 @@ module Harness {
let optionRegex = /^[\/]{2}\s*@(\w+)\s*:\s*(\S*)/gm; // multiple matches on multiple lines
function extractCompilerSettings(content: string): CompilerSettings {
let opts: CompilerSettings = {};
let match: RegExpExecArray;
@@ -1660,11 +1679,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 }),
+1
View File
@@ -163,6 +163,7 @@ class ProjectRunner extends RunnerBase {
mapRoot: testCase.resolveMapRoot && testCase.mapRoot ? Harness.IO.resolvePath(testCase.mapRoot) : testCase.mapRoot,
sourceRoot: testCase.resolveSourceRoot && testCase.sourceRoot ? Harness.IO.resolvePath(testCase.sourceRoot) : testCase.sourceRoot,
module: moduleKind,
moduleResolution: ts.ModuleResolutionKind.Classic, // currently all tests use classic module resolution kind, this will change in the future
noResolve: testCase.noResolve,
rootDir: testCase.rootDir
};
+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;
+30 -2
View File
@@ -88,6 +88,7 @@ declare module Intl {
timeZoneName?: string;
formatMatcher?: string;
hour12?: boolean;
timeZone?: string;
}
interface ResolvedDateTimeFormatOptions {
@@ -157,17 +158,44 @@ interface Number {
interface Date {
/**
* Converts a date to a string by using the current or specified locale.
* Converts a date and time to a string by using the current or specified locale.
* @param locales An array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used.
* @param options An object that contains one or more properties that specify comparison options.
*/
toLocaleString(locales?: string[], options?: Intl.DateTimeFormatOptions): string;
/**
* Converts a date to a string by using the current or specified locale.
* @param locales An array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used.
* @param options An object that contains one or more properties that specify comparison options.
*/
toLocaleDateString(locales?: string[], options?: Intl.DateTimeFormatOptions): string;
/**
* Converts a time to a string by using the current or specified locale.
* @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used.
* @param options An object that contains one or more properties that specify comparison options.
*/
toLocaleTimeString(locale?: string[], options?: Intl.DateTimeFormatOptions): string;
/**
* Converts a date and time to a string by using the current or specified locale.
* @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used.
* @param options An object that contains one or more properties that specify comparison options.
*/
toLocaleString(locale?: string, options?: Intl.DateTimeFormatOptions): string;
/**
* Converts a date to a string by using the current or specified locale.
* @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used.
* @param options An object that contains one or more properties that specify comparison options.
*/
toLocaleString(locale?: string, options?: Intl.DateTimeFormatOptions): string;
toLocaleDateString(locale?: string, options?: Intl.DateTimeFormatOptions): string;
/**
* Converts a time to a string by using the current or specified locale.
* @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used.
* @param options An object that contains one or more properties that specify comparison options.
*/
toLocaleTimeString(locale?: string, options?: Intl.DateTimeFormatOptions): string;
}
+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;
+31 -31
View File
@@ -614,30 +614,30 @@ namespace ts.server {
}
this.configuredProjects = configuredProjects;
}
removeConfiguredProject(project: Project) {
project.projectFileWatcher.close();
this.configuredProjects = copyListRemovingItem(project, this.configuredProjects);
let fileNames = project.getFileNames();
for (let fileName of fileNames) {
let info = this.getScriptInfo(fileName);
if (info.defaultProject == project){
info.defaultProject = undefined;
}
removeConfiguredProject(project: Project) {
project.projectFileWatcher.close();
this.configuredProjects = copyListRemovingItem(project, this.configuredProjects);
let fileNames = project.getFileNames();
for (let fileName of fileNames) {
let info = this.getScriptInfo(fileName);
if (info.defaultProject == project) {
info.defaultProject = undefined;
}
}
}
setConfiguredProjectRoot(info: ScriptInfo) {
for (var i = 0, len = this.configuredProjects.length; i < len; i++) {
let configuredProject = this.configuredProjects[i];
if (configuredProject.isRoot(info)) {
info.defaultProject = configuredProject;
configuredProject.addOpenRef();
return true;
}
}
return false;
for (var i = 0, len = this.configuredProjects.length; i < len; i++) {
let configuredProject = this.configuredProjects[i];
if (configuredProject.isRoot(info)) {
info.defaultProject = configuredProject;
configuredProject.addOpenRef();
return true;
}
}
return false;
}
addOpenFile(info: ScriptInfo) {
@@ -785,7 +785,7 @@ namespace ts.server {
updateProjectStructure() {
this.log("updating project structure from ...", "Info");
this.printProjects();
let unattachedOpenFiles: ScriptInfo[] = [];
let openFileRootsConfigured: ScriptInfo[] = [];
for (let info of this.openFileRootsConfigured) {
@@ -921,10 +921,10 @@ namespace ts.server {
this.printProjects();
return info;
}
openOrUpdateConfiguredProjectForFile(fileName: string) {
let searchPath = ts.normalizePath(getDirectoryPath(fileName));
this.log("Search path: " + searchPath,"Info");
this.log("Search path: " + searchPath, "Info");
let configFileName = this.findConfigFile(searchPath);
if (configFileName) {
this.log("Config file name: " + configFileName, "Info");
@@ -935,7 +935,7 @@ namespace ts.server {
this.log("Error opening config file " + configFileName + " " + configResult.errorMsg);
}
else {
this.log("Opened configuration file " + configFileName,"Info");
this.log("Opened configuration file " + configFileName, "Info");
this.configuredProjects.push(configResult.project);
}
}
@@ -1000,7 +1000,7 @@ namespace ts.server {
for (var i = 0, len = this.configuredProjects.length; i < len; i++) {
var project = this.configuredProjects[i];
project.updateGraph();
this.psLogger.info("Project (configured) " + (i+this.inferredProjects.length).toString());
this.psLogger.info("Project (configured) " + (i + this.inferredProjects.length).toString());
this.psLogger.info(project.filesToString());
this.psLogger.info("-----------------------------------------------");
}
@@ -1048,10 +1048,10 @@ namespace ts.server {
else {
var parsedCommandLine = ts.parseConfigFile(rawConfig.config, this.host, dirPath);
if (parsedCommandLine.errors && (parsedCommandLine.errors.length > 0)) {
return { succeeded: false, error: { errorMsg: "tsconfig option errors" }};
return { succeeded: false, error: { errorMsg: "tsconfig option errors" } };
}
else if (parsedCommandLine.fileNames == null) {
return { succeeded: false, error: { errorMsg: "no files found" }}
return { succeeded: false, error: { errorMsg: "no files found" } }
}
else {
var projectOptions: ProjectOptions = {
@@ -1068,7 +1068,7 @@ namespace ts.server {
let { succeeded, projectOptions, error } = this.configFileToProjectOptions(configFilename);
if (!succeeded) {
return error;
}
}
else {
let proj = this.createProject(configFilename, projectOptions);
for (let i = 0, len = projectOptions.files.length; i < len; i++) {
@@ -1086,7 +1086,7 @@ namespace ts.server {
return { success: true, project: proj };
}
}
updateConfiguredProject(project: Project) {
if (!this.host.fileExists(project.projectFilename)) {
this.log("Config file deleted");
@@ -1098,16 +1098,16 @@ namespace ts.server {
return error;
}
else {
let oldFileNames = project.compilerService.host.roots.map(info => info.fileName);
let oldFileNames = project.compilerService.host.roots.map(info => info.fileName);
let newFileNames = projectOptions.files;
let fileNamesToRemove = oldFileNames.filter(f => newFileNames.indexOf(f) < 0);
let fileNamesToAdd = newFileNames.filter(f => oldFileNames.indexOf(f) < 0);
for (let fileName of fileNamesToRemove) {
let info = this.getScriptInfo(fileName);
project.removeRoot(info);
}
for (let fileName of fileNamesToAdd) {
let info = this.getScriptInfo(fileName);
if (!info) {
+12 -8
View File
@@ -32,7 +32,7 @@ namespace ts.formatting {
*/
interface DynamicIndentation {
getIndentationForToken(tokenLine: number, tokenKind: SyntaxKind): number;
getIndentationForComment(owningToken: SyntaxKind): number;
getIndentationForComment(owningToken: SyntaxKind, tokenIndentation: number): number;
/**
* Indentation for open and close tokens of the node if it is block or another node that needs special indentation
* ... {
@@ -455,7 +455,7 @@ namespace ts.formatting {
function getDynamicIndentation(node: Node, nodeStartLine: number, indentation: number, delta: number): DynamicIndentation {
return {
getIndentationForComment: kind => {
getIndentationForComment: (kind, tokenIndentation) => {
switch (kind) {
// preceding comment to the token that closes the indentation scope inherits the indentation from the scope
// .. {
@@ -463,9 +463,10 @@ namespace ts.formatting {
// }
case SyntaxKind.CloseBraceToken:
case SyntaxKind.CloseBracketToken:
case SyntaxKind.CloseParenToken:
return indentation + delta;
}
return indentation;
return tokenIndentation !== Constants.Unknown ? tokenIndentation : indentation;
},
getIndentationForToken: (line, kind) => {
if (nodeStartLine !== line && node.decorators) {
@@ -716,8 +717,14 @@ namespace ts.formatting {
}
if (indentToken) {
let indentNextTokenOrTrivia = true;
let tokenIndentation = (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) ?
dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind) :
Constants.Unknown;
if (currentTokenInfo.leadingTrivia) {
let commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind, tokenIndentation);
let indentNextTokenOrTrivia = true;
for (let triviaItem of currentTokenInfo.leadingTrivia) {
if (!rangeContainsRange(originalRange, triviaItem)) {
continue;
@@ -725,13 +732,11 @@ namespace ts.formatting {
switch (triviaItem.kind) {
case SyntaxKind.MultiLineCommentTrivia:
let commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind);
indentMultilineComment(triviaItem, commentIndentation, /*firstLineIsIndented*/ !indentNextTokenOrTrivia);
indentNextTokenOrTrivia = false;
break;
case SyntaxKind.SingleLineCommentTrivia:
if (indentNextTokenOrTrivia) {
let commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind);
insertIndentation(triviaItem.pos, commentIndentation, /*lineAdded*/ false);
indentNextTokenOrTrivia = false;
}
@@ -744,8 +749,7 @@ namespace ts.formatting {
}
// indent token only if is it is in target range and does not overlap with any error ranges
if (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) {
let tokenIndentation = dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind);
if (tokenIndentation !== Constants.Unknown) {
insertIndentation(currentTokenInfo.token.pos, tokenIndentation, lineAdded);
lastIndentedLine = tokenStart.line;
+23 -2
View File
@@ -17,7 +17,8 @@ namespace ts.formatting {
Scan,
RescanGreaterThanToken,
RescanSlashToken,
RescanTemplateToken
RescanTemplateToken,
RescanJsxIdentifier
}
export function getFormattingScanner(sourceFile: SourceFile, startPos: number, endPos: number): FormattingScanner {
@@ -108,6 +109,20 @@ namespace ts.formatting {
return false;
}
function shouldRescanJsxIdentifier(node: Node): boolean {
if (node.parent) {
switch(node.parent.kind) {
case SyntaxKind.JsxAttribute:
case SyntaxKind.JsxOpeningElement:
case SyntaxKind.JsxClosingElement:
case SyntaxKind.JsxSelfClosingElement:
return node.kind === SyntaxKind.Identifier;
}
}
return false;
}
function shouldRescanSlashToken(container: Node): boolean {
return container.kind === SyntaxKind.RegularExpressionLiteral;
@@ -141,7 +156,9 @@ namespace ts.formatting {
? ScanAction.RescanSlashToken
: shouldRescanTemplateToken(n)
? ScanAction.RescanTemplateToken
: ScanAction.Scan
: shouldRescanJsxIdentifier(n)
? ScanAction.RescanJsxIdentifier
: ScanAction.Scan
if (lastTokenInfo && expectedScanAction === lastScanAction) {
// readTokenInfo was called before with the same expected scan action.
@@ -176,6 +193,10 @@ namespace ts.formatting {
currentToken = scanner.reScanTemplateToken();
lastScanAction = ScanAction.RescanTemplateToken;
}
else if (expectedScanAction === ScanAction.RescanJsxIdentifier && currentToken === SyntaxKind.Identifier) {
currentToken = scanner.scanJsxIdentifier();
lastScanAction = ScanAction.RescanJsxIdentifier;
}
else {
lastScanAction = ScanAction.Scan;
}
+52 -1
View File
@@ -213,6 +213,28 @@ 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;
// Type operation
public SpaceBeforeBar: Rule;
public NoSpaceBeforeBar: Rule;
public SpaceAfterBar: Rule;
public NoSpaceAfterBar: Rule;
public SpaceBeforeAmpersand: Rule;
public SpaceAfterAmpersand: Rule;
constructor() {
///
/// Common Rules
@@ -252,7 +274,7 @@ namespace ts.formatting {
this.SpaceBeforeOpenBraceInFunction = new Rule(RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, SyntaxKind.OpenBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), RuleAction.Space), RuleFlags.CanDeleteNewLines);
// Place a space before open brace in a TypeScript declaration that has braces as children (class, module, enum, etc)
this.TypeScriptOpenBraceLeftTokenRange = Shared.TokenRange.FromTokens([SyntaxKind.Identifier, SyntaxKind.MultiLineCommentTrivia]);
this.TypeScriptOpenBraceLeftTokenRange = Shared.TokenRange.FromTokens([SyntaxKind.Identifier, SyntaxKind.MultiLineCommentTrivia, SyntaxKind.ClassKeyword]);
this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new Rule(RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, SyntaxKind.OpenBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), RuleAction.Space), RuleFlags.CanDeleteNewLines);
// Place a space before open brace in a control flow construct
@@ -360,6 +382,28 @@ 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));
// type operation
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));
this.SpaceBeforeAmpersand = new Rule(RuleDescriptor.create3(SyntaxKind.AmpersandToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
this.SpaceAfterAmpersand = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.AmpersandToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
// These rules are higher in priority than user-configurable rules.
this.HighPriorityCommonRules =
[
@@ -386,6 +430,12 @@ 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,
this.SpaceBeforeAmpersand, this.SpaceAfterAmpersand,
// TypeScript-specific rules
this.NoSpaceAfterConstructor, this.NoSpaceAfterModuleImport,
@@ -617,6 +667,7 @@ namespace ts.formatting {
static NodeIsTypeScriptDeclWithBlockContext(node: Node): boolean {
switch (node.kind) {
case SyntaxKind.ClassDeclaration:
case SyntaxKind.ClassExpression:
case SyntaxKind.InterfaceDeclaration:
case SyntaxKind.EnumDeclaration:
case SyntaxKind.TypeLiteral:
+12 -2
View File
@@ -406,8 +406,10 @@ namespace ts.formatting {
function nodeContentIsAlwaysIndented(kind: SyntaxKind): boolean {
switch (kind) {
case SyntaxKind.ClassDeclaration:
case SyntaxKind.ClassExpression:
case SyntaxKind.InterfaceDeclaration:
case SyntaxKind.EnumDeclaration:
case SyntaxKind.TypeAliasDeclaration:
case SyntaxKind.ArrayLiteralExpression:
case SyntaxKind.Block:
case SyntaxKind.ModuleBlock:
@@ -429,6 +431,16 @@ namespace ts.formatting {
case SyntaxKind.ArrayBindingPattern:
case SyntaxKind.ObjectBindingPattern:
case SyntaxKind.JsxElement:
case SyntaxKind.JsxSelfClosingElement:
case SyntaxKind.MethodSignature:
case SyntaxKind.CallSignature:
case SyntaxKind.ConstructSignature:
case SyntaxKind.Parameter:
case SyntaxKind.FunctionType:
case SyntaxKind.ConstructorType:
case SyntaxKind.ParenthesizedType:
case SyntaxKind.TaggedTemplateExpression:
case SyntaxKind.AwaitExpression:
return true;
}
return false;
@@ -448,8 +460,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:
+42 -16
View File
@@ -1866,7 +1866,7 @@ namespace ts {
let sourceMapText: string;
// Create a compilerHost object to allow the compiler to read and write files
let compilerHost: CompilerHost = {
getSourceFile: (fileName, target) => fileName === inputFileName ? sourceFile : undefined,
getSourceFile: (fileName, target) => fileName === normalizeSlashes(inputFileName) ? sourceFile : undefined,
writeFile: (name, text, writeByteOrderMark) => {
if (fileExtensionIs(name, ".map")) {
Debug.assert(sourceMapText === undefined, `Unexpected multiple source map outputs for the file '${name}'`);
@@ -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;
@@ -5860,6 +5885,7 @@ namespace ts {
result.push(getReferenceEntryFromNode(node));
}
break;
case SyntaxKind.ClassExpression:
case SyntaxKind.ClassDeclaration:
// Make sure the container belongs to the same class
// and has the appropriate static modifier from the original container.
+25 -14
View File
@@ -360,7 +360,7 @@ namespace ts {
return find(startNode || sourceFile);
function findRightmostToken(n: Node): Node {
if (isToken(n)) {
if (isToken(n) || n.kind === SyntaxKind.JsxText) {
return n;
}
@@ -371,24 +371,35 @@ namespace ts {
}
function find(n: Node): Node {
if (isToken(n)) {
if (isToken(n) || n.kind === SyntaxKind.JsxText) {
return n;
}
let children = n.getChildren();
const children = n.getChildren();
for (let i = 0, len = children.length; i < len; i++) {
let child = children[i];
if (nodeHasTokens(child)) {
if (position <= child.end) {
if (child.getStart(sourceFile) >= position) {
// actual start of the node is past the position - previous token should be at the end of previous child
let candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ i);
return candidate && findRightmostToken(candidate)
}
else {
// candidate should be in this node
return find(child);
}
// condition 'position < child.end' checks if child node end after the position
// in the example below this condition will be false for 'aaaa' and 'bbbb' and true for 'ccc'
// aaaa___bbbb___$__ccc
// after we found child node with end after the position we check if start of the node is after the position.
// if yes - then position is in the trivia and we need to look into the previous child to find the token in question.
// if no - position is in the node itself so we should recurse in it.
// NOTE: JsxText is a weird kind of node that can contain only whitespaces (since they are not counted as trivia).
// if this is the case - then we should assume that token in question is located in previous child.
if (position < child.end && (nodeHasTokens(child) || child.kind === SyntaxKind.JsxText)) {
const start = child.getStart(sourceFile);
const lookInPreviousChild =
(start >= position) || // cursor in the leading trivia
(child.kind === SyntaxKind.JsxText && start === child.end); // whitespace only JsxText
if (lookInPreviousChild) {
// actual start of the node is past the position - previous token should be at the end of previous child
let candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ i);
return candidate && findRightmostToken(candidate)
}
else {
// candidate should be in this node
return find(child);
}
}
}
@@ -4,7 +4,7 @@ tests/cases/compiler/aliasAssignments_1.ts(5,1): error TS2322: Type 'typeof "tes
==== tests/cases/compiler/aliasAssignments_1.ts (2 errors) ====
import moduleA = require("aliasAssignments_moduleA");
import moduleA = require("./aliasAssignments_moduleA");
var x = moduleA;
x = 1; // Should be error
~
@@ -6,7 +6,7 @@ export class someClass {
}
//// [aliasAssignments_1.ts]
import moduleA = require("aliasAssignments_moduleA");
import moduleA = require("./aliasAssignments_moduleA");
var x = moduleA;
x = 1; // Should be error
var y = 1;
@@ -21,7 +21,7 @@ var someClass = (function () {
})();
exports.someClass = someClass;
//// [aliasAssignments_1.js]
var moduleA = require("aliasAssignments_moduleA");
var moduleA = require("./aliasAssignments_moduleA");
var x = moduleA;
x = 1; // Should be error
var y = 1;
@@ -6,14 +6,14 @@ export class Model {
}
//// [aliasUsage1_moduleA.ts]
import Backbone = require("aliasUsage1_backbone");
import Backbone = require("./aliasUsage1_backbone");
export class VisualizationModel extends Backbone.Model {
// interesting stuff here
}
//// [aliasUsage1_main.ts]
import Backbone = require("aliasUsage1_backbone");
import moduleA = require("aliasUsage1_moduleA");
import Backbone = require("./aliasUsage1_backbone");
import moduleA = require("./aliasUsage1_moduleA");
interface IHasVisualizationModel {
VisualizationModel: typeof Backbone.Model;
}
@@ -40,7 +40,7 @@ var __extends = (this && this.__extends) || function (d, b) {
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var Backbone = require("aliasUsage1_backbone");
var Backbone = require("./aliasUsage1_backbone");
var VisualizationModel = (function (_super) {
__extends(VisualizationModel, _super);
function VisualizationModel() {
@@ -50,7 +50,7 @@ var VisualizationModel = (function (_super) {
})(Backbone.Model);
exports.VisualizationModel = VisualizationModel;
//// [aliasUsage1_main.js]
var moduleA = require("aliasUsage1_moduleA");
var moduleA = require("./aliasUsage1_moduleA");
var C2 = (function () {
function C2() {
}
@@ -1,12 +1,12 @@
=== tests/cases/compiler/aliasUsage1_main.ts ===
import Backbone = require("aliasUsage1_backbone");
import Backbone = require("./aliasUsage1_backbone");
>Backbone : Symbol(Backbone, Decl(aliasUsage1_main.ts, 0, 0))
import moduleA = require("aliasUsage1_moduleA");
>moduleA : Symbol(moduleA, Decl(aliasUsage1_main.ts, 0, 50))
import moduleA = require("./aliasUsage1_moduleA");
>moduleA : Symbol(moduleA, Decl(aliasUsage1_main.ts, 0, 52))
interface IHasVisualizationModel {
>IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsage1_main.ts, 1, 48))
>IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsage1_main.ts, 1, 50))
VisualizationModel: typeof Backbone.Model;
>VisualizationModel : Symbol(VisualizationModel, Decl(aliasUsage1_main.ts, 2, 34))
@@ -19,7 +19,7 @@ class C2 {
x: IHasVisualizationModel;
>x : Symbol(x, Decl(aliasUsage1_main.ts, 5, 10))
>IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsage1_main.ts, 1, 48))
>IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsage1_main.ts, 1, 50))
get A() {
>A : Symbol(A, Decl(aliasUsage1_main.ts, 6, 30), Decl(aliasUsage1_main.ts, 9, 5))
@@ -35,7 +35,7 @@ class C2 {
x = moduleA;
>x : Symbol(x, Decl(aliasUsage1_main.ts, 10, 10))
>moduleA : Symbol(moduleA, Decl(aliasUsage1_main.ts, 0, 50))
>moduleA : Symbol(moduleA, Decl(aliasUsage1_main.ts, 0, 52))
}
}
=== tests/cases/compiler/aliasUsage1_backbone.ts ===
@@ -47,11 +47,11 @@ export class Model {
}
=== tests/cases/compiler/aliasUsage1_moduleA.ts ===
import Backbone = require("aliasUsage1_backbone");
import Backbone = require("./aliasUsage1_backbone");
>Backbone : Symbol(Backbone, Decl(aliasUsage1_moduleA.ts, 0, 0))
export class VisualizationModel extends Backbone.Model {
>VisualizationModel : Symbol(VisualizationModel, Decl(aliasUsage1_moduleA.ts, 0, 50))
>VisualizationModel : Symbol(VisualizationModel, Decl(aliasUsage1_moduleA.ts, 0, 52))
>Backbone.Model : Symbol(Backbone.Model, Decl(aliasUsage1_backbone.ts, 0, 0))
>Backbone : Symbol(Backbone, Decl(aliasUsage1_moduleA.ts, 0, 0))
>Model : Symbol(Backbone.Model, Decl(aliasUsage1_backbone.ts, 0, 0))
@@ -1,8 +1,8 @@
=== tests/cases/compiler/aliasUsage1_main.ts ===
import Backbone = require("aliasUsage1_backbone");
import Backbone = require("./aliasUsage1_backbone");
>Backbone : typeof Backbone
import moduleA = require("aliasUsage1_moduleA");
import moduleA = require("./aliasUsage1_moduleA");
>moduleA : typeof moduleA
interface IHasVisualizationModel {
@@ -48,7 +48,7 @@ export class Model {
}
=== tests/cases/compiler/aliasUsage1_moduleA.ts ===
import Backbone = require("aliasUsage1_backbone");
import Backbone = require("./aliasUsage1_backbone");
>Backbone : typeof Backbone
export class VisualizationModel extends Backbone.Model {
@@ -6,14 +6,14 @@ export class Model {
}
//// [aliasUsageInArray_moduleA.ts]
import Backbone = require("aliasUsageInArray_backbone");
import Backbone = require("./aliasUsageInArray_backbone");
export class VisualizationModel extends Backbone.Model {
// interesting stuff here
}
//// [aliasUsageInArray_main.ts]
import Backbone = require("aliasUsageInArray_backbone");
import moduleA = require("aliasUsageInArray_moduleA");
import Backbone = require("./aliasUsageInArray_backbone");
import moduleA = require("./aliasUsageInArray_moduleA");
interface IHasVisualizationModel {
VisualizationModel: typeof Backbone.Model;
}
@@ -34,7 +34,7 @@ var __extends = (this && this.__extends) || function (d, b) {
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var Backbone = require("aliasUsageInArray_backbone");
var Backbone = require("./aliasUsageInArray_backbone");
var VisualizationModel = (function (_super) {
__extends(VisualizationModel, _super);
function VisualizationModel() {
@@ -44,6 +44,6 @@ var VisualizationModel = (function (_super) {
})(Backbone.Model);
exports.VisualizationModel = VisualizationModel;
//// [aliasUsageInArray_main.js]
var moduleA = require("aliasUsageInArray_moduleA");
var moduleA = require("./aliasUsageInArray_moduleA");
var xs = [moduleA];
var xs2 = [moduleA];
@@ -1,12 +1,12 @@
=== tests/cases/compiler/aliasUsageInArray_main.ts ===
import Backbone = require("aliasUsageInArray_backbone");
import Backbone = require("./aliasUsageInArray_backbone");
>Backbone : Symbol(Backbone, Decl(aliasUsageInArray_main.ts, 0, 0))
import moduleA = require("aliasUsageInArray_moduleA");
>moduleA : Symbol(moduleA, Decl(aliasUsageInArray_main.ts, 0, 56))
import moduleA = require("./aliasUsageInArray_moduleA");
>moduleA : Symbol(moduleA, Decl(aliasUsageInArray_main.ts, 0, 58))
interface IHasVisualizationModel {
>IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInArray_main.ts, 1, 54))
>IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInArray_main.ts, 1, 56))
VisualizationModel: typeof Backbone.Model;
>VisualizationModel : Symbol(VisualizationModel, Decl(aliasUsageInArray_main.ts, 2, 34))
@@ -17,13 +17,13 @@ interface IHasVisualizationModel {
var xs: IHasVisualizationModel[] = [moduleA];
>xs : Symbol(xs, Decl(aliasUsageInArray_main.ts, 6, 3))
>IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInArray_main.ts, 1, 54))
>moduleA : Symbol(moduleA, Decl(aliasUsageInArray_main.ts, 0, 56))
>IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInArray_main.ts, 1, 56))
>moduleA : Symbol(moduleA, Decl(aliasUsageInArray_main.ts, 0, 58))
var xs2: typeof moduleA[] = [moduleA];
>xs2 : Symbol(xs2, Decl(aliasUsageInArray_main.ts, 7, 3))
>moduleA : Symbol(moduleA, Decl(aliasUsageInArray_main.ts, 0, 56))
>moduleA : Symbol(moduleA, Decl(aliasUsageInArray_main.ts, 0, 56))
>moduleA : Symbol(moduleA, Decl(aliasUsageInArray_main.ts, 0, 58))
>moduleA : Symbol(moduleA, Decl(aliasUsageInArray_main.ts, 0, 58))
=== tests/cases/compiler/aliasUsageInArray_backbone.ts ===
export class Model {
@@ -34,11 +34,11 @@ export class Model {
}
=== tests/cases/compiler/aliasUsageInArray_moduleA.ts ===
import Backbone = require("aliasUsageInArray_backbone");
import Backbone = require("./aliasUsageInArray_backbone");
>Backbone : Symbol(Backbone, Decl(aliasUsageInArray_moduleA.ts, 0, 0))
export class VisualizationModel extends Backbone.Model {
>VisualizationModel : Symbol(VisualizationModel, Decl(aliasUsageInArray_moduleA.ts, 0, 56))
>VisualizationModel : Symbol(VisualizationModel, Decl(aliasUsageInArray_moduleA.ts, 0, 58))
>Backbone.Model : Symbol(Backbone.Model, Decl(aliasUsageInArray_backbone.ts, 0, 0))
>Backbone : Symbol(Backbone, Decl(aliasUsageInArray_moduleA.ts, 0, 0))
>Model : Symbol(Backbone.Model, Decl(aliasUsageInArray_backbone.ts, 0, 0))
@@ -1,8 +1,8 @@
=== tests/cases/compiler/aliasUsageInArray_main.ts ===
import Backbone = require("aliasUsageInArray_backbone");
import Backbone = require("./aliasUsageInArray_backbone");
>Backbone : typeof Backbone
import moduleA = require("aliasUsageInArray_moduleA");
import moduleA = require("./aliasUsageInArray_moduleA");
>moduleA : typeof moduleA
interface IHasVisualizationModel {
@@ -36,7 +36,7 @@ export class Model {
}
=== tests/cases/compiler/aliasUsageInArray_moduleA.ts ===
import Backbone = require("aliasUsageInArray_backbone");
import Backbone = require("./aliasUsageInArray_backbone");
>Backbone : typeof Backbone
export class VisualizationModel extends Backbone.Model {
@@ -6,14 +6,14 @@ export class Model {
}
//// [aliasUsageInFunctionExpression_moduleA.ts]
import Backbone = require("aliasUsageInFunctionExpression_backbone");
import Backbone = require("./aliasUsageInFunctionExpression_backbone");
export class VisualizationModel extends Backbone.Model {
// interesting stuff here
}
//// [aliasUsageInFunctionExpression_main.ts]
import Backbone = require("aliasUsageInFunctionExpression_backbone");
import moduleA = require("aliasUsageInFunctionExpression_moduleA");
import Backbone = require("./aliasUsageInFunctionExpression_backbone");
import moduleA = require("./aliasUsageInFunctionExpression_moduleA");
interface IHasVisualizationModel {
VisualizationModel: typeof Backbone.Model;
}
@@ -33,7 +33,7 @@ var __extends = (this && this.__extends) || function (d, b) {
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var Backbone = require("aliasUsageInFunctionExpression_backbone");
var Backbone = require("./aliasUsageInFunctionExpression_backbone");
var VisualizationModel = (function (_super) {
__extends(VisualizationModel, _super);
function VisualizationModel() {
@@ -43,6 +43,6 @@ var VisualizationModel = (function (_super) {
})(Backbone.Model);
exports.VisualizationModel = VisualizationModel;
//// [aliasUsageInFunctionExpression_main.js]
var moduleA = require("aliasUsageInFunctionExpression_moduleA");
var moduleA = require("./aliasUsageInFunctionExpression_moduleA");
var f = function (x) { return x; };
f = function (x) { return moduleA; };
@@ -294,8 +294,8 @@ module EmptyTypes {
// Order matters here so test all the variants
var a1 = [{ x: 0, y: 'a' }, { x: 'a', y: 'a' }, { x: anyObj, y: 'a' }];
>a1 : ({ x: number; y: string; } | { x: string; y: string; } | { x: any; y: string; })[]
>[{ x: 0, y: 'a' }, { x: 'a', y: 'a' }, { x: anyObj, y: 'a' }] : ({ x: number; y: string; } | { x: string; y: string; } | { x: any; y: string; })[]
>a1 : { x: any; y: string; }[]
>[{ x: 0, y: 'a' }, { x: 'a', y: 'a' }, { x: anyObj, y: 'a' }] : { x: any; y: string; }[]
>{ x: 0, y: 'a' } : { x: number; y: string; }
>x : number
>0 : number
@@ -313,8 +313,8 @@ module EmptyTypes {
>'a' : string
var a2 = [{ x: anyObj, y: 'a' }, { x: 0, y: 'a' }, { x: 'a', y: 'a' }];
>a2 : ({ x: any; y: string; } | { x: number; y: string; } | { x: string; y: string; })[]
>[{ x: anyObj, y: 'a' }, { x: 0, y: 'a' }, { x: 'a', y: 'a' }] : ({ x: any; y: string; } | { x: number; y: string; } | { x: string; y: string; })[]
>a2 : { x: any; y: string; }[]
>[{ x: anyObj, y: 'a' }, { x: 0, y: 'a' }, { x: 'a', y: 'a' }] : { x: any; y: string; }[]
>{ x: anyObj, y: 'a' } : { x: any; y: string; }
>x : any
>anyObj : any
@@ -332,8 +332,8 @@ module EmptyTypes {
>'a' : string
var a3 = [{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }];
>a3 : ({ x: number; y: string; } | { x: any; y: string; } | { x: string; y: string; })[]
>[{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }] : ({ x: number; y: string; } | { x: any; y: string; } | { x: string; y: string; })[]
>a3 : { x: any; y: string; }[]
>[{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }] : { x: any; y: string; }[]
>{ x: 0, y: 'a' } : { x: number; y: string; }
>x : number
>0 : number
@@ -639,7 +639,7 @@ module NonEmptyTypes {
>x : number
>y : base
>base : base
>[{ x: 7, y: new derived() }, { x: 5, y: new base() }] : ({ x: number; y: derived; } | { x: number; y: base; })[]
>[{ x: 7, y: new derived() }, { x: 5, y: new base() }] : { x: number; y: base; }[]
>{ x: 7, y: new derived() } : { x: number; y: derived; }
>x : number
>7 : number
@@ -658,7 +658,7 @@ module NonEmptyTypes {
>x : boolean
>y : base
>base : base
>[{ x: true, y: new derived() }, { x: false, y: new base() }] : ({ x: boolean; y: derived; } | { x: boolean; y: base; })[]
>[{ x: true, y: new derived() }, { x: false, y: new base() }] : { x: boolean; y: base; }[]
>{ x: true, y: new derived() } : { x: boolean; y: derived; }
>x : boolean
>true : boolean
@@ -697,8 +697,8 @@ module NonEmptyTypes {
// Order matters here so test all the variants
var a1 = [{ x: 0, y: 'a' }, { x: 'a', y: 'a' }, { x: anyObj, y: 'a' }];
>a1 : ({ x: number; y: string; } | { x: string; y: string; } | { x: any; y: string; })[]
>[{ x: 0, y: 'a' }, { x: 'a', y: 'a' }, { x: anyObj, y: 'a' }] : ({ x: number; y: string; } | { x: string; y: string; } | { x: any; y: string; })[]
>a1 : { x: any; y: string; }[]
>[{ x: 0, y: 'a' }, { x: 'a', y: 'a' }, { x: anyObj, y: 'a' }] : { x: any; y: string; }[]
>{ x: 0, y: 'a' } : { x: number; y: string; }
>x : number
>0 : number
@@ -716,8 +716,8 @@ module NonEmptyTypes {
>'a' : string
var a2 = [{ x: anyObj, y: 'a' }, { x: 0, y: 'a' }, { x: 'a', y: 'a' }];
>a2 : ({ x: any; y: string; } | { x: number; y: string; } | { x: string; y: string; })[]
>[{ x: anyObj, y: 'a' }, { x: 0, y: 'a' }, { x: 'a', y: 'a' }] : ({ x: any; y: string; } | { x: number; y: string; } | { x: string; y: string; })[]
>a2 : { x: any; y: string; }[]
>[{ x: anyObj, y: 'a' }, { x: 0, y: 'a' }, { x: 'a', y: 'a' }] : { x: any; y: string; }[]
>{ x: anyObj, y: 'a' } : { x: any; y: string; }
>x : any
>anyObj : any
@@ -735,8 +735,8 @@ module NonEmptyTypes {
>'a' : string
var a3 = [{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }];
>a3 : ({ x: number; y: string; } | { x: any; y: string; } | { x: string; y: string; })[]
>[{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }] : ({ x: number; y: string; } | { x: any; y: string; } | { x: string; y: string; })[]
>a3 : { x: any; y: string; }[]
>[{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }] : { x: any; y: string; }[]
>{ x: 0, y: 'a' } : { x: number; y: string; }
>x : number
>0 : number
@@ -769,29 +769,29 @@ module NonEmptyTypes {
>base2 : typeof base2
var b1 = [baseObj, base2Obj, ifaceObj];
>b1 : (base | base2 | iface)[]
>[baseObj, base2Obj, ifaceObj] : (base | base2 | iface)[]
>b1 : iface[]
>[baseObj, base2Obj, ifaceObj] : iface[]
>baseObj : base
>base2Obj : base2
>ifaceObj : iface
var b2 = [base2Obj, baseObj, ifaceObj];
>b2 : (base2 | base | iface)[]
>[base2Obj, baseObj, ifaceObj] : (base2 | base | iface)[]
>b2 : iface[]
>[base2Obj, baseObj, ifaceObj] : iface[]
>base2Obj : base2
>baseObj : base
>ifaceObj : iface
var b3 = [baseObj, ifaceObj, base2Obj];
>b3 : (base | iface | base2)[]
>[baseObj, ifaceObj, base2Obj] : (base | iface | base2)[]
>b3 : iface[]
>[baseObj, ifaceObj, base2Obj] : iface[]
>baseObj : base
>ifaceObj : iface
>base2Obj : base2
var b4 = [ifaceObj, baseObj, base2Obj];
>b4 : (iface | base | base2)[]
>[ifaceObj, baseObj, base2Obj] : (iface | base | base2)[]
>b4 : iface[]
>[ifaceObj, baseObj, base2Obj] : iface[]
>ifaceObj : iface
>baseObj : base
>base2Obj : base2
@@ -1,4 +1,4 @@
tests/cases/compiler/arrayCast.ts(3,1): error TS2352: Neither type '{ foo: string; }[]' nor type '{ id: number; }[]' is assignable to the other.
tests/cases/compiler/arrayCast.ts(3,23): error TS2352: Neither type '{ foo: string; }[]' nor type '{ id: number; }[]' is assignable to the other.
Type '{ foo: string; }' is not assignable to type '{ id: number; }'.
Object literal may only specify known properties, and 'foo' does not exist in type '{ id: number; }'.
@@ -7,7 +7,7 @@ tests/cases/compiler/arrayCast.ts(3,1): error TS2352: Neither type '{ foo: strin
// Should fail. Even though the array is contextually typed with { id: number }[], it still
// has type { foo: string }[], which is not assignable to { id: number }[].
<{ id: number; }[]>[{ foo: "s" }];
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~
!!! error TS2352: Neither type '{ foo: string; }[]' nor type '{ id: number; }[]' is assignable to the other.
!!! error TS2352: Type '{ foo: string; }' is not assignable to type '{ id: number; }'.
!!! error TS2352: Object literal may only specify known properties, and 'foo' does not exist in type '{ id: number; }'.
@@ -1,8 +1,8 @@
tests/cases/compiler/arrayLiteralTypeInference.ts(13,5): error TS2322: Type '({ id: number; trueness: boolean; } | { id: number; name: string; })[]' is not assignable to type 'Action[]'.
tests/cases/compiler/arrayLiteralTypeInference.ts(14,14): error TS2322: Type '({ id: number; trueness: boolean; } | { id: number; name: string; })[]' is not assignable to type 'Action[]'.
Type '{ id: number; trueness: boolean; } | { id: number; name: string; }' is not assignable to type 'Action'.
Type '{ id: number; trueness: boolean; }' is not assignable to type 'Action'.
Object literal may only specify known properties, and 'trueness' does not exist in type 'Action'.
tests/cases/compiler/arrayLiteralTypeInference.ts(29,5): error TS2322: Type '({ id: number; trueness: boolean; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'.
tests/cases/compiler/arrayLiteralTypeInference.ts(31,18): error TS2322: Type '({ id: number; trueness: boolean; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'.
Type '{ id: number; trueness: boolean; } | { id: number; name: string; }' is not assignable to type '{ id: number; }'.
Type '{ id: number; trueness: boolean; }' is not assignable to type '{ id: number; }'.
Object literal may only specify known properties, and 'trueness' does not exist in type '{ id: number; }'.
@@ -22,12 +22,12 @@ tests/cases/compiler/arrayLiteralTypeInference.ts(29,5): error TS2322: Type '({
}
var x1: Action[] = [
~~
{ id: 2, trueness: false },
~~~~~~~~~~~~~~~
!!! error TS2322: Type '({ id: number; trueness: boolean; } | { id: number; name: string; })[]' is not assignable to type 'Action[]'.
!!! error TS2322: Type '{ id: number; trueness: boolean; } | { id: number; name: string; }' is not assignable to type 'Action'.
!!! error TS2322: Type '{ id: number; trueness: boolean; }' is not assignable to type 'Action'.
!!! error TS2322: Object literal may only specify known properties, and 'trueness' does not exist in type 'Action'.
{ id: 2, trueness: false },
{ id: 3, name: "three" }
]
@@ -43,13 +43,13 @@ tests/cases/compiler/arrayLiteralTypeInference.ts(29,5): error TS2322: Type '({
]
var z1: { id: number }[] =
~~
[
{ id: 2, trueness: false },
~~~~~~~~~~~~~~~
!!! error TS2322: Type '({ id: number; trueness: boolean; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'.
!!! error TS2322: Type '{ id: number; trueness: boolean; } | { id: number; name: string; }' is not assignable to type '{ id: number; }'.
!!! error TS2322: Type '{ id: number; trueness: boolean; }' is not assignable to type '{ id: number; }'.
!!! error TS2322: Object literal may only specify known properties, and 'trueness' does not exist in type '{ id: number; }'.
[
{ id: 2, trueness: false },
{ id: 3, name: "three" }
]
@@ -36,8 +36,8 @@ var cs = [a, b, c]; // { x: number; y?: number };[]
>c : { x: number; a?: number; }
var ds = [(x: Object) => 1, (x: string) => 2]; // { (x:Object) => number }[]
>ds : (((x: Object) => number) | ((x: string) => number))[]
>[(x: Object) => 1, (x: string) => 2] : (((x: Object) => number) | ((x: string) => number))[]
>ds : ((x: Object) => number)[]
>[(x: Object) => 1, (x: string) => 2] : ((x: Object) => number)[]
>(x: Object) => 1 : (x: Object) => number
>x : Object
>Object : Object
@@ -47,8 +47,8 @@ var ds = [(x: Object) => 1, (x: string) => 2]; // { (x:Object) => number }[]
>2 : number
var es = [(x: string) => 2, (x: Object) => 1]; // { (x:string) => number }[]
>es : (((x: string) => number) | ((x: Object) => number))[]
>[(x: string) => 2, (x: Object) => 1] : (((x: string) => number) | ((x: Object) => number))[]
>es : ((x: string) => number)[]
>[(x: string) => 2, (x: Object) => 1] : ((x: string) => number)[]
>(x: string) => 2 : (x: string) => number
>x : string
>2 : number
@@ -1,4 +1,4 @@
tests/cases/conformance/expressions/arrayLiterals/arrayLiterals.ts(24,5): error TS2322: Type '({ a: string; b: number; c: string; } | { a: string; b: number; c: number; })[]' is not assignable to type '{ [n: number]: { a: string; b: number; }; }'.
tests/cases/conformance/expressions/arrayLiterals/arrayLiterals.ts(24,77): error TS2322: Type '({ a: string; b: number; c: string; } | { a: string; b: number; c: number; })[]' is not assignable to type '{ [n: number]: { a: string; b: number; }; }'.
Index signatures are incompatible.
Type '{ a: string; b: number; c: string; } | { a: string; b: number; c: number; }' is not assignable to type '{ a: string; b: number; }'.
Type '{ a: string; b: number; c: string; }' is not assignable to type '{ a: string; b: number; }'.
@@ -30,7 +30,7 @@ tests/cases/conformance/expressions/arrayLiterals/arrayLiterals.ts(24,5): error
// Contextual type C with numeric index signature makes array literal of EveryType E of type BCT(E,C)[]
var context1: { [n: number]: { a: string; b: number; }; } = [{ a: '', b: 0, c: '' }, { a: "", b: 3, c: 0 }];
~~~~~~~~
~~~~~
!!! error TS2322: Type '({ a: string; b: number; c: string; } | { a: string; b: number; c: number; })[]' is not assignable to type '{ [n: number]: { a: string; b: number; }; }'.
!!! error TS2322: Index signatures are incompatible.
!!! error TS2322: Type '{ a: string; b: number; c: string; } | { a: string; b: number; c: number; }' is not assignable to type '{ a: string; b: number; }'.
@@ -77,8 +77,8 @@ var myDerivedList: DerivedList<number>;
>DerivedList : DerivedList<U>
var as = [list, myDerivedList]; // List<number>[]
>as : (List<number> | DerivedList<number>)[]
>[list, myDerivedList] : (List<number> | DerivedList<number>)[]
>as : List<number>[]
>[list, myDerivedList] : List<number>[]
>list : List<number>
>myDerivedList : DerivedList<number>
@@ -1,35 +0,0 @@
tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayOfFunctionTypes3.ts(17,13): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'.
tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayOfFunctionTypes3.ts(26,10): error TS2349: Cannot invoke an expression whose type lacks a call signature.
==== tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayOfFunctionTypes3.ts (2 errors) ====
// valid uses of arrays of function types
var x = [() => 1, () => { }];
var r2 = x[0]();
class C {
foo: string;
}
var y = [C, C];
var r3 = new y[0]();
var a: { (x: number): number; (x: string): string; };
var b: { (x: number): number; (x: string): string; };
var c: { (x: number): number; (x: any): any; };
var z = [a, b, c];
var r4 = z[0];
var r5 = r4(''); // any not string
~~
!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'.
var r5b = r4(1);
var a2: { <T>(x: T): number; (x: string): string;};
var b2: { <T>(x: T): number; (x: string): string; };
var c2: { (x: number): number; <T>(x: T): any; };
var z2 = [a2, b2, c2];
var r6 = z2[0];
var r7 = r6(''); // any not string
~~~~~~
!!! error TS2349: Cannot invoke an expression whose type lacks a call signature.
@@ -0,0 +1,93 @@
=== tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayOfFunctionTypes3.ts ===
// valid uses of arrays of function types
var x = [() => 1, () => { }];
>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 2, 3))
var r2 = x[0]();
>r2 : Symbol(r2, Decl(arrayOfFunctionTypes3.ts, 3, 3))
>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 2, 3))
class C {
>C : Symbol(C, Decl(arrayOfFunctionTypes3.ts, 3, 16))
foo: string;
>foo : Symbol(foo, Decl(arrayOfFunctionTypes3.ts, 5, 9))
}
var y = [C, C];
>y : Symbol(y, Decl(arrayOfFunctionTypes3.ts, 8, 3))
>C : Symbol(C, Decl(arrayOfFunctionTypes3.ts, 3, 16))
>C : Symbol(C, Decl(arrayOfFunctionTypes3.ts, 3, 16))
var r3 = new y[0]();
>r3 : Symbol(r3, Decl(arrayOfFunctionTypes3.ts, 9, 3))
>y : Symbol(y, Decl(arrayOfFunctionTypes3.ts, 8, 3))
var a: { (x: number): number; (x: string): string; };
>a : Symbol(a, Decl(arrayOfFunctionTypes3.ts, 11, 3))
>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 11, 10))
>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 11, 31))
var b: { (x: number): number; (x: string): string; };
>b : Symbol(b, Decl(arrayOfFunctionTypes3.ts, 12, 3))
>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 12, 10))
>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 12, 31))
var c: { (x: number): number; (x: any): any; };
>c : Symbol(c, Decl(arrayOfFunctionTypes3.ts, 13, 3))
>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 13, 10))
>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 13, 31))
var z = [a, b, c];
>z : Symbol(z, Decl(arrayOfFunctionTypes3.ts, 14, 3))
>a : Symbol(a, Decl(arrayOfFunctionTypes3.ts, 11, 3))
>b : Symbol(b, Decl(arrayOfFunctionTypes3.ts, 12, 3))
>c : Symbol(c, Decl(arrayOfFunctionTypes3.ts, 13, 3))
var r4 = z[0];
>r4 : Symbol(r4, Decl(arrayOfFunctionTypes3.ts, 15, 3))
>z : Symbol(z, Decl(arrayOfFunctionTypes3.ts, 14, 3))
var r5 = r4(''); // any not string
>r5 : Symbol(r5, Decl(arrayOfFunctionTypes3.ts, 16, 3))
>r4 : Symbol(r4, Decl(arrayOfFunctionTypes3.ts, 15, 3))
var r5b = r4(1);
>r5b : Symbol(r5b, Decl(arrayOfFunctionTypes3.ts, 17, 3))
>r4 : Symbol(r4, Decl(arrayOfFunctionTypes3.ts, 15, 3))
var a2: { <T>(x: T): number; (x: string): string;};
>a2 : Symbol(a2, Decl(arrayOfFunctionTypes3.ts, 19, 3))
>T : Symbol(T, Decl(arrayOfFunctionTypes3.ts, 19, 11))
>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 19, 14))
>T : Symbol(T, Decl(arrayOfFunctionTypes3.ts, 19, 11))
>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 19, 30))
var b2: { <T>(x: T): number; (x: string): string; };
>b2 : Symbol(b2, Decl(arrayOfFunctionTypes3.ts, 20, 3))
>T : Symbol(T, Decl(arrayOfFunctionTypes3.ts, 20, 11))
>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 20, 14))
>T : Symbol(T, Decl(arrayOfFunctionTypes3.ts, 20, 11))
>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 20, 30))
var c2: { (x: number): number; <T>(x: T): any; };
>c2 : Symbol(c2, Decl(arrayOfFunctionTypes3.ts, 21, 3))
>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 21, 11))
>T : Symbol(T, Decl(arrayOfFunctionTypes3.ts, 21, 32))
>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 21, 35))
>T : Symbol(T, Decl(arrayOfFunctionTypes3.ts, 21, 32))
var z2 = [a2, b2, c2];
>z2 : Symbol(z2, Decl(arrayOfFunctionTypes3.ts, 23, 3))
>a2 : Symbol(a2, Decl(arrayOfFunctionTypes3.ts, 19, 3))
>b2 : Symbol(b2, Decl(arrayOfFunctionTypes3.ts, 20, 3))
>c2 : Symbol(c2, Decl(arrayOfFunctionTypes3.ts, 21, 3))
var r6 = z2[0];
>r6 : Symbol(r6, Decl(arrayOfFunctionTypes3.ts, 24, 3))
>z2 : Symbol(z2, Decl(arrayOfFunctionTypes3.ts, 23, 3))
var r7 = r6(''); // any not string
>r7 : Symbol(r7, Decl(arrayOfFunctionTypes3.ts, 25, 3))
>r6 : Symbol(r6, Decl(arrayOfFunctionTypes3.ts, 24, 3))
@@ -0,0 +1,116 @@
=== tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayOfFunctionTypes3.ts ===
// valid uses of arrays of function types
var x = [() => 1, () => { }];
>x : (() => void)[]
>[() => 1, () => { }] : (() => void)[]
>() => 1 : () => number
>1 : number
>() => { } : () => void
var r2 = x[0]();
>r2 : void
>x[0]() : void
>x[0] : () => void
>x : (() => void)[]
>0 : number
class C {
>C : C
foo: string;
>foo : string
}
var y = [C, C];
>y : typeof C[]
>[C, C] : typeof C[]
>C : typeof C
>C : typeof C
var r3 = new y[0]();
>r3 : C
>new y[0]() : C
>y[0] : typeof C
>y : typeof C[]
>0 : number
var a: { (x: number): number; (x: string): string; };
>a : { (x: number): number; (x: string): string; }
>x : number
>x : string
var b: { (x: number): number; (x: string): string; };
>b : { (x: number): number; (x: string): string; }
>x : number
>x : string
var c: { (x: number): number; (x: any): any; };
>c : { (x: number): number; (x: any): any; }
>x : number
>x : any
var z = [a, b, c];
>z : { (x: number): number; (x: any): any; }[]
>[a, b, c] : { (x: number): number; (x: any): any; }[]
>a : { (x: number): number; (x: string): string; }
>b : { (x: number): number; (x: string): string; }
>c : { (x: number): number; (x: any): any; }
var r4 = z[0];
>r4 : { (x: number): number; (x: any): any; }
>z[0] : { (x: number): number; (x: any): any; }
>z : { (x: number): number; (x: any): any; }[]
>0 : number
var r5 = r4(''); // any not string
>r5 : any
>r4('') : any
>r4 : { (x: number): number; (x: any): any; }
>'' : string
var r5b = r4(1);
>r5b : number
>r4(1) : number
>r4 : { (x: number): number; (x: any): any; }
>1 : number
var a2: { <T>(x: T): number; (x: string): string;};
>a2 : { <T>(x: T): number; (x: string): string; }
>T : T
>x : T
>T : T
>x : string
var b2: { <T>(x: T): number; (x: string): string; };
>b2 : { <T>(x: T): number; (x: string): string; }
>T : T
>x : T
>T : T
>x : string
var c2: { (x: number): number; <T>(x: T): any; };
>c2 : { (x: number): number; <T>(x: T): any; }
>x : number
>T : T
>x : T
>T : T
var z2 = [a2, b2, c2];
>z2 : { (x: number): number; <T>(x: T): any; }[]
>[a2, b2, c2] : { (x: number): number; <T>(x: T): any; }[]
>a2 : { <T>(x: T): number; (x: string): string; }
>b2 : { <T>(x: T): number; (x: string): string; }
>c2 : { (x: number): number; <T>(x: T): any; }
var r6 = z2[0];
>r6 : { (x: number): number; <T>(x: T): any; }
>z2[0] : { (x: number): number; <T>(x: T): any; }
>z2 : { (x: number): number; <T>(x: T): any; }[]
>0 : number
var r7 = r6(''); // any not string
>r7 : any
>r6('') : any
>r6 : { (x: number): number; <T>(x: T): any; }
>'' : string
@@ -1,8 +1,8 @@
tests/cases/compiler/assignmentCompatBug2.ts(1,5): error TS2322: Type '{ a: number; }' is not assignable to type '{ b: number; }'.
tests/cases/compiler/assignmentCompatBug2.ts(1,27): error TS2322: Type '{ a: number; }' is not assignable to type '{ b: number; }'.
Object literal may only specify known properties, and 'a' does not exist in type '{ b: number; }'.
tests/cases/compiler/assignmentCompatBug2.ts(3,1): error TS2322: Type '{ a: number; }' is not assignable to type '{ b: number; }'.
tests/cases/compiler/assignmentCompatBug2.ts(3,8): error TS2322: Type '{ a: number; }' is not assignable to type '{ b: number; }'.
Object literal may only specify known properties, and 'a' does not exist in type '{ b: number; }'.
tests/cases/compiler/assignmentCompatBug2.ts(5,1): error TS2322: Type '{ b: number; a: number; }' is not assignable to type '{ b: number; }'.
tests/cases/compiler/assignmentCompatBug2.ts(5,13): error TS2322: Type '{ b: number; a: number; }' is not assignable to type '{ b: number; }'.
Object literal may only specify known properties, and 'a' does not exist in type '{ b: number; }'.
tests/cases/compiler/assignmentCompatBug2.ts(15,1): error TS2322: Type '{ f: (n: number) => number; g: (s: string) => number; }' is not assignable to type '{ f(n: number): number; g(s: string): number; m: number; n?: number; k?(a: any): any; }'.
Property 'm' is missing in type '{ f: (n: number) => number; g: (s: string) => number; }'.
@@ -14,17 +14,17 @@ tests/cases/compiler/assignmentCompatBug2.ts(33,1): error TS2322: Type '{ f: (n:
==== tests/cases/compiler/assignmentCompatBug2.ts (6 errors) ====
var b2: { b: number;} = { a: 0 }; // error
~~
~~~~
!!! error TS2322: Type '{ a: number; }' is not assignable to type '{ b: number; }'.
!!! error TS2322: Object literal may only specify known properties, and 'a' does not exist in type '{ b: number; }'.
b2 = { a: 0 }; // error
~~
~~~~
!!! error TS2322: Type '{ a: number; }' is not assignable to type '{ b: number; }'.
!!! error TS2322: Object literal may only specify known properties, and 'a' does not exist in type '{ b: number; }'.
b2 = {b: 0, a: 0 };
~~
~~~~
!!! error TS2322: Type '{ b: number; a: number; }' is not assignable to type '{ b: number; }'.
!!! error TS2322: Object literal may only specify known properties, and 'a' does not exist in type '{ b: number; }'.
@@ -1,4 +1,4 @@
tests/cases/compiler/assignmentCompatBug5.ts(2,6): error TS2345: Argument of type '{ b: number; }' is not assignable to parameter of type '{ a: number; }'.
tests/cases/compiler/assignmentCompatBug5.ts(2,8): error TS2345: Argument of type '{ b: number; }' is not assignable to parameter of type '{ a: number; }'.
Object literal may only specify known properties, and 'b' does not exist in type '{ a: number; }'.
tests/cases/compiler/assignmentCompatBug5.ts(5,6): error TS2345: Argument of type 'string[]' is not assignable to parameter of type 'number[]'.
Type 'string' is not assignable to type 'number'.
@@ -12,7 +12,7 @@ tests/cases/compiler/assignmentCompatBug5.ts(9,6): error TS2345: Argument of typ
==== tests/cases/compiler/assignmentCompatBug5.ts (4 errors) ====
function foo1(x: { a: number; }) { }
foo1({ b: 5 });
~~~~~~~~
~~~~
!!! error TS2345: Argument of type '{ b: number; }' is not assignable to parameter of type '{ a: number; }'.
!!! error TS2345: Object literal may only specify known properties, and 'b' does not exist in type '{ a: number; }'.
@@ -46,8 +46,8 @@ var r = true ? 1 : 2;
>2 : number
var r3 = true ? 1 : {};
>r3 : number | {}
>true ? 1 : {} : number | {}
>r3 : {}
>true ? 1 : {} : {}
>true : boolean
>1 : number
>{} : {}
@@ -67,8 +67,8 @@ var r5 = true ? b : a; // typeof b
>a : { x: number; y?: number; }
var r6 = true ? (x: number) => { } : (x: Object) => { }; // returns number => void
>r6 : ((x: number) => void) | ((x: Object) => void)
>true ? (x: number) => { } : (x: Object) => { } : ((x: number) => void) | ((x: Object) => void)
>r6 : (x: number) => void
>true ? (x: number) => { } : (x: Object) => { } : (x: number) => void
>true : boolean
>(x: number) => { } : (x: number) => void
>x : number
@@ -80,7 +80,7 @@ var r7: (x: Object) => void = true ? (x: number) => { } : (x: Object) => { };
>r7 : (x: Object) => void
>x : Object
>Object : Object
>true ? (x: number) => { } : (x: Object) => { } : ((x: number) => void) | ((x: Object) => void)
>true ? (x: number) => { } : (x: Object) => { } : (x: number) => void
>true : boolean
>(x: number) => { } : (x: number) => void
>x : number
@@ -89,8 +89,8 @@ var r7: (x: Object) => void = true ? (x: number) => { } : (x: Object) => { };
>Object : Object
var r8 = true ? (x: Object) => { } : (x: number) => { }; // returns Object => void
>r8 : ((x: Object) => void) | ((x: number) => void)
>true ? (x: Object) => { } : (x: number) => { } : ((x: Object) => void) | ((x: number) => void)
>r8 : (x: Object) => void
>true ? (x: Object) => { } : (x: number) => { } : (x: Object) => void
>true : boolean
>(x: Object) => { } : (x: Object) => void
>x : Object
@@ -107,8 +107,8 @@ var r10: Base = true ? derived : derived2; // no error since we use the contextu
>derived2 : Derived2
var r11 = true ? base : derived2;
>r11 : Base | Derived2
>true ? base : derived2 : Base | Derived2
>r11 : Base
>true ? base : derived2 : Base
>true : boolean
>base : Base
>derived2 : Derived2
@@ -27,43 +27,43 @@ var z: Z;
// All these arrays should be X[]
var b1 = [x, y, z];
>b1 : (X | Y | Z)[]
>[x, y, z] : (X | Y | Z)[]
>b1 : X[]
>[x, y, z] : X[]
>x : X
>y : Y
>z : Z
var b2 = [x, z, y];
>b2 : (X | Z | Y)[]
>[x, z, y] : (X | Z | Y)[]
>b2 : X[]
>[x, z, y] : X[]
>x : X
>z : Z
>y : Y
var b3 = [y, x, z];
>b3 : (Y | X | Z)[]
>[y, x, z] : (Y | X | Z)[]
>b3 : X[]
>[y, x, z] : X[]
>y : Y
>x : X
>z : Z
var b4 = [y, z, x];
>b4 : (Y | Z | X)[]
>[y, z, x] : (Y | Z | X)[]
>b4 : X[]
>[y, z, x] : X[]
>y : Y
>z : Z
>x : X
var b5 = [z, x, y];
>b5 : (Z | X | Y)[]
>[z, x, y] : (Z | X | Y)[]
>b5 : X[]
>[z, x, y] : X[]
>z : Z
>x : X
>y : Y
var b6 = [z, y, x];
>b6 : (Z | Y | X)[]
>[z, y, x] : (Z | Y | X)[]
>b6 : X[]
>[z, y, x] : X[]
>z : Z
>y : Y
>x : X
@@ -31,21 +31,21 @@ var b: B;
//Cond ? Expr1 : Expr2, Expr1 is supertype
//Be Not contextually typed
true ? x : a;
>true ? x : a : X | A
>true ? x : a : X
>true : boolean
>x : X
>a : A
var result1 = true ? x : a;
>result1 : X | A
>true ? x : a : X | A
>result1 : X
>true ? x : a : X
>true : boolean
>x : X
>a : A
//Expr1 and Expr2 are literals
true ? {} : 1;
>true ? {} : 1 : {} | number
>true ? {} : 1 : {}
>true : boolean
>{} : {}
>1 : number
@@ -63,8 +63,8 @@ true ? { a: 1 } : { a: 2, b: 'string' };
>'string' : string
var result2 = true ? {} : 1;
>result2 : {} | number
>true ? {} : 1 : {} | number
>result2 : {}
>true ? {} : 1 : {}
>true : boolean
>{} : {}
>1 : number
@@ -86,7 +86,7 @@ var result3 = true ? { a: 1 } : { a: 2, b: 'string' };
var resultIsX1: X = true ? x : a;
>resultIsX1 : X
>X : X
>true ? x : a : X | A
>true ? x : a : X
>true : boolean
>x : X
>a : A
@@ -95,7 +95,7 @@ var result4: (t: A) => any = true ? (m) => m.propertyX : (n) => n.propertyA;
>result4 : (t: A) => any
>t : A
>A : A
>true ? (m) => m.propertyX : (n) => n.propertyA : ((m: A) => any) | ((n: A) => number)
>true ? (m) => m.propertyX : (n) => n.propertyA : (m: A) => any
>true : boolean
>(m) => m.propertyX : (m: A) => any
>m : A
@@ -111,21 +111,21 @@ var result4: (t: A) => any = true ? (m) => m.propertyX : (n) => n.propertyA;
//Cond ? Expr1 : Expr2, Expr2 is supertype
//Be Not contextually typed
true ? a : x;
>true ? a : x : A | X
>true ? a : x : X
>true : boolean
>a : A
>x : X
var result5 = true ? a : x;
>result5 : A | X
>true ? a : x : A | X
>result5 : X
>true ? a : x : X
>true : boolean
>a : A
>x : X
//Expr1 and Expr2 are literals
true ? 1 : {};
>true ? 1 : {} : number | {}
>true ? 1 : {} : {}
>true : boolean
>1 : number
>{} : {}
@@ -143,8 +143,8 @@ true ? { a: 2, b: 'string' } : { a: 1 };
>1 : number
var result6 = true ? 1 : {};
>result6 : number | {}
>true ? 1 : {} : number | {}
>result6 : {}
>true ? 1 : {} : {}
>true : boolean
>1 : number
>{} : {}
@@ -166,7 +166,7 @@ var result7 = true ? { a: 2, b: 'string' } : { a: 1 };
var resultIsX2: X = true ? x : a;
>resultIsX2 : X
>X : X
>true ? x : a : X | A
>true ? x : a : X
>true : boolean
>x : X
>a : A
@@ -175,7 +175,7 @@ var result8: (t: A) => any = true ? (m) => m.propertyA : (n) => n.propertyX;
>result8 : (t: A) => any
>t : A
>A : A
>true ? (m) => m.propertyA : (n) => n.propertyX : ((m: A) => number) | ((n: A) => any)
>true ? (m) => m.propertyA : (n) => n.propertyX : (n: A) => any
>true : boolean
>(m) => m.propertyA : (m: A) => number
>m : A
@@ -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,
~~~~
@@ -1,4 +1,4 @@
tests/cases/compiler/contextualTyping12.ts(1,13): error TS2322: Type '({ id: number; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'.
tests/cases/compiler/contextualTyping12.ts(1,57): error TS2322: Type '({ id: number; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'.
Type '{ id: number; } | { id: number; name: string; }' is not assignable to type '{ id: number; }'.
Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'.
Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'.
@@ -6,7 +6,7 @@ tests/cases/compiler/contextualTyping12.ts(1,13): error TS2322: Type '({ id: num
==== tests/cases/compiler/contextualTyping12.ts (1 errors) ====
class foo { public bar:{id:number;}[] = [{id:1}, {id:2, name:"foo"}]; }
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~
!!! error TS2322: Type '({ id: number; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'.
!!! error TS2322: Type '{ id: number; } | { id: number; name: string; }' is not assignable to type '{ id: number; }'.
!!! error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'.
@@ -1,9 +1,9 @@
tests/cases/compiler/contextualTyping17.ts(1,33): error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'.
tests/cases/compiler/contextualTyping17.ts(1,47): error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'.
Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'.
==== tests/cases/compiler/contextualTyping17.ts (1 errors) ====
var foo: {id:number;} = {id:4}; foo = {id: 5, name:"foo"};
~~~
~~~~~~~~~~
!!! error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'.
!!! error TS2322: Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'.
@@ -1,9 +1,9 @@
tests/cases/compiler/contextualTyping2.ts(1,5): error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'.
tests/cases/compiler/contextualTyping2.ts(1,32): error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'.
Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'.
==== tests/cases/compiler/contextualTyping2.ts (1 errors) ====
var foo: {id:number;} = {id:4, name:"foo"};
~~~
~~~~~~~~~~
!!! error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'.
!!! error TS2322: Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'.
@@ -1,4 +1,4 @@
tests/cases/compiler/contextualTyping20.ts(1,36): error TS2322: Type '({ id: number; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'.
tests/cases/compiler/contextualTyping20.ts(1,58): error TS2322: Type '({ id: number; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'.
Type '{ id: number; } | { id: number; name: string; }' is not assignable to type '{ id: number; }'.
Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'.
Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'.
@@ -6,7 +6,7 @@ tests/cases/compiler/contextualTyping20.ts(1,36): error TS2322: Type '({ id: num
==== tests/cases/compiler/contextualTyping20.ts (1 errors) ====
var foo:{id:number;}[] = [{id:1}]; foo = [{id:1}, {id:2, name:"foo"}];
~~~
~~~~~~~~~~
!!! error TS2322: Type '({ id: number; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'.
!!! error TS2322: Type '{ id: number; } | { id: number; name: string; }' is not assignable to type '{ id: number; }'.
!!! error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'.
@@ -1,9 +1,9 @@
tests/cases/compiler/contextualTyping4.ts(1,13): error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'.
tests/cases/compiler/contextualTyping4.ts(1,46): error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'.
Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'.
==== tests/cases/compiler/contextualTyping4.ts (1 errors) ====
class foo { public bar:{id:number;} = {id:5, name:"foo"}; }
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~
!!! error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'.
!!! error TS2322: Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'.
@@ -1,4 +1,4 @@
tests/cases/compiler/contextualTyping9.ts(1,5): error TS2322: Type '({ id: number; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'.
tests/cases/compiler/contextualTyping9.ts(1,42): error TS2322: Type '({ id: number; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'.
Type '{ id: number; } | { id: number; name: string; }' is not assignable to type '{ id: number; }'.
Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'.
Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'.
@@ -6,7 +6,7 @@ tests/cases/compiler/contextualTyping9.ts(1,5): error TS2322: Type '({ id: numbe
==== tests/cases/compiler/contextualTyping9.ts (1 errors) ====
var foo:{id:number;}[] = [{id:1}, {id:2, name:"foo"}];
~~~
~~~~~~~~~~
!!! error TS2322: Type '({ id: number; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'.
!!! error TS2322: Type '{ id: number; } | { id: number; name: string; }' is not assignable to type '{ id: number; }'.
!!! error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'.
@@ -23,8 +23,8 @@ class C extends A {
}
var xs = [(x: A) => { }, (x: B) => { }, (x: C) => { }];
>xs : (((x: A) => void) | ((x: B) => void) | ((x: C) => void))[]
>[(x: A) => { }, (x: B) => { }, (x: C) => { }] : (((x: A) => void) | ((x: B) => void) | ((x: C) => void))[]
>xs : ((x: A) => void)[]
>[(x: A) => { }, (x: B) => { }, (x: C) => { }] : ((x: A) => void)[]
>(x: A) => { } : (x: A) => void
>x : A
>A : A
@@ -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
}
@@ -34,6 +34,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var service_1 = require("./service");
var MyComponent = (function () {
function MyComponent(Service) {
this.Service = Service;
@@ -0,0 +1,39 @@
//// [decoratorMetadataOnInferredType.ts]
declare var console: {
log(msg: string): void;
};
class A {
constructor() { console.log('new A'); }
}
function decorator(target: Object, propertyKey: string) {
}
export class B {
@decorator
x = new A();
}
//// [decoratorMetadataOnInferredType.js]
var A = (function () {
function A() {
console.log('new A');
}
return A;
})();
function decorator(target, propertyKey) {
}
var B = (function () {
function B() {
this.x = new A();
}
__decorate([
decorator,
__metadata('design:type', Object)
], B.prototype, "x");
return B;
})();
exports.B = B;
@@ -0,0 +1,38 @@
=== tests/cases/compiler/decoratorMetadataOnInferredType.ts ===
declare var console: {
>console : Symbol(console, Decl(decoratorMetadataOnInferredType.ts, 1, 11))
log(msg: string): void;
>log : Symbol(log, Decl(decoratorMetadataOnInferredType.ts, 1, 22))
>msg : Symbol(msg, Decl(decoratorMetadataOnInferredType.ts, 2, 8))
};
class A {
>A : Symbol(A, Decl(decoratorMetadataOnInferredType.ts, 3, 2))
constructor() { console.log('new A'); }
>console.log : Symbol(log, Decl(decoratorMetadataOnInferredType.ts, 1, 22))
>console : Symbol(console, Decl(decoratorMetadataOnInferredType.ts, 1, 11))
>log : Symbol(log, Decl(decoratorMetadataOnInferredType.ts, 1, 22))
}
function decorator(target: Object, propertyKey: string) {
>decorator : Symbol(decorator, Decl(decoratorMetadataOnInferredType.ts, 7, 1))
>target : Symbol(target, Decl(decoratorMetadataOnInferredType.ts, 9, 19))
>Object : Symbol(Object, Decl(lib.d.ts, 92, 1), Decl(lib.d.ts, 223, 11))
>propertyKey : Symbol(propertyKey, Decl(decoratorMetadataOnInferredType.ts, 9, 34))
}
export class B {
>B : Symbol(B, Decl(decoratorMetadataOnInferredType.ts, 10, 1))
@decorator
>decorator : Symbol(decorator, Decl(decoratorMetadataOnInferredType.ts, 7, 1))
x = new A();
>x : Symbol(x, Decl(decoratorMetadataOnInferredType.ts, 12, 16))
>A : Symbol(A, Decl(decoratorMetadataOnInferredType.ts, 3, 2))
}
@@ -0,0 +1,41 @@
=== tests/cases/compiler/decoratorMetadataOnInferredType.ts ===
declare var console: {
>console : { log(msg: string): void; }
log(msg: string): void;
>log : (msg: string) => void
>msg : string
};
class A {
>A : A
constructor() { console.log('new A'); }
>console.log('new A') : void
>console.log : (msg: string) => void
>console : { log(msg: string): void; }
>log : (msg: string) => void
>'new A' : string
}
function decorator(target: Object, propertyKey: string) {
>decorator : (target: Object, propertyKey: string) => void
>target : Object
>Object : Object
>propertyKey : string
}
export class B {
>B : B
@decorator
>decorator : (target: Object, propertyKey: string) => void
x = new A();
>x : A
>new A() : A
>A : typeof A
}
@@ -0,0 +1,39 @@
//// [decoratorMetadataWithConstructorType.ts]
declare var console: {
log(msg: string): void;
};
class A {
constructor() { console.log('new A'); }
}
function decorator(target: Object, propertyKey: string) {
}
export class B {
@decorator
x: A = new A();
}
//// [decoratorMetadataWithConstructorType.js]
var A = (function () {
function A() {
console.log('new A');
}
return A;
})();
function decorator(target, propertyKey) {
}
var B = (function () {
function B() {
this.x = new A();
}
__decorate([
decorator,
__metadata('design:type', A)
], B.prototype, "x");
return B;
})();
exports.B = B;
@@ -0,0 +1,39 @@
=== tests/cases/compiler/decoratorMetadataWithConstructorType.ts ===
declare var console: {
>console : Symbol(console, Decl(decoratorMetadataWithConstructorType.ts, 1, 11))
log(msg: string): void;
>log : Symbol(log, Decl(decoratorMetadataWithConstructorType.ts, 1, 22))
>msg : Symbol(msg, Decl(decoratorMetadataWithConstructorType.ts, 2, 8))
};
class A {
>A : Symbol(A, Decl(decoratorMetadataWithConstructorType.ts, 3, 2))
constructor() { console.log('new A'); }
>console.log : Symbol(log, Decl(decoratorMetadataWithConstructorType.ts, 1, 22))
>console : Symbol(console, Decl(decoratorMetadataWithConstructorType.ts, 1, 11))
>log : Symbol(log, Decl(decoratorMetadataWithConstructorType.ts, 1, 22))
}
function decorator(target: Object, propertyKey: string) {
>decorator : Symbol(decorator, Decl(decoratorMetadataWithConstructorType.ts, 7, 1))
>target : Symbol(target, Decl(decoratorMetadataWithConstructorType.ts, 9, 19))
>Object : Symbol(Object, Decl(lib.d.ts, 92, 1), Decl(lib.d.ts, 223, 11))
>propertyKey : Symbol(propertyKey, Decl(decoratorMetadataWithConstructorType.ts, 9, 34))
}
export class B {
>B : Symbol(B, Decl(decoratorMetadataWithConstructorType.ts, 10, 1))
@decorator
>decorator : Symbol(decorator, Decl(decoratorMetadataWithConstructorType.ts, 7, 1))
x: A = new A();
>x : Symbol(x, Decl(decoratorMetadataWithConstructorType.ts, 12, 16))
>A : Symbol(A, Decl(decoratorMetadataWithConstructorType.ts, 3, 2))
>A : Symbol(A, Decl(decoratorMetadataWithConstructorType.ts, 3, 2))
}
@@ -0,0 +1,42 @@
=== tests/cases/compiler/decoratorMetadataWithConstructorType.ts ===
declare var console: {
>console : { log(msg: string): void; }
log(msg: string): void;
>log : (msg: string) => void
>msg : string
};
class A {
>A : A
constructor() { console.log('new A'); }
>console.log('new A') : void
>console.log : (msg: string) => void
>console : { log(msg: string): void; }
>log : (msg: string) => void
>'new A' : string
}
function decorator(target: Object, propertyKey: string) {
>decorator : (target: Object, propertyKey: string) => void
>target : Object
>Object : Object
>propertyKey : string
}
export class B {
>B : B
@decorator
>decorator : (target: Object, propertyKey: string) => void
x: A = new A();
>x : A
>A : A
>new A() : A
>A : typeof A
}
@@ -0,0 +1,51 @@
//// [tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision.ts] ////
//// [db.ts]
export class db {
public doSomething() {
}
}
//// [service.ts]
import {db} from './db';
function someDecorator(target) {
return target;
}
@someDecorator
class MyClass {
db: db;
constructor(db: db) {
this.db = db;
this.db.doSomething();
}
}
export {MyClass};
//// [db.js]
var db = (function () {
function db() {
}
db.prototype.doSomething = function () {
};
return db;
})();
exports.db = db;
//// [service.js]
var db_1 = require('./db');
function someDecorator(target) {
return target;
}
var MyClass = (function () {
function MyClass(db) {
this.db = db;
this.db.doSomething();
}
MyClass = __decorate([
someDecorator,
__metadata('design:paramtypes', [db_1.db])
], MyClass);
return MyClass;
})();
exports.MyClass = MyClass;
@@ -0,0 +1,51 @@
=== tests/cases/compiler/db.ts ===
export class db {
>db : Symbol(db, Decl(db.ts, 0, 0))
public doSomething() {
>doSomething : Symbol(doSomething, Decl(db.ts, 0, 17))
}
}
=== tests/cases/compiler/service.ts ===
import {db} from './db';
>db : Symbol(db, Decl(service.ts, 0, 8))
function someDecorator(target) {
>someDecorator : Symbol(someDecorator, Decl(service.ts, 0, 24))
>target : Symbol(target, Decl(service.ts, 1, 23))
return target;
>target : Symbol(target, Decl(service.ts, 1, 23))
}
@someDecorator
>someDecorator : Symbol(someDecorator, Decl(service.ts, 0, 24))
class MyClass {
>MyClass : Symbol(MyClass, Decl(service.ts, 3, 1))
db: db;
>db : Symbol(db, Decl(service.ts, 5, 15))
>db : Symbol(db, Decl(service.ts, 0, 8))
constructor(db: db) {
>db : Symbol(db, Decl(service.ts, 8, 16))
>db : Symbol(db, Decl(service.ts, 0, 8))
this.db = db;
>this.db : Symbol(db, Decl(service.ts, 5, 15))
>this : Symbol(MyClass, Decl(service.ts, 3, 1))
>db : Symbol(db, Decl(service.ts, 5, 15))
>db : Symbol(db, Decl(service.ts, 8, 16))
this.db.doSomething();
>this.db.doSomething : Symbol(db.doSomething, Decl(db.ts, 0, 17))
>this.db : Symbol(db, Decl(service.ts, 5, 15))
>this : Symbol(MyClass, Decl(service.ts, 3, 1))
>db : Symbol(db, Decl(service.ts, 5, 15))
>doSomething : Symbol(db.doSomething, Decl(db.ts, 0, 17))
}
}
export {MyClass};
>MyClass : Symbol(MyClass, Decl(service.ts, 13, 8))
@@ -0,0 +1,53 @@
=== tests/cases/compiler/db.ts ===
export class db {
>db : db
public doSomething() {
>doSomething : () => void
}
}
=== tests/cases/compiler/service.ts ===
import {db} from './db';
>db : typeof db
function someDecorator(target) {
>someDecorator : (target: any) => any
>target : any
return target;
>target : any
}
@someDecorator
>someDecorator : (target: any) => any
class MyClass {
>MyClass : MyClass
db: db;
>db : db
>db : db
constructor(db: db) {
>db : db
>db : db
this.db = db;
>this.db = db : db
>this.db : db
>this : MyClass
>db : db
>db : db
this.db.doSomething();
>this.db.doSomething() : void
>this.db.doSomething : () => void
>this.db : db
>this : MyClass
>db : db
>doSomething : () => void
}
}
export {MyClass};
>MyClass : typeof MyClass
@@ -0,0 +1,51 @@
//// [tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision2.ts] ////
//// [db.ts]
export class db {
public doSomething() {
}
}
//// [service.ts]
import {db as Database} from './db';
function someDecorator(target) {
return target;
}
@someDecorator
class MyClass {
db: Database;
constructor(db: Database) { // no collision
this.db = db;
this.db.doSomething();
}
}
export {MyClass};
//// [db.js]
var db = (function () {
function db() {
}
db.prototype.doSomething = function () {
};
return db;
})();
exports.db = db;
//// [service.js]
var db_1 = require('./db');
function someDecorator(target) {
return target;
}
var MyClass = (function () {
function MyClass(db) {
this.db = db;
this.db.doSomething();
}
MyClass = __decorate([
someDecorator,
__metadata('design:paramtypes', [db_1.db])
], MyClass);
return MyClass;
})();
exports.MyClass = MyClass;
@@ -0,0 +1,52 @@
=== tests/cases/compiler/db.ts ===
export class db {
>db : Symbol(db, Decl(db.ts, 0, 0))
public doSomething() {
>doSomething : Symbol(doSomething, Decl(db.ts, 0, 17))
}
}
=== tests/cases/compiler/service.ts ===
import {db as Database} from './db';
>db : Symbol(Database, Decl(service.ts, 0, 8))
>Database : Symbol(Database, Decl(service.ts, 0, 8))
function someDecorator(target) {
>someDecorator : Symbol(someDecorator, Decl(service.ts, 0, 36))
>target : Symbol(target, Decl(service.ts, 1, 23))
return target;
>target : Symbol(target, Decl(service.ts, 1, 23))
}
@someDecorator
>someDecorator : Symbol(someDecorator, Decl(service.ts, 0, 36))
class MyClass {
>MyClass : Symbol(MyClass, Decl(service.ts, 3, 1))
db: Database;
>db : Symbol(db, Decl(service.ts, 5, 15))
>Database : Symbol(Database, Decl(service.ts, 0, 8))
constructor(db: Database) { // no collision
>db : Symbol(db, Decl(service.ts, 8, 16))
>Database : Symbol(Database, Decl(service.ts, 0, 8))
this.db = db;
>this.db : Symbol(db, Decl(service.ts, 5, 15))
>this : Symbol(MyClass, Decl(service.ts, 3, 1))
>db : Symbol(db, Decl(service.ts, 5, 15))
>db : Symbol(db, Decl(service.ts, 8, 16))
this.db.doSomething();
>this.db.doSomething : Symbol(Database.doSomething, Decl(db.ts, 0, 17))
>this.db : Symbol(db, Decl(service.ts, 5, 15))
>this : Symbol(MyClass, Decl(service.ts, 3, 1))
>db : Symbol(db, Decl(service.ts, 5, 15))
>doSomething : Symbol(Database.doSomething, Decl(db.ts, 0, 17))
}
}
export {MyClass};
>MyClass : Symbol(MyClass, Decl(service.ts, 13, 8))
@@ -0,0 +1,54 @@
=== tests/cases/compiler/db.ts ===
export class db {
>db : db
public doSomething() {
>doSomething : () => void
}
}
=== tests/cases/compiler/service.ts ===
import {db as Database} from './db';
>db : typeof Database
>Database : typeof Database
function someDecorator(target) {
>someDecorator : (target: any) => any
>target : any
return target;
>target : any
}
@someDecorator
>someDecorator : (target: any) => any
class MyClass {
>MyClass : MyClass
db: Database;
>db : Database
>Database : Database
constructor(db: Database) { // no collision
>db : Database
>Database : Database
this.db = db;
>this.db = db : Database
>this.db : Database
>this : MyClass
>db : Database
>db : Database
this.db.doSomething();
>this.db.doSomething() : void
>this.db.doSomething : () => void
>this.db : Database
>this : MyClass
>db : Database
>doSomething : () => void
}
}
export {MyClass};
>MyClass : typeof MyClass
@@ -0,0 +1,51 @@
//// [tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision3.ts] ////
//// [db.ts]
export class db {
public doSomething() {
}
}
//// [service.ts]
import db = require('./db');
function someDecorator(target) {
return target;
}
@someDecorator
class MyClass {
db: db.db;
constructor(db: db.db) { // collision with namespace of external module db
this.db = db;
this.db.doSomething();
}
}
export {MyClass};
//// [db.js]
var db = (function () {
function db() {
}
db.prototype.doSomething = function () {
};
return db;
})();
exports.db = db;
//// [service.js]
var db = require('./db');
function someDecorator(target) {
return target;
}
var MyClass = (function () {
function MyClass(db) {
this.db = db;
this.db.doSomething();
}
MyClass = __decorate([
someDecorator,
__metadata('design:paramtypes', [db.db])
], MyClass);
return MyClass;
})();
exports.MyClass = MyClass;
@@ -0,0 +1,53 @@
=== tests/cases/compiler/service.ts ===
import db = require('./db');
>db : Symbol(db, Decl(service.ts, 0, 0))
function someDecorator(target) {
>someDecorator : Symbol(someDecorator, Decl(service.ts, 0, 28))
>target : Symbol(target, Decl(service.ts, 1, 23))
return target;
>target : Symbol(target, Decl(service.ts, 1, 23))
}
@someDecorator
>someDecorator : Symbol(someDecorator, Decl(service.ts, 0, 28))
class MyClass {
>MyClass : Symbol(MyClass, Decl(service.ts, 3, 1))
db: db.db;
>db : Symbol(db, Decl(service.ts, 5, 15))
>db : Symbol(db, Decl(service.ts, 0, 0))
>db : Symbol(db.db, Decl(db.ts, 0, 0))
constructor(db: db.db) { // collision with namespace of external module db
>db : Symbol(db, Decl(service.ts, 8, 16))
>db : Symbol(db, Decl(service.ts, 0, 0))
>db : Symbol(db.db, Decl(db.ts, 0, 0))
this.db = db;
>this.db : Symbol(db, Decl(service.ts, 5, 15))
>this : Symbol(MyClass, Decl(service.ts, 3, 1))
>db : Symbol(db, Decl(service.ts, 5, 15))
>db : Symbol(db, Decl(service.ts, 8, 16))
this.db.doSomething();
>this.db.doSomething : Symbol(db.db.doSomething, Decl(db.ts, 0, 17))
>this.db : Symbol(db, Decl(service.ts, 5, 15))
>this : Symbol(MyClass, Decl(service.ts, 3, 1))
>db : Symbol(db, Decl(service.ts, 5, 15))
>doSomething : Symbol(db.db.doSomething, Decl(db.ts, 0, 17))
}
}
export {MyClass};
>MyClass : Symbol(MyClass, Decl(service.ts, 13, 8))
=== tests/cases/compiler/db.ts ===
export class db {
>db : Symbol(db, Decl(db.ts, 0, 0))
public doSomething() {
>doSomething : Symbol(doSomething, Decl(db.ts, 0, 17))
}
}
@@ -0,0 +1,55 @@
=== tests/cases/compiler/service.ts ===
import db = require('./db');
>db : typeof db
function someDecorator(target) {
>someDecorator : (target: any) => any
>target : any
return target;
>target : any
}
@someDecorator
>someDecorator : (target: any) => any
class MyClass {
>MyClass : MyClass
db: db.db;
>db : db.db
>db : any
>db : db.db
constructor(db: db.db) { // collision with namespace of external module db
>db : db.db
>db : any
>db : db.db
this.db = db;
>this.db = db : db.db
>this.db : db.db
>this : MyClass
>db : db.db
>db : db.db
this.db.doSomething();
>this.db.doSomething() : void
>this.db.doSomething : () => void
>this.db : db.db
>this : MyClass
>db : db.db
>doSomething : () => void
}
}
export {MyClass};
>MyClass : typeof MyClass
=== tests/cases/compiler/db.ts ===
export class db {
>db : db
public doSomething() {
>doSomething : () => void
}
}
@@ -0,0 +1,27 @@
tests/cases/compiler/service.ts(1,8): error TS1192: Module '"tests/cases/compiler/db"' has no default export.
==== tests/cases/compiler/db.ts (0 errors) ====
export class db {
public doSomething() {
}
}
==== tests/cases/compiler/service.ts (1 errors) ====
import db from './db'; // error no default export
~~
!!! error TS1192: Module '"tests/cases/compiler/db"' has no default export.
function someDecorator(target) {
return target;
}
@someDecorator
class MyClass {
db: db.db;
constructor(db: db.db) {
this.db = db;
this.db.doSomething();
}
}
export {MyClass};
@@ -0,0 +1,51 @@
//// [tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision4.ts] ////
//// [db.ts]
export class db {
public doSomething() {
}
}
//// [service.ts]
import db from './db'; // error no default export
function someDecorator(target) {
return target;
}
@someDecorator
class MyClass {
db: db.db;
constructor(db: db.db) {
this.db = db;
this.db.doSomething();
}
}
export {MyClass};
//// [db.js]
var db = (function () {
function db() {
}
db.prototype.doSomething = function () {
};
return db;
})();
exports.db = db;
//// [service.js]
var db_1 = require('./db'); // error no default export
function someDecorator(target) {
return target;
}
var MyClass = (function () {
function MyClass(db) {
this.db = db;
this.db.doSomething();
}
MyClass = __decorate([
someDecorator,
__metadata('design:paramtypes', [Object])
], MyClass);
return MyClass;
})();
exports.MyClass = MyClass;
@@ -0,0 +1,52 @@
//// [tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision5.ts] ////
//// [db.ts]
export default class db {
public doSomething() {
}
}
//// [service.ts]
import db from './db';
function someDecorator(target) {
return target;
}
@someDecorator
class MyClass {
db: db;
constructor(db: db) { // collision
this.db = db;
this.db.doSomething();
}
}
export {MyClass};
//// [db.js]
var db = (function () {
function db() {
}
db.prototype.doSomething = function () {
};
return db;
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = db;
//// [service.js]
var db_1 = require('./db');
function someDecorator(target) {
return target;
}
var MyClass = (function () {
function MyClass(db) {
this.db = db;
this.db.doSomething();
}
MyClass = __decorate([
someDecorator,
__metadata('design:paramtypes', [db_1.default])
], MyClass);
return MyClass;
})();
exports.MyClass = MyClass;
@@ -0,0 +1,51 @@
=== tests/cases/compiler/db.ts ===
export default class db {
>db : Symbol(db, Decl(db.ts, 0, 0))
public doSomething() {
>doSomething : Symbol(doSomething, Decl(db.ts, 0, 25))
}
}
=== tests/cases/compiler/service.ts ===
import db from './db';
>db : Symbol(db, Decl(service.ts, 0, 6))
function someDecorator(target) {
>someDecorator : Symbol(someDecorator, Decl(service.ts, 0, 22))
>target : Symbol(target, Decl(service.ts, 1, 23))
return target;
>target : Symbol(target, Decl(service.ts, 1, 23))
}
@someDecorator
>someDecorator : Symbol(someDecorator, Decl(service.ts, 0, 22))
class MyClass {
>MyClass : Symbol(MyClass, Decl(service.ts, 3, 1))
db: db;
>db : Symbol(db, Decl(service.ts, 5, 15))
>db : Symbol(db, Decl(service.ts, 0, 6))
constructor(db: db) { // collision
>db : Symbol(db, Decl(service.ts, 8, 16))
>db : Symbol(db, Decl(service.ts, 0, 6))
this.db = db;
>this.db : Symbol(db, Decl(service.ts, 5, 15))
>this : Symbol(MyClass, Decl(service.ts, 3, 1))
>db : Symbol(db, Decl(service.ts, 5, 15))
>db : Symbol(db, Decl(service.ts, 8, 16))
this.db.doSomething();
>this.db.doSomething : Symbol(db.doSomething, Decl(db.ts, 0, 25))
>this.db : Symbol(db, Decl(service.ts, 5, 15))
>this : Symbol(MyClass, Decl(service.ts, 3, 1))
>db : Symbol(db, Decl(service.ts, 5, 15))
>doSomething : Symbol(db.doSomething, Decl(db.ts, 0, 25))
}
}
export {MyClass};
>MyClass : Symbol(MyClass, Decl(service.ts, 13, 8))
@@ -0,0 +1,53 @@
=== tests/cases/compiler/db.ts ===
export default class db {
>db : db
public doSomething() {
>doSomething : () => void
}
}
=== tests/cases/compiler/service.ts ===
import db from './db';
>db : typeof db
function someDecorator(target) {
>someDecorator : (target: any) => any
>target : any
return target;
>target : any
}
@someDecorator
>someDecorator : (target: any) => any
class MyClass {
>MyClass : MyClass
db: db;
>db : db
>db : db
constructor(db: db) { // collision
>db : db
>db : db
this.db = db;
>this.db = db : db
>this.db : db
>this : MyClass
>db : db
>db : db
this.db.doSomething();
>this.db.doSomething() : void
>this.db.doSomething : () => void
>this.db : db
>this : MyClass
>db : db
>doSomething : () => void
}
}
export {MyClass};
>MyClass : typeof MyClass
@@ -0,0 +1,52 @@
//// [tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision6.ts] ////
//// [db.ts]
export default class db {
public doSomething() {
}
}
//// [service.ts]
import database from './db';
function someDecorator(target) {
return target;
}
@someDecorator
class MyClass {
db: database;
constructor(db: database) { // no collision
this.db = db;
this.db.doSomething();
}
}
export {MyClass};
//// [db.js]
var db = (function () {
function db() {
}
db.prototype.doSomething = function () {
};
return db;
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = db;
//// [service.js]
var db_1 = require('./db');
function someDecorator(target) {
return target;
}
var MyClass = (function () {
function MyClass(db) {
this.db = db;
this.db.doSomething();
}
MyClass = __decorate([
someDecorator,
__metadata('design:paramtypes', [db_1.default])
], MyClass);
return MyClass;
})();
exports.MyClass = MyClass;
@@ -0,0 +1,51 @@
=== tests/cases/compiler/db.ts ===
export default class db {
>db : Symbol(db, Decl(db.ts, 0, 0))
public doSomething() {
>doSomething : Symbol(doSomething, Decl(db.ts, 0, 25))
}
}
=== tests/cases/compiler/service.ts ===
import database from './db';
>database : Symbol(database, Decl(service.ts, 0, 6))
function someDecorator(target) {
>someDecorator : Symbol(someDecorator, Decl(service.ts, 0, 28))
>target : Symbol(target, Decl(service.ts, 1, 23))
return target;
>target : Symbol(target, Decl(service.ts, 1, 23))
}
@someDecorator
>someDecorator : Symbol(someDecorator, Decl(service.ts, 0, 28))
class MyClass {
>MyClass : Symbol(MyClass, Decl(service.ts, 3, 1))
db: database;
>db : Symbol(db, Decl(service.ts, 5, 15))
>database : Symbol(database, Decl(service.ts, 0, 6))
constructor(db: database) { // no collision
>db : Symbol(db, Decl(service.ts, 8, 16))
>database : Symbol(database, Decl(service.ts, 0, 6))
this.db = db;
>this.db : Symbol(db, Decl(service.ts, 5, 15))
>this : Symbol(MyClass, Decl(service.ts, 3, 1))
>db : Symbol(db, Decl(service.ts, 5, 15))
>db : Symbol(db, Decl(service.ts, 8, 16))
this.db.doSomething();
>this.db.doSomething : Symbol(database.doSomething, Decl(db.ts, 0, 25))
>this.db : Symbol(db, Decl(service.ts, 5, 15))
>this : Symbol(MyClass, Decl(service.ts, 3, 1))
>db : Symbol(db, Decl(service.ts, 5, 15))
>doSomething : Symbol(database.doSomething, Decl(db.ts, 0, 25))
}
}
export {MyClass};
>MyClass : Symbol(MyClass, Decl(service.ts, 13, 8))
@@ -0,0 +1,53 @@
=== tests/cases/compiler/db.ts ===
export default class db {
>db : db
public doSomething() {
>doSomething : () => void
}
}
=== tests/cases/compiler/service.ts ===
import database from './db';
>database : typeof database
function someDecorator(target) {
>someDecorator : (target: any) => any
>target : any
return target;
>target : any
}
@someDecorator
>someDecorator : (target: any) => any
class MyClass {
>MyClass : MyClass
db: database;
>db : database
>database : database
constructor(db: database) { // no collision
>db : database
>database : database
this.db = db;
>this.db = db : database
>this.db : database
>this : MyClass
>db : database
>db : database
this.db.doSomething();
>this.db.doSomething() : void
>this.db.doSomething : () => void
>this.db : database
>this : MyClass
>db : database
>doSomething : () => void
}
}
export {MyClass};
>MyClass : typeof MyClass
@@ -0,0 +1,30 @@
tests/cases/compiler/service.ts(7,9): error TS2503: Cannot find namespace 'db'.
tests/cases/compiler/service.ts(9,21): error TS2503: Cannot find namespace 'db'.
==== tests/cases/compiler/db.ts (0 errors) ====
export default class db {
public doSomething() {
}
}
==== tests/cases/compiler/service.ts (2 errors) ====
import db from './db';
function someDecorator(target) {
return target;
}
@someDecorator
class MyClass {
db: db.db; //error
~~
!!! error TS2503: Cannot find namespace 'db'.
constructor(db: db.db) { // error
~~
!!! error TS2503: Cannot find namespace 'db'.
this.db = db;
this.db.doSomething();
}
}
export {MyClass};
@@ -0,0 +1,52 @@
//// [tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision7.ts] ////
//// [db.ts]
export default class db {
public doSomething() {
}
}
//// [service.ts]
import db from './db';
function someDecorator(target) {
return target;
}
@someDecorator
class MyClass {
db: db.db; //error
constructor(db: db.db) { // error
this.db = db;
this.db.doSomething();
}
}
export {MyClass};
//// [db.js]
var db = (function () {
function db() {
}
db.prototype.doSomething = function () {
};
return db;
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = db;
//// [service.js]
var db_1 = require('./db');
function someDecorator(target) {
return target;
}
var MyClass = (function () {
function MyClass(db) {
this.db = db;
this.db.doSomething();
}
MyClass = __decorate([
someDecorator,
__metadata('design:paramtypes', [Object])
], MyClass);
return MyClass;
})();
exports.MyClass = MyClass;
@@ -0,0 +1,51 @@
//// [tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision8.ts] ////
//// [db.ts]
export class db {
public doSomething() {
}
}
//// [service.ts]
import database = require('./db');
function someDecorator(target) {
return target;
}
@someDecorator
class MyClass {
db: database.db;
constructor(db: database.db) { // no collision
this.db = db;
this.db.doSomething();
}
}
export {MyClass};
//// [db.js]
var db = (function () {
function db() {
}
db.prototype.doSomething = function () {
};
return db;
})();
exports.db = db;
//// [service.js]
var database = require('./db');
function someDecorator(target) {
return target;
}
var MyClass = (function () {
function MyClass(db) {
this.db = db;
this.db.doSomething();
}
MyClass = __decorate([
someDecorator,
__metadata('design:paramtypes', [database.db])
], MyClass);
return MyClass;
})();
exports.MyClass = MyClass;

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