mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge branch 'master' into getDefinition
This commit is contained in:
@@ -348,6 +348,7 @@ function deleteTemporaryProjectOutput() {
|
||||
}
|
||||
}
|
||||
|
||||
var testTimeout = 5000;
|
||||
desc("Runs the tests using the built run.js file. Syntax is jake runtests. Optional parameters 'host=', 'tests=[regex], reporter=[list|spec|json|<more>]'.");
|
||||
task("runtests", ["tests", builtLocalDirectory], function() {
|
||||
cleanTestDirs();
|
||||
@@ -367,14 +368,14 @@ task("runtests", ["tests", builtLocalDirectory], function() {
|
||||
reporter = process.env.reporter || process.env.r || 'dot';
|
||||
// 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 + ' --timeout 3000 ' + run;
|
||||
var cmd = host + " -R " + reporter + tests + colors + ' -t ' + testTimeout + ' ' + run;
|
||||
console.log(cmd);
|
||||
exec(cmd, deleteTemporaryProjectOutput);
|
||||
}, {async: true});
|
||||
|
||||
desc("Generates code coverage data via instanbul")
|
||||
task("generate-code-coverage", ["tests", builtLocalDirectory], function () {
|
||||
var cmd = "istanbul cover node_modules/mocha/bin/_mocha -- -R dot " + run;
|
||||
var cmd = 'istanbul cover node_modules/mocha/bin/_mocha -- -R min -t ' + testTimeout + ' ' + run;
|
||||
console.log(cmd);
|
||||
exec(cmd);
|
||||
}, { async: true });
|
||||
|
||||
Vendored
+31
-25
@@ -1157,6 +1157,11 @@ interface ArrayBuffer {
|
||||
* Read-only. The length of the ArrayBuffer (in bytes).
|
||||
*/
|
||||
byteLength: number;
|
||||
|
||||
/**
|
||||
* Returns a section of an ArrayBuffer.
|
||||
*/
|
||||
slice(begin:number, end?:number): ArrayBuffer;
|
||||
}
|
||||
|
||||
declare var ArrayBuffer: {
|
||||
@@ -3826,6 +3831,32 @@ declare var Window: {
|
||||
new(): Window;
|
||||
}
|
||||
|
||||
interface FormData {
|
||||
append(name: any, value: any, blobName?: string): void;
|
||||
}
|
||||
declare var FormData: {
|
||||
prototype: FormData;
|
||||
new (form?: HTMLFormElement): FormData;
|
||||
}
|
||||
|
||||
interface SourceBuffer extends EventTarget {
|
||||
updating: boolean;
|
||||
appendWindowStart: number;
|
||||
appendWindowEnd: number;
|
||||
buffered: TimeRanges;
|
||||
timestampOffset: number;
|
||||
audioTracks: AudioTrackList;
|
||||
appendBuffer(data: ArrayBufferView): void;
|
||||
appendBuffer(data: ArrayBuffer): void;
|
||||
remove(start: number, end: number): void;
|
||||
abort(): void;
|
||||
appendStream(stream: MSStream, maxSize?: number): void;
|
||||
}
|
||||
declare var SourceBuffer: {
|
||||
prototype: SourceBuffer;
|
||||
new(): SourceBuffer;
|
||||
}
|
||||
|
||||
interface NavigatorID {
|
||||
appVersion: string;
|
||||
appName: string;
|
||||
@@ -12157,14 +12188,6 @@ declare var MSManipulationEvent: {
|
||||
MS_MANIPULATION_STATE_CANCELLED: number;
|
||||
}
|
||||
|
||||
interface FormData {
|
||||
append(name: any, value: any, blobName?: string): void;
|
||||
}
|
||||
declare var FormData: {
|
||||
prototype: FormData;
|
||||
new(): FormData;
|
||||
}
|
||||
|
||||
interface HTMLDataListElement extends HTMLElement {
|
||||
options: HTMLCollection;
|
||||
}
|
||||
@@ -12583,23 +12606,6 @@ interface RandomSource {
|
||||
getRandomValues(array: ArrayBufferView): ArrayBufferView;
|
||||
}
|
||||
|
||||
interface SourceBuffer extends EventTarget {
|
||||
updating: boolean;
|
||||
appendWindowStart: number;
|
||||
appendWindowEnd: number;
|
||||
buffered: TimeRanges;
|
||||
timestampOffset: number;
|
||||
audioTracks: AudioTrackList;
|
||||
appendBuffer(data: ArrayBuffer): void;
|
||||
remove(start: number, end: number): void;
|
||||
abort(): void;
|
||||
appendStream(stream: MSStream, maxSize?: number): void;
|
||||
}
|
||||
declare var SourceBuffer: {
|
||||
prototype: SourceBuffer;
|
||||
new(): SourceBuffer;
|
||||
}
|
||||
|
||||
interface MSInputMethodContext extends EventTarget {
|
||||
oncandidatewindowshow: (ev: any) => any;
|
||||
target: HTMLElement;
|
||||
|
||||
Vendored
+31
-25
@@ -30,6 +30,11 @@ interface ArrayBuffer {
|
||||
* Read-only. The length of the ArrayBuffer (in bytes).
|
||||
*/
|
||||
byteLength: number;
|
||||
|
||||
/**
|
||||
* Returns a section of an ArrayBuffer.
|
||||
*/
|
||||
slice(begin:number, end?:number): ArrayBuffer;
|
||||
}
|
||||
|
||||
declare var ArrayBuffer: {
|
||||
@@ -2699,6 +2704,32 @@ declare var Window: {
|
||||
new(): Window;
|
||||
}
|
||||
|
||||
interface FormData {
|
||||
append(name: any, value: any, blobName?: string): void;
|
||||
}
|
||||
declare var FormData: {
|
||||
prototype: FormData;
|
||||
new (form?: HTMLFormElement): FormData;
|
||||
}
|
||||
|
||||
interface SourceBuffer extends EventTarget {
|
||||
updating: boolean;
|
||||
appendWindowStart: number;
|
||||
appendWindowEnd: number;
|
||||
buffered: TimeRanges;
|
||||
timestampOffset: number;
|
||||
audioTracks: AudioTrackList;
|
||||
appendBuffer(data: ArrayBufferView): void;
|
||||
appendBuffer(data: ArrayBuffer): void;
|
||||
remove(start: number, end: number): void;
|
||||
abort(): void;
|
||||
appendStream(stream: MSStream, maxSize?: number): void;
|
||||
}
|
||||
declare var SourceBuffer: {
|
||||
prototype: SourceBuffer;
|
||||
new(): SourceBuffer;
|
||||
}
|
||||
|
||||
interface NavigatorID {
|
||||
appVersion: string;
|
||||
appName: string;
|
||||
@@ -11030,14 +11061,6 @@ declare var MSManipulationEvent: {
|
||||
MS_MANIPULATION_STATE_CANCELLED: number;
|
||||
}
|
||||
|
||||
interface FormData {
|
||||
append(name: any, value: any, blobName?: string): void;
|
||||
}
|
||||
declare var FormData: {
|
||||
prototype: FormData;
|
||||
new(): FormData;
|
||||
}
|
||||
|
||||
interface HTMLDataListElement extends HTMLElement {
|
||||
options: HTMLCollection;
|
||||
}
|
||||
@@ -11456,23 +11479,6 @@ interface RandomSource {
|
||||
getRandomValues(array: ArrayBufferView): ArrayBufferView;
|
||||
}
|
||||
|
||||
interface SourceBuffer extends EventTarget {
|
||||
updating: boolean;
|
||||
appendWindowStart: number;
|
||||
appendWindowEnd: number;
|
||||
buffered: TimeRanges;
|
||||
timestampOffset: number;
|
||||
audioTracks: AudioTrackList;
|
||||
appendBuffer(data: ArrayBuffer): void;
|
||||
remove(start: number, end: number): void;
|
||||
abort(): void;
|
||||
appendStream(stream: MSStream, maxSize?: number): void;
|
||||
}
|
||||
declare var SourceBuffer: {
|
||||
prototype: SourceBuffer;
|
||||
new(): SourceBuffer;
|
||||
}
|
||||
|
||||
interface MSInputMethodContext extends EventTarget {
|
||||
oncandidatewindowshow: (ev: any) => any;
|
||||
target: HTMLElement;
|
||||
|
||||
Vendored
+5
@@ -30,6 +30,11 @@ interface ArrayBuffer {
|
||||
* Read-only. The length of the ArrayBuffer (in bytes).
|
||||
*/
|
||||
byteLength: number;
|
||||
|
||||
/**
|
||||
* Returns a section of an ArrayBuffer.
|
||||
*/
|
||||
slice(begin:number, end?:number): ArrayBuffer;
|
||||
}
|
||||
|
||||
declare var ArrayBuffer: {
|
||||
|
||||
@@ -172,9 +172,12 @@ var ts;
|
||||
Duplicate_number_index_signature: { code: 2233, category: 1 /* Error */, key: "Duplicate number index signature." },
|
||||
All_declarations_of_an_interface_must_have_identical_type_parameters: { code: 2234, category: 1 /* Error */, key: "All declarations of an interface must have identical type parameters." },
|
||||
Expression_resolves_to_variable_declaration_i_that_compiler_uses_to_initialize_rest_parameter: { code: 2235, category: 1 /* Error */, key: "Expression resolves to variable declaration '_i' that compiler uses to initialize rest parameter." },
|
||||
Constructor_implementation_expected: { code: 2240, category: 1 /* Error */, key: "Constructor implementation expected." },
|
||||
Function_implementation_name_must_be_0: { code: 2239, category: 1 /* Error */, key: "Function implementation name must be '{0}'." },
|
||||
Constructor_implementation_is_missing: { code: 2240, category: 1 /* Error */, key: "Constructor implementation is missing." },
|
||||
An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements: { code: 2245, category: 1 /* Error */, key: "An export assignment cannot be used in a module with other exported elements." },
|
||||
A_parameter_property_is_only_allowed_in_a_constructor_implementation: { code: 2246, category: 1 /* Error */, key: "A parameter property is only allowed in a constructor implementation." },
|
||||
Function_overload_must_be_static: { code: 2247, category: 1 /* Error */, key: "Function overload must be static." },
|
||||
Function_overload_must_not_be_static: { code: 2248, category: 1 /* Error */, key: "Function overload must not be static." },
|
||||
Circular_definition_of_import_alias_0: { code: 3000, category: 1 /* Error */, key: "Circular definition of import alias '{0}'." },
|
||||
Cannot_find_name_0: { code: 3001, category: 1 /* Error */, key: "Cannot find name '{0}'." },
|
||||
Module_0_has_no_exported_member_1: { code: 3002, category: 1 /* Error */, key: "Module '{0}' has no exported member '{1}'." },
|
||||
@@ -291,7 +294,7 @@ var ts;
|
||||
Types_of_parameters_0_and_1_are_incompatible_Colon: { code: -9999999, category: 1 /* Error */, key: "Types of parameters '{0}' and '{1}' are incompatible:" },
|
||||
Unknown_identifier_0: { code: -9999999, category: 1 /* Error */, key: "Unknown identifier '{0}'." },
|
||||
Property_0_is_inaccessible: { code: -9999999, category: 1 /* Error */, key: "Property '{0}' is inaccessible." },
|
||||
Function_implementation_expected: { code: -9999999, category: 1 /* Error */, key: "Function implementation expected." },
|
||||
Function_implementation_is_missing_or_not_immediately_following_the_declaration: { code: -9999999, category: 1 /* Error */, key: "Function implementation is missing or not immediately following the declaration." },
|
||||
Property_0_of_type_1_is_not_assignable_to_string_index_type_2: { code: -9999999, category: 1 /* Error */, key: "Property '{0}' of type '{1}' is not assignable to string index type '{2}'." },
|
||||
Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2: { code: -9999999, category: 1 /* Error */, key: "Property '{0}' of type '{1}' is not assignable to numeric index type '{2}'." },
|
||||
Numeric_index_type_0_is_not_assignable_to_string_index_type_1: { code: -9999999, category: 1 /* Error */, key: "Numeric index type '{0}' is not assignable to string index type '{1}'." },
|
||||
@@ -320,7 +323,7 @@ var ts;
|
||||
Unsupported_locale_0: { code: -9999999, category: 1 /* Error */, key: "Unsupported locale {0}." },
|
||||
Unable_to_open_file_0: { code: -9999999, category: 1 /* Error */, key: "Unable to open file {0}." },
|
||||
Corrupted_locale_file_0: { code: -9999999, category: 1 /* Error */, key: "Corrupted locale file {0}." },
|
||||
No_input_files_specified: { code: -9999999, category: 1 /* Error */, key: "No input files specified." },
|
||||
No_input_files_specified: { code: -9999999, category: 1 /* Error */, key: "No input files specified." }
|
||||
};
|
||||
})(ts || (ts = {}));
|
||||
var ts;
|
||||
@@ -430,7 +433,7 @@ var ts;
|
||||
">>>=": 51 /* GreaterThanGreaterThanGreaterThanEqualsToken */,
|
||||
"&=": 52 /* AmpersandEqualsToken */,
|
||||
"|=": 53 /* BarEqualsToken */,
|
||||
"^=": 54 /* CaretEqualsToken */,
|
||||
"^=": 54 /* CaretEqualsToken */
|
||||
};
|
||||
var unicodeES3IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1610, 1649, 1747, 1749, 1749, 1765, 1766, 1786, 1788, 1808, 1808, 1810, 1836, 1920, 1957, 2309, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2784, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3294, 3294, 3296, 3297, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3424, 3425, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3805, 3840, 3840, 3904, 3911, 3913, 3946, 3976, 3979, 4096, 4129, 4131, 4135, 4137, 4138, 4176, 4181, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6067, 6176, 6263, 6272, 6312, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8319, 8319, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12346, 12353, 12436, 12445, 12446, 12449, 12538, 12540, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65138, 65140, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500, ];
|
||||
var unicodeES3IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 768, 846, 864, 866, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1155, 1158, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1441, 1443, 1465, 1467, 1469, 1471, 1471, 1473, 1474, 1476, 1476, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1621, 1632, 1641, 1648, 1747, 1749, 1756, 1759, 1768, 1770, 1773, 1776, 1788, 1808, 1836, 1840, 1866, 1920, 1968, 2305, 2307, 2309, 2361, 2364, 2381, 2384, 2388, 2392, 2403, 2406, 2415, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2492, 2494, 2500, 2503, 2504, 2507, 2509, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2562, 2562, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2649, 2652, 2654, 2654, 2662, 2676, 2689, 2691, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2784, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2876, 2883, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2913, 2918, 2927, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3031, 3031, 3047, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3134, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3168, 3169, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3262, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3297, 3302, 3311, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3390, 3395, 3398, 3400, 3402, 3405, 3415, 3415, 3424, 3425, 3430, 3439, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3805, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3946, 3953, 3972, 3974, 3979, 3984, 3991, 3993, 4028, 4038, 4038, 4096, 4129, 4131, 4135, 4137, 4138, 4140, 4146, 4150, 4153, 4160, 4169, 4176, 4185, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 4969, 4977, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6099, 6112, 6121, 6160, 6169, 6176, 6263, 6272, 6313, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8319, 8319, 8400, 8412, 8417, 8417, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12346, 12353, 12436, 12441, 12442, 12445, 12446, 12449, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65056, 65059, 65075, 65076, 65101, 65103, 65136, 65138, 65140, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65381, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500, ];
|
||||
@@ -1031,7 +1034,7 @@ var ts;
|
||||
if (token === 27 /* SlashToken */ || token === 47 /* SlashEqualsToken */) {
|
||||
var p = tokenPos + 1;
|
||||
var inEscape = false;
|
||||
var inClass = false;
|
||||
var inCharacterClass = false;
|
||||
while (true) {
|
||||
if (p >= len) {
|
||||
return token;
|
||||
@@ -1043,23 +1046,24 @@ var ts;
|
||||
if (inEscape) {
|
||||
inEscape = false;
|
||||
}
|
||||
else if (ch === 47 /* slash */) {
|
||||
else if (ch === 47 /* slash */ && !inCharacterClass) {
|
||||
break;
|
||||
}
|
||||
else if (ch === 91 /* openBracket */) {
|
||||
inClass = true;
|
||||
inCharacterClass = true;
|
||||
}
|
||||
else if (ch === 92 /* backslash */) {
|
||||
inEscape = true;
|
||||
}
|
||||
else if (ch === 93 /* closeBracket */) {
|
||||
inClass = false;
|
||||
inCharacterClass = false;
|
||||
}
|
||||
p++;
|
||||
}
|
||||
p++;
|
||||
while (isIdentifierPart(text.charCodeAt(p)))
|
||||
while (isIdentifierPart(text.charCodeAt(p))) {
|
||||
p++;
|
||||
}
|
||||
pos = p;
|
||||
tokenValue = text.substring(tokenPos, pos);
|
||||
token = 4 /* RegularExpressionLiteral */;
|
||||
@@ -1573,6 +1577,13 @@ var ts;
|
||||
CharacterCodes[CharacterCodes["verticalTab"] = 0x0B] = "verticalTab";
|
||||
})(ts.CharacterCodes || (ts.CharacterCodes = {}));
|
||||
var CharacterCodes = ts.CharacterCodes;
|
||||
(function (ByteOrderMark) {
|
||||
ByteOrderMark[ByteOrderMark["None"] = 0] = "None";
|
||||
ByteOrderMark[ByteOrderMark["Utf8"] = 1] = "Utf8";
|
||||
ByteOrderMark[ByteOrderMark["Utf16BigEndian"] = 2] = "Utf16BigEndian";
|
||||
ByteOrderMark[ByteOrderMark["Utf16LittleEndian"] = 3] = "Utf16LittleEndian";
|
||||
})(ts.ByteOrderMark || (ts.ByteOrderMark = {}));
|
||||
var ByteOrderMark = ts.ByteOrderMark;
|
||||
})(ts || (ts = {}));
|
||||
var ts;
|
||||
(function (ts) {
|
||||
@@ -1704,6 +1715,19 @@ var ts;
|
||||
return result;
|
||||
}
|
||||
ts.forEachValue = forEachValue;
|
||||
function forEachKey(map, callback) {
|
||||
var result;
|
||||
for (var id in map) {
|
||||
if (result = callback(id))
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
ts.forEachKey = forEachKey;
|
||||
function lookUp(map, key) {
|
||||
return hasProperty(map, key) ? map[key] : undefined;
|
||||
}
|
||||
ts.lookUp = lookUp;
|
||||
function mapToArray(map) {
|
||||
var result = [];
|
||||
for (var id in map)
|
||||
@@ -1766,14 +1790,14 @@ var ts;
|
||||
};
|
||||
}
|
||||
ts.chainDiagnosticMessages = chainDiagnosticMessages;
|
||||
function flattenDiagnosticChain(file, start, length, diagnosticChain) {
|
||||
function flattenDiagnosticChain(file, start, length, diagnosticChain, newLine) {
|
||||
var code = diagnosticChain.code;
|
||||
var category = diagnosticChain.category;
|
||||
var messageText = "";
|
||||
var indent = 0;
|
||||
while (diagnosticChain) {
|
||||
if (indent) {
|
||||
messageText += sys.newLine;
|
||||
messageText += newLine;
|
||||
for (var i = 0; i < indent; i++) {
|
||||
messageText += " ";
|
||||
}
|
||||
@@ -2010,7 +2034,7 @@ var ts;
|
||||
pos: 0,
|
||||
end: 0,
|
||||
flags: 0,
|
||||
parent: undefined,
|
||||
parent: undefined
|
||||
};
|
||||
return Node;
|
||||
},
|
||||
@@ -2301,12 +2325,12 @@ var ts;
|
||||
return ts.createFileDiagnostic(file, start, length, message, arg0, arg1, arg2);
|
||||
}
|
||||
ts.createDiagnosticForNode = createDiagnosticForNode;
|
||||
function createDiagnosticForNodeFromMessageChain(node, messageChain) {
|
||||
function createDiagnosticForNodeFromMessageChain(node, messageChain, newLine) {
|
||||
node = getErrorSpanForNode(node);
|
||||
var file = getSourceFileOfNode(node);
|
||||
var start = ts.skipTrivia(file.text, node.pos);
|
||||
var length = node.end - start;
|
||||
return ts.flattenDiagnosticChain(file, start, length, messageChain);
|
||||
return ts.flattenDiagnosticChain(file, start, length, messageChain, newLine);
|
||||
}
|
||||
ts.createDiagnosticForNodeFromMessageChain = createDiagnosticForNodeFromMessageChain;
|
||||
function getErrorSpanForNode(node) {
|
||||
@@ -2474,6 +2498,15 @@ var ts;
|
||||
return s.parameters.length > 0 && (s.parameters[s.parameters.length - 1].flags & 8 /* Rest */) !== 0;
|
||||
}
|
||||
ts.hasRestParameters = hasRestParameters;
|
||||
function isInAmbientContext(node) {
|
||||
while (node) {
|
||||
if (node.flags & (2 /* Ambient */ | 512 /* DeclarationFile */))
|
||||
return true;
|
||||
node = node.parent;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
ts.isInAmbientContext = isInAmbientContext;
|
||||
var ParsingContext;
|
||||
(function (ParsingContext) {
|
||||
ParsingContext[ParsingContext["SourceElements"] = 0] = "SourceElements";
|
||||
@@ -2649,7 +2682,7 @@ var ts;
|
||||
pushCurrentLabelSet: pushCurrentLabelSet,
|
||||
pushFunctionBoundary: pushFunctionBoundary,
|
||||
pop: pop,
|
||||
nodeIsNestedInLabel: nodeIsNestedInLabel,
|
||||
nodeIsNestedInLabel: nodeIsNestedInLabel
|
||||
};
|
||||
})();
|
||||
function getLineAndCharacterlFromSourcePosition(position) {
|
||||
@@ -3489,7 +3522,11 @@ var ts;
|
||||
var parameter = createNode(114 /* Parameter */, identifier.pos);
|
||||
parameter.name = identifier;
|
||||
finishNode(parameter);
|
||||
var signature = { parameters: [parameter] };
|
||||
var parameters = [];
|
||||
parameters.push(parameter);
|
||||
parameters.pos = parameter.pos;
|
||||
parameters.end = parameter.end;
|
||||
var signature = { parameters: parameters };
|
||||
return parseArrowExpressionTail(identifier.pos, signature, false);
|
||||
}
|
||||
function tryParseParenthesizedArrowFunctionExpression() {
|
||||
@@ -5051,7 +5088,7 @@ var ts;
|
||||
getDiagnostics: getDiagnostics,
|
||||
getGlobalDiagnostics: getGlobalDiagnostics,
|
||||
getTypeChecker: function () { return ts.createTypeChecker(program); },
|
||||
getCommonSourceDirectory: function () { return commonSourceDirectory; },
|
||||
getCommonSourceDirectory: function () { return commonSourceDirectory; }
|
||||
};
|
||||
return program;
|
||||
function getSourceFile(filename) {
|
||||
@@ -5528,6 +5565,7 @@ var ts;
|
||||
var compilerOptions = program.getCompilerOptions();
|
||||
var sourceMapDataList = compilerOptions.sourceMap ? [] : undefined;
|
||||
var diagnostics = [];
|
||||
var newLine = program.getCompilerHost().getNewLine();
|
||||
function getSourceFilePathInNewDir(newDirPath, sourceFile) {
|
||||
var sourceFilePath = ts.getNormalizedPathFromPathCompoments(ts.getNormalizedPathComponents(sourceFile.filename, compilerHost.getCurrentDirectory()));
|
||||
sourceFilePath = sourceFilePath.replace(program.getCommonSourceDirectory(), "");
|
||||
@@ -5617,7 +5655,7 @@ var ts;
|
||||
}
|
||||
function writeLine() {
|
||||
if (!lineStart) {
|
||||
output += sys.newLine;
|
||||
output += newLine;
|
||||
lineCount++;
|
||||
linePos = output.length;
|
||||
lineStart = true;
|
||||
@@ -6658,6 +6696,7 @@ var ts;
|
||||
write(" {");
|
||||
scopeEmitStart(node, "constructor");
|
||||
increaseIndent();
|
||||
emitCaptureThisForNodeIfNecessary(node);
|
||||
if (ctor) {
|
||||
emitDefaultValueAssignments(ctor);
|
||||
emitRestParameter(ctor);
|
||||
@@ -6678,7 +6717,6 @@ var ts;
|
||||
emitEnd(node.baseType);
|
||||
}
|
||||
}
|
||||
emitCaptureThisForNodeIfNecessary(node);
|
||||
emitMemberAssignments(node, 0);
|
||||
if (ctor) {
|
||||
var statements = ctor.body.statements;
|
||||
@@ -7463,7 +7501,7 @@ var ts;
|
||||
function writeReferencePath(referencedFile) {
|
||||
var declFileName = referencedFile.flags & 512 /* DeclarationFile */ ? referencedFile.filename : shouldEmitToOwnFile(referencedFile) ? getOwnEmitOutputFilePath(referencedFile, ".d.ts") : ts.getModuleNameFromFilename(compilerOptions.out) + ".d.ts";
|
||||
declFileName = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizeSlashes(jsFilePath)), declFileName, compilerHost.getCurrentDirectory(), false);
|
||||
referencePathsOutput += "/// <reference path='" + declFileName + "' />" + sys.newLine;
|
||||
referencePathsOutput += "/// <reference path='" + declFileName + "' />" + newLine;
|
||||
}
|
||||
if (root) {
|
||||
var addedGlobalFileReference = false;
|
||||
@@ -7562,7 +7600,32 @@ var ts;
|
||||
var potentialThisCollisions = [];
|
||||
var diagnostics = [];
|
||||
var diagnosticsModified = false;
|
||||
var checker;
|
||||
var checker = {
|
||||
getProgram: function () { return program; },
|
||||
getDiagnostics: getDiagnostics,
|
||||
getGlobalDiagnostics: getGlobalDiagnostics,
|
||||
getNodeCount: function () { return ts.sum(program.getSourceFiles(), "nodeCount"); },
|
||||
getIdentifierCount: function () { return ts.sum(program.getSourceFiles(), "identifierCount"); },
|
||||
getSymbolCount: function () { return ts.sum(program.getSourceFiles(), "symbolCount"); },
|
||||
getTypeCount: function () { return typeCount; },
|
||||
checkProgram: checkProgram,
|
||||
emitFiles: invokeEmitter,
|
||||
getSymbolOfNode: getSymbolOfNode,
|
||||
getParentOfSymbol: getParentOfSymbol,
|
||||
getTypeOfSymbol: getTypeOfSymbol,
|
||||
getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol,
|
||||
getPropertiesOfType: getPropertiesOfType,
|
||||
getSignaturesOfType: getSignaturesOfType,
|
||||
getIndexTypeOfType: getIndexTypeOfType,
|
||||
getReturnTypeOfSignature: getReturnTypeOfSignature,
|
||||
resolveEntityName: resolveEntityName,
|
||||
getSymbolsInScope: getSymbolsInScope,
|
||||
getSymbolOfIdentifier: getSymbolOfIdentifier,
|
||||
getTypeOfExpression: getTypeOfExpression,
|
||||
typeToString: typeToString,
|
||||
symbolToString: symbolToString,
|
||||
getAugmentedPropertiesOfApparentType: getAugmentedPropertiesOfApparentType
|
||||
};
|
||||
function addDiagnostic(diagnostic) {
|
||||
diagnostics.push(diagnostic);
|
||||
diagnosticsModified = true;
|
||||
@@ -8146,9 +8209,9 @@ var ts;
|
||||
}
|
||||
};
|
||||
}
|
||||
function typeToString(type, flags) {
|
||||
function typeToString(type, enclosingDeclaration, flags) {
|
||||
var stringWriter = createSingleLineTextWriter();
|
||||
writeTypeToTextWriter(type, null, flags, stringWriter);
|
||||
writeTypeToTextWriter(type, enclosingDeclaration, flags, stringWriter);
|
||||
return stringWriter.getText();
|
||||
}
|
||||
function writeTypeToTextWriter(type, enclosingDeclaration, flags, writer) {
|
||||
@@ -8673,7 +8736,7 @@ var ts;
|
||||
type.baseTypes.push(baseType);
|
||||
}
|
||||
else {
|
||||
error(declaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, 1 /* WriteArrayAsGenericType */));
|
||||
error(declaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 1 /* WriteArrayAsGenericType */));
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -8713,7 +8776,7 @@ var ts;
|
||||
type.baseTypes.push(baseType);
|
||||
}
|
||||
else {
|
||||
error(declaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, 1 /* WriteArrayAsGenericType */));
|
||||
error(declaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 1 /* WriteArrayAsGenericType */));
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -9206,7 +9269,7 @@ var ts;
|
||||
type = createTypeReference(type, ts.map(node.typeArguments, function (t) { return getTypeFromTypeNode(t); }));
|
||||
}
|
||||
else {
|
||||
error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, typeToString(type, 1 /* WriteArrayAsGenericType */), typeParameters.length);
|
||||
error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, typeToString(type, undefined, 1 /* WriteArrayAsGenericType */), typeParameters.length);
|
||||
type = undefined;
|
||||
}
|
||||
}
|
||||
@@ -9548,7 +9611,7 @@ var ts;
|
||||
var typeName2 = typeToString(base);
|
||||
var errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Named_properties_0_of_types_1_and_2_are_not_identical, prop.name, typeName1, typeName2);
|
||||
errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Interface_0_cannot_simultaneously_extend_types_1_and_2_Colon, typeToString(type), typeName1, typeName2);
|
||||
addDiagnostic(ts.createDiagnosticForNodeFromMessageChain(typeNode, errorInfo));
|
||||
addDiagnostic(ts.createDiagnosticForNodeFromMessageChain(typeNode, errorInfo, program.getCompilerHost().getNewLine()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9585,7 +9648,7 @@ var ts;
|
||||
error(errorNode, ts.Diagnostics.Excessive_stack_depth_comparing_types_0_and_1, typeToString(source), typeToString(target));
|
||||
}
|
||||
else if (errorInfo) {
|
||||
addDiagnostic(ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo));
|
||||
addDiagnostic(ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo, program.getCompilerHost().getNewLine()));
|
||||
}
|
||||
return result;
|
||||
function reportError(message, arg0, arg1) {
|
||||
@@ -10109,7 +10172,7 @@ var ts;
|
||||
return {
|
||||
typeParameters: typeParameters,
|
||||
inferences: inferences,
|
||||
inferredTypes: new Array(typeParameters.length),
|
||||
inferredTypes: new Array(typeParameters.length)
|
||||
};
|
||||
}
|
||||
function inferTypes(context, source, target) {
|
||||
@@ -11419,7 +11482,7 @@ var ts;
|
||||
}
|
||||
function checkAccessorDeclaration(node) {
|
||||
if (node.kind === 118 /* GetAccessor */) {
|
||||
if (!isInAmbientContext(node) && node.body && !(bodyContainsAReturnStatement(node.body) || bodyContainsSingleThrowStatement(node.body))) {
|
||||
if (!ts.isInAmbientContext(node) && node.body && !(bodyContainsAReturnStatement(node.body) || bodyContainsSingleThrowStatement(node.body))) {
|
||||
error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement);
|
||||
}
|
||||
}
|
||||
@@ -11468,15 +11531,7 @@ var ts;
|
||||
getTypeFromArrayTypeNode(node);
|
||||
}
|
||||
function isPrivateWithinAmbient(node) {
|
||||
return (node.flags & 32 /* Private */) && isInAmbientContext(node);
|
||||
}
|
||||
function isInAmbientContext(node) {
|
||||
while (node) {
|
||||
if (node.flags & (2 /* Ambient */ | 512 /* DeclarationFile */))
|
||||
return true;
|
||||
node = node.parent;
|
||||
}
|
||||
return false;
|
||||
return (node.flags & 32 /* Private */) && ts.isInAmbientContext(node);
|
||||
}
|
||||
function checkSpecializedSignatureDeclaration(signatureDeclarationNode) {
|
||||
var signature = getSignatureFromDeclaration(signatureDeclarationNode);
|
||||
@@ -11498,7 +11553,7 @@ var ts;
|
||||
}
|
||||
function getEffectiveDeclarationFlags(n, flagsToCheck) {
|
||||
var flags = n.flags;
|
||||
if (n.parent.kind !== 170 /* InterfaceDeclaration */ && isInAmbientContext(n)) {
|
||||
if (n.parent.kind !== 170 /* InterfaceDeclaration */ && ts.isInAmbientContext(n)) {
|
||||
if (!(flags & 2 /* Ambient */)) {
|
||||
flags |= 1 /* Export */;
|
||||
}
|
||||
@@ -11535,44 +11590,82 @@ var ts;
|
||||
var hasOverloads = false;
|
||||
var bodyDeclaration;
|
||||
var lastSeenNonAmbientDeclaration;
|
||||
var previousDeclaration;
|
||||
var declarations = symbol.declarations;
|
||||
var isConstructor = (symbol.flags & 4096 /* Constructor */) !== 0;
|
||||
function reportImplementationExpectedError(node) {
|
||||
var seen = false;
|
||||
var subsequentNode = ts.forEachChild(node.parent, function (c) {
|
||||
if (seen) {
|
||||
return c;
|
||||
}
|
||||
else {
|
||||
seen = c === node;
|
||||
}
|
||||
});
|
||||
if (subsequentNode) {
|
||||
if (subsequentNode.kind === node.kind) {
|
||||
var errorNode = subsequentNode.name || subsequentNode;
|
||||
if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) {
|
||||
ts.Debug.assert(node.kind === 116 /* Method */);
|
||||
ts.Debug.assert((node.flags & 64 /* Static */) !== (subsequentNode.flags & 64 /* Static */));
|
||||
var diagnostic = node.flags & 64 /* Static */ ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static;
|
||||
error(errorNode, diagnostic);
|
||||
return;
|
||||
}
|
||||
else if (subsequentNode.body) {
|
||||
error(errorNode, ts.Diagnostics.Function_implementation_name_must_be_0, ts.identifierToString(node.name));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
var errorNode = node.name || node;
|
||||
if (isConstructor) {
|
||||
error(errorNode, ts.Diagnostics.Constructor_implementation_is_missing);
|
||||
}
|
||||
else {
|
||||
error(errorNode, ts.Diagnostics.Function_implementation_is_missing_or_not_immediately_following_the_declaration);
|
||||
}
|
||||
}
|
||||
var isExportSymbolInsideModule = symbol.parent && symbol.parent.flags & ts.SymbolFlags.Module;
|
||||
for (var i = 0; i < declarations.length; i++) {
|
||||
var node = declarations[i];
|
||||
var inAmbientContext = ts.isInAmbientContext(node);
|
||||
var inAmbientContextOrInterface = node.parent.kind === 170 /* InterfaceDeclaration */ || node.parent.kind === 125 /* TypeLiteral */ || inAmbientContext;
|
||||
if (inAmbientContextOrInterface) {
|
||||
previousDeclaration = undefined;
|
||||
}
|
||||
if (node.kind === 167 /* FunctionDeclaration */ || node.kind === 116 /* Method */ || node.kind === 117 /* Constructor */) {
|
||||
var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck);
|
||||
someNodeFlags |= currentNodeFlags;
|
||||
allNodeFlags &= currentNodeFlags;
|
||||
var inAmbientContext = isInAmbientContext(node);
|
||||
var inAmbientContextOrInterface = node.parent.kind === 170 /* InterfaceDeclaration */ || node.parent.kind === 125 /* TypeLiteral */ || inAmbientContext;
|
||||
if (!inAmbientContextOrInterface) {
|
||||
lastSeenNonAmbientDeclaration = node;
|
||||
}
|
||||
if (node.body) {
|
||||
if (bodyDeclaration) {
|
||||
if (isConstructor) {
|
||||
error(node, ts.Diagnostics.Multiple_constructor_implementations_are_not_allowed);
|
||||
}
|
||||
else {
|
||||
error(node, ts.Diagnostics.Duplicate_function_implementation);
|
||||
}
|
||||
if (node.body && bodyDeclaration) {
|
||||
if (isConstructor) {
|
||||
error(node, ts.Diagnostics.Multiple_constructor_implementations_are_not_allowed);
|
||||
}
|
||||
else {
|
||||
error(node, ts.Diagnostics.Duplicate_function_implementation);
|
||||
}
|
||||
}
|
||||
else if (!isExportSymbolInsideModule && previousDeclaration && previousDeclaration.parent === node.parent && previousDeclaration.end !== node.pos) {
|
||||
reportImplementationExpectedError(previousDeclaration);
|
||||
}
|
||||
if (node.body) {
|
||||
if (!bodyDeclaration) {
|
||||
bodyDeclaration = node;
|
||||
}
|
||||
}
|
||||
else {
|
||||
hasOverloads = true;
|
||||
}
|
||||
previousDeclaration = node;
|
||||
if (!inAmbientContextOrInterface) {
|
||||
lastSeenNonAmbientDeclaration = node;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body) {
|
||||
if (isConstructor) {
|
||||
error(lastSeenNonAmbientDeclaration, ts.Diagnostics.Constructor_implementation_expected);
|
||||
}
|
||||
else {
|
||||
error(lastSeenNonAmbientDeclaration, ts.Diagnostics.Function_implementation_expected);
|
||||
}
|
||||
if (!isExportSymbolInsideModule && lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body) {
|
||||
reportImplementationExpectedError(lastSeenNonAmbientDeclaration);
|
||||
}
|
||||
if (hasOverloads) {
|
||||
checkFlagAgreementBetweenOverloads(declarations, bodyDeclaration, flagsToCheck, someNodeFlags, allNodeFlags);
|
||||
@@ -11675,7 +11768,7 @@ var ts;
|
||||
ts.forEach(node.statements, checkSourceElement);
|
||||
}
|
||||
function checkCollisionWithArgumentsInGeneratedCode(node) {
|
||||
if (!ts.hasRestParameters(node) || isInAmbientContext(node) || !node.body) {
|
||||
if (!ts.hasRestParameters(node) || ts.isInAmbientContext(node) || !node.body) {
|
||||
return;
|
||||
}
|
||||
ts.forEach(node.parameters, function (p) {
|
||||
@@ -11689,7 +11782,7 @@ var ts;
|
||||
return;
|
||||
}
|
||||
if (node.kind === 114 /* Parameter */) {
|
||||
if (node.parent.body && ts.hasRestParameters(node.parent) && !isInAmbientContext(node)) {
|
||||
if (node.parent.body && ts.hasRestParameters(node.parent) && !ts.isInAmbientContext(node)) {
|
||||
error(node, ts.Diagnostics.Duplicate_identifier_i_Compiler_uses_i_to_initialize_rest_parameter);
|
||||
}
|
||||
return;
|
||||
@@ -11726,7 +11819,7 @@ var ts;
|
||||
if (node.kind === 115 /* Property */ || node.kind === 116 /* Method */ || node.kind === 118 /* GetAccessor */ || node.kind === 119 /* SetAccessor */) {
|
||||
return false;
|
||||
}
|
||||
if (isInAmbientContext(node)) {
|
||||
if (ts.isInAmbientContext(node)) {
|
||||
return false;
|
||||
}
|
||||
if (node.kind === 114 /* Parameter */ && !node.parent.body) {
|
||||
@@ -11761,7 +11854,7 @@ var ts;
|
||||
return;
|
||||
}
|
||||
var enclosingClass = getAncestor(node, 169 /* ClassDeclaration */);
|
||||
if (!enclosingClass || isInAmbientContext(enclosingClass)) {
|
||||
if (!enclosingClass || ts.isInAmbientContext(enclosingClass)) {
|
||||
return;
|
||||
}
|
||||
if (enclosingClass.baseType) {
|
||||
@@ -11994,7 +12087,7 @@ var ts;
|
||||
var type = getDeclaredTypeOfSymbol(symbol);
|
||||
var staticType = getTypeOfSymbol(symbol);
|
||||
if (node.baseType) {
|
||||
emitExtends = emitExtends || !isInAmbientContext(node);
|
||||
emitExtends = emitExtends || !ts.isInAmbientContext(node);
|
||||
checkTypeReference(node.baseType);
|
||||
}
|
||||
if (type.baseTypes.length) {
|
||||
@@ -12147,7 +12240,7 @@ var ts;
|
||||
var enumSymbol = getSymbolOfNode(node);
|
||||
var enumType = getDeclaredTypeOfSymbol(enumSymbol);
|
||||
var autoValue = 0;
|
||||
var ambient = isInAmbientContext(node);
|
||||
var ambient = ts.isInAmbientContext(node);
|
||||
ts.forEach(node.members, function (member) {
|
||||
var initializer = member.initializer;
|
||||
if (initializer) {
|
||||
@@ -12190,7 +12283,7 @@ var ts;
|
||||
var declarations = symbol.declarations;
|
||||
for (var i = 0; i < declarations.length; i++) {
|
||||
var declaration = declarations[i];
|
||||
if ((declaration.kind === 169 /* ClassDeclaration */ || (declaration.kind === 167 /* FunctionDeclaration */ && declaration.body)) && !isInAmbientContext(declaration)) {
|
||||
if ((declaration.kind === 169 /* ClassDeclaration */ || (declaration.kind === 167 /* FunctionDeclaration */ && declaration.body)) && !ts.isInAmbientContext(declaration)) {
|
||||
return declaration;
|
||||
}
|
||||
}
|
||||
@@ -12200,7 +12293,7 @@ var ts;
|
||||
checkCollisionWithCapturedThisVariable(node, node.name);
|
||||
checkExportsOnMergedDeclarations(node);
|
||||
var symbol = getSymbolOfNode(node);
|
||||
if (symbol.flags & 128 /* ValueModule */ && symbol.declarations.length > 1 && !isInAmbientContext(node)) {
|
||||
if (symbol.flags & 128 /* ValueModule */ && symbol.declarations.length > 1 && !ts.isInAmbientContext(node)) {
|
||||
var classOrFunc = getFirstNonAmbientClassOrFunctionDeclaration(symbol);
|
||||
if (classOrFunc) {
|
||||
if (ts.getSourceFileOfNode(node) !== ts.getSourceFileOfNode(classOrFunc)) {
|
||||
@@ -12502,7 +12595,7 @@ var ts;
|
||||
}
|
||||
function isTypeReferenceIdentifier(identifier) {
|
||||
var node = identifier;
|
||||
while (node.parent && node.parent.kind === 112 /* QualifiedName */)
|
||||
if (node.parent && node.parent.kind === 112 /* QualifiedName */)
|
||||
node = node.parent;
|
||||
return node.parent && node.parent.kind === 123 /* TypeReference */;
|
||||
}
|
||||
@@ -12566,9 +12659,18 @@ var ts;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function isRightSideOfQualifiedName(node) {
|
||||
return (node.parent.kind === 112 /* QualifiedName */ || node.parent.kind === 130 /* PropertyAccess */) && node.parent.right === node;
|
||||
}
|
||||
function getSymbolOfIdentifier(identifier) {
|
||||
if (isExpression(identifier)) {
|
||||
if (isRightSideOfQualifiedName()) {
|
||||
if (isRightSideOfQualifiedName(identifier)) {
|
||||
var node = identifier.parent;
|
||||
var symbol = getNodeLinks(node).resolvedSymbol;
|
||||
if (!symbol) {
|
||||
checkPropertyAccess(node);
|
||||
}
|
||||
return getNodeLinks(node).resolvedSymbol;
|
||||
}
|
||||
return resolveEntityName(identifier, identifier, ts.SymbolFlags.Value);
|
||||
}
|
||||
@@ -12576,12 +12678,48 @@ var ts;
|
||||
return getSymbolOfNode(identifier.parent);
|
||||
}
|
||||
if (isTypeReferenceIdentifier(identifier)) {
|
||||
var entityName = isRightSideOfQualifiedName() ? identifier.parent : identifier;
|
||||
var entityName = isRightSideOfQualifiedName(identifier) ? identifier.parent : identifier;
|
||||
var meaning = entityName.parent.kind === 123 /* TypeReference */ ? ts.SymbolFlags.Type : ts.SymbolFlags.Namespace;
|
||||
return resolveEntityName(entityName, entityName, meaning);
|
||||
}
|
||||
function isRightSideOfQualifiedName() {
|
||||
return (identifier.parent.kind === 112 /* QualifiedName */ || identifier.parent.kind === 130 /* PropertyAccess */) && identifier.parent.right === identifier;
|
||||
}
|
||||
function getTypeOfExpression(node) {
|
||||
if (isExpression(node)) {
|
||||
while (isRightSideOfQualifiedName(node)) {
|
||||
node = node.parent;
|
||||
}
|
||||
return getApparentType(checkExpression(node));
|
||||
}
|
||||
return unknownType;
|
||||
}
|
||||
function getAugmentedPropertiesOfApparentType(type) {
|
||||
var apparentType = getApparentType(type);
|
||||
if (apparentType.flags & ts.TypeFlags.ObjectType) {
|
||||
var propertiesByName = {};
|
||||
var results = [];
|
||||
ts.forEach(getPropertiesOfType(apparentType), function (s) {
|
||||
propertiesByName[s.name] = s;
|
||||
results.push(s);
|
||||
});
|
||||
var resolved = resolveObjectTypeMembers(type);
|
||||
ts.forEachValue(resolved.members, function (s) {
|
||||
if (symbolIsValue(s) && !propertiesByName[s.name]) {
|
||||
propertiesByName[s.name] = s;
|
||||
results.push(s);
|
||||
}
|
||||
});
|
||||
if (resolved === anyFunctionType || resolved.callSignatures.length || resolved.constructSignatures.length) {
|
||||
ts.forEach(getPropertiesOfType(globalFunctionType), function (s) {
|
||||
if (!propertiesByName[s.name]) {
|
||||
propertiesByName[s.name] = s;
|
||||
results.push(s);
|
||||
}
|
||||
});
|
||||
}
|
||||
return results;
|
||||
}
|
||||
else {
|
||||
return getPropertiesOfType(apparentType);
|
||||
}
|
||||
}
|
||||
function isExternalModuleSymbol(symbol) {
|
||||
@@ -12740,28 +12878,6 @@ var ts;
|
||||
globalRegExpType = getGlobalType("RegExp");
|
||||
}
|
||||
initializeTypeChecker();
|
||||
checker = {
|
||||
getProgram: function () { return program; },
|
||||
getDiagnostics: getDiagnostics,
|
||||
getGlobalDiagnostics: getGlobalDiagnostics,
|
||||
getNodeCount: function () { return ts.sum(program.getSourceFiles(), "nodeCount"); },
|
||||
getIdentifierCount: function () { return ts.sum(program.getSourceFiles(), "identifierCount"); },
|
||||
getSymbolCount: function () { return ts.sum(program.getSourceFiles(), "symbolCount"); },
|
||||
getTypeCount: function () { return typeCount; },
|
||||
checkProgram: checkProgram,
|
||||
emitFiles: invokeEmitter,
|
||||
getSymbolOfNode: getSymbolOfNode,
|
||||
getParentOfSymbol: getParentOfSymbol,
|
||||
getTypeOfSymbol: getTypeOfSymbol,
|
||||
getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol,
|
||||
getPropertiesOfType: getPropertiesOfType,
|
||||
getSignaturesOfType: getSignaturesOfType,
|
||||
getIndexTypeOfType: getIndexTypeOfType,
|
||||
getReturnTypeOfSignature: getReturnTypeOfSignature,
|
||||
resolveEntityName: resolveEntityName,
|
||||
getSymbolsInScope: getSymbolsInScope,
|
||||
getSymbolOfIdentifier: getSymbolOfIdentifier
|
||||
};
|
||||
return checker;
|
||||
}
|
||||
ts.createTypeChecker = createTypeChecker;
|
||||
@@ -12774,7 +12890,7 @@ var ts;
|
||||
"m": "module",
|
||||
"o": "out",
|
||||
"t": "target",
|
||||
"v": "version",
|
||||
"v": "version"
|
||||
};
|
||||
var options = [
|
||||
{ name: "charset", type: "string" },
|
||||
@@ -13031,7 +13147,8 @@ var ts;
|
||||
writeFile: writeFile,
|
||||
getCurrentDirectory: function () { return currentDirectory || (currentDirectory = sys.getCurrentDirectory()); },
|
||||
useCaseSensitiveFileNames: function () { return sys.useCaseSensitiveFileNames; },
|
||||
getCanonicalFileName: ts.getCanonicalFileName
|
||||
getCanonicalFileName: ts.getCanonicalFileName,
|
||||
getNewLine: function () { return sys.newLine; }
|
||||
};
|
||||
}
|
||||
function executeCommandLine(args) {
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -171,8 +171,13 @@ module ts {
|
||||
parent = node;
|
||||
if (symbolKind & SymbolFlags.IsContainer) {
|
||||
container = node;
|
||||
if (lastContainer) lastContainer.nextContainer = container;
|
||||
lastContainer = container;
|
||||
// If container is not on container list, add it to the list
|
||||
if (lastContainer !== container && !container.nextContainer) {
|
||||
if (lastContainer) {
|
||||
lastContainer.nextContainer = container;
|
||||
}
|
||||
lastContainer = container;
|
||||
}
|
||||
}
|
||||
forEachChild(node, bind);
|
||||
container = saveContainer;
|
||||
@@ -247,7 +252,7 @@ module ts {
|
||||
|
||||
function bindCatchVariableDeclaration(node: CatchBlock) {
|
||||
var symbol = createSymbol(SymbolFlags.Variable, node.variable.text || "__missing");
|
||||
addDeclarationToSymbol(symbol, node.variable, SymbolFlags.Variable);
|
||||
addDeclarationToSymbol(symbol, node, SymbolFlags.Variable);
|
||||
var saveParent = parent;
|
||||
parent = node;
|
||||
forEachChild(node, bind);
|
||||
|
||||
+365
-233
@@ -41,6 +41,9 @@ module ts {
|
||||
var anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
|
||||
var noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
|
||||
|
||||
var anySignature = createSignature(undefined, undefined, emptyArray, anyType, 0, false, false);
|
||||
var unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, 0, false, false);
|
||||
|
||||
var globals: SymbolTable = {};
|
||||
|
||||
var globalObjectType: ObjectType;
|
||||
@@ -53,6 +56,7 @@ module ts {
|
||||
|
||||
var stringLiteralTypes: Map<StringLiteralType> = {};
|
||||
|
||||
var fullTypeCheck = false;
|
||||
var emitExtends = false;
|
||||
|
||||
var mergedSymbols: Symbol[] = [];
|
||||
@@ -328,7 +332,7 @@ module ts {
|
||||
case SyntaxKind.CatchBlock:
|
||||
var id = (<CatchBlock>location).variable;
|
||||
if (name === id.text) {
|
||||
return returnResolvedSymbol((<CatchBlock>location).variable.symbol);
|
||||
return returnResolvedSymbol(location.symbol);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -444,13 +448,15 @@ module ts {
|
||||
return moduleSymbol;
|
||||
}
|
||||
|
||||
function getExportAssignmentSymbol(symbol: Symbol): Symbol {
|
||||
function getExportAssignmentSymbol(symbol: Symbol): Symbol {
|
||||
checkTypeOfExportAssignmentSymbol(symbol);
|
||||
return symbol.exportAssignSymbol === unknownSymbol ? undefined : symbol.exportAssignSymbol;
|
||||
var symbolLinks = getSymbolLinks(symbol);
|
||||
return symbolLinks.exportAssignSymbol === unknownSymbol ? undefined : symbolLinks.exportAssignSymbol;
|
||||
}
|
||||
|
||||
function checkTypeOfExportAssignmentSymbol(containerSymbol: Symbol): void {
|
||||
if (!containerSymbol.exportAssignSymbol) {
|
||||
var symbolLinks = getSymbolLinks(containerSymbol);
|
||||
if (!symbolLinks.exportAssignSymbol) {
|
||||
var exportInformation = collectExportInformationForSourceFileOrModule(containerSymbol);
|
||||
if (exportInformation.exportAssignments.length) {
|
||||
if (exportInformation.exportAssignments.length > 1) {
|
||||
@@ -471,7 +477,7 @@ module ts {
|
||||
var exportSymbol = resolveName(node, node.exportName.text, meaning, Diagnostics.Cannot_find_name_0, identifierToString(node.exportName));
|
||||
}
|
||||
}
|
||||
containerSymbol.exportAssignSymbol = exportSymbol || unknownSymbol;
|
||||
symbolLinks.exportAssignSymbol = exportSymbol || unknownSymbol;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1103,129 +1109,99 @@ module ts {
|
||||
}
|
||||
|
||||
function getTypeOfVariableDeclaration(declaration: VariableDeclaration): Type {
|
||||
var type: Type;
|
||||
|
||||
if (declaration.parent.kind === SyntaxKind.CatchBlock || declaration.parent.kind === SyntaxKind.ForInStatement) {
|
||||
type = anyType;
|
||||
// A variable declared in a for..in statement is always of type any
|
||||
if (declaration.parent.kind === SyntaxKind.ForInStatement) {
|
||||
return anyType;
|
||||
}
|
||||
else if (declaration.type) {
|
||||
type = getTypeFromTypeNode(declaration.type);
|
||||
// Use type from type annotation if one is present
|
||||
if (declaration.type) {
|
||||
return getTypeFromTypeNode(declaration.type);
|
||||
}
|
||||
else {
|
||||
// TypeScript 1.0 spec (April 2014):
|
||||
// If only one accessor includes a type annotation, the other behaves as if it had the same type annotation.
|
||||
// If neither accessor includes a type annotation, the inferred return type of the get accessor becomes the parameter type of the set accessor.
|
||||
if (declaration.kind === SyntaxKind.Parameter && declaration.parent.kind === SyntaxKind.SetAccessor) {
|
||||
if (declaration.kind === SyntaxKind.Parameter) {
|
||||
var func = <FunctionDeclaration>declaration.parent;
|
||||
// For a parameter of a set accessor, use the type of the get accessor if one is present
|
||||
if (func.kind === SyntaxKind.SetAccessor) {
|
||||
var getter = <AccessorDeclaration>getDeclarationOfKind(declaration.parent.symbol, SyntaxKind.GetAccessor);
|
||||
if (getter) {
|
||||
//getReturnTypeOfSignature will check both type annotation and return type inferred from body
|
||||
type = getReturnTypeOfSignature(getSignatureFromDeclaration(getter));
|
||||
return getReturnTypeOfSignature(getSignatureFromDeclaration(getter));
|
||||
}
|
||||
}
|
||||
|
||||
var unwidenedType: Type;
|
||||
|
||||
if (!type) {
|
||||
if (declaration.initializer) {
|
||||
unwidenedType = checkAndMarkExpression(declaration.initializer);
|
||||
type = getWidenedType(unwidenedType);
|
||||
}
|
||||
else if (declaration.flags & NodeFlags.Rest) {
|
||||
type = createArrayType(anyType);
|
||||
}
|
||||
else {
|
||||
type = anyType;
|
||||
}
|
||||
}
|
||||
|
||||
if (program.getCompilerOptions().noImplicitAny && shouldReportNoImplicitAnyOnVariableOrParameterOrProperty(declaration, type, unwidenedType)) {
|
||||
reportNoImplicitAnyOnVariableOrParameterOrProperty(declaration, type);
|
||||
// Use contextual parameter type if one is available
|
||||
var type = getContextuallyTypedParameterType(declaration);
|
||||
if (type) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
// Use the type of the initializer expression if one is present
|
||||
if (declaration.initializer) {
|
||||
var unwidenedType = checkAndMarkExpression(declaration.initializer);
|
||||
var type = getWidenedType(unwidenedType);
|
||||
if (type !== unwidenedType) {
|
||||
checkImplicitAny(type);
|
||||
}
|
||||
return type;
|
||||
}
|
||||
// Rest parameters default to type any[], other parameters default to type any
|
||||
var type = declaration.flags & NodeFlags.Rest ? createArrayType(anyType) : anyType;
|
||||
checkImplicitAny(type);
|
||||
return type;
|
||||
|
||||
function shouldReportNoImplicitAnyOnVariableOrParameterOrProperty(declaration: VariableDeclaration, type: Type, unwidenedType: Type): boolean {
|
||||
// If we attempted to widen, the resulting type has to be a different.
|
||||
if (type === unwidenedType) {
|
||||
return false;
|
||||
function checkImplicitAny(type: Type) {
|
||||
if (!program.getCompilerOptions().noImplicitAny) {
|
||||
return;
|
||||
}
|
||||
|
||||
// We need to have ended up with 'any', 'any[]', 'any[][]', etc.
|
||||
if (getInnermostTypeOfNestedArrayTypes(type) !== anyType) {
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
// Ignore privates within ambient contexts; they exist purely for documentative purposes to avoid name clashing.
|
||||
// (e.g. privates within .d.ts files do not expose type information)
|
||||
if (isPrivateWithinAmbient(declaration) || (declaration.kind === SyntaxKind.Parameter && isPrivateWithinAmbient(declaration.parent))) {
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function reportNoImplicitAnyOnVariableOrParameterOrProperty(declaration: VariableDeclaration, type: Type): void {
|
||||
var varName = identifierToString(declaration.name);
|
||||
var typeName = typeToString(type);
|
||||
|
||||
switch (declaration.kind) {
|
||||
case SyntaxKind.VariableDeclaration:
|
||||
error(declaration, Diagnostics.Variable_0_implicitly_has_an_1_type, varName, typeName)
|
||||
break;
|
||||
|
||||
case SyntaxKind.Property:
|
||||
error(declaration, Diagnostics.Member_0_implicitly_has_an_1_type, varName, typeName)
|
||||
var diagnostic = Diagnostics.Member_0_implicitly_has_an_1_type;
|
||||
break;
|
||||
|
||||
case SyntaxKind.Parameter:
|
||||
var funcDeclaration = <FunctionDeclaration>declaration.parent;
|
||||
|
||||
// If this is a rest parameter, we should have widened specifically to 'any[]'.
|
||||
if (declaration.flags & NodeFlags.Rest) {
|
||||
error(declaration, Diagnostics.Rest_parameter_0_implicitly_has_an_any_type, varName)
|
||||
}
|
||||
else {
|
||||
error(declaration, Diagnostics.Parameter_0_implicitly_has_an_1_type, varName, typeName)
|
||||
}
|
||||
|
||||
var diagnostic = declaration.flags & NodeFlags.Rest ?
|
||||
Diagnostics.Rest_parameter_0_implicitly_has_an_any_type :
|
||||
Diagnostics.Parameter_0_implicitly_has_an_1_type;
|
||||
break;
|
||||
|
||||
default:
|
||||
Debug.fail("Received a '" + SyntaxKind[declaration.kind] + "', but expected '" +
|
||||
SyntaxKind[SyntaxKind.VariableDeclaration] + "', '" +
|
||||
SyntaxKind[SyntaxKind.Property] + "', or '" +
|
||||
SyntaxKind[SyntaxKind.Parameter] + "'.\r\n");
|
||||
var diagnostic = Diagnostics.Variable_0_implicitly_has_an_1_type;
|
||||
}
|
||||
error(declaration, diagnostic, identifierToString(declaration.name), typeToString(type));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function getTypeOfVariableOrParameterOrProperty(symbol: Symbol): Type {
|
||||
var links = getSymbolLinks(symbol);
|
||||
if (!links.type) {
|
||||
// Handle prototype property
|
||||
if (symbol.flags & SymbolFlags.Prototype) {
|
||||
links.type = getTypeOfPrototypeProperty(symbol);
|
||||
return links.type = getTypeOfPrototypeProperty(symbol);
|
||||
}
|
||||
else {
|
||||
links.type = resolvingType;
|
||||
var type = getTypeOfVariableDeclaration(<VariableDeclaration>symbol.valueDeclaration);
|
||||
if (links.type === resolvingType) {
|
||||
links.type = type;
|
||||
}
|
||||
// Handle catch clause variables
|
||||
var declaration = symbol.valueDeclaration;
|
||||
if (declaration.kind === SyntaxKind.CatchBlock) {
|
||||
return links.type = anyType;
|
||||
}
|
||||
// Handle variable, parameter or property
|
||||
links.type = resolvingType;
|
||||
var type = getTypeOfVariableDeclaration(<VariableDeclaration>declaration);
|
||||
if (links.type === resolvingType) {
|
||||
links.type = type;
|
||||
}
|
||||
}
|
||||
|
||||
else if (links.type === resolvingType) {
|
||||
links.type = anyType;
|
||||
}
|
||||
|
||||
return links.type;
|
||||
|
||||
}
|
||||
|
||||
function getSetAccessorTypeAnnotationNode(accessor: AccessorDeclaration): TypeNode {
|
||||
return accessor && accessor.parameters.length > 0 && accessor.parameters[0].type;
|
||||
return accessor && accessor.parameters.length > 0 && accessor.parameters[0].type;
|
||||
}
|
||||
|
||||
function getAnnotatedAccessorType(accessor: AccessorDeclaration): Type {
|
||||
@@ -2295,15 +2271,17 @@ module ts {
|
||||
}
|
||||
|
||||
function instantiateType(type: Type, mapper: TypeMapper): Type {
|
||||
if (type.flags & TypeFlags.TypeParameter) {
|
||||
return mapper(type);
|
||||
}
|
||||
if (type.flags & TypeFlags.Anonymous) {
|
||||
return type.symbol && type.symbol.flags & (SymbolFlags.Function | SymbolFlags.Method | SymbolFlags.TypeLiteral | SymbolFlags.ObjectLiteral) ?
|
||||
instantiateAnonymousType(<ObjectType>type, mapper) : type;
|
||||
}
|
||||
if (type.flags & TypeFlags.Reference) {
|
||||
return createTypeReference((<TypeReference>type).target, instantiateList((<TypeReference>type).typeArguments, mapper, instantiateType));
|
||||
if (mapper !== identityMapper) {
|
||||
if (type.flags & TypeFlags.TypeParameter) {
|
||||
return mapper(type);
|
||||
}
|
||||
if (type.flags & TypeFlags.Anonymous) {
|
||||
return type.symbol && type.symbol.flags & (SymbolFlags.Function | SymbolFlags.Method | SymbolFlags.TypeLiteral | SymbolFlags.ObjectLiteral) ?
|
||||
instantiateAnonymousType(<ObjectType>type, mapper) : type;
|
||||
}
|
||||
if (type.flags & TypeFlags.Reference) {
|
||||
return createTypeReference((<TypeReference>type).target, instantiateList((<TypeReference>type).typeArguments, mapper, instantiateType));
|
||||
}
|
||||
}
|
||||
return type;
|
||||
}
|
||||
@@ -3460,22 +3438,166 @@ module ts {
|
||||
return unknownType;
|
||||
}
|
||||
|
||||
// Return contextual type of parameter or undefined if no contextual type is available
|
||||
function getContextuallyTypedParameterType(parameter: ParameterDeclaration): Type {
|
||||
var func = <FunctionDeclaration>parameter.parent;
|
||||
if (func.kind === SyntaxKind.FunctionExpression || func.kind === SyntaxKind.ArrowFunction) {
|
||||
if (isContextSensitiveExpression(func)) {
|
||||
var signature = getContextualSignature(func);
|
||||
if (signature) {
|
||||
return getTypeAtPosition(signature, indexOf(func.parameters, parameter));
|
||||
}
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function getContextualTypeForInitializerExpression(node: Expression): Type {
|
||||
var declaration = <VariableDeclaration>node.parent;
|
||||
if (node === declaration.initializer) {
|
||||
if (declaration.type) {
|
||||
return getTypeFromTypeNode(declaration.type);
|
||||
}
|
||||
if (declaration.kind === SyntaxKind.Parameter) {
|
||||
return getContextuallyTypedParameterType(declaration);
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function getContextualTypeForReturnExpression(node: Expression): Type {
|
||||
var func = getContainingFunction(node);
|
||||
if (func) {
|
||||
// If the containing function has a return type annotation, is a constructor, or is a get accessor whose
|
||||
// corresponding set accessor has a type annotation, return statements in the function are contextually typed
|
||||
if (func.type || func.kind === SyntaxKind.Constructor || func.kind === SyntaxKind.GetAccessor && getSetAccessorTypeAnnotationNode(<AccessorDeclaration>getDeclarationOfKind(func.symbol, SyntaxKind.SetAccessor))) {
|
||||
return getReturnTypeOfSignature(getSignatureFromDeclaration(func));
|
||||
}
|
||||
// Otherwise, if the containing function is contextually typed by a function type with exactly one call signature
|
||||
// and that call signature is non-generic, return statements are contextually typed by the return type of the signature
|
||||
var signature = getContextualSignature(func);
|
||||
if (signature) {
|
||||
return getReturnTypeOfSignature(signature);
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function getContextualTypeForArgument(node: Expression): Type {
|
||||
var callExpression = <CallExpression>node.parent;
|
||||
var argIndex = indexOf(callExpression.arguments, node);
|
||||
if (argIndex >= 0) {
|
||||
var signature = getResolvedSignature(callExpression);
|
||||
return getTypeAtPosition(signature, argIndex);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function getContextualTypeForBinaryOperand(node: Expression): Type {
|
||||
var binaryExpression = <BinaryExpression>node.parent;
|
||||
var operator = binaryExpression.operator;
|
||||
if (operator >= SyntaxKind.FirstAssignment && operator <= SyntaxKind.LastAssignment) {
|
||||
if (node === binaryExpression.right) {
|
||||
return checkExpression(binaryExpression.left);
|
||||
}
|
||||
}
|
||||
else if (operator === SyntaxKind.BarBarToken) {
|
||||
var type = getContextualType(binaryExpression);
|
||||
if (!type && node === binaryExpression.right) {
|
||||
type = checkExpression(binaryExpression.left);
|
||||
}
|
||||
return type;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function getContextualTypeForPropertyExpression(node: Expression): Type {
|
||||
var declaration = <PropertyDeclaration>node.parent;
|
||||
var objectLiteral = <ObjectLiteral>declaration.parent;
|
||||
var type = getContextualType(objectLiteral);
|
||||
var name = declaration.name.text;
|
||||
if (type && name) {
|
||||
var prop = getPropertyOfType(type, name);
|
||||
if (prop) {
|
||||
return getTypeOfSymbol(prop);
|
||||
}
|
||||
return isNumericName(name) && getIndexTypeOfType(type, IndexKind.Number) || getIndexTypeOfType(type, IndexKind.String);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function getContextualTypeForElementExpression(node: Expression): Type {
|
||||
var arrayLiteral = <ArrayLiteral>node.parent;
|
||||
var type = getContextualType(arrayLiteral);
|
||||
return type ? getIndexTypeOfType(type, IndexKind.Number) : undefined;
|
||||
}
|
||||
|
||||
function getContextualTypeForConditionalOperand(node: Expression): Type {
|
||||
var conditional = <ConditionalExpression>node.parent;
|
||||
return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional) : undefined;
|
||||
}
|
||||
|
||||
function getContextualType(node: Expression): Type {
|
||||
if (node.contextualType) {
|
||||
return node.contextualType;
|
||||
}
|
||||
var parent = node.parent;
|
||||
switch (parent.kind) {
|
||||
case SyntaxKind.VariableDeclaration:
|
||||
case SyntaxKind.Parameter:
|
||||
case SyntaxKind.Property:
|
||||
return getContextualTypeForInitializerExpression(node);
|
||||
case SyntaxKind.ArrowFunction:
|
||||
case SyntaxKind.ReturnStatement:
|
||||
return getContextualTypeForReturnExpression(node);
|
||||
case SyntaxKind.CallExpression:
|
||||
case SyntaxKind.NewExpression:
|
||||
return getContextualTypeForArgument(node);
|
||||
case SyntaxKind.TypeAssertion:
|
||||
return getTypeFromTypeNode((<TypeAssertion>parent).type);
|
||||
case SyntaxKind.BinaryExpression:
|
||||
return getContextualTypeForBinaryOperand(node);
|
||||
case SyntaxKind.PropertyAssignment:
|
||||
return getContextualTypeForPropertyExpression(node);
|
||||
case SyntaxKind.ArrayLiteral:
|
||||
return getContextualTypeForElementExpression(node);
|
||||
case SyntaxKind.ConditionalExpression:
|
||||
return getContextualTypeForConditionalOperand(node);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function getContextualSignature(node: Expression): Signature {
|
||||
var type = getContextualType(node);
|
||||
if (type) {
|
||||
var signatures = getSignaturesOfType(type, SignatureKind.Call);
|
||||
if (signatures.length === 1) {
|
||||
var signature = signatures[0];
|
||||
if (!signature.typeParameters) {
|
||||
return signature;
|
||||
}
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// Presence of a contextual type mapper indicates inferential typing, except the identityMapper object is
|
||||
// used as a special marker for other purposes.
|
||||
function isInferentialContext(mapper: TypeMapper) {
|
||||
return mapper && mapper !== identityMapper;
|
||||
}
|
||||
|
||||
function checkArrayLiteral(node: ArrayLiteral, contextualType?: Type, contextualMapper?: TypeMapper): Type {
|
||||
var contextualElementType = contextualType && getIndexTypeOfType(contextualType, IndexKind.Number);
|
||||
function checkArrayLiteral(node: ArrayLiteral, contextualMapper?: TypeMapper): Type {
|
||||
var elementTypes: Type[] = [];
|
||||
forEach(node.elements, element => {
|
||||
if (element.kind !== SyntaxKind.OmittedExpression) {
|
||||
var type = checkExpression(element, contextualElementType, contextualMapper);
|
||||
var type = checkExpression(element, contextualMapper);
|
||||
if (!contains(elementTypes, type)) elementTypes.push(type);
|
||||
}
|
||||
});
|
||||
var elementType = getBestCommonType(elementTypes, isInferentialContext(contextualMapper) ? undefined : contextualElementType, true);
|
||||
var contextualType = isInferentialContext(contextualMapper) ? undefined : getContextualType(node);
|
||||
var contextualElementType = contextualType && getIndexTypeOfType(contextualType, IndexKind.Number);
|
||||
var elementType = getBestCommonType(elementTypes, contextualElementType, true);
|
||||
if (!elementType) elementType = elementTypes.length ? emptyObjectType : undefinedType;
|
||||
return createArrayType(elementType);
|
||||
}
|
||||
@@ -3484,22 +3606,16 @@ module ts {
|
||||
return !isNaN(<number><any>name);
|
||||
}
|
||||
|
||||
function getContextualTypeForProperty(type: Type, name: string) {
|
||||
var prop = getPropertyOfType(type, name);
|
||||
if (prop) return getTypeOfSymbol(prop);
|
||||
return isNumericName(name) && getIndexTypeOfType(type, IndexKind.Number) || getIndexTypeOfType(type, IndexKind.String);
|
||||
}
|
||||
|
||||
function checkObjectLiteral(node: ObjectLiteral, contextualType?: Type, contextualMapper?: TypeMapper): Type {
|
||||
function checkObjectLiteral(node: ObjectLiteral, contextualMapper?: TypeMapper): Type {
|
||||
var members = node.symbol.members;
|
||||
var properties: SymbolTable = {};
|
||||
var contextualType = getContextualType(node);
|
||||
|
||||
for (var id in members) {
|
||||
if (hasProperty(members, id)) {
|
||||
var member = members[id];
|
||||
if (member.flags & SymbolFlags.Property) {
|
||||
var contextualPropType = contextualType && getContextualTypeForProperty(contextualType, member.name);
|
||||
var type = checkExpression((<PropertyDeclaration>member.declarations[0]).initializer, contextualPropType, contextualMapper);
|
||||
var type = checkExpression((<PropertyDeclaration>member.declarations[0]).initializer, contextualMapper);
|
||||
var prop = <TransientSymbol>createSymbol(SymbolFlags.Property | SymbolFlags.Transient, member.name);
|
||||
prop.declarations = member.declarations;
|
||||
prop.parent = member.parent;
|
||||
@@ -3526,11 +3642,11 @@ module ts {
|
||||
properties[member.name] = member;
|
||||
}
|
||||
}
|
||||
var stringIndexType = getIndexType(properties, IndexKind.String);
|
||||
var numberIndexType = getIndexType(properties, IndexKind.Number);
|
||||
var stringIndexType = getIndexType(IndexKind.String);
|
||||
var numberIndexType = getIndexType(IndexKind.Number);
|
||||
return createAnonymousType(node.symbol, properties, emptyArray, emptyArray, stringIndexType, numberIndexType);
|
||||
|
||||
function getIndexType(properties: SymbolTable, kind: IndexKind) {
|
||||
function getIndexType(kind: IndexKind) {
|
||||
if (contextualType) {
|
||||
var indexType = getIndexTypeOfType(contextualType, kind);
|
||||
if (indexType) {
|
||||
@@ -3543,7 +3659,6 @@ module ts {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return getBestCommonType(propTypes, isInferentialContext(contextualMapper) ? undefined : indexType);
|
||||
}
|
||||
}
|
||||
@@ -3658,14 +3773,16 @@ module ts {
|
||||
return unknownType;
|
||||
}
|
||||
|
||||
function checkUntypedCall(node: CallExpression): Type {
|
||||
forEach(node.arguments, argument => { checkExpression(argument); });
|
||||
return anyType;
|
||||
function resolveUntypedCall(node: CallExpression): Signature {
|
||||
forEach(node.arguments, argument => {
|
||||
checkExpression(argument);
|
||||
});
|
||||
return anySignature;
|
||||
}
|
||||
|
||||
function checkErrorCall(node: CallExpression): Type {
|
||||
checkUntypedCall(node);
|
||||
return unknownType;
|
||||
function resolveErrorCall(node: CallExpression): Signature {
|
||||
resolveUntypedCall(node);
|
||||
return unknownSignature;
|
||||
}
|
||||
|
||||
function isCandidateSignature(node: CallExpression, signature: Signature) {
|
||||
@@ -3724,7 +3841,7 @@ module ts {
|
||||
|
||||
// Inferentially type an expression by a contextual parameter type (section 4.12.2 in TypeScript spec)
|
||||
function inferentiallyTypeExpession(expr: Expression, contextualType: Type, contextualMapper: TypeMapper): Type {
|
||||
var type = checkExpression(expr, contextualType, contextualMapper);
|
||||
var type = checkExpressionWithContextualType(expr, contextualType, contextualMapper);
|
||||
var signature = getSingleCallSignature(type);
|
||||
if (signature && signature.typeParameters) {
|
||||
var contextualSignature = getSingleCallSignature(contextualType);
|
||||
@@ -3781,7 +3898,7 @@ module ts {
|
||||
// String literals get string literal types unless we're reporting errors
|
||||
var argType = arg.kind === SyntaxKind.StringLiteral && !reportErrors ?
|
||||
getStringLiteralType(<LiteralExpression>arg) :
|
||||
checkExpression(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined);
|
||||
checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined);
|
||||
// Use argument expression as error location when reporting errors
|
||||
var isValidArgument = checkTypeRelatedTo(argType, paramType, relation, reportErrors ? arg : undefined,
|
||||
Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1,
|
||||
@@ -3794,12 +3911,12 @@ module ts {
|
||||
return true;
|
||||
}
|
||||
|
||||
function checkCall(node: CallExpression, signatures: Signature[]): Type {
|
||||
function resolveCall(node: CallExpression, signatures: Signature[]): Signature {
|
||||
forEach(node.typeArguments, checkSourceElement);
|
||||
var candidates = collectCandidates(node, signatures);
|
||||
if (!candidates.length) {
|
||||
error(node, Diagnostics.Supplied_parameters_do_not_match_any_signature_of_call_target);
|
||||
return checkErrorCall(node);
|
||||
return resolveErrorCall(node);
|
||||
}
|
||||
var args = node.arguments || emptyArray;
|
||||
var excludeArgument: boolean[];
|
||||
@@ -3825,7 +3942,7 @@ module ts {
|
||||
}
|
||||
var index = excludeArgument ? indexOf(excludeArgument, true) : -1;
|
||||
if (index < 0) {
|
||||
return getReturnTypeOfSignature(candidate);
|
||||
return candidate;
|
||||
}
|
||||
excludeArgument[index] = false;
|
||||
}
|
||||
@@ -3838,35 +3955,29 @@ module ts {
|
||||
// No signatures were applicable. Now report errors based on the last applicable signature with
|
||||
// no arguments excluded from assignability checks.
|
||||
checkApplicableSignature(node, candidate, relation, undefined, /*reportErrors*/ true);
|
||||
return checkErrorCall(node);
|
||||
return resolveErrorCall(node);
|
||||
}
|
||||
|
||||
function checkCallExpression(node: CallExpression): Type {
|
||||
function resolveCallExpression(node: CallExpression): Signature {
|
||||
if (node.func.kind === SyntaxKind.SuperKeyword) {
|
||||
var superType = checkSuperExpression(node.func, true);
|
||||
if (superType !== unknownType) {
|
||||
checkCall(node, getSignaturesOfType(superType, SignatureKind.Construct));
|
||||
return resolveCall(node, getSignaturesOfType(superType, SignatureKind.Construct));
|
||||
}
|
||||
else {
|
||||
checkUntypedCall(node);
|
||||
}
|
||||
|
||||
// TS 1.0 spec: 4.8.1
|
||||
// The type of a super call expression is Void.
|
||||
return voidType;
|
||||
return resolveUntypedCall(node);
|
||||
}
|
||||
|
||||
var funcType = checkExpression(node.func);
|
||||
if (funcType === unknownType) {
|
||||
// Another error has already been reported
|
||||
return checkErrorCall(node);
|
||||
return resolveErrorCall(node);
|
||||
}
|
||||
|
||||
var apparentType = getApparentType(funcType)
|
||||
if (<Type>apparentType === unknownType) {
|
||||
// handler cases when funcType is type parameter with invalid constraint
|
||||
// Another error was already reported
|
||||
return checkErrorCall(node);
|
||||
return resolveErrorCall(node);
|
||||
}
|
||||
|
||||
// Technically, this signatures list may be incomplete. We are taking the apparent type,
|
||||
@@ -3885,7 +3996,7 @@ module ts {
|
||||
if (node.typeArguments) {
|
||||
error(node, Diagnostics.Untyped_function_calls_may_not_accept_type_arguments);
|
||||
}
|
||||
return checkUntypedCall(node);
|
||||
return resolveUntypedCall(node);
|
||||
}
|
||||
// If FuncExpr's apparent type(section 3.8.1) is a function type, the call is a typed function call.
|
||||
// TypeScript employs overload resolution in typed function calls in order to support functions
|
||||
@@ -3897,16 +4008,16 @@ module ts {
|
||||
else {
|
||||
error(node, Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature);
|
||||
}
|
||||
return checkErrorCall(node);
|
||||
return resolveErrorCall(node);
|
||||
}
|
||||
return checkCall(node, callSignatures);
|
||||
return resolveCall(node, callSignatures);
|
||||
}
|
||||
|
||||
function checkNewExpression(node: NewExpression): Type {
|
||||
function resolveNewExpression(node: NewExpression): Signature {
|
||||
var expressionType = checkExpression(node.func);
|
||||
if (expressionType === unknownType) {
|
||||
// Another error has already been reported
|
||||
return checkErrorCall(node);
|
||||
return resolveErrorCall(node);
|
||||
}
|
||||
// TS 1.0 spec: 4.11
|
||||
// If ConstructExpr is of type Any, Args can be any argument
|
||||
@@ -3916,7 +4027,7 @@ module ts {
|
||||
error(node, Diagnostics.Untyped_function_calls_may_not_accept_type_arguments);
|
||||
}
|
||||
|
||||
return checkUntypedCall(node);
|
||||
return resolveUntypedCall(node);
|
||||
}
|
||||
|
||||
// If ConstructExpr's apparent type(section 3.8.1) is an object type with one or
|
||||
@@ -3928,7 +4039,7 @@ module ts {
|
||||
if (<Type>expressionType === unknownType) {
|
||||
// handler cases when original expressionType is a type parameter with invalid constraint
|
||||
// another error has already been reported
|
||||
return checkErrorCall(node);
|
||||
return resolveErrorCall(node);
|
||||
}
|
||||
|
||||
// Technically, this signatures list may be incomplete. We are taking the apparent type,
|
||||
@@ -3937,7 +4048,7 @@ module ts {
|
||||
// that the user will not add any.
|
||||
var constructSignatures = getSignaturesOfType(expressionType, SignatureKind.Construct);
|
||||
if (constructSignatures.length) {
|
||||
return checkCall(node, constructSignatures);
|
||||
return resolveCall(node, constructSignatures);
|
||||
}
|
||||
|
||||
// If ConstructExpr's apparent type is an object type with no construct signatures but
|
||||
@@ -3946,45 +4057,54 @@ module ts {
|
||||
// operation is Any.
|
||||
var callSignatures = getSignaturesOfType(expressionType, SignatureKind.Call);
|
||||
if (callSignatures.length) {
|
||||
var type = checkCall(node, callSignatures);
|
||||
|
||||
if (type !== voidType) {
|
||||
var signature = resolveCall(node, callSignatures);
|
||||
if (getReturnTypeOfSignature(signature) !== voidType) {
|
||||
error(node, Diagnostics.Only_a_void_function_can_be_called_with_the_new_keyword);
|
||||
}
|
||||
|
||||
// Since we found no constructor signature, we (implicitly) return any.
|
||||
if (program.getCompilerOptions().noImplicitAny) {
|
||||
error(node, Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type);
|
||||
}
|
||||
|
||||
return anyType;
|
||||
return signature;
|
||||
}
|
||||
|
||||
error(node, Diagnostics.Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature);
|
||||
return checkErrorCall(node);
|
||||
return resolveErrorCall(node);
|
||||
}
|
||||
|
||||
function getResolvedSignature(node: CallExpression): Signature {
|
||||
var links = getNodeLinks(node);
|
||||
if (!links.resolvedSignature) {
|
||||
links.resolvedSignature = anySignature;
|
||||
links.resolvedSignature = node.kind === SyntaxKind.CallExpression ? resolveCallExpression(node) : resolveNewExpression(node);
|
||||
}
|
||||
return links.resolvedSignature;
|
||||
}
|
||||
|
||||
function checkCallExpression(node: CallExpression): Type {
|
||||
var signature = getResolvedSignature(node);
|
||||
if (node.func.kind === SyntaxKind.SuperKeyword) {
|
||||
return voidType;
|
||||
}
|
||||
if (node.kind === SyntaxKind.NewExpression) {
|
||||
var declaration = signature.declaration;
|
||||
if (declaration && (declaration.kind !== SyntaxKind.Constructor && declaration.kind !== SyntaxKind.ConstructSignature)) {
|
||||
// When resolved signature is a call signature (and not a construct signature) the result type is any
|
||||
if (program.getCompilerOptions().noImplicitAny) {
|
||||
error(node, Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type);
|
||||
}
|
||||
return anyType;
|
||||
}
|
||||
}
|
||||
return getReturnTypeOfSignature(signature);
|
||||
}
|
||||
|
||||
function checkTypeAssertion(node: TypeAssertion): Type {
|
||||
var exprType = checkExpression(node.operand);
|
||||
var targetType = getTypeFromTypeNode(node.type);
|
||||
if (targetType === unknownType) return unknownType;
|
||||
var exprType = checkExpression(node.operand, targetType);
|
||||
var widenedType = getWidenedType(exprType);
|
||||
if (!(isTypeAssignableTo(exprType, targetType) || isTypeAssignableTo(targetType, widenedType))) {
|
||||
checkTypeAssignableTo(targetType, widenedType, node, Diagnostics.Neither_type_0_nor_type_1_is_assignable_to_the_other_Colon, Diagnostics.Neither_type_0_nor_type_1_is_assignable_to_the_other);
|
||||
}
|
||||
return targetType;
|
||||
}
|
||||
|
||||
function getContextualSignature(contextualType: Type) {
|
||||
if (contextualType) {
|
||||
var signatures = getSignaturesOfType(contextualType, SignatureKind.Call);
|
||||
if (signatures.length === 1) {
|
||||
var signature = signatures[0];
|
||||
if (!signature.typeParameters) {
|
||||
return signature;
|
||||
}
|
||||
if (targetType !== unknownType) {
|
||||
var widenedType = getWidenedType(exprType);
|
||||
if (!(isTypeAssignableTo(exprType, targetType) || isTypeAssignableTo(targetType, widenedType))) {
|
||||
checkTypeAssignableTo(targetType, widenedType, node, Diagnostics.Neither_type_0_nor_type_1_is_assignable_to_the_other_Colon, Diagnostics.Neither_type_0_nor_type_1_is_assignable_to_the_other);
|
||||
}
|
||||
}
|
||||
return targetType;
|
||||
}
|
||||
|
||||
function getTypeAtPosition(signature: Signature, pos: number): Type {
|
||||
@@ -4011,9 +4131,9 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
function getReturnTypeFromBody(func: FunctionDeclaration, contextualType?: Type, contextualMapper?: TypeMapper): Type {
|
||||
function getReturnTypeFromBody(func: FunctionDeclaration, contextualMapper?: TypeMapper): Type {
|
||||
if (func.body.kind !== SyntaxKind.FunctionBlock) {
|
||||
var unwidenedType = checkAndMarkExpression(func.body, contextualType, contextualMapper);
|
||||
var unwidenedType = checkAndMarkExpression(func.body, contextualMapper);
|
||||
var widenedType = getWidenedType(unwidenedType);
|
||||
|
||||
if (program.getCompilerOptions().noImplicitAny && widenedType !== unwidenedType && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) {
|
||||
@@ -4024,7 +4144,7 @@ module ts {
|
||||
}
|
||||
|
||||
// Aggregate the types of expressions within all the return statements.
|
||||
var types = checkAndAggregateReturnExpressionTypes(<Block>func.body, contextualType, contextualMapper);
|
||||
var types = checkAndAggregateReturnExpressionTypes(<Block>func.body, contextualMapper);
|
||||
|
||||
// Try to return the best common type if we have any return expressions.
|
||||
if (types.length > 0) {
|
||||
@@ -4087,13 +4207,13 @@ module ts {
|
||||
}
|
||||
|
||||
/// Returns a set of types relating to every return expression relating to a function block.
|
||||
function checkAndAggregateReturnExpressionTypes(body: Block, contextualType?: Type, contextualMapper?: TypeMapper): Type[] {
|
||||
function checkAndAggregateReturnExpressionTypes(body: Block, contextualMapper?: TypeMapper): Type[] {
|
||||
var aggregatedTypes: Type[] = [];
|
||||
|
||||
forEachReturnStatement(body, returnStatement => {
|
||||
var expr = returnStatement.expression;
|
||||
if (expr) {
|
||||
var type = checkAndMarkExpression(expr, contextualType, contextualMapper);
|
||||
var type = checkAndMarkExpression(expr, contextualMapper);
|
||||
if (!contains(aggregatedTypes, type)) {
|
||||
aggregatedTypes.push(type);
|
||||
}
|
||||
@@ -4146,42 +4266,48 @@ module ts {
|
||||
error(func.type, Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement);
|
||||
}
|
||||
|
||||
function checkFunctionExpression(node: FunctionExpression, contextualType?: Type, contextualMapper?: TypeMapper): Type {
|
||||
function checkFunctionExpression(node: FunctionExpression, contextualMapper?: TypeMapper): Type {
|
||||
// The identityMapper object is used to indicate that function expressions are wildcards
|
||||
if (contextualMapper === identityMapper) {
|
||||
return anyFunctionType;
|
||||
}
|
||||
|
||||
var type = getTypeOfSymbol(node.symbol);
|
||||
var links = getNodeLinks(node);
|
||||
|
||||
if (!(links.flags & NodeCheckFlags.TypeChecked)) {
|
||||
var signature = getSignaturesOfType(type, SignatureKind.Call)[0];
|
||||
var contextualSignature = getContextualSignature(contextualType);
|
||||
if (contextualSignature) {
|
||||
if (!node.typeParameters && !forEach(node.parameters, p => p.type)) {
|
||||
assignContextualParameterTypes(signature, contextualSignature, contextualMapper || identityMapper);
|
||||
}
|
||||
if (!node.type) {
|
||||
signature.resolvedReturnType = resolvingType;
|
||||
var returnType = getReturnTypeFromBody(node, getReturnTypeOfSignature(contextualSignature), contextualMapper);
|
||||
if (signature.resolvedReturnType === resolvingType) {
|
||||
signature.resolvedReturnType = returnType;
|
||||
var type = getTypeOfSymbol(node.symbol);
|
||||
// Check if function expression is contextually typed and assign parameter types if so
|
||||
if (!(links.flags & NodeCheckFlags.ContextChecked)) {
|
||||
var contextualSignature = getContextualSignature(node);
|
||||
// If a type check is started at a function expression that is an argument of a function call, obtaining the
|
||||
// contextual type may recursively get back to here during overload resolution of the call. If so, we will have
|
||||
// already assigned contextual types.
|
||||
if (!(links.flags & NodeCheckFlags.ContextChecked)) {
|
||||
links.flags |= NodeCheckFlags.ContextChecked;
|
||||
if (contextualSignature) {
|
||||
var signature = getSignaturesOfType(type, SignatureKind.Call)[0];
|
||||
if (isContextSensitiveExpression(node)) {
|
||||
assignContextualParameterTypes(signature, contextualSignature, contextualMapper || identityMapper);
|
||||
}
|
||||
if (!node.type) {
|
||||
signature.resolvedReturnType = resolvingType;
|
||||
var returnType = getReturnTypeFromBody(node, contextualMapper);
|
||||
if (signature.resolvedReturnType === resolvingType) {
|
||||
signature.resolvedReturnType = returnType;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNode(node.type));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (fullTypeCheck && !(links.flags & NodeCheckFlags.TypeChecked)) {
|
||||
checkSignatureDeclaration(node);
|
||||
if (node.type) {
|
||||
checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNode(node.type));
|
||||
}
|
||||
if (node.body.kind === SyntaxKind.FunctionBlock) {
|
||||
checkSourceElement(node.body);
|
||||
}
|
||||
else {
|
||||
var returnType = getReturnTypeOfSignature(signature);
|
||||
var exprType = checkExpression(node.body);
|
||||
if (node.type) {
|
||||
// Use default error messages for this check
|
||||
checkTypeAssignableTo(checkExpression(node.body, returnType), returnType, node.body, /*chainedMessage*/ undefined, /*terminalMessage*/ undefined);
|
||||
checkTypeAssignableTo(exprType, getTypeFromTypeNode(node.type), node.body, undefined, undefined);
|
||||
}
|
||||
}
|
||||
links.flags |= NodeCheckFlags.TypeChecked;
|
||||
@@ -4311,13 +4437,10 @@ module ts {
|
||||
return booleanType;
|
||||
}
|
||||
|
||||
function checkBinaryExpression(node: BinaryExpression, contextualType?: Type, contextualMapper?: TypeMapper) {
|
||||
function checkBinaryExpression(node: BinaryExpression, contextualMapper?: TypeMapper) {
|
||||
var operator = node.operator;
|
||||
var leftContextualType = operator === SyntaxKind.BarBarToken ? contextualType : undefined
|
||||
var leftType = checkExpression(node.left, leftContextualType, contextualMapper);
|
||||
var rightContextualType = operator >= SyntaxKind.FirstAssignment && operator <= SyntaxKind.LastAssignment ? leftType :
|
||||
operator === SyntaxKind.BarBarToken ? contextualType || leftType : undefined;
|
||||
var rightType = checkExpression(node.right, rightContextualType, contextualMapper);
|
||||
var leftType = checkExpression(node.left, contextualMapper);
|
||||
var rightType = checkExpression(node.right, contextualMapper);
|
||||
switch (operator) {
|
||||
case SyntaxKind.AsteriskToken:
|
||||
case SyntaxKind.AsteriskEqualsToken:
|
||||
@@ -4409,7 +4532,7 @@ module ts {
|
||||
case SyntaxKind.AmpersandAmpersandToken:
|
||||
return rightType;
|
||||
case SyntaxKind.BarBarToken:
|
||||
return getBestCommonType([leftType, rightType], isInferentialContext(contextualMapper) ? undefined : contextualType);
|
||||
return getBestCommonType([leftType, rightType], isInferentialContext(contextualMapper) ? undefined : getContextualType(node));
|
||||
case SyntaxKind.EqualsToken:
|
||||
checkAssignmentOperator(rightType);
|
||||
return rightType;
|
||||
@@ -4439,40 +4562,46 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
function checkConditionalExpression(node: ConditionalExpression, contextualType?: Type, contextualMapper?: TypeMapper): Type {
|
||||
function checkConditionalExpression(node: ConditionalExpression, contextualMapper?: TypeMapper): Type {
|
||||
checkExpression(node.condition);
|
||||
var type1 = checkExpression(node.whenTrue, contextualType, contextualMapper);
|
||||
var type2 = checkExpression(node.whenFalse, contextualType, contextualMapper);
|
||||
var resultType = getBestCommonType([type1, type2], isInferentialContext(contextualMapper) ? undefined : contextualType, true);
|
||||
var type1 = checkExpression(node.whenTrue, contextualMapper);
|
||||
var type2 = checkExpression(node.whenFalse, contextualMapper);
|
||||
var contextualType = isInferentialContext(contextualMapper) ? undefined : getContextualType(node);
|
||||
var resultType = getBestCommonType([type1, type2], contextualType, true);
|
||||
if (!resultType) {
|
||||
|
||||
if (contextualType && !isInferentialContext(contextualMapper)) {
|
||||
if (contextualType) {
|
||||
error(node, Diagnostics.No_best_common_type_exists_between_0_1_and_2, typeToString(contextualType), typeToString(type1), typeToString(type2));
|
||||
}
|
||||
else {
|
||||
error(node, Diagnostics.No_best_common_type_exists_between_0_and_1, typeToString(type1), typeToString(type2));
|
||||
}
|
||||
|
||||
resultType = emptyObjectType;
|
||||
}
|
||||
return resultType;
|
||||
}
|
||||
|
||||
function checkAndMarkExpression(node: Expression, contextualType?: Type, contextualMapper?: TypeMapper): Type {
|
||||
var result = checkExpression(node, contextualType, contextualMapper);
|
||||
function checkExpressionWithContextualType(node: Expression, contextualType: Type, contextualMapper?: TypeMapper): Type {
|
||||
var saveContextualType = node.contextualType;
|
||||
node.contextualType = contextualType;
|
||||
var result = checkExpression(node, contextualMapper);
|
||||
node.contextualType = saveContextualType;
|
||||
return result;
|
||||
}
|
||||
|
||||
function checkAndMarkExpression(node: Expression, contextualMapper?: TypeMapper): Type {
|
||||
var result = checkExpression(node, contextualMapper);
|
||||
getNodeLinks(node).flags |= NodeCheckFlags.TypeChecked;
|
||||
return result;
|
||||
}
|
||||
|
||||
// Checks an expression and returns its type. The contextualType parameter provides a contextual type for
|
||||
// the check or is undefined if there is no contextual type. The contextualMapper parameter serves two
|
||||
// purposes: When contextualMapper is not undefined and not equal to the identityMapper function object
|
||||
// it provides a type mapper to use during inferential typing (the contextual type is then a generic type).
|
||||
// When contextualMapper is equal to the identityMapper function object, it serves as an indicator that all
|
||||
// contained function and arrow expressions should be considered to have the wildcard function type; this
|
||||
// form of type check is used during overload resolution to exclude contextually typed function and arrow
|
||||
// expressions in the initial phase.
|
||||
function checkExpression(node: Expression, contextualType?: Type, contextualMapper?: TypeMapper): Type {
|
||||
// Checks an expression and returns its type. The contextualMapper parameter serves two purposes: When
|
||||
// contextualMapper is not undefined and not equal to the identityMapper function object it indicates that the
|
||||
// expression is being inferentially typed (section 4.12.2 in spec) and provides the type mapper to use in
|
||||
// conjuction with the generic contextual type. When contextualMapper is equal to the identityMapper function
|
||||
// object, it serves as an indicator that all contained function and arrow expressions should be considered to
|
||||
// have the wildcard function type; this form of type check is used during overload resolution to exclude
|
||||
// contextually typed function and arrow expressions in the initial phase.
|
||||
function checkExpression(node: Expression, contextualMapper?: TypeMapper): Type {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.Identifier:
|
||||
return checkIdentifier(<Identifier>node);
|
||||
@@ -4494,32 +4623,31 @@ module ts {
|
||||
case SyntaxKind.QualifiedName:
|
||||
return checkPropertyAccess(<QualifiedName>node);
|
||||
case SyntaxKind.ArrayLiteral:
|
||||
return checkArrayLiteral(<ArrayLiteral>node, contextualType, contextualMapper);
|
||||
return checkArrayLiteral(<ArrayLiteral>node, contextualMapper);
|
||||
case SyntaxKind.ObjectLiteral:
|
||||
return checkObjectLiteral(<ObjectLiteral>node, contextualType, contextualMapper);
|
||||
return checkObjectLiteral(<ObjectLiteral>node, contextualMapper);
|
||||
case SyntaxKind.PropertyAccess:
|
||||
return checkPropertyAccess(<PropertyAccess>node);
|
||||
case SyntaxKind.IndexedAccess:
|
||||
return checkIndexedAccess(<IndexedAccess>node);
|
||||
case SyntaxKind.CallExpression:
|
||||
return checkCallExpression(<CallExpression>node);
|
||||
case SyntaxKind.NewExpression:
|
||||
return checkNewExpression(<NewExpression>node);
|
||||
return checkCallExpression(<CallExpression>node);
|
||||
case SyntaxKind.TypeAssertion:
|
||||
return checkTypeAssertion(<TypeAssertion>node);
|
||||
case SyntaxKind.ParenExpression:
|
||||
return checkExpression((<ParenExpression>node).expression);
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.ArrowFunction:
|
||||
return checkFunctionExpression(<FunctionExpression>node, contextualType, contextualMapper);
|
||||
return checkFunctionExpression(<FunctionExpression>node, contextualMapper);
|
||||
case SyntaxKind.PrefixOperator:
|
||||
return checkPrefixExpression(<UnaryExpression>node);
|
||||
case SyntaxKind.PostfixOperator:
|
||||
return checkPostfixExpression(<UnaryExpression>node);
|
||||
case SyntaxKind.BinaryExpression:
|
||||
return checkBinaryExpression(<BinaryExpression>node, contextualType, contextualMapper);
|
||||
return checkBinaryExpression(<BinaryExpression>node, contextualMapper);
|
||||
case SyntaxKind.ConditionalExpression:
|
||||
return checkConditionalExpression(<ConditionalExpression>node, contextualType, contextualMapper);
|
||||
return checkConditionalExpression(<ConditionalExpression>node, contextualMapper);
|
||||
}
|
||||
return unknownType;
|
||||
}
|
||||
@@ -5324,7 +5452,7 @@ module ts {
|
||||
if (node.initializer) {
|
||||
if (!(getNodeLinks(node.initializer).flags & NodeCheckFlags.TypeChecked)) {
|
||||
// Use default messages
|
||||
checkTypeAssignableTo(checkAndMarkExpression(node.initializer, type), type, node, /*chainedMessage*/ undefined, /*terminalMessage*/ undefined);
|
||||
checkTypeAssignableTo(checkAndMarkExpression(node.initializer), type, node, /*chainedMessage*/ undefined, /*terminalMessage*/ undefined);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5445,12 +5573,12 @@ module ts {
|
||||
func.type ||
|
||||
(func.kind === SyntaxKind.GetAccessor && getSetAccessorTypeAnnotationNode(<AccessorDeclaration>getDeclarationOfKind(func.symbol, SyntaxKind.SetAccessor)));
|
||||
if (checkAssignability) {
|
||||
checkTypeAssignableTo(checkExpression(node.expression, returnType), returnType, node.expression, /*chainedMessage*/ undefined, /*terminalMessage*/ undefined);
|
||||
checkTypeAssignableTo(checkExpression(node.expression), returnType, node.expression, /*chainedMessage*/ undefined, /*terminalMessage*/ undefined);
|
||||
}
|
||||
else if (func.kind == SyntaxKind.Constructor) {
|
||||
// constructor doesn't have explicit return type annontation and yet its return type is known - declaring type
|
||||
// handle constructors and issue specialized error message for them.
|
||||
if (!isTypeAssignableTo(checkExpression(node.expression, returnType), returnType)) {
|
||||
if (!isTypeAssignableTo(checkExpression(node.expression), returnType)) {
|
||||
error(node.expression, Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class);
|
||||
}
|
||||
}
|
||||
@@ -6047,9 +6175,12 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
// Fully type check a source file and collect the relevant diagnostics. The fullTypeCheck flag is true during this
|
||||
// operation, but otherwise is false when the compiler is used by the language service.
|
||||
function checkSourceFile(node: SourceFile) {
|
||||
var links = getNodeLinks(node);
|
||||
if (!(links.flags & NodeCheckFlags.TypeChecked)) {
|
||||
fullTypeCheck = true;
|
||||
emitExtends = false;
|
||||
potentialThisCollisions.length = 0;
|
||||
forEach(node.statements, checkSourceElement);
|
||||
@@ -6066,6 +6197,7 @@ module ts {
|
||||
}
|
||||
if (emitExtends) links.flags |= NodeCheckFlags.EmitExtends;
|
||||
links.flags |= NodeCheckFlags.TypeChecked;
|
||||
fullTypeCheck = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,9 +11,10 @@ module ts {
|
||||
"o": "out",
|
||||
"t": "target",
|
||||
"v": "version",
|
||||
"w": "watch",
|
||||
};
|
||||
|
||||
var options: CommandLineOption[] = [
|
||||
var optionDeclarations: CommandLineOption[] = [
|
||||
{ name: "charset", type: "string" },
|
||||
{ name: "codepage", type: "number" },
|
||||
{ name: "declaration", type: "boolean" },
|
||||
@@ -32,14 +33,15 @@ module ts {
|
||||
{ name: "sourceMap", type: "boolean" },
|
||||
{ name: "sourceRoot", type: "string" },
|
||||
{ name: "target", type: { "es3": ScriptTarget.ES3, "es5": ScriptTarget.ES5 }, error: Diagnostics.Argument_for_target_option_must_be_es3_or_es5 },
|
||||
{ name: "version", type: "boolean" }
|
||||
{ name: "version", type: "boolean" },
|
||||
{ name: "watch", type: "boolean" }
|
||||
];
|
||||
|
||||
// Map command line switches to compiler options' property descriptors. Keys must be lower case spellings of command line switches.
|
||||
// The 'name' property specifies the property name in the CompilerOptions type. The 'type' property specifies the type of the option.
|
||||
var optionDeclarations: Map<CommandLineOption> = {};
|
||||
forEach(options, option => {
|
||||
optionDeclarations[option.name.toLowerCase()] = option;
|
||||
var optionMap: Map<CommandLineOption> = {};
|
||||
forEach(optionDeclarations, option => {
|
||||
optionMap[option.name.toLowerCase()] = option;
|
||||
});
|
||||
|
||||
export function parseCommandLine(commandLine: string[]): ParsedCommandLine {
|
||||
@@ -73,8 +75,8 @@ module ts {
|
||||
s = shortOptionNames[s];
|
||||
}
|
||||
|
||||
if (hasProperty(optionDeclarations, s)) {
|
||||
var opt = optionDeclarations[s];
|
||||
if (hasProperty(optionMap, s)) {
|
||||
var opt = optionMap[s];
|
||||
|
||||
// Check to see if no argument was provided (e.g. "--locale" is the last command-line argument).
|
||||
if (!args[i] && opt.type !== "boolean") {
|
||||
|
||||
@@ -114,7 +114,11 @@ module ts {
|
||||
}
|
||||
|
||||
export function isEmpty<T>(map: Map<T>) {
|
||||
for (var id in map) return false;
|
||||
for (var id in map) {
|
||||
if (hasProperty(map, id)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -209,6 +209,7 @@ module ts {
|
||||
Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property: { code: 4019, category: DiagnosticCategory.NoPrefix, key: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member property." },
|
||||
In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enum_element: { code: 4024, category: DiagnosticCategory.Error, key: "In an enum with multiple declarations, only one declaration can omit an initializer for its first enum element." },
|
||||
Named_properties_0_of_types_1_and_2_are_not_identical: { code: 4032, category: DiagnosticCategory.NoPrefix, key: "Named properties '{0}' of types '{1}' and '{2}' are not identical." },
|
||||
The_current_host_does_not_support_the_0_option: { code: 5001, category: DiagnosticCategory.Error, key: "The current host does not support the '{0}' option." },
|
||||
Cannot_find_the_common_subdirectory_path_for_the_input_files: { code: 5009, category: DiagnosticCategory.Error, key: "Cannot find the common subdirectory path for the input files." },
|
||||
Cannot_read_file_0_Colon_1: { code: 5012, category: DiagnosticCategory.Error, key: "Cannot read file '{0}': {1}" },
|
||||
Unsupported_file_encoding: { code: 5013, category: DiagnosticCategory.NoPrefix, key: "Unsupported file encoding." },
|
||||
@@ -216,6 +217,8 @@ module ts {
|
||||
Option_mapRoot_cannot_be_specified_without_specifying_sourcemap_option: { code: 5038, category: DiagnosticCategory.Error, key: "Option mapRoot cannot be specified without specifying sourcemap option." },
|
||||
Option_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option: { code: 5039, category: DiagnosticCategory.Error, key: "Option sourceRoot cannot be specified without specifying sourcemap option." },
|
||||
Version_0: { code: 6029, category: DiagnosticCategory.Message, key: "Version {0}" },
|
||||
File_change_detected_Compiling: { code: 6032, category: DiagnosticCategory.Message, key: "File change detected. Compiling..." },
|
||||
Compilation_complete_Watching_for_file_changes: { code: 6042, category: DiagnosticCategory.Message, key: "Compilation complete. Watching for file changes." },
|
||||
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." },
|
||||
|
||||
@@ -830,6 +830,10 @@
|
||||
"category": "NoPrefix",
|
||||
"code": 4032
|
||||
},
|
||||
"The current host does not support the '{0}' option.": {
|
||||
"category": "Error",
|
||||
"code": 5001
|
||||
},
|
||||
"Cannot find the common subdirectory path for the input files.": {
|
||||
"category": "Error",
|
||||
"code": 5009
|
||||
@@ -854,12 +858,18 @@
|
||||
"category": "Error",
|
||||
"code": 5039
|
||||
},
|
||||
|
||||
"Version {0}": {
|
||||
"category": "Message",
|
||||
"code": 6029
|
||||
},
|
||||
|
||||
},
|
||||
"File change detected. Compiling...": {
|
||||
"category": "Message",
|
||||
"code": 6032
|
||||
},
|
||||
"Compilation complete. Watching for file changes.": {
|
||||
"category": "Message",
|
||||
"code": 6042
|
||||
},
|
||||
"Variable '{0}' implicitly has an '{1}' type.": {
|
||||
"category": "Error",
|
||||
"code": 7005
|
||||
|
||||
@@ -1371,6 +1371,7 @@ module ts {
|
||||
write(" {");
|
||||
scopeEmitStart(node, "constructor");
|
||||
increaseIndent();
|
||||
emitCaptureThisForNodeIfNecessary(node);
|
||||
if (ctor) {
|
||||
emitDefaultValueAssignments(ctor);
|
||||
emitRestParameter(ctor);
|
||||
@@ -1390,8 +1391,7 @@ module ts {
|
||||
write("_super.apply(this, arguments);");
|
||||
emitEnd(node.baseType);
|
||||
}
|
||||
}
|
||||
emitCaptureThisForNodeIfNecessary(node);
|
||||
}
|
||||
emitMemberAssignments(node, /*nonstatic*/0);
|
||||
if (ctor) {
|
||||
var statements: Node[] = (<Block>ctor.body).statements;
|
||||
|
||||
+16
-6
@@ -417,7 +417,7 @@ module ts {
|
||||
nodeIsNestedInLabel(label: Identifier, requireIterationStatement: boolean, stopAtFunctionBoundary: boolean): ControlBlockContext;
|
||||
}
|
||||
|
||||
export function createSourceFile(filename: string, sourceText: string, languageVersion: ScriptTarget): SourceFile {
|
||||
export function createSourceFile(filename: string, sourceText: string, languageVersion: ScriptTarget, byteOrderMark: ByteOrderMark, version: number = 0, isOpen: boolean = false): SourceFile {
|
||||
var file: SourceFile;
|
||||
var scanner: Scanner;
|
||||
var token: SyntaxKind;
|
||||
@@ -3523,11 +3523,14 @@ module ts {
|
||||
file.externalModuleIndicator = getExternalModuleIndicator();
|
||||
file.nodeCount = nodeCount;
|
||||
file.identifierCount = identifierCount;
|
||||
file.version = version;
|
||||
file.byteOrderMark = byteOrderMark;
|
||||
file.isOpen = isOpen;
|
||||
file.languageVersion = languageVersion;
|
||||
return file;
|
||||
}
|
||||
|
||||
export function createProgram(rootNames: string[], options: CompilerOptions, host: CompilerHost): Program {
|
||||
|
||||
var program: Program;
|
||||
var files: SourceFile[] = [];
|
||||
var filesByName: Map<SourceFile> = {};
|
||||
@@ -3536,7 +3539,9 @@ module ts {
|
||||
var commonSourceDirectory: string;
|
||||
|
||||
forEach(rootNames, name => processRootFile(name, false));
|
||||
if (!seenNoDefaultLib) processRootFile(host.getDefaultLibFilename(), true);
|
||||
if (!seenNoDefaultLib) {
|
||||
processRootFile(host.getDefaultLibFilename(), true);
|
||||
}
|
||||
verifyCompilerOptions();
|
||||
errors.sort(compareDiagnostics);
|
||||
program = {
|
||||
@@ -3627,7 +3632,7 @@ module ts {
|
||||
|
||||
function processReferencedFiles(file: SourceFile, basePath: string) {
|
||||
forEach(file.referencedFiles, ref => {
|
||||
processSourceFile(normalizePath(combinePaths(basePath, ref.filename)), false, file, ref.pos, ref.end);
|
||||
processSourceFile(normalizePath(combinePaths(basePath, ref.filename)), /* isDefaultLib */ false, file, ref.pos, ref.end);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -3640,9 +3645,14 @@ module ts {
|
||||
var searchPath = basePath;
|
||||
while (true) {
|
||||
var searchName = normalizePath(combinePaths(searchPath, moduleName));
|
||||
if (findModuleSourceFile(searchName + ".ts", nameLiteral) || findModuleSourceFile(searchName + ".d.ts", nameLiteral)) break;
|
||||
if (findModuleSourceFile(searchName + ".ts", nameLiteral) || findModuleSourceFile(searchName + ".d.ts", nameLiteral)) {
|
||||
break;
|
||||
}
|
||||
|
||||
var parentPath = getDirectoryPath(searchPath);
|
||||
if (parentPath === searchPath) break;
|
||||
if (parentPath === searchPath) {
|
||||
break;
|
||||
}
|
||||
searchPath = parentPath;
|
||||
}
|
||||
}
|
||||
|
||||
+21
-1
@@ -5,9 +5,9 @@ interface System {
|
||||
newLine: string;
|
||||
useCaseSensitiveFileNames: boolean;
|
||||
write(s: string): void;
|
||||
writeErr(s: string): void;
|
||||
readFile(fileName: string, encoding?: string): string;
|
||||
writeFile(fileName: string, data: string): void;
|
||||
watchFile?(fileName: string, callback: (fileName: string) => void): FileWatcher;
|
||||
resolvePath(path: string): string;
|
||||
fileExists(path: string): boolean;
|
||||
directoryExists(path: string): boolean;
|
||||
@@ -18,6 +18,10 @@ interface System {
|
||||
exit(exitCode?: number): void;
|
||||
}
|
||||
|
||||
interface FileWatcher {
|
||||
close(): void;
|
||||
}
|
||||
|
||||
declare var require: any;
|
||||
declare var module: any;
|
||||
declare var process: any;
|
||||
@@ -187,6 +191,22 @@ var sys: System = (function () {
|
||||
},
|
||||
readFile: readFile,
|
||||
writeFile: writeFile,
|
||||
watchFile: (fileName, callback) => {
|
||||
// watchFile polls a file every 250ms, picking up file notifications.
|
||||
_fs.watchFile(fileName, { persistent: true, interval: 250 }, fileChanged);
|
||||
|
||||
return {
|
||||
close() { _fs.unwatchFile(fileName, fileChanged); }
|
||||
};
|
||||
|
||||
function fileChanged(curr: any, prev: any) {
|
||||
if (+curr.mtime <= +prev.mtime) {
|
||||
return;
|
||||
}
|
||||
|
||||
callback(fileName);
|
||||
};
|
||||
},
|
||||
resolvePath: function (path: string): string {
|
||||
return _path.resolve(path);
|
||||
},
|
||||
|
||||
+124
-22
@@ -81,10 +81,10 @@ module ts {
|
||||
function reportDiagnostic(error: Diagnostic) {
|
||||
if (error.file) {
|
||||
var loc = error.file.getLineAndCharacterFromPosition(error.start);
|
||||
sys.writeErr(error.file.filename + "(" + loc.line + "," + loc.character + "): " + error.messageText + sys.newLine);
|
||||
sys.write(error.file.filename + "(" + loc.line + "," + loc.character + "): " + error.messageText + sys.newLine);
|
||||
}
|
||||
else {
|
||||
sys.writeErr(error.messageText + sys.newLine);
|
||||
sys.write(error.messageText + sys.newLine);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ module ts {
|
||||
}
|
||||
|
||||
function reportStatisticalValue(name: string, value: string) {
|
||||
sys.writeErr(padRight(name + ":", 12) + padLeft(value.toString(), 10) + sys.newLine);
|
||||
sys.write(padRight(name + ":", 12) + padLeft(value.toString(), 10) + sys.newLine);
|
||||
}
|
||||
|
||||
function reportCountStatistic(name: string, count: number) {
|
||||
@@ -135,7 +135,7 @@ module ts {
|
||||
}
|
||||
text = "";
|
||||
}
|
||||
return text !== undefined ? createSourceFile(filename, text, languageVersion) : undefined;
|
||||
return text !== undefined ? createSourceFile(filename, text, languageVersion, ByteOrderMark.None) : undefined;
|
||||
}
|
||||
|
||||
function writeFile(fileName: string, data: string, onError?: (message: string) => void) {
|
||||
@@ -179,33 +179,133 @@ module ts {
|
||||
};
|
||||
}
|
||||
|
||||
export function executeCommandLine(args: string[]): number {
|
||||
var cmds = parseCommandLine(args);
|
||||
export function executeCommandLine(args: string[]): void {
|
||||
var commandLine = parseCommandLine(args);
|
||||
|
||||
if (cmds.options.locale) {
|
||||
validateLocaleAndSetLanguage(cmds.options.locale, cmds.errors);
|
||||
if (commandLine.options.locale) {
|
||||
validateLocaleAndSetLanguage(commandLine.options.locale, commandLine.errors);
|
||||
}
|
||||
|
||||
if (cmds.filenames.length === 0 && !(cmds.options.help || cmds.options.version)) {
|
||||
cmds.errors.push(createCompilerDiagnostic(Diagnostics.No_input_files_specified));
|
||||
}
|
||||
|
||||
if (cmds.options.version) {
|
||||
if (commandLine.options.version) {
|
||||
reportDiagnostic(createCompilerDiagnostic(Diagnostics.Version_0, version));
|
||||
return 0;
|
||||
sys.exit(0);
|
||||
}
|
||||
|
||||
if (cmds.filenames.length === 0 || cmds.options.help) {
|
||||
if (commandLine.options.help) {
|
||||
// TODO (drosen): Usage.
|
||||
sys.exit(0);
|
||||
}
|
||||
|
||||
if (cmds.errors.length) {
|
||||
reportDiagnostics(cmds.errors);
|
||||
return 1;
|
||||
if (commandLine.filenames.length === 0) {
|
||||
commandLine.errors.push(createCompilerDiagnostic(Diagnostics.No_input_files_specified));
|
||||
}
|
||||
|
||||
if (commandLine.errors.length) {
|
||||
reportDiagnostics(commandLine.errors);
|
||||
sys.exit(1);
|
||||
}
|
||||
|
||||
var defaultCompilerHost = createCompilerHost(commandLine.options);
|
||||
|
||||
if (commandLine.options.watch) {
|
||||
if (!sys.watchFile) {
|
||||
reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--watch"));
|
||||
sys.exit(1);
|
||||
}
|
||||
|
||||
watchProgram(commandLine, defaultCompilerHost);
|
||||
}
|
||||
else {
|
||||
sys.exit(compile(commandLine, defaultCompilerHost).errors.length > 0 ? 1 : 0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Compiles the program once, and then watches all given and referenced files for changes.
|
||||
* Upon detecting a file change, watchProgram will queue up file modification events for the next
|
||||
* 250ms and then perform a recompilation. The reasoning is that in some cases, an editor can
|
||||
* save all files at once, and we'd like to just perform a single recompilation.
|
||||
*/
|
||||
function watchProgram(commandLine: ParsedCommandLine, compilerHost: CompilerHost): void {
|
||||
var watchers: Map<FileWatcher> = {};
|
||||
var updatedFiles: Map<boolean> = {};
|
||||
|
||||
// Compile the program the first time and watch all given/referenced files.
|
||||
var program = compile(commandLine, compilerHost).program;
|
||||
reportDiagnostic(createCompilerDiagnostic(Diagnostics.Compilation_complete_Watching_for_file_changes));
|
||||
addWatchers(program);
|
||||
return;
|
||||
|
||||
function addWatchers(program: Program) {
|
||||
forEach(program.getSourceFiles(), f => {
|
||||
var filename = f.filename;
|
||||
watchers[filename] = sys.watchFile(filename, fileUpdated);
|
||||
});
|
||||
}
|
||||
|
||||
function removeWatchers(program: Program) {
|
||||
forEach(program.getSourceFiles(), f => {
|
||||
var filename = f.filename;
|
||||
if (hasProperty(watchers, filename)) {
|
||||
watchers[filename].close();
|
||||
}
|
||||
});
|
||||
|
||||
watchers = {};
|
||||
}
|
||||
|
||||
// Fired off whenever a file is changed.
|
||||
function fileUpdated(filename: string) {
|
||||
var firstNotification = isEmpty(updatedFiles);
|
||||
|
||||
updatedFiles[filename] = true;
|
||||
|
||||
// Only start this off when the first file change comes in,
|
||||
// so that we can batch up all further changes.
|
||||
if (firstNotification) {
|
||||
setTimeout(() => {
|
||||
var changedFiles = updatedFiles;
|
||||
updatedFiles = {};
|
||||
|
||||
recompile(changedFiles);
|
||||
}, 250);
|
||||
}
|
||||
}
|
||||
|
||||
function recompile(changedFiles: Map<boolean>) {
|
||||
reportDiagnostic(createCompilerDiagnostic(Diagnostics.File_change_detected_Compiling));
|
||||
// Remove all the watchers, as we may not be watching every file
|
||||
// specified since the last compilation cycle.
|
||||
removeWatchers(program);
|
||||
|
||||
// Gets us syntactically correct files from the last compilation.
|
||||
var getUnmodifiedSourceFile = program.getSourceFile;
|
||||
|
||||
// We create a new compiler host for this compilation cycle.
|
||||
// This new host is effectively the same except that 'getSourceFile'
|
||||
// will try to reuse the SourceFiles from the last compilation cycle
|
||||
// so long as they were not modified.
|
||||
var newCompilerHost = clone(compilerHost);
|
||||
newCompilerHost.getSourceFile = (fileName, languageVersion, onError) => {
|
||||
if (!hasProperty(changedFiles, fileName)) {
|
||||
var sourceFile = getUnmodifiedSourceFile(fileName);
|
||||
if (sourceFile) {
|
||||
return sourceFile;
|
||||
}
|
||||
}
|
||||
|
||||
return compilerHost.getSourceFile(fileName, languageVersion, onError);
|
||||
};
|
||||
|
||||
program = compile(commandLine, newCompilerHost).program;
|
||||
reportDiagnostic(createCompilerDiagnostic(Diagnostics.Compilation_complete_Watching_for_file_changes));
|
||||
addWatchers(program);
|
||||
}
|
||||
}
|
||||
|
||||
function compile(commandLine: ParsedCommandLine, compilerHost: CompilerHost) {
|
||||
var parseStart = new Date().getTime();
|
||||
var program = createProgram(cmds.filenames, cmds.options, createCompilerHost(cmds.options));
|
||||
var program = createProgram(commandLine.filenames, commandLine.options, compilerHost);
|
||||
var bindStart = new Date().getTime();
|
||||
var errors = program.getDiagnostics();
|
||||
if (errors.length) {
|
||||
@@ -224,7 +324,7 @@ module ts {
|
||||
}
|
||||
|
||||
reportDiagnostics(errors);
|
||||
if (cmds.options.diagnostics) {
|
||||
if (commandLine.options.diagnostics) {
|
||||
reportCountStatistic("Files", program.getSourceFiles().length);
|
||||
reportCountStatistic("Lines", countLines(program));
|
||||
reportCountStatistic("Nodes", checker ? checker.getNodeCount() : 0);
|
||||
@@ -237,8 +337,10 @@ module ts {
|
||||
reportTimeStatistic("Emit time", reportStart - emitStart);
|
||||
reportTimeStatistic("Total time", reportStart - parseStart);
|
||||
}
|
||||
return errors.length ? 1 : 0;
|
||||
|
||||
return { program: program, errors: errors };
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
sys.exit(ts.executeCommandLine(sys.args));
|
||||
ts.executeCommandLine(sys.args);
|
||||
|
||||
+17
-9
@@ -320,7 +320,9 @@ module ts {
|
||||
text: string;
|
||||
}
|
||||
|
||||
export interface Expression extends Node { }
|
||||
export interface Expression extends Node {
|
||||
contextualType?: Type; // Used to temporarily assign a contextual type during overload resolution
|
||||
}
|
||||
|
||||
export interface UnaryExpression extends Expression {
|
||||
operator: SyntaxKind;
|
||||
@@ -523,6 +525,10 @@ module ts {
|
||||
nodeCount: number;
|
||||
identifierCount: number;
|
||||
symbolCount: number;
|
||||
byteOrderMark: ByteOrderMark;
|
||||
isOpen: boolean;
|
||||
version: number;
|
||||
languageVersion: ScriptTarget;
|
||||
}
|
||||
|
||||
export interface Program {
|
||||
@@ -718,7 +724,6 @@ module ts {
|
||||
members?: SymbolTable; // Class, interface or literal instance members
|
||||
exports?: SymbolTable; // Module exports
|
||||
exportSymbol?: Symbol; // Exported symbol associated with this symbol
|
||||
exportAssignSymbol?: Symbol; // Symbol exported from external module
|
||||
valueDeclaration?: Declaration // First value declaration of the symbol
|
||||
}
|
||||
|
||||
@@ -728,6 +733,7 @@ module ts {
|
||||
declaredType?: Type; // Type of class, interface, enum, or type parameter
|
||||
mapper?: TypeMapper; // Type mapper for instantiation alias
|
||||
referenced?: boolean; // True if alias symbol has been referenced as a value
|
||||
exportAssignSymbol?: Symbol; // Symbol exported from external module
|
||||
}
|
||||
|
||||
export interface TransientSymbol extends Symbol, SymbolLinks { }
|
||||
@@ -737,17 +743,18 @@ module ts {
|
||||
}
|
||||
|
||||
export enum NodeCheckFlags {
|
||||
TypeChecked = 0x00000001, // Node has been type checked
|
||||
LexicalThis = 0x00000002, // Lexical 'this' reference
|
||||
CaptureThis = 0x00000004, // Lexical 'this' used in body
|
||||
EmitExtends = 0x00000008, // Emit __extends
|
||||
SuperInstance = 0x00000010, // Instance 'super' reference
|
||||
SuperStatic = 0x00000020, // Static 'super' reference
|
||||
TypeChecked = 0x00000001, // Node has been type checked
|
||||
LexicalThis = 0x00000002, // Lexical 'this' reference
|
||||
CaptureThis = 0x00000004, // Lexical 'this' used in body
|
||||
EmitExtends = 0x00000008, // Emit __extends
|
||||
SuperInstance = 0x00000010, // Instance 'super' reference
|
||||
SuperStatic = 0x00000020, // Static 'super' reference
|
||||
ContextChecked = 0x00000040, // Contextual types have been assigned
|
||||
}
|
||||
|
||||
export interface NodeLinks {
|
||||
resolvedType?: Type; // Cached type of type node
|
||||
resolvedSignature?: Signature; // Cached signature of signature node
|
||||
resolvedSignature?: Signature; // Cached signature of signature node or call expression
|
||||
resolvedSymbol?: Symbol; // Cached name resolution result
|
||||
flags?: NodeCheckFlags; // Set of flags specific to Node
|
||||
enumMemberValue?: number; // Constant value of enum member
|
||||
@@ -933,6 +940,7 @@ module ts {
|
||||
sourceRoot?: string;
|
||||
target?: ScriptTarget;
|
||||
version?: boolean;
|
||||
watch?: boolean;
|
||||
|
||||
[option: string]: any;
|
||||
}
|
||||
|
||||
+31
-29
@@ -226,7 +226,8 @@ module FourSlash {
|
||||
});
|
||||
}
|
||||
|
||||
// NEWTODO: Re-implement commented-out section
|
||||
// NEWTODO: Re-implement commented-out section
|
||||
|
||||
//harnessCompiler.addInputFiles(inputFiles);
|
||||
//try {
|
||||
// var resolvedFiles = harnessCompiler.resolve();
|
||||
@@ -246,8 +247,15 @@ module FourSlash {
|
||||
// harnessCompiler.reset();
|
||||
//}
|
||||
|
||||
/// NEWTODO: For now do not resolve, just use the input files
inputFiles.forEach(file => {
if (!Harness.isLibraryFile(file.unitName)) {
this.languageServiceShimHost.addScript(file.unitName, file.content);
}
});
|
||||
this.languageServiceShimHost.addScript('lib.d.ts', Harness.Compiler.libTextMinimal);
|
||||
/// NEWTODO: For now do not resolve, just use the input files
|
||||
inputFiles.forEach(file => {
|
||||
if (!Harness.isLibraryFile(file.unitName)) {
|
||||
this.languageServiceShimHost.addScript(file.unitName, file.content);
|
||||
}
|
||||
});
|
||||
|
||||
this.languageServiceShimHost.addScript('lib.d.ts', Harness.Compiler.libTextMinimal);
|
||||
|
||||
|
||||
// Sneak into the language service and get its compiler so we can examine the syntax trees
|
||||
this.languageService = this.languageServiceShimHost.getLanguageService().languageService;
|
||||
@@ -1875,6 +1883,9 @@ module FourSlash {
|
||||
xmlData.push(xml);
|
||||
}
|
||||
|
||||
// Cache these between executions so we don't have to re-parse them for every test
|
||||
var fourslashSourceFile: ts.SourceFile = undefined;
|
||||
var libdtsSourceFile: ts.SourceFile = undefined;
|
||||
export function runFourSlashTestContent(content: string, fileName: string): TestXmlData {
|
||||
// Parse out the files and their metadata
|
||||
var testData = parseTestData(content, fileName);
|
||||
@@ -1882,34 +1893,27 @@ module FourSlash {
|
||||
currentTestState = new TestState(testData);
|
||||
|
||||
var result = '';
|
||||
var tsFn = 'tests/cases/fourslash/fourslash.ts';
|
||||
var fourslashFilename = 'fourslash.ts';
|
||||
var tsFn = 'tests/cases/fourslash/' + fourslashFilename;
|
||||
fourslashSourceFile = fourslashSourceFile || ts.createSourceFile(tsFn, Harness.IO.readFile(tsFn), ts.ScriptTarget.ES5, ts.ByteOrderMark.None, /*version*/ 0, /*isOpen*/ false);
|
||||
libdtsSourceFile = libdtsSourceFile || ts.createSourceFile('lib.d.ts', Harness.Compiler.libTextMinimal, ts.ScriptTarget.ES3, ts.ByteOrderMark.None, /*version*/ 0, /*isOpen*/ false);
|
||||
|
||||
fsOutput.reset();
|
||||
fsErrors.reset();
|
||||
var files: { [filename: string]: ts.SourceFile; } = {};
|
||||
files[fourslashFilename] = fourslashSourceFile;
|
||||
files[fileName] = ts.createSourceFile(fileName, content, ts.ScriptTarget.ES5, ts.ByteOrderMark.None, /*version*/ 0, /*isOpen*/ false);
|
||||
files['lib.d.ts'] = libdtsSourceFile;
|
||||
|
||||
var harnessCompiler = Harness.Compiler.getCompiler();
|
||||
harnessCompiler.reset();
|
||||
var host = Harness.Compiler.createCompilerHost(files, (fn, contents) => result = contents);
|
||||
var program = ts.createProgram([fileName, fourslashFilename], {}, host);
|
||||
var checker = ts.createTypeChecker(program);
|
||||
checker.checkProgram();
|
||||
|
||||
var filesToAdd = [
|
||||
{ unitName: tsFn, content: Harness.IO.readFile(tsFn) },
|
||||
{ unitName: fileName, content: Harness.IO.readFile(fileName) }
|
||||
];
|
||||
harnessCompiler.addInputFiles(filesToAdd);
|
||||
|
||||
var emitterIOHost: Harness.Compiler.IEmitterIOHost = {
|
||||
writeFile: (path: string, contents: string, writeByteOrderMark: boolean) => fsOutput.Write(contents),
|
||||
resolvePath: (s: string) => s
|
||||
var errs = checker.getDiagnostics(files[fileName]);
|
||||
if (errs.length > 0) {
|
||||
throw new Error('Error compiling ' + fileName + ': ' + errs.map(e => e.messageText).join('\r\n'));
|
||||
}
|
||||
|
||||
harnessCompiler.emitAll(emitterIOHost);
|
||||
fsOutput.Close();
|
||||
fsErrors.Close();
|
||||
|
||||
if (fsErrors.lines.length > 0) {
|
||||
throw new Error('Error compiling ' + fileName + ': ' + fsErrors.lines.join('\r\n'));
|
||||
}
|
||||
|
||||
result = fsOutput.lines.join('\r\n');
|
||||
checker.emitFiles();
|
||||
result = result || ''; // Might have an empty fourslash file
|
||||
|
||||
// Compile and execute the test
|
||||
try {
|
||||
@@ -1917,8 +1921,6 @@ module FourSlash {
|
||||
} catch (err) {
|
||||
// Debugging: FourSlash.currentTestState.printCurrentFileState();
|
||||
throw err;
|
||||
} finally {
|
||||
harnessCompiler.reset();
|
||||
}
|
||||
|
||||
var xmlData = currentTestState.getTestXmlData();
|
||||
|
||||
@@ -11,7 +11,7 @@ class FourslashRunner extends RunnerBase {
|
||||
|
||||
public initializeTests() {
|
||||
if (this.tests.length === 0) {
|
||||
this.tests = this.enumerateFiles(this.basePath);
|
||||
this.tests = this.enumerateFiles(this.basePath, /\.ts/i);
|
||||
}
|
||||
|
||||
describe("fourslash tests", () => {
|
||||
|
||||
@@ -544,7 +544,7 @@ module Harness {
|
||||
} else {
|
||||
var lib = 'lib.d.ts';
|
||||
if (fn.substr(fn.length - lib.length) === lib) {
|
||||
return filemap[fn] = ts.createSourceFile('lib.d.ts', libTextMinimal, languageVersion);
|
||||
return filemap[fn] = ts.createSourceFile('lib.d.ts', libTextMinimal, languageVersion, ts.ByteOrderMark.None);
|
||||
}
|
||||
// Don't throw here -- the compiler might be looking for a test that actually doesn't exist as part of the TC
|
||||
return null;
|
||||
@@ -720,7 +720,7 @@ module Harness {
|
||||
var filemap: { [name: string]: ts.SourceFile; } = {};
|
||||
var register = (file: { unitName: string; content: string; }) => {
|
||||
var filename = Path.switchToForwardSlashes(file.unitName);
|
||||
filemap[filename] = ts.createSourceFile(filename, file.content, options.target);
|
||||
filemap[filename] = ts.createSourceFile(filename, file.content, options.target, ts.ByteOrderMark.None);
|
||||
};
|
||||
inputFiles.forEach(register);
|
||||
otherFiles.forEach(register);
|
||||
|
||||
@@ -147,20 +147,19 @@ module Harness.LanguageService {
|
||||
scriptSnapshot: TypeScript.IScriptSnapshot,
|
||||
byteOrderMark: ts.ByteOrderMark,
|
||||
version: number,
|
||||
isOpen: boolean,
|
||||
referencedFiles: string[]= []): ts.Document {
|
||||
return ts.createDocument(compilationSettings, fileName, scriptSnapshot, byteOrderMark, version, isOpen, referencedFiles);
|
||||
isOpen: boolean): ts.SourceFile {
|
||||
return ts.createSourceFile(fileName, scriptSnapshot.getText(0, scriptSnapshot.getLength()), compilationSettings.target, byteOrderMark, version, isOpen);
|
||||
}
|
||||
|
||||
public updateDocument(
|
||||
document: ts.Document,
|
||||
document: ts.SourceFile,
|
||||
fileName: string,
|
||||
compilationSettings: ts.CompilerOptions,
|
||||
scriptSnapshot: TypeScript.IScriptSnapshot,
|
||||
version: number,
|
||||
isOpen: boolean,
|
||||
textChangeRange: TypeScript.TextChangeRange
|
||||
): ts.Document {
|
||||
): ts.SourceFile {
|
||||
return document.update(scriptSnapshot, version, isOpen, textChangeRange);
|
||||
}
|
||||
|
||||
|
||||
@@ -139,7 +139,7 @@ class ProjectRunner extends RunnerBase {
|
||||
function getSourceFile(filename: string, languageVersion: ts.ScriptTarget): ts.SourceFile {
|
||||
var sourceFile: ts.SourceFile = undefined;
|
||||
if (filename === 'lib.d.ts') {
|
||||
sourceFile = ts.createSourceFile('lib.d.ts', Harness.Compiler.libTextMinimal, languageVersion);
|
||||
sourceFile = ts.createSourceFile('lib.d.ts', Harness.Compiler.libTextMinimal, languageVersion, ts.ByteOrderMark.None);
|
||||
}
|
||||
else {
|
||||
assert.isTrue(!ts.filter(readInputFiles, sourceFile => sourceFile.filename == filename).length, "Compiler trying to read same file again: " + filename);
|
||||
@@ -154,7 +154,7 @@ class ProjectRunner extends RunnerBase {
|
||||
}
|
||||
|
||||
if (text !== undefined) {
|
||||
sourceFile = ts.createSourceFile(filename, text, languageVersion)
|
||||
sourceFile = ts.createSourceFile(filename, text, languageVersion, ts.ByteOrderMark.None);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ module RWC {
|
||||
catch (e) {
|
||||
// Leave fileContents undefined;
|
||||
}
|
||||
return ts.createSourceFile(fileName, fileContents, languageVersion);
|
||||
return ts.createSourceFile(fileName, fileContents, languageVersion, ts.ByteOrderMark.None);
|
||||
},
|
||||
getDefaultLibFilename: () => libPath,
|
||||
writeFile: (fn, contents) => emitterIOHost.writeFile(fn, contents, false),
|
||||
|
||||
Vendored
+26
-25
@@ -1865,6 +1865,32 @@ declare var Window: {
|
||||
new(): Window;
|
||||
}
|
||||
|
||||
interface FormData {
|
||||
append(name: any, value: any, blobName?: string): void;
|
||||
}
|
||||
declare var FormData: {
|
||||
prototype: FormData;
|
||||
new (form?: HTMLFormElement): FormData;
|
||||
}
|
||||
|
||||
interface SourceBuffer extends EventTarget {
|
||||
updating: boolean;
|
||||
appendWindowStart: number;
|
||||
appendWindowEnd: number;
|
||||
buffered: TimeRanges;
|
||||
timestampOffset: number;
|
||||
audioTracks: AudioTrackList;
|
||||
appendBuffer(data: ArrayBufferView): void;
|
||||
appendBuffer(data: ArrayBuffer): void;
|
||||
remove(start: number, end: number): void;
|
||||
abort(): void;
|
||||
appendStream(stream: MSStream, maxSize?: number): void;
|
||||
}
|
||||
declare var SourceBuffer: {
|
||||
prototype: SourceBuffer;
|
||||
new(): SourceBuffer;
|
||||
}
|
||||
|
||||
interface NavigatorID {
|
||||
appVersion: string;
|
||||
appName: string;
|
||||
@@ -10196,14 +10222,6 @@ declare var MSManipulationEvent: {
|
||||
MS_MANIPULATION_STATE_CANCELLED: number;
|
||||
}
|
||||
|
||||
interface FormData {
|
||||
append(name: any, value: any, blobName?: string): void;
|
||||
}
|
||||
declare var FormData: {
|
||||
prototype: FormData;
|
||||
new(): FormData;
|
||||
}
|
||||
|
||||
interface HTMLDataListElement extends HTMLElement {
|
||||
options: HTMLCollection;
|
||||
}
|
||||
@@ -10622,23 +10640,6 @@ interface RandomSource {
|
||||
getRandomValues(array: ArrayBufferView): ArrayBufferView;
|
||||
}
|
||||
|
||||
interface SourceBuffer extends EventTarget {
|
||||
updating: boolean;
|
||||
appendWindowStart: number;
|
||||
appendWindowEnd: number;
|
||||
buffered: TimeRanges;
|
||||
timestampOffset: number;
|
||||
audioTracks: AudioTrackList;
|
||||
appendBuffer(data: ArrayBuffer): void;
|
||||
remove(start: number, end: number): void;
|
||||
abort(): void;
|
||||
appendStream(stream: MSStream, maxSize?: number): void;
|
||||
}
|
||||
declare var SourceBuffer: {
|
||||
prototype: SourceBuffer;
|
||||
new(): SourceBuffer;
|
||||
}
|
||||
|
||||
interface MSInputMethodContext extends EventTarget {
|
||||
oncandidatewindowshow: (ev: any) => any;
|
||||
target: HTMLElement;
|
||||
|
||||
Vendored
+5
@@ -14,6 +14,11 @@ interface ArrayBuffer {
|
||||
* Read-only. The length of the ArrayBuffer (in bytes).
|
||||
*/
|
||||
byteLength: number;
|
||||
|
||||
/**
|
||||
* Returns a section of an ArrayBuffer.
|
||||
*/
|
||||
slice(begin:number, end?:number): ArrayBuffer;
|
||||
}
|
||||
|
||||
declare var ArrayBuffer: {
|
||||
|
||||
+171
-212
@@ -68,6 +68,13 @@ module ts {
|
||||
getReturnType(): Type;
|
||||
}
|
||||
|
||||
export interface SourceFile {
|
||||
getSourceUnit(): TypeScript.SourceUnitSyntax;
|
||||
getSyntaxTree(): TypeScript.SyntaxTree;
|
||||
getBloomFilter(): TypeScript.BloomFilter;
|
||||
update(scriptSnapshot: TypeScript.IScriptSnapshot, version: number, isOpen: boolean, textChangeRange: TypeScript.TextChangeRange): SourceFile;
|
||||
}
|
||||
|
||||
var scanner: Scanner = createScanner(ScriptTarget.ES5);
|
||||
|
||||
var emptyArray: any [] = [];
|
||||
@@ -82,7 +89,6 @@ module ts {
|
||||
}
|
||||
|
||||
class NodeObject implements Node {
|
||||
|
||||
public kind: SyntaxKind;
|
||||
public pos: number;
|
||||
public end: number;
|
||||
@@ -298,6 +304,130 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
var incrementalParse: IncrementalParse = TypeScript.IncrementalParser.parse;
|
||||
|
||||
class SourceFileObject extends NodeObject implements SourceFile {
|
||||
public filename: string;
|
||||
public text: string;
|
||||
public getLineAndCharacterFromPosition(position: number): { line: number; character: number } { return null; }
|
||||
public amdDependencies: string[];
|
||||
public referencedFiles: FileReference[];
|
||||
public syntacticErrors: Diagnostic[];
|
||||
public semanticErrors: Diagnostic[];
|
||||
public hasNoDefaultLib: boolean;
|
||||
public externalModuleIndicator: Node; // The first node that causes this file to be an external module
|
||||
public nodeCount: number;
|
||||
public identifierCount: number;
|
||||
public symbolCount: number;
|
||||
public statements: NodeArray<Statement>;
|
||||
public byteOrderMark: ByteOrderMark;
|
||||
public version: number;
|
||||
public isOpen: boolean;
|
||||
public languageVersion: ScriptTarget;
|
||||
|
||||
private bloomFilter: TypeScript.BloomFilter;
|
||||
private syntaxTree: TypeScript.SyntaxTree;
|
||||
private scriptSnapshot: TypeScript.IScriptSnapshot;
|
||||
|
||||
public getSourceUnit(): TypeScript.SourceUnitSyntax {
|
||||
// If we don't have a script, create one from our parse tree.
|
||||
return this.getSyntaxTree().sourceUnit();
|
||||
}
|
||||
|
||||
public getLineMap(): TypeScript.LineMap {
|
||||
return this.getSyntaxTree().lineMap();
|
||||
}
|
||||
|
||||
public getSyntaxTree(): TypeScript.SyntaxTree {
|
||||
if (!this.syntaxTree) {
|
||||
var start = new Date().getTime();
|
||||
|
||||
this.syntaxTree = TypeScript.Parser.parse(
|
||||
this.filename, TypeScript.SimpleText.fromScriptSnapshot(this.scriptSnapshot), this.languageVersion, this.isDeclareFile());
|
||||
|
||||
var time = new Date().getTime() - start;
|
||||
|
||||
//TypeScript.syntaxTreeParseTime += time;
|
||||
}
|
||||
|
||||
return this.syntaxTree;
|
||||
}
|
||||
|
||||
private isDeclareFile(): boolean {
|
||||
return TypeScript.isDTSFile(this.filename);
|
||||
}
|
||||
|
||||
public getBloomFilter(): TypeScript.BloomFilter {
|
||||
if (!this.bloomFilter) {
|
||||
var identifiers = TypeScript.createIntrinsicsObject<boolean>();
|
||||
var pre = function (cur: TypeScript.ISyntaxElement) {
|
||||
if (TypeScript.ASTHelpers.isValidAstNode(cur)) {
|
||||
if (cur.kind() === TypeScript.SyntaxKind.IdentifierName) {
|
||||
var nodeText = TypeScript.tokenValueText((<TypeScript.ISyntaxToken>cur));
|
||||
|
||||
identifiers[nodeText] = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
TypeScript.getAstWalkerFactory().simpleWalk(this.getSourceUnit(), pre, null, identifiers);
|
||||
|
||||
var identifierCount = 0;
|
||||
for (var name in identifiers) {
|
||||
if (identifiers[name]) {
|
||||
identifierCount++;
|
||||
}
|
||||
}
|
||||
|
||||
this.bloomFilter = new TypeScript.BloomFilter(identifierCount);
|
||||
this.bloomFilter.addKeys(identifiers);
|
||||
}
|
||||
return this.bloomFilter;
|
||||
}
|
||||
|
||||
public update(scriptSnapshot: TypeScript.IScriptSnapshot, version: number, isOpen: boolean, textChangeRange: TypeScript.TextChangeRange): SourceFile {
|
||||
// See if we are currently holding onto a syntax tree. We may not be because we're
|
||||
// either a closed file, or we've just been lazy and haven't had to create the syntax
|
||||
// tree yet. Access the field instead of the method so we don't accidently realize
|
||||
// the old syntax tree.
|
||||
var oldSyntaxTree = this.syntaxTree;
|
||||
|
||||
if (textChangeRange !== null && Debug.shouldAssert(AssertionLevel.Normal)) {
|
||||
var oldText = this.scriptSnapshot;
|
||||
var newText = scriptSnapshot;
|
||||
|
||||
TypeScript.Debug.assert((oldText.getLength() - textChangeRange.span().length() + textChangeRange.newLength()) === newText.getLength());
|
||||
|
||||
if (Debug.shouldAssert(AssertionLevel.VeryAggressive)) {
|
||||
var oldTextPrefix = oldText.getText(0, textChangeRange.span().start());
|
||||
var newTextPrefix = newText.getText(0, textChangeRange.span().start());
|
||||
TypeScript.Debug.assert(oldTextPrefix === newTextPrefix);
|
||||
|
||||
var oldTextSuffix = oldText.getText(textChangeRange.span().end(), oldText.getLength());
|
||||
var newTextSuffix = newText.getText(textChangeRange.newSpan().end(), newText.getLength());
|
||||
TypeScript.Debug.assert(oldTextSuffix === newTextSuffix);
|
||||
}
|
||||
}
|
||||
|
||||
var text = TypeScript.SimpleText.fromScriptSnapshot(scriptSnapshot);
|
||||
|
||||
// If we don't have a text change, or we don't have an old syntax tree, then do a full
|
||||
// parse. Otherwise, do an incremental parse.
|
||||
var newSyntaxTree = textChangeRange === null || oldSyntaxTree === null
|
||||
? TypeScript.Parser.parse(this.filename, text, this.languageVersion, TypeScript.isDTSFile(this.filename))
|
||||
: TypeScript.IncrementalParser.parse(oldSyntaxTree, textChangeRange, text);
|
||||
|
||||
return SourceFileObject.createSourceFileObject(this.languageVersion, this.filename, scriptSnapshot, this.byteOrderMark, version, isOpen, newSyntaxTree);
|
||||
}
|
||||
|
||||
public static createSourceFileObject(languageVersion: ScriptTarget, filename: string, scriptSnapshot: TypeScript.IScriptSnapshot, byteOrderMark: ByteOrderMark, version: number, isOpen: boolean, syntaxTree: TypeScript.SyntaxTree) {
|
||||
var newSoruceFile = <SourceFileObject><any>createSourceFile(filename, scriptSnapshot.getText(0, scriptSnapshot.getLength()), languageVersion, byteOrderMark, version, isOpen);
|
||||
newSoruceFile.scriptSnapshot = scriptSnapshot;
|
||||
newSoruceFile.syntaxTree = syntaxTree;
|
||||
return newSoruceFile;
|
||||
}
|
||||
}
|
||||
|
||||
export interface Logger {
|
||||
information(): boolean;
|
||||
debug(): boolean;
|
||||
@@ -567,17 +697,17 @@ module ts {
|
||||
byteOrderMark: ByteOrderMark,
|
||||
version: number,
|
||||
isOpen: boolean,
|
||||
referencedFiles: string[]): Document;
|
||||
referencedFiles: string[]): SourceFile;
|
||||
|
||||
updateDocument(
|
||||
document: Document,
|
||||
soruceFile: SourceFile,
|
||||
filename: string,
|
||||
compilationSettings: CompilerOptions,
|
||||
scriptSnapshot: TypeScript.IScriptSnapshot,
|
||||
version: number,
|
||||
isOpen: boolean,
|
||||
textChangeRange: TypeScript.TextChangeRange
|
||||
): Document;
|
||||
): SourceFile;
|
||||
|
||||
releaseDocument(filename: string, compilationSettings: CompilerOptions): void
|
||||
}
|
||||
@@ -671,172 +801,6 @@ module ts {
|
||||
(oldSyntaxTree: TypeScript.SyntaxTree, textChangeRange: TypeScript.TextChangeRange, newText: TypeScript.ISimpleText): TypeScript.SyntaxTree
|
||||
}
|
||||
|
||||
export interface Document {
|
||||
getFilename(): string;
|
||||
getByteOrderMark(): ByteOrderMark;
|
||||
getVersion(): number;
|
||||
isOpen(): boolean;
|
||||
getSourceUnit(): TypeScript.SourceUnitSyntax;
|
||||
getSyntaxTree(): TypeScript.SyntaxTree;
|
||||
getSourceFile(): SourceFile;
|
||||
getBloomFilter(): TypeScript.BloomFilter;
|
||||
update(scriptSnapshot: TypeScript.IScriptSnapshot, version: number, isOpen: boolean, textChangeRange: TypeScript.TextChangeRange): Document;
|
||||
}
|
||||
|
||||
class DocumentObject implements Document {
|
||||
private bloomFilter: TypeScript.BloomFilter = null;
|
||||
|
||||
// By default, our Document class doesn't support incremental update of its conten
|
||||
// However, we enable other layers (like teh services layer) to inject the capability
|
||||
// into us by setting this function.
|
||||
public static incrementalParse: IncrementalParse = TypeScript.IncrementalParser.parse;
|
||||
|
||||
constructor(private compilationSettings: CompilerOptions,
|
||||
public filename: string,
|
||||
public referencedFiles: string[],
|
||||
private scriptSnapshot: TypeScript.IScriptSnapshot,
|
||||
public byteOrderMark: ByteOrderMark,
|
||||
public version: number,
|
||||
public _isOpen: boolean,
|
||||
private syntaxTree: TypeScript.SyntaxTree,
|
||||
private soruceFile: SourceFile) {
|
||||
}
|
||||
|
||||
public getFilename(): string {
|
||||
return this.filename;
|
||||
}
|
||||
|
||||
public getVersion(): number {
|
||||
return this.version;
|
||||
}
|
||||
|
||||
public isOpen(): boolean {
|
||||
return this._isOpen;
|
||||
}
|
||||
|
||||
public getByteOrderMark(): ByteOrderMark {
|
||||
return this.byteOrderMark;
|
||||
}
|
||||
public isDeclareFile(): boolean {
|
||||
return TypeScript.isDTSFile(this.filename);
|
||||
}
|
||||
|
||||
public getSourceUnit(): TypeScript.SourceUnitSyntax {
|
||||
// If we don't have a script, create one from our parse tree.
|
||||
return this.getSyntaxTree().sourceUnit();
|
||||
}
|
||||
|
||||
public getLineMap(): TypeScript.LineMap {
|
||||
return this.getSyntaxTree().lineMap();
|
||||
}
|
||||
|
||||
public getSyntaxTree(): TypeScript.SyntaxTree {
|
||||
if (!this.syntaxTree) {
|
||||
var start = new Date().getTime();
|
||||
|
||||
this.syntaxTree = TypeScript.Parser.parse(
|
||||
this.filename, TypeScript.SimpleText.fromScriptSnapshot(this.scriptSnapshot), this.compilationSettings.target, this.isDeclareFile());
|
||||
|
||||
var time = new Date().getTime() - start;
|
||||
|
||||
//TypeScript.syntaxTreeParseTime += time;
|
||||
}
|
||||
|
||||
return this.syntaxTree;
|
||||
}
|
||||
|
||||
public getSourceFile(): SourceFile {
|
||||
if (!this.soruceFile) {
|
||||
var start = new Date().getTime();
|
||||
|
||||
this.soruceFile = createSourceFile(this.filename, this.scriptSnapshot.getText(0, this.scriptSnapshot.getLength()), this.compilationSettings.target);
|
||||
|
||||
var time = new Date().getTime() - start;
|
||||
|
||||
//TypeScript.astParseTime += time;
|
||||
}
|
||||
|
||||
return this.soruceFile;
|
||||
}
|
||||
|
||||
public getBloomFilter(): TypeScript.BloomFilter {
|
||||
if (!this.bloomFilter) {
|
||||
var identifiers = TypeScript.createIntrinsicsObject<boolean>();
|
||||
var pre = function (cur: TypeScript.ISyntaxElement) {
|
||||
if (TypeScript.ASTHelpers.isValidAstNode(cur)) {
|
||||
if (cur.kind() === TypeScript.SyntaxKind.IdentifierName) {
|
||||
var nodeText = TypeScript.tokenValueText((<TypeScript.ISyntaxToken>cur));
|
||||
|
||||
identifiers[nodeText] = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
TypeScript.getAstWalkerFactory().simpleWalk(this.getSourceUnit(), pre, null, identifiers);
|
||||
|
||||
var identifierCount = 0;
|
||||
for (var name in identifiers) {
|
||||
if (identifiers[name]) {
|
||||
identifierCount++;
|
||||
}
|
||||
}
|
||||
|
||||
this.bloomFilter = new TypeScript.BloomFilter(identifierCount);
|
||||
this.bloomFilter.addKeys(identifiers);
|
||||
}
|
||||
return this.bloomFilter;
|
||||
}
|
||||
|
||||
// Returns true if this file should get emitted into its own unique output file.
|
||||
// Otherwise, it should be written into a single output file along with the rest of hte
|
||||
// documents in the compilation.
|
||||
public emitToOwnOutputFile(): boolean {
|
||||
// If we haven't specified an output file in our settings, then we're definitely
|
||||
// emitting to our own file. Also, if we're an external module, then we're
|
||||
// definitely emitting to our own file.
|
||||
return !this.compilationSettings.out || this.getSyntaxTree().isExternalModule();
|
||||
}
|
||||
|
||||
public update(scriptSnapshot: TypeScript.IScriptSnapshot, version: number, isOpen: boolean, textChangeRange: TypeScript.TextChangeRange): Document {
|
||||
// See if we are currently holding onto a syntax tree. We may not be because we're
|
||||
// either a closed file, or we've just been lazy and haven't had to create the syntax
|
||||
// tree yet. Access the field instead of the method so we don't accidently realize
|
||||
// the old syntax tree.
|
||||
var oldSyntaxTree = this.syntaxTree;
|
||||
|
||||
if (textChangeRange !== null && Debug.shouldAssert(AssertionLevel.Normal)) {
|
||||
var oldText = this.scriptSnapshot;
|
||||
var newText = scriptSnapshot;
|
||||
|
||||
TypeScript.Debug.assert((oldText.getLength() - textChangeRange.span().length() + textChangeRange.newLength()) === newText.getLength());
|
||||
|
||||
if (Debug.shouldAssert(AssertionLevel.VeryAggressive)) {
|
||||
var oldTextPrefix = oldText.getText(0, textChangeRange.span().start());
|
||||
var newTextPrefix = newText.getText(0, textChangeRange.span().start());
|
||||
TypeScript.Debug.assert(oldTextPrefix === newTextPrefix);
|
||||
|
||||
var oldTextSuffix = oldText.getText(textChangeRange.span().end(), oldText.getLength());
|
||||
var newTextSuffix = newText.getText(textChangeRange.newSpan().end(), newText.getLength());
|
||||
TypeScript.Debug.assert(oldTextSuffix === newTextSuffix);
|
||||
}
|
||||
}
|
||||
|
||||
var text = TypeScript.SimpleText.fromScriptSnapshot(scriptSnapshot);
|
||||
|
||||
// If we don't have a text change, or we don't have an old syntax tree, then do a full
|
||||
// parse. Otherwise, do an incremental parse.
|
||||
var newSyntaxTree = textChangeRange === null || oldSyntaxTree === null || DocumentObject.incrementalParse === null
|
||||
? TypeScript.Parser.parse(this.filename, text, this.compilationSettings.target, TypeScript.isDTSFile(this.filename))
|
||||
: DocumentObject.incrementalParse(oldSyntaxTree, textChangeRange, text);
|
||||
|
||||
return new DocumentObject(this.compilationSettings, this.filename, this.referencedFiles, scriptSnapshot, this.byteOrderMark, version, isOpen, newSyntaxTree, /*soruceFile*/ null);
|
||||
}
|
||||
}
|
||||
|
||||
export function createDocument(compilationSettings: CompilerOptions, fileName: string, scriptSnapshot: TypeScript.IScriptSnapshot, byteOrderMark: ByteOrderMark, version: number, isOpen: boolean, referencedFiles: string[]): Document {
|
||||
return new DocumentObject(compilationSettings, fileName, referencedFiles, scriptSnapshot, byteOrderMark, version, isOpen, /*syntaxTree:*/ null, /*soruceFile*/ null);
|
||||
}
|
||||
|
||||
/// Language Service
|
||||
|
||||
interface CompletionSession {
|
||||
@@ -865,7 +829,7 @@ module ts {
|
||||
}
|
||||
|
||||
interface DocumentRegistryEntry {
|
||||
document: Document;
|
||||
sourceFile: SourceFile;
|
||||
refCount: number;
|
||||
owners: string[];
|
||||
}
|
||||
@@ -1157,17 +1121,17 @@ module ts {
|
||||
function reportStats() {
|
||||
var bucketInfoArray = Object.keys(buckets).filter(name => name && name.charAt(0) === '_').map(name => {
|
||||
var entries = lookUp(buckets, name);
|
||||
var documents: { name: string; refCount: number; references: string[]; }[] = [];
|
||||
var soruceFiles: { name: string; refCount: number; references: string[]; }[] = [];
|
||||
for (var i in entries) {
|
||||
var entry = entries[i];
|
||||
documents.push({
|
||||
soruceFiles.push({
|
||||
name: i,
|
||||
refCount: entry.refCount,
|
||||
references: entry.owners.slice(0)
|
||||
});
|
||||
}
|
||||
documents.sort((x, y) => y.refCount - x.refCount);
|
||||
return { bucket: name, documents: documents }
|
||||
soruceFiles.sort((x, y) => y.refCount - x.refCount);
|
||||
return { bucket: name, sourceFiles: soruceFiles }
|
||||
});
|
||||
return JSON.stringify(bucketInfoArray, null, 2);
|
||||
}
|
||||
@@ -1178,46 +1142,45 @@ module ts {
|
||||
scriptSnapshot: TypeScript.IScriptSnapshot,
|
||||
byteOrderMark: ByteOrderMark,
|
||||
version: number,
|
||||
isOpen: boolean,
|
||||
referencedFiles: string[]= []): Document {
|
||||
isOpen: boolean): SourceFile {
|
||||
|
||||
var bucket = getBucketForCompilationSettings(compilationSettings, /*createIfMissing*/ true);
|
||||
var entry = lookUp(bucket, filename);
|
||||
if (!entry) {
|
||||
var document = createDocument(compilationSettings, filename, scriptSnapshot, byteOrderMark, version, isOpen, referencedFiles);
|
||||
var sourceFile = createSourceFile(filename, scriptSnapshot.getText(0, scriptSnapshot.getLength()), compilationSettings.target, byteOrderMark, version, isOpen);
|
||||
|
||||
bucket[filename] = entry = {
|
||||
document: document,
|
||||
sourceFile: sourceFile,
|
||||
refCount: 0,
|
||||
owners: []
|
||||
};
|
||||
}
|
||||
entry.refCount++;
|
||||
|
||||
return entry.document;
|
||||
return entry.sourceFile;
|
||||
}
|
||||
|
||||
function updateDocument(
|
||||
document: Document,
|
||||
sourceFile: SourceFile,
|
||||
filename: string,
|
||||
compilationSettings: CompilerOptions,
|
||||
scriptSnapshot: TypeScript.IScriptSnapshot,
|
||||
version: number,
|
||||
isOpen: boolean,
|
||||
textChangeRange: TypeScript.TextChangeRange
|
||||
): Document {
|
||||
): SourceFile {
|
||||
|
||||
var bucket = getBucketForCompilationSettings(compilationSettings, /*createIfMissing*/ false);
|
||||
Debug.assert(bucket);
|
||||
var entry = lookUp(bucket, filename);
|
||||
Debug.assert(entry);
|
||||
|
||||
if (entry.document.isOpen() === isOpen && entry.document.getVersion() === version) {
|
||||
return entry.document;
|
||||
if (entry.sourceFile.isOpen === isOpen && entry.sourceFile.version === version) {
|
||||
return entry.sourceFile;
|
||||
}
|
||||
|
||||
entry.document = entry.document.update(scriptSnapshot, version, isOpen, textChangeRange);
|
||||
return entry.document;
|
||||
entry.sourceFile = entry.sourceFile.update(scriptSnapshot, version, isOpen, textChangeRange);
|
||||
return entry.sourceFile;
|
||||
}
|
||||
|
||||
function releaseDocument(filename: string, compilationSettings: CompilerOptions): void {
|
||||
@@ -1258,7 +1221,6 @@ module ts {
|
||||
var program: Program;
|
||||
var typeChecker: TypeChecker;
|
||||
var useCaseSensitivefilenames = false;
|
||||
var documentsByName: Map<Document> = {};
|
||||
var documentRegistry = documentRegistry;
|
||||
var cancellationToken = new CancellationTokenObject(host.getCancellationToken());
|
||||
var activeCompletionSession: CompletionSession; // The current active completion session, used to get the completion entry details
|
||||
@@ -1268,18 +1230,19 @@ module ts {
|
||||
TypeScript.LocalizedDiagnosticMessages = host.getLocalizedDiagnosticMessages();
|
||||
}
|
||||
|
||||
function getDocument(filename: string): Document {
|
||||
return lookUp(documentsByName, filename);
|
||||
function getSourceFile(filename: string): SourceFile {
|
||||
Debug.assert(!!program, "'getSoruceFile(filename)' is called before 'program' is initialized, consider calling 'synchronizeHostData()' first");
|
||||
return program.getSourceFile(filename);
|
||||
}
|
||||
|
||||
function createCompilerHost(): CompilerHost {
|
||||
return {
|
||||
getSourceFile: (filename, languageVersion) => {
|
||||
var document = getDocument(filename);
|
||||
var sourceFile = getSourceFile(filename);
|
||||
|
||||
Debug.assert(!!document, "document can not be undefined");
|
||||
Debug.assert(!!sourceFile, "sourceFile can not be undefined");
|
||||
|
||||
return document.getSourceFile();
|
||||
return sourceFile.getSourceFile();
|
||||
},
|
||||
getCancellationToken: () => cancellationToken,
|
||||
getCanonicalFileName: (filename) => useCaseSensitivefilenames ? filename : filename.toLowerCase(),
|
||||
@@ -1328,7 +1291,6 @@ module ts {
|
||||
var filename = oldSourceFiles[i].filename;
|
||||
if (!hostCache.contains(filename) || changesInCompilationSettingsAffectSyntax) {
|
||||
documentRegistry.releaseDocument(filename, oldSettings);
|
||||
delete documentsByName[filename];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1345,12 +1307,12 @@ module ts {
|
||||
var isOpen = hostCache.isOpen(filename);
|
||||
var scriptSnapshot = hostCache.getScriptSnapshot(filename);
|
||||
|
||||
var document: Document = getDocument(filename);
|
||||
if (document) {
|
||||
var sourceFile: SourceFile = getSourceFile(filename);
|
||||
if (sourceFile) {
|
||||
//
|
||||
// If the document is the same, assume no update
|
||||
// If the sourceFile is the same, assume no update
|
||||
//
|
||||
if (document.getVersion() === version && document.isOpen() === isOpen) {
|
||||
if (sourceFile.version === version && sourceFile.isOpen === isOpen) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1361,18 +1323,15 @@ module ts {
|
||||
// the old buffer alive that represented the file on disk (as the host has moved to a
|
||||
// new text buffer).
|
||||
var textChangeRange: TypeScript.TextChangeRange = null;
|
||||
if (document.isOpen && isOpen) {
|
||||
textChangeRange = hostCache.getScriptTextChangeRangeSinceVersion(filename, document.getVersion());
|
||||
if (sourceFile.isOpen && isOpen) {
|
||||
textChangeRange = hostCache.getScriptTextChangeRangeSinceVersion(filename, sourceFile.version);
|
||||
}
|
||||
|
||||
document = documentRegistry.updateDocument(document, filename, compilationSettings, scriptSnapshot, version, isOpen, textChangeRange);
|
||||
sourceFile = documentRegistry.updateDocument(sourceFile, filename, compilationSettings, scriptSnapshot, version, isOpen, textChangeRange);
|
||||
}
|
||||
else {
|
||||
document = documentRegistry.acquireDocument(filename, compilationSettings, scriptSnapshot, hostCache.getByteOrderMark(filename), version, isOpen, []);
|
||||
sourceFile = documentRegistry.acquireDocument(filename, compilationSettings, scriptSnapshot, hostCache.getByteOrderMark(filename), version, isOpen, []);
|
||||
}
|
||||
|
||||
// Remeber the new document
|
||||
documentsByName[filename] = document;
|
||||
}
|
||||
|
||||
// Now create a new compiler
|
||||
@@ -1583,10 +1542,10 @@ module ts {
|
||||
|
||||
filename = TypeScript.switchToForwardSlashes(filename);
|
||||
|
||||
var document = getDocument(filename);
|
||||
var sourceUnit = document.getSourceUnit();
|
||||
var sourceFile = getSourceFile(filename);
|
||||
var sourceUnit = sourceFile.getSourceUnit();
|
||||
|
||||
if (isCompletionListBlocker(document.getSyntaxTree().sourceUnit(), position)) {
|
||||
if (isCompletionListBlocker(sourceFile.getSyntaxTree().sourceUnit(), position)) {
|
||||
host.log("Returning an empty list because completion was blocked.");
|
||||
return null;
|
||||
}
|
||||
@@ -1632,7 +1591,7 @@ module ts {
|
||||
}
|
||||
|
||||
// TODO: this is a hack for now, we need a proper walking mechanism to verify that we have the correct node
|
||||
var mappedNode = getNodeAtPosition(document.getSourceFile(), TypeScript.end(node) - 1);
|
||||
var mappedNode = getNodeAtPosition(sourceFile.getSourceFile(), TypeScript.end(node) - 1);
|
||||
|
||||
Debug.assert(mappedNode, "Could not map a Fidelity node to an AST node");
|
||||
|
||||
@@ -1658,7 +1617,7 @@ module ts {
|
||||
getCompletionEntriesFromSymbols(symbols, activeCompletionSession);
|
||||
}
|
||||
else {
|
||||
var containingObjectLiteral = getContainingObjectLiteralApplicableForCompletion(document.getSyntaxTree().sourceUnit(), position);
|
||||
var containingObjectLiteral = getContainingObjectLiteralApplicableForCompletion(sourceFile.getSyntaxTree().sourceUnit(), position);
|
||||
|
||||
// Object literal expression, look up possible property names from contextual type
|
||||
if (containingObjectLiteral) {
|
||||
@@ -1843,8 +1802,8 @@ module ts {
|
||||
synchronizeHostData();
|
||||
|
||||
filename = TypeScript.switchToForwardSlashes(filename);
|
||||
var document = getDocument(filename);
|
||||
var node = getNodeAtPosition(document.getSourceFile(), position);
|
||||
var sourceFile = getSourceFile(filename);
|
||||
var node = getNodeAtPosition(sourceFile.getSourceFile(), position);
|
||||
if (!node) return undefined;
|
||||
|
||||
var symbol = typeChecker.getSymbolOfIdentifierLikeNode(node);
|
||||
@@ -2370,7 +2329,7 @@ module ts {
|
||||
getNodeConstructor: kind => {
|
||||
function Node() {
|
||||
}
|
||||
var proto = new NodeObject();
|
||||
var proto = kind === SyntaxKind.SourceFile ? new SourceFileObject() : new NodeObject();
|
||||
proto.kind = kind;
|
||||
proto.pos = 0;
|
||||
proto.end = 0;
|
||||
|
||||
@@ -114,8 +114,8 @@ var Base = (function () {
|
||||
var Derived = (function (_super) {
|
||||
__extends(Derived, _super);
|
||||
function Derived() {
|
||||
_super.call(this, function () { return _this; });
|
||||
var _this = this;
|
||||
_super.call(this, function () { return _this; });
|
||||
}
|
||||
return Derived;
|
||||
})(Base);
|
||||
@@ -147,8 +147,8 @@ var M2;
|
||||
var Derived = (function (_super) {
|
||||
__extends(Derived, _super);
|
||||
function Derived() {
|
||||
_super.call(this, function () { return _this; });
|
||||
var _this = this;
|
||||
_super.call(this, function () { return _this; });
|
||||
}
|
||||
return Derived;
|
||||
})(Base);
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
//// [captureThisInSuperCall.ts]
|
||||
class A {
|
||||
constructor(p:any) {}
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
constructor() { super({ test: () => this.someMethod()}); }
|
||||
someMethod() {}
|
||||
}
|
||||
|
||||
//// [captureThisInSuperCall.js]
|
||||
var __extends = this.__extends || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
__.prototype = b.prototype;
|
||||
d.prototype = new __();
|
||||
};
|
||||
var A = (function () {
|
||||
function A(p) {
|
||||
}
|
||||
return A;
|
||||
})();
|
||||
var B = (function (_super) {
|
||||
__extends(B, _super);
|
||||
function B() {
|
||||
var _this = this;
|
||||
_super.call(this, { test: function () { return _this.someMethod(); } });
|
||||
}
|
||||
B.prototype.someMethod = function () {
|
||||
};
|
||||
return B;
|
||||
})(A);
|
||||
@@ -33,8 +33,8 @@ class Test1 {
|
||||
//// [classMemberInitializerWithLamdaScoping.js]
|
||||
var Test = (function () {
|
||||
function Test(field) {
|
||||
this.field = field;
|
||||
var _this = this;
|
||||
this.field = field;
|
||||
this.messageHandler = function () {
|
||||
var field = _this.field;
|
||||
console.log(field);
|
||||
|
||||
+2
-2
@@ -47,8 +47,8 @@ var Foo2 = (function () {
|
||||
})();
|
||||
var Foo3 = (function () {
|
||||
function Foo3(_this) {
|
||||
this._this = _this;
|
||||
var _this = this;
|
||||
this._this = _this;
|
||||
var lambda = function () {
|
||||
return function (x) { return _this; };
|
||||
};
|
||||
@@ -66,8 +66,8 @@ var Foo4 = (function () {
|
||||
})();
|
||||
var Foo5 = (function () {
|
||||
function Foo5(_this) {
|
||||
this._this = _this;
|
||||
var _this = this;
|
||||
this._this = _this;
|
||||
var lambda = function () {
|
||||
return function (x) { return _this; };
|
||||
};
|
||||
|
||||
@@ -58,9 +58,9 @@ var Derived2 = (function (_super) {
|
||||
var Derived3 = (function (_super) {
|
||||
__extends(Derived3, _super);
|
||||
function Derived3(a) {
|
||||
var _this = this;
|
||||
_super.call(this, function () { return _this; });
|
||||
this.a = a;
|
||||
var _this = this;
|
||||
}
|
||||
return Derived3;
|
||||
})(Base);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
==== tests/cases/conformance/functions/functionImplementationErrors.ts (7 errors) ====
|
||||
==== tests/cases/conformance/functions/functionImplementationErrors.ts (8 errors) ====
|
||||
// FunctionExpression with no return type annotation with multiple return statements with unrelated types
|
||||
var f1 = function () {
|
||||
~~~~~~~~~~~~~
|
||||
@@ -68,6 +68,8 @@
|
||||
// FunctionExpression with non -void return type annotation with a throw, no return, and other code
|
||||
// Should be error but isn't
|
||||
undefined === function (): number {
|
||||
~~~~~~
|
||||
!!! A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement.
|
||||
throw undefined;
|
||||
var x = 4;
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
==== tests/cases/compiler/implicitAnyGetAndSetAccessorWithAnyReturnType.ts (9 errors) ====
|
||||
==== tests/cases/compiler/implicitAnyGetAndSetAccessorWithAnyReturnType.ts (8 errors) ====
|
||||
// these should be errors
|
||||
class GetAndSet {
|
||||
getAndSet = null; // error at "getAndSet"
|
||||
@@ -14,8 +14,6 @@
|
||||
public set haveGetAndSet(value) { // error at "value"
|
||||
~~~~~~~~~~~~~
|
||||
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
~~~~~
|
||||
!!! Parameter 'value' implicitly has an 'any' type.
|
||||
this.getAndSet = value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,8 +26,8 @@ module M {
|
||||
//// [lambdaPropSelf.js]
|
||||
var Person = (function () {
|
||||
function Person(name, children) {
|
||||
this.name = name;
|
||||
var _this = this;
|
||||
this.name = name;
|
||||
this.addChild = function () { return _this.children.push("New child"); };
|
||||
this.children = ko.observableArray(children);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
==== tests/cases/conformance/parser/ecmascript5/Generics/parserCastVersusArrowFunction1.ts (7 errors) ====
|
||||
==== tests/cases/conformance/parser/ecmascript5/Generics/parserCastVersusArrowFunction1.ts (13 errors) ====
|
||||
var v = <T>() => 1;
|
||||
var v = <T>a;
|
||||
~
|
||||
!!! Cannot find name 'T'.
|
||||
~
|
||||
!!! Cannot find name 'a'.
|
||||
|
||||
var v = <T>(a) => 1;
|
||||
~
|
||||
@@ -17,9 +19,19 @@
|
||||
var v = <T>(a);
|
||||
~
|
||||
!!! Cannot find name 'T'.
|
||||
~
|
||||
!!! Cannot find name 'a'.
|
||||
var v = <T>(a, b);
|
||||
~
|
||||
!!! Cannot find name 'T'.
|
||||
~
|
||||
!!! Cannot find name 'a'.
|
||||
~
|
||||
!!! Cannot find name 'b'.
|
||||
var v = <T>(a = 1, b = 2);
|
||||
~
|
||||
!!! Cannot find name 'T'.
|
||||
!!! Cannot find name 'T'.
|
||||
~
|
||||
!!! Cannot find name 'a'.
|
||||
~
|
||||
!!! Cannot find name 'b'.
|
||||
@@ -1,4 +1,4 @@
|
||||
==== tests/cases/conformance/parser/ecmascript5/parserRealSource8.ts (133 errors) ====
|
||||
==== tests/cases/conformance/parser/ecmascript5/parserRealSource8.ts (134 errors) ====
|
||||
// Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0.
|
||||
// See LICENSE.txt in the project root for complete license information.
|
||||
|
||||
@@ -383,6 +383,8 @@
|
||||
outerFnc.type.members = (<SymbolScopeBuilder>(<TypeSymbol>container).type.memberScope).valueMembers;
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
!!! Cannot find name 'SymbolScopeBuilder'.
|
||||
~~~~~~~~~~
|
||||
!!! Cannot find name 'TypeSymbol'.
|
||||
}
|
||||
funcScope = context.scopeChain.fnc.type.memberScope;
|
||||
outerFnc.innerStaticFuncs[outerFnc.innerStaticFuncs.length] = funcDecl;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
==== tests/cases/conformance/parser/ecmascript5/VariableDeclarations/parserVariableDeclaration3.ts (3 errors) ====
|
||||
==== tests/cases/conformance/parser/ecmascript5/VariableDeclarations/parserVariableDeclaration3.ts (4 errors) ====
|
||||
function runTests() {
|
||||
var outfile = new Harness.Compiler.WriterAggregator()
|
||||
~~~~~~~
|
||||
@@ -8,6 +8,8 @@
|
||||
!!! Cannot find name 'Harness'.
|
||||
, compiler = <TypeScript.TypeScriptCompiler>new TypeScript.TypeScriptCompiler(outerr)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! Cannot find name 'TypeScript'.
|
||||
~~~~~~~~~~
|
||||
!!! Cannot find name 'TypeScript'.
|
||||
, code;
|
||||
}
|
||||
@@ -36,9 +36,9 @@ var M;
|
||||
(function (M) {
|
||||
var C = (function () {
|
||||
function C(c1, c2, c3) {
|
||||
var _this = this;
|
||||
this.c1 = c1;
|
||||
this.c2 = c2;
|
||||
var _this = this;
|
||||
this.x = C.y + this.c1 + this.c2 + c3;
|
||||
this.g = function (v) { return C.f(_this.x + C.y + v + _this.c1 + _this.c2 + C.pub); };
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
//// [testContainerList.ts]
|
||||
// Regression test for #325
|
||||
module A {
|
||||
class C {
|
||||
constructor(public d: {}) { }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// [testContainerList.js]
|
||||
var A;
|
||||
(function (A) {
|
||||
var C = (function () {
|
||||
function C(d) {
|
||||
this.d = d;
|
||||
}
|
||||
return C;
|
||||
})();
|
||||
})(A || (A = {}));
|
||||
@@ -25,8 +25,8 @@ var Base = (function () {
|
||||
var Super = (function (_super) {
|
||||
__extends(Super, _super);
|
||||
function Super() {
|
||||
_super.call(this, (function () { return _this; })());
|
||||
var _this = this;
|
||||
_super.call(this, (function () { return _this; })());
|
||||
}
|
||||
return Super;
|
||||
})(Base);
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
class A {
|
||||
constructor(p:any) {}
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
constructor() { super({ test: () => this.someMethod()}); }
|
||||
someMethod() {}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// Regression test for #325
|
||||
module A {
|
||||
class C {
|
||||
constructor(public d: {}) { }
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
edit.disableFormatting();
|
||||
|
||||
goTo.marker(1);
|
||||
goTo.marker('1');
|
||||
|
||||
edit.insert(" compareTo(): number;\n");
|
||||
diagnostics.validateTypesAtPositions(168,84,53,118,22);
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
edit.disableFormatting();
|
||||
|
||||
goTo.marker(1);
|
||||
goTo.marker('1');
|
||||
|
||||
edit.insert(", 'world'");
|
||||
diagnostics.validateTypesAtPositions(78);
|
||||
|
||||
@@ -10,18 +10,18 @@
|
||||
|
||||
edit.disableFormatting();
|
||||
|
||||
goTo.marker(1);
|
||||
goTo.marker('1');
|
||||
|
||||
edit.deleteAtCaret(9);
|
||||
|
||||
goTo.marker(3);
|
||||
goTo.marker('3');
|
||||
|
||||
edit.deleteAtCaret(7);
|
||||
|
||||
goTo.marker(2);
|
||||
goTo.marker('2');
|
||||
|
||||
edit.deleteAtCaret(7);
|
||||
|
||||
goTo.marker(4);
|
||||
goTo.marker('4');
|
||||
diagnostics.validateTypesAtPositions(43);
|
||||
|
||||
|
||||
@@ -27,8 +27,7 @@
|
||||
////class Bar<T> extends testClass</*type3*/
|
||||
////var x : testClass<,, /*type4*/any>;
|
||||
|
||||
debugger;
|
||||
// goTo.marker("1");
|
||||
goTo.marker("1");
|
||||
// verify.currentSignatureParamterCountIs(3);
|
||||
// verify.currentSignatureHelpIs("testFunction<T extends IFoo, U, M extends IFoo>(a: T, b: U, c: M): M");
|
||||
|
||||
|
||||
@@ -13,6 +13,6 @@
|
||||
|
||||
edit.disableFormatting();
|
||||
|
||||
goTo.marker(1);
|
||||
goTo.marker('1');
|
||||
|
||||
//edit.insert("\nimport I1 = module(\"exportEqualsInterface_A\");\n");
|
||||
|
||||
@@ -18,10 +18,10 @@
|
||||
////
|
||||
|
||||
edit.disableFormatting();
|
||||
goTo.marker(1);
|
||||
goTo.marker('1');
|
||||
|
||||
edit.deleteAtCaret(24);
|
||||
|
||||
goTo.marker(1);
|
||||
goTo.marker('1');
|
||||
|
||||
edit.insert("export = connectExport;\n");
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
//// {| "itemName": "ABC", "kind": "module", "parentName": "" |}module ABC {
|
||||
//// export var {| "itemName": "x", "kind": "var" |}x = 3;
|
||||
//// }
|
||||
debugger;
|
||||
|
||||
verify.getScriptLexicalStructureListCount(12);
|
||||
test.markers().forEach(marker => {
|
||||
if (marker.data) {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
//////inside a comment foo(/*insideComment*/
|
||||
////cl/*invalidContext*/ass InvalidSignatureHelpLocation { }
|
||||
////InvalidSignatureHelpLocation(/*validContext*/);
|
||||
debugger;
|
||||
|
||||
goTo.marker('insideComment');
|
||||
verify.not.signatureHelpPresent();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user