Merge branch 'master' into navbar

Conflicts:
	src/services/services.ts
This commit is contained in:
Daniel Rosenwasser
2014-09-24 10:40:59 -07:00
240 changed files with 15687 additions and 8175 deletions
+3 -4
View File
@@ -63,7 +63,6 @@ var harnessSources = [
"sourceMapRecorder.ts",
"harnessLanguageService.ts",
"fourslash.ts",
"external/json2.ts",
"runnerbase.ts",
"compilerRunner.ts",
"typeWriter.ts",
@@ -318,7 +317,7 @@ function exec(cmd, completeHandler) {
complete();
})
try{
ex.run();
ex.run();
} catch(e) {
console.log('Exception: ' + e)
}
@@ -342,7 +341,7 @@ function cleanTestDirs() {
function writeTestConfigFile(tests, testConfigFile) {
console.log('Running test(s): ' + tests);
var testConfigContents = '{\n' + '\ttest: [\'' + tests + '\']\n}';
fs.writeFileSync('test.config', testConfigContents);
fs.writeFileSync('test.config', testConfigContents);
}
function deleteTemporaryProjectOutput() {
@@ -385,7 +384,7 @@ desc("Generates code coverage data via instanbul")
task("generate-code-coverage", ["tests", builtLocalDirectory], function () {
var cmd = 'istanbul cover node_modules/mocha/bin/_mocha -- -R min -t ' + testTimeout + ' ' + run;
console.log(cmd);
exec(cmd);
exec(cmd);
}, { async: true });
// Browser tests
+12 -10
View File
@@ -47,16 +47,18 @@ npm install
Use one of the following to build and test:
```
jake local # Build the compiler into built/local
jake clean # Delete the built compiler
jake LKG # Replace the last known good with the built one.
# Bootstrapping step to be executed when the built compiler reaches a stable state.
jake tests # Build the test infrastructure using the built compiler.
jake runtests # Run tests using the built compiler and test infrastructure.
# You can override the host or specify a test for this command.
# Use host=<hostName> or tests=<testPath>.
jake baseline-accept # This replaces the baseline test results with the results obtained from jake runtests.
jake -T # List the above commands.
jake local # Build the compiler into built/local
jake clean # Delete the built compiler
jake LKG # Replace the last known good with the built one.
# Bootstrapping step to be executed when the built compiler reaches a stable state.
jake tests # Build the test infrastructure using the built compiler.
jake runtests # Run tests using the built compiler and test infrastructure.
# You can override the host or specify a test for this command.
# Use host=<hostName> or tests=<testPath>.
jake runtests-browser # Runs the tests using the built run.js file. Syntax is jake runtests. Optional
parameters 'host=', 'tests=[regex], reporter=[list|spec|json|<more>]'.
jake baseline-accept # This replaces the baseline test results with the results obtained from jake runtests.
jake -T # List the above commands.
```
-61
View File
@@ -19,67 +19,6 @@ limitations under the License.
---------------------------------------------
Third Party Code Components
--------------------------------------------
---- Mozilla Developer Code---------
The following Mozilla Developer Code is under Public Domain as updated after Aug. 20, 2012, see, https://developer.mozilla.org/en-US/docs/Project:Copyrights
1. Array filter Compatibility Method,
Available at https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/filter
Any copyright is dedicated to the Public Domain.
2. Array forEach Compatibility Method,
Available at https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/forEach
Any copyright is dedicated to the Public Domain.
3. Array indexOf Compatibility Method,
Available at https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/indexOf
Any copyright is dedicated to the Public Domain.
4. Array map Compatibility Method,
Available at https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/map
Any copyright is dedicated to the Public Domain.
5. Array Reduce Compatibility Method,
Available at https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/Reduce
Any copyright is dedicated to the Public Domain.
6. String Trim Compatibility Method,
Available at https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/Trim
Any copyright is dedicated to the Public Domain.
7. Date now Compatibility Method,
Available at https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/now
Any copyright is dedicated to the Public Domain.
------------JSON2 Script------------------------
json2.js 2012-10-08
Public Domain.
NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
See, http://www.JSON.org/js.html
--------------r.js----------------------
Copyright (c) 2010-2011 Dojo Foundation. All Rights Reserved.
Originally License under MIT License
-------------------------------------------------------------------------
Provided for Informational Purposes Only
MIT License
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
------------------- DefinitelyTyped --------------------
This file is based on or incorporates material from the projects listed below (collectively ?Third Party Code?). Microsoft is not the original author of the Third Party Code. The original copyright notice and the license, under which Microsoft received such Third Party Code, are set forth below. Such licenses and notices are provided for informational purposes only. Microsoft, not the third party, licenses the Third Party Code to you under the terms set forth in the EULA for the Microsoft Product. Microsoft reserves all other rights not expressly granted under this agreement, whether by implication, estoppel or otherwise.
+16 -16
View File
@@ -1182,14 +1182,14 @@ interface Int8Array extends ArrayBufferView {
/**
* Sets a value or an array of values.
* @param A typed or untyped array of values to set.
* @param array A typed or untyped array of values to set.
* @param offset The index in the current array at which the values are to be written.
*/
set(array: Int8Array, offset?: number): void;
/**
* Sets a value or an array of values.
* @param A typed or untyped array of values to set.
* @param array A typed or untyped array of values to set.
* @param offset The index in the current array at which the values are to be written.
*/
set(array: number[], offset?: number): void;
@@ -1240,14 +1240,14 @@ interface Uint8Array extends ArrayBufferView {
/**
* Sets a value or an array of values.
* @param A typed or untyped array of values to set.
* @param array A typed or untyped array of values to set.
* @param offset The index in the current array at which the values are to be written.
*/
set(array: Uint8Array, offset?: number): void;
/**
* Sets a value or an array of values.
* @param A typed or untyped array of values to set.
* @param array A typed or untyped array of values to set.
* @param offset The index in the current array at which the values are to be written.
*/
set(array: number[], offset?: number): void;
@@ -1298,14 +1298,14 @@ interface Int16Array extends ArrayBufferView {
/**
* Sets a value or an array of values.
* @param A typed or untyped array of values to set.
* @param array A typed or untyped array of values to set.
* @param offset The index in the current array at which the values are to be written.
*/
set(array: Int16Array, offset?: number): void;
/**
* Sets a value or an array of values.
* @param A typed or untyped array of values to set.
* @param array A typed or untyped array of values to set.
* @param offset The index in the current array at which the values are to be written.
*/
set(array: number[], offset?: number): void;
@@ -1356,14 +1356,14 @@ interface Uint16Array extends ArrayBufferView {
/**
* Sets a value or an array of values.
* @param A typed or untyped array of values to set.
* @param array A typed or untyped array of values to set.
* @param offset The index in the current array at which the values are to be written.
*/
set(array: Uint16Array, offset?: number): void;
/**
* Sets a value or an array of values.
* @param A typed or untyped array of values to set.
* @param array A typed or untyped array of values to set.
* @param offset The index in the current array at which the values are to be written.
*/
set(array: number[], offset?: number): void;
@@ -1414,14 +1414,14 @@ interface Int32Array extends ArrayBufferView {
/**
* Sets a value or an array of values.
* @param A typed or untyped array of values to set.
* @param array A typed or untyped array of values to set.
* @param offset The index in the current array at which the values are to be written.
*/
set(array: Int32Array, offset?: number): void;
/**
* Sets a value or an array of values.
* @param A typed or untyped array of values to set.
* @param array A typed or untyped array of values to set.
* @param offset The index in the current array at which the values are to be written.
*/
set(array: number[], offset?: number): void;
@@ -1472,14 +1472,14 @@ interface Uint32Array extends ArrayBufferView {
/**
* Sets a value or an array of values.
* @param A typed or untyped array of values to set.
* @param array A typed or untyped array of values to set.
* @param offset The index in the current array at which the values are to be written.
*/
set(array: Uint32Array, offset?: number): void;
/**
* Sets a value or an array of values.
* @param A typed or untyped array of values to set.
* @param array A typed or untyped array of values to set.
* @param offset The index in the current array at which the values are to be written.
*/
set(array: number[], offset?: number): void;
@@ -1530,14 +1530,14 @@ interface Float32Array extends ArrayBufferView {
/**
* Sets a value or an array of values.
* @param A typed or untyped array of values to set.
* @param array A typed or untyped array of values to set.
* @param offset The index in the current array at which the values are to be written.
*/
set(array: Float32Array, offset?: number): void;
/**
* Sets a value or an array of values.
* @param A typed or untyped array of values to set.
* @param array A typed or untyped array of values to set.
* @param offset The index in the current array at which the values are to be written.
*/
set(array: number[], offset?: number): void;
@@ -1588,14 +1588,14 @@ interface Float64Array extends ArrayBufferView {
/**
* Sets a value or an array of values.
* @param A typed or untyped array of values to set.
* @param array A typed or untyped array of values to set.
* @param offset The index in the current array at which the values are to be written.
*/
set(array: Float64Array, offset?: number): void;
/**
* Sets a value or an array of values.
* @param A typed or untyped array of values to set.
* @param array A typed or untyped array of values to set.
* @param offset The index in the current array at which the values are to be written.
*/
set(array: number[], offset?: number): void;
+16 -16
View File
@@ -79,14 +79,14 @@ interface Int8Array extends ArrayBufferView {
/**
* Sets a value or an array of values.
* @param A typed or untyped array of values to set.
* @param array A typed or untyped array of values to set.
* @param offset The index in the current array at which the values are to be written.
*/
set(array: Int8Array, offset?: number): void;
/**
* Sets a value or an array of values.
* @param A typed or untyped array of values to set.
* @param array A typed or untyped array of values to set.
* @param offset The index in the current array at which the values are to be written.
*/
set(array: number[], offset?: number): void;
@@ -137,14 +137,14 @@ interface Uint8Array extends ArrayBufferView {
/**
* Sets a value or an array of values.
* @param A typed or untyped array of values to set.
* @param array A typed or untyped array of values to set.
* @param offset The index in the current array at which the values are to be written.
*/
set(array: Uint8Array, offset?: number): void;
/**
* Sets a value or an array of values.
* @param A typed or untyped array of values to set.
* @param array A typed or untyped array of values to set.
* @param offset The index in the current array at which the values are to be written.
*/
set(array: number[], offset?: number): void;
@@ -195,14 +195,14 @@ interface Int16Array extends ArrayBufferView {
/**
* Sets a value or an array of values.
* @param A typed or untyped array of values to set.
* @param array A typed or untyped array of values to set.
* @param offset The index in the current array at which the values are to be written.
*/
set(array: Int16Array, offset?: number): void;
/**
* Sets a value or an array of values.
* @param A typed or untyped array of values to set.
* @param array A typed or untyped array of values to set.
* @param offset The index in the current array at which the values are to be written.
*/
set(array: number[], offset?: number): void;
@@ -253,14 +253,14 @@ interface Uint16Array extends ArrayBufferView {
/**
* Sets a value or an array of values.
* @param A typed or untyped array of values to set.
* @param array A typed or untyped array of values to set.
* @param offset The index in the current array at which the values are to be written.
*/
set(array: Uint16Array, offset?: number): void;
/**
* Sets a value or an array of values.
* @param A typed or untyped array of values to set.
* @param array A typed or untyped array of values to set.
* @param offset The index in the current array at which the values are to be written.
*/
set(array: number[], offset?: number): void;
@@ -311,14 +311,14 @@ interface Int32Array extends ArrayBufferView {
/**
* Sets a value or an array of values.
* @param A typed or untyped array of values to set.
* @param array A typed or untyped array of values to set.
* @param offset The index in the current array at which the values are to be written.
*/
set(array: Int32Array, offset?: number): void;
/**
* Sets a value or an array of values.
* @param A typed or untyped array of values to set.
* @param array A typed or untyped array of values to set.
* @param offset The index in the current array at which the values are to be written.
*/
set(array: number[], offset?: number): void;
@@ -369,14 +369,14 @@ interface Uint32Array extends ArrayBufferView {
/**
* Sets a value or an array of values.
* @param A typed or untyped array of values to set.
* @param array A typed or untyped array of values to set.
* @param offset The index in the current array at which the values are to be written.
*/
set(array: Uint32Array, offset?: number): void;
/**
* Sets a value or an array of values.
* @param A typed or untyped array of values to set.
* @param array A typed or untyped array of values to set.
* @param offset The index in the current array at which the values are to be written.
*/
set(array: number[], offset?: number): void;
@@ -427,14 +427,14 @@ interface Float32Array extends ArrayBufferView {
/**
* Sets a value or an array of values.
* @param A typed or untyped array of values to set.
* @param array A typed or untyped array of values to set.
* @param offset The index in the current array at which the values are to be written.
*/
set(array: Float32Array, offset?: number): void;
/**
* Sets a value or an array of values.
* @param A typed or untyped array of values to set.
* @param array A typed or untyped array of values to set.
* @param offset The index in the current array at which the values are to be written.
*/
set(array: number[], offset?: number): void;
@@ -485,14 +485,14 @@ interface Float64Array extends ArrayBufferView {
/**
* Sets a value or an array of values.
* @param A typed or untyped array of values to set.
* @param array A typed or untyped array of values to set.
* @param offset The index in the current array at which the values are to be written.
*/
set(array: Float64Array, offset?: number): void;
/**
* Sets a value or an array of values.
* @param A typed or untyped array of values to set.
* @param array A typed or untyped array of values to set.
* @param offset The index in the current array at which the values are to be written.
*/
set(array: number[], offset?: number): void;
+16 -16
View File
@@ -79,14 +79,14 @@ interface Int8Array extends ArrayBufferView {
/**
* Sets a value or an array of values.
* @param A typed or untyped array of values to set.
* @param array A typed or untyped array of values to set.
* @param offset The index in the current array at which the values are to be written.
*/
set(array: Int8Array, offset?: number): void;
/**
* Sets a value or an array of values.
* @param A typed or untyped array of values to set.
* @param array A typed or untyped array of values to set.
* @param offset The index in the current array at which the values are to be written.
*/
set(array: number[], offset?: number): void;
@@ -137,14 +137,14 @@ interface Uint8Array extends ArrayBufferView {
/**
* Sets a value or an array of values.
* @param A typed or untyped array of values to set.
* @param array A typed or untyped array of values to set.
* @param offset The index in the current array at which the values are to be written.
*/
set(array: Uint8Array, offset?: number): void;
/**
* Sets a value or an array of values.
* @param A typed or untyped array of values to set.
* @param array A typed or untyped array of values to set.
* @param offset The index in the current array at which the values are to be written.
*/
set(array: number[], offset?: number): void;
@@ -195,14 +195,14 @@ interface Int16Array extends ArrayBufferView {
/**
* Sets a value or an array of values.
* @param A typed or untyped array of values to set.
* @param array A typed or untyped array of values to set.
* @param offset The index in the current array at which the values are to be written.
*/
set(array: Int16Array, offset?: number): void;
/**
* Sets a value or an array of values.
* @param A typed or untyped array of values to set.
* @param array A typed or untyped array of values to set.
* @param offset The index in the current array at which the values are to be written.
*/
set(array: number[], offset?: number): void;
@@ -253,14 +253,14 @@ interface Uint16Array extends ArrayBufferView {
/**
* Sets a value or an array of values.
* @param A typed or untyped array of values to set.
* @param array A typed or untyped array of values to set.
* @param offset The index in the current array at which the values are to be written.
*/
set(array: Uint16Array, offset?: number): void;
/**
* Sets a value or an array of values.
* @param A typed or untyped array of values to set.
* @param array A typed or untyped array of values to set.
* @param offset The index in the current array at which the values are to be written.
*/
set(array: number[], offset?: number): void;
@@ -311,14 +311,14 @@ interface Int32Array extends ArrayBufferView {
/**
* Sets a value or an array of values.
* @param A typed or untyped array of values to set.
* @param array A typed or untyped array of values to set.
* @param offset The index in the current array at which the values are to be written.
*/
set(array: Int32Array, offset?: number): void;
/**
* Sets a value or an array of values.
* @param A typed or untyped array of values to set.
* @param array A typed or untyped array of values to set.
* @param offset The index in the current array at which the values are to be written.
*/
set(array: number[], offset?: number): void;
@@ -369,14 +369,14 @@ interface Uint32Array extends ArrayBufferView {
/**
* Sets a value or an array of values.
* @param A typed or untyped array of values to set.
* @param array A typed or untyped array of values to set.
* @param offset The index in the current array at which the values are to be written.
*/
set(array: Uint32Array, offset?: number): void;
/**
* Sets a value or an array of values.
* @param A typed or untyped array of values to set.
* @param array A typed or untyped array of values to set.
* @param offset The index in the current array at which the values are to be written.
*/
set(array: number[], offset?: number): void;
@@ -427,14 +427,14 @@ interface Float32Array extends ArrayBufferView {
/**
* Sets a value or an array of values.
* @param A typed or untyped array of values to set.
* @param array A typed or untyped array of values to set.
* @param offset The index in the current array at which the values are to be written.
*/
set(array: Float32Array, offset?: number): void;
/**
* Sets a value or an array of values.
* @param A typed or untyped array of values to set.
* @param array A typed or untyped array of values to set.
* @param offset The index in the current array at which the values are to be written.
*/
set(array: number[], offset?: number): void;
@@ -485,14 +485,14 @@ interface Float64Array extends ArrayBufferView {
/**
* Sets a value or an array of values.
* @param A typed or untyped array of values to set.
* @param array A typed or untyped array of values to set.
* @param offset The index in the current array at which the values are to be written.
*/
set(array: Float64Array, offset?: number): void;
/**
* Sets a value or an array of values.
* @param A typed or untyped array of values to set.
* @param array A typed or untyped array of values to set.
* @param offset The index in the current array at which the values are to be written.
*/
set(array: number[], offset?: number): void;
+2484 -2071
View File
File diff suppressed because it is too large Load Diff
+5084 -3579
View File
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
+1 -1
View File
@@ -226,7 +226,7 @@ module ts {
function bindConstructorDeclaration(node: ConstructorDeclaration) {
bindDeclaration(node, SymbolFlags.Constructor, 0);
forEach(node.parameters, p => {
if (p.flags & (NodeFlags.Public | NodeFlags.Private)) {
if (p.flags & (NodeFlags.Public | NodeFlags.Private | NodeFlags.Protected)) {
bindDeclaration(p, SymbolFlags.Property, SymbolFlags.PropertyExcludes);
}
});
+503 -221
View File
File diff suppressed because it is too large Load Diff
@@ -138,9 +138,9 @@ module ts {
Type_0_is_not_assignable_to_type_1_Colon: { code: 2322, category: DiagnosticCategory.Error, key: "Type '{0}' is not assignable to type '{1}':" },
Type_0_is_not_assignable_to_type_1: { code: 2323, category: DiagnosticCategory.Error, key: "Type '{0}' is not assignable to type '{1}'." },
Property_0_is_missing_in_type_1: { code: 2324, category: DiagnosticCategory.Error, key: "Property '{0}' is missing in type '{1}'." },
Private_property_0_cannot_be_reimplemented: { code: 2325, category: DiagnosticCategory.Error, key: "Private property '{0}' cannot be reimplemented." },
Property_0_is_private_in_type_1_but_not_in_type_2: { code: 2325, category: DiagnosticCategory.Error, key: "Property '{0}' is private in type '{1}' but not in type '{2}'." },
Types_of_property_0_are_incompatible_Colon: { code: 2326, category: DiagnosticCategory.Error, key: "Types of property '{0}' are incompatible:" },
Required_property_0_cannot_be_reimplemented_with_optional_property_in_1: { code: 2327, category: DiagnosticCategory.Error, key: "Required property '{0}' cannot be reimplemented with optional property in '{1}'." },
Property_0_is_optional_in_type_1_but_required_in_type_2: { code: 2327, category: DiagnosticCategory.Error, key: "Property '{0}' is optional in type '{1}' but required in type '{2}'." },
Types_of_parameters_0_and_1_are_incompatible_Colon: { code: 2328, category: DiagnosticCategory.Error, key: "Types of parameters '{0}' and '{1}' are incompatible:" },
Index_signature_is_missing_in_type_0: { code: 2329, category: DiagnosticCategory.Error, key: "Index signature is missing in type '{0}'." },
Index_signatures_are_incompatible_Colon: { code: 2330, category: DiagnosticCategory.Error, key: "Index signatures are incompatible:" },
@@ -153,8 +153,8 @@ module ts {
Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors: { code: 2337, category: DiagnosticCategory.Error, key: "Super calls are not permitted outside constructors or in nested functions inside constructors" },
super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class: { code: 2338, category: DiagnosticCategory.Error, key: "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class" },
Property_0_does_not_exist_on_type_1: { code: 2339, category: DiagnosticCategory.Error, key: "Property '{0}' does not exist on type '{1}'." },
Only_public_methods_of_the_base_class_are_accessible_via_the_super_keyword: { code: 2340, category: DiagnosticCategory.Error, key: "Only public methods of the base class are accessible via the 'super' keyword" },
Property_0_is_inaccessible: { code: 2341, category: DiagnosticCategory.Error, key: "Property '{0}' is inaccessible." },
Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: { code: 2340, category: DiagnosticCategory.Error, key: "Only public and protected methods of the base class are accessible via the 'super' keyword" },
Property_0_is_private_and_only_accessible_within_class_1: { code: 2341, category: DiagnosticCategory.Error, key: "Property '{0}' is private and only accessible within class '{1}'." },
An_index_expression_argument_must_be_of_type_string_number_or_any: { code: 2342, category: DiagnosticCategory.Error, key: "An index expression argument must be of type 'string', 'number', or 'any'." },
Type_0_does_not_satisfy_the_constraint_1_Colon: { code: 2343, category: DiagnosticCategory.Error, key: "Type '{0}' does not satisfy the constraint '{1}':" },
Type_0_does_not_satisfy_the_constraint_1: { code: 2344, category: DiagnosticCategory.Error, key: "Type '{0}' does not satisfy the constraint '{1}'." },
@@ -198,7 +198,7 @@ module ts {
Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature: { code: 2382, category: DiagnosticCategory.Error, key: "Specialized overload signature is not assignable to any non-specialized signature." },
Overload_signatures_must_all_be_exported_or_not_exported: { code: 2383, category: DiagnosticCategory.Error, key: "Overload signatures must all be exported or not exported." },
Overload_signatures_must_all_be_ambient_or_non_ambient: { code: 2384, category: DiagnosticCategory.Error, key: "Overload signatures must all be ambient or non-ambient." },
Overload_signatures_must_all_be_public_or_private: { code: 2385, category: DiagnosticCategory.Error, key: "Overload signatures must all be public or private." },
Overload_signatures_must_all_be_public_private_or_protected: { code: 2385, category: DiagnosticCategory.Error, key: "Overload signatures must all be public, private or protected." },
Overload_signatures_must_all_be_optional_or_required: { code: 2386, category: DiagnosticCategory.Error, key: "Overload signatures must all be optional or required." },
Function_overload_must_be_static: { code: 2387, category: DiagnosticCategory.Error, key: "Function overload must be static." },
Function_overload_must_not_be_static: { code: 2388, category: DiagnosticCategory.Error, key: "Function overload must not be static." },
@@ -255,6 +255,11 @@ module ts {
Import_declaration_in_an_ambient_external_module_declaration_cannot_reference_external_module_through_relative_external_module_name: { code: 2439, category: DiagnosticCategory.Error, key: "Import declaration in an ambient external module declaration cannot reference external module through relative external module name." },
Import_declaration_conflicts_with_local_declaration_of_0: { code: 2440, category: DiagnosticCategory.Error, key: "Import declaration conflicts with local declaration of '{0}'" },
Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_an_external_module: { code: 2441, category: DiagnosticCategory.Error, key: "Duplicate identifier '{0}'. Compiler reserves name '{1}' in top level scope of an external module." },
Types_have_separate_declarations_of_a_private_property_0: { code: 2442, category: DiagnosticCategory.Error, key: "Types have separate declarations of a private property '{0}'." },
Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2: { code: 2443, category: DiagnosticCategory.Error, key: "Property '{0}' is protected but type '{1}' is not a class derived from '{2}'." },
Property_0_is_protected_in_type_1_but_public_in_type_2: { code: 2444, category: DiagnosticCategory.Error, key: "Property '{0}' is protected in type '{1}' but public in type '{2}'." },
Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses: { code: 2445, category: DiagnosticCategory.Error, key: "Property '{0}' is protected and only accessible within class '{1}' and its subclasses." },
Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1: { code: 2446, category: DiagnosticCategory.Error, key: "Property '{0}' is protected and only accessible through an instance of class '{1}'." },
Import_declaration_0_is_using_private_name_1: { code: 4000, category: DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." },
Type_parameter_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4001, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using name '{1}' from private module '{2}'." },
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." },
+25 -6
View File
@@ -544,7 +544,7 @@
"category": "Error",
"code": 2324
},
"Private property '{0}' cannot be reimplemented.": {
"Property '{0}' is private in type '{1}' but not in type '{2}'.": {
"category": "Error",
"code": 2325
},
@@ -552,7 +552,7 @@
"category": "Error",
"code": 2326
},
"Required property '{0}' cannot be reimplemented with optional property in '{1}'.": {
"Property '{0}' is optional in type '{1}' but required in type '{2}'.": {
"category": "Error",
"code": 2327
},
@@ -604,11 +604,11 @@
"category": "Error",
"code": 2339
},
"Only public methods of the base class are accessible via the 'super' keyword": {
"Only public and protected methods of the base class are accessible via the 'super' keyword": {
"category": "Error",
"code": 2340
},
"Property '{0}' is inaccessible.": {
"Property '{0}' is private and only accessible within class '{1}'.": {
"category": "Error",
"code": 2341
},
@@ -784,7 +784,7 @@
"category": "Error",
"code": 2384
},
"Overload signatures must all be public or private.": {
"Overload signatures must all be public, private or protected.": {
"category": "Error",
"code": 2385
},
@@ -1012,7 +1012,26 @@
"category": "Error",
"code": 2441
},
"Types have separate declarations of a private property '{0}'.": {
"category": "Error",
"code": 2442
},
"Property '{0}' is protected but type '{1}' is not a class derived from '{2}'.": {
"category": "Error",
"code": 2443
},
"Property '{0}' is protected in type '{1}' but public in type '{2}'.": {
"category": "Error",
"code": 2444
},
"Property '{0}' is protected and only accessible within class '{1}' and its subclasses.": {
"category": "Error",
"code": 2445
},
"Property '{0}' is protected and only accessible through an instance of class '{1}'.": {
"category": "Error",
"code": 2446
},
"Import declaration '{0}' is using private name '{1}'.": {
"category": "Error",
+91 -37
View File
@@ -101,7 +101,7 @@ module ts {
};
}
function createTextWriter(writeSymbol: (symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags)=> void): EmitTextWriter {
function createTextWriter(trackSymbol: (symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags)=> void): EmitTextWriter {
var output = "";
var indent = 0;
var lineStart = true;
@@ -149,7 +149,7 @@ module ts {
return {
write: write,
writeSymbol: writeSymbol,
trackSymbol: trackSymbol,
rawWrite: rawWrite,
writeLiteral: writeLiteral,
writeLine: writeLine,
@@ -182,7 +182,7 @@ module ts {
});
}
function emitComments(comments: Comment[], trailingSeparator: boolean, writer: EmitTextWriter, writeComment: (comment: Comment, writer: EmitTextWriter) => void) {
function emitComments(comments: CommentRange[], trailingSeparator: boolean, writer: EmitTextWriter, writeComment: (comment: CommentRange, writer: EmitTextWriter) => void) {
var emitLeadingSpace = !trailingSeparator;
forEach(comments, comment => {
if (emitLeadingSpace) {
@@ -203,7 +203,7 @@ module ts {
});
}
function emitNewLineBeforeLeadingComments(node: TextRange, leadingComments: Comment[], writer: EmitTextWriter) {
function emitNewLineBeforeLeadingComments(node: TextRange, leadingComments: CommentRange[], writer: EmitTextWriter) {
// If the leading comments start on different line than the start of node, write new line
if (leadingComments && leadingComments.length && node.pos !== leadingComments[0].pos &&
getLineOfLocalPosition(node.pos) !== getLineOfLocalPosition(leadingComments[0].pos)) {
@@ -211,7 +211,7 @@ module ts {
}
}
function writeCommentRange(comment: Comment, writer: EmitTextWriter) {
function writeCommentRange(comment: CommentRange, writer: EmitTextWriter) {
if (currentSourceFile.text.charCodeAt(comment.pos + 1) === CharacterCodes.asterisk) {
var firstCommentLineAndCharacter = currentSourceFile.getLineAndCharacterFromPosition(comment.pos);
var firstCommentLineIndent: number;
@@ -307,7 +307,7 @@ module ts {
}
function emitJavaScript(jsFilePath: string, root?: SourceFile) {
var writer = createTextWriter(writeSymbol);
var writer = createTextWriter(trackSymbol);
var write = writer.write;
var writeLine = writer.writeLine;
var increaseIndent = writer.increaseIndent;
@@ -363,7 +363,7 @@ module ts {
/** Sourcemap data that will get encoded */
var sourceMapData: SourceMapData;
function writeSymbol(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags) { }
function trackSymbol(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags) { }
function initializeEmitterWithSourceMaps() {
var sourceMapDir: string; // The directory in which sourcemap will be
@@ -585,23 +585,71 @@ module ts {
sourceMapNameIndices.pop();
};
function writeCommentRangeWithMap(comment: Comment, writer: EmitTextWriter) {
function writeCommentRangeWithMap(comment: CommentRange, writer: EmitTextWriter) {
recordSourceMapSpan(comment.pos);
writeCommentRange(comment, writer);
recordSourceMapSpan(comment.end);
}
var escapedCharsRegExp = /[\t\v\f\b\0\r\n\"\u2028\u2029\u0085]/g;
var escapedCharsMap: Map<string> = {
"\t": "\\t",
"\v": "\\v",
"\f": "\\f",
"\b": "\\b",
"\0": "\\0",
"\r": "\\r",
"\n": "\\n",
"\"": "\\\"",
"\u2028": "\\u2028", // lineSeparator
"\u2029": "\\u2029", // paragraphSeparator
"\u0085": "\\u0085" // nextLine
};
function serializeSourceMapContents(version: number, file: string, sourceRoot: string, sources: string[], names: string[], mappings: string) {
if (typeof JSON !== "undefined") {
return JSON.stringify({
version: version,
file: file,
sourceRoot: sourceRoot,
sources: sources,
names: names,
mappings: mappings
});
}
return "{\"version\":" + version + ",\"file\":\"" + escapeString(file) + "\",\"sourceRoot\":\"" + escapeString(sourceRoot) + "\",\"sources\":[" + serializeStringArray(sources) + "],\"names\":[" + serializeStringArray(names) + "],\"mappings\":\"" + escapeString(mappings) + "\"}";
/** This does not support the full escape characters, it only supports the subset that can be used in file names
* or string literals. If the information encoded in the map changes, this needs to be revisited. */
function escapeString(s: string): string {
return escapedCharsRegExp.test(s) ? s.replace(escapedCharsRegExp, c => {
return escapedCharsMap[c] || c;
}) : s;
}
function serializeStringArray(list: string[]): string {
var output = "";
for (var i = 0, n = list.length; i < n; i++) {
if (i) {
output += ",";
}
output += "\"" + escapeString(list[i]) + "\"";
}
return output;
}
}
function writeJavaScriptAndSourceMapFile(emitOutput: string, writeByteOrderMark: boolean) {
// Write source map file
encodeLastRecordedSourceMapSpan();
writeFile(sourceMapData.sourceMapFilePath, JSON.stringify({
version: 3,
file: sourceMapData.sourceMapFile,
sourceRoot: sourceMapData.sourceMapSourceRoot,
sources: sourceMapData.sourceMapSources,
names: sourceMapData.sourceMapNames,
mappings: sourceMapData.sourceMapMappings
}), /*writeByteOrderMark*/ false);
writeFile(sourceMapData.sourceMapFilePath, serializeSourceMapContents(
3,
sourceMapData.sourceMapFile,
sourceMapData.sourceMapSourceRoot,
sourceMapData.sourceMapSources,
sourceMapData.sourceMapNames,
sourceMapData.sourceMapMappings), /*writeByteOrderMark*/ false);
sourceMapDataList.push(sourceMapData);
// Write sourcemap url to the js file and write the js file
@@ -868,14 +916,15 @@ module ts {
}
function emitPropertyAccess(node: PropertyAccess) {
var text = resolver.getPropertyAccessSubstitution(node);
if (text) {
write(text);
return;
var constantValue = resolver.getConstantValue(node);
if (constantValue !== undefined) {
write(constantValue.toString() + " /* " + identifierToString(node.right) + " */");
}
else {
emit(node.left);
write(".");
emit(node.right);
}
emit(node.left);
write(".");
emit(node.right);
}
function emitIndexedAccess(node: IndexedAccess) {
@@ -2107,7 +2156,7 @@ module ts {
function getLeadingCommentsWithoutDetachedComments() {
// get the leading comments from detachedPos
var leadingComments = getLeadingComments(currentSourceFile.text, detachedCommentsInfo[detachedCommentsInfo.length - 1].detachedCommentEndPos);
var leadingComments = getLeadingCommentRanges(currentSourceFile.text, detachedCommentsInfo[detachedCommentsInfo.length - 1].detachedCommentEndPos);
if (detachedCommentsInfo.length - 1) {
detachedCommentsInfo.pop();
}
@@ -2121,14 +2170,14 @@ module ts {
function getLeadingCommentsToEmit(node: Node) {
// Emit the leading comments only if the parent's pos doesn't match because parent should take care of emitting these comments
if (node.parent.kind === SyntaxKind.SourceFile || node.pos !== node.parent.pos) {
var leadingComments: Comment[];
var leadingComments: CommentRange[];
if (hasDetachedComments(node.pos)) {
// get comments without detached comments
leadingComments = getLeadingCommentsWithoutDetachedComments();
}
else {
// get the leading comments from the node
leadingComments = getLeadingCommentsOfNode(node, currentSourceFile);
leadingComments = getLeadingCommentRangesOfNode(node, currentSourceFile);
}
return leadingComments;
}
@@ -2144,21 +2193,21 @@ module ts {
function emitTrailingDeclarationComments(node: Node) {
// Emit the trailing comments only if the parent's end doesn't match
if (node.parent.kind === SyntaxKind.SourceFile || node.end !== node.parent.end) {
var trailingComments = getTrailingComments(currentSourceFile.text, node.end);
var trailingComments = getTrailingCommentRanges(currentSourceFile.text, node.end);
// trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/
emitComments(trailingComments, /*trailingSeparator*/ false, writer, writeComment);
}
}
function emitLeadingCommentsOfLocalPosition(pos: number) {
var leadingComments: Comment[];
var leadingComments: CommentRange[];
if (hasDetachedComments(pos)) {
// get comments without detached comments
leadingComments = getLeadingCommentsWithoutDetachedComments();
}
else {
// get the leading comments from the node
leadingComments = getLeadingComments(currentSourceFile.text, pos);
leadingComments = getLeadingCommentRanges(currentSourceFile.text, pos);
}
emitNewLineBeforeLeadingComments({ pos: pos, end: pos }, leadingComments, writer);
// Leading comments are emitted at /*leading comment1 */space/*leading comment*/space
@@ -2166,10 +2215,10 @@ module ts {
}
function emitDetachedCommentsAtPosition(node: TextRange) {
var leadingComments = getLeadingComments(currentSourceFile.text, node.pos);
var leadingComments = getLeadingCommentRanges(currentSourceFile.text, node.pos);
if (leadingComments) {
var detachedComments: Comment[] = [];
var lastComment: Comment;
var detachedComments: CommentRange[] = [];
var lastComment: CommentRange;
forEach(leadingComments, comment => {
if (lastComment) {
@@ -2213,7 +2262,7 @@ module ts {
function emitPinnedOrTripleSlashCommentsOfNode(node: Node) {
var pinnedComments = ts.filter(getLeadingCommentsToEmit(node), isPinnedOrTripleSlashComment);
function isPinnedOrTripleSlashComment(comment: Comment) {
function isPinnedOrTripleSlashComment(comment: CommentRange) {
if (currentSourceFile.text.charCodeAt(comment.pos + 1) === CharacterCodes.asterisk) {
return currentSourceFile.text.charCodeAt(comment.pos + 2) === CharacterCodes.exclamation;
}
@@ -2252,7 +2301,7 @@ module ts {
}
function emitDeclarations(jsFilePath: string, root?: SourceFile) {
var writer = createTextWriter(writeSymbol);
var writer = createTextWriter(trackSymbol);
var write = writer.write;
var writeLine = writer.writeLine;
var increaseIndent = writer.increaseIndent;
@@ -2280,7 +2329,7 @@ module ts {
var oldWriter = writer;
forEach(importDeclarations, aliasToWrite => {
var aliasEmitInfo = forEach(aliasDeclarationEmitInfo, declEmitInfo => declEmitInfo.declaration === aliasToWrite ? declEmitInfo : undefined);
writer = createTextWriter(writeSymbol);
writer = createTextWriter(trackSymbol);
for (var declarationIndent = aliasEmitInfo.indent; declarationIndent; declarationIndent--) {
writer.increaseIndent();
}
@@ -2291,10 +2340,9 @@ module ts {
writer = oldWriter;
}
function writeSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags) {
function trackSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags) {
var symbolAccesibilityResult = resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning);
if (symbolAccesibilityResult.accessibility === SymbolAccessibility.Accessible) {
resolver.writeSymbol(symbol, enclosingDeclaration, meaning, writer);
// write the aliases
if (symbolAccesibilityResult && symbolAccesibilityResult.aliasesToMakeVisible) {
@@ -2371,12 +2419,18 @@ module ts {
if (node.flags & NodeFlags.Private) {
write("private ");
}
else if (node.flags & NodeFlags.Protected) {
write("protected ");
}
write("static ");
}
else {
if (node.flags & NodeFlags.Private) {
write("private ");
}
else if (node.flags & NodeFlags.Protected) {
write("protected ");
}
// If the node is parented in the current source file we need to emit export declare or just export
else if (node.parent === currentSourceFile) {
// If the node is exported
+32 -7
View File
@@ -131,25 +131,27 @@ module ts {
return (<Identifier>(<ExpressionStatement>node).expression).text === "use strict";
}
export function getLeadingCommentsOfNode(node: Node, sourceFileOfNode: SourceFile) {
export function getLeadingCommentRangesOfNode(node: Node, sourceFileOfNode?: SourceFile) {
sourceFileOfNode = sourceFileOfNode || getSourceFileOfNode(node);
// If parameter/type parameter, the prev token trailing comments are part of this node too
if (node.kind === SyntaxKind.Parameter || node.kind === SyntaxKind.TypeParameter) {
// e.g. (/** blah */ a, /** blah */ b);
return concatenate(getTrailingComments(sourceFileOfNode.text, node.pos),
return concatenate(getTrailingCommentRanges(sourceFileOfNode.text, node.pos),
// e.g.: (
// /** blah */ a,
// /** blah */ b);
getLeadingComments(sourceFileOfNode.text, node.pos));
getLeadingCommentRanges(sourceFileOfNode.text, node.pos));
}
else {
return getLeadingComments(sourceFileOfNode.text, node.pos);
return getLeadingCommentRanges(sourceFileOfNode.text, node.pos);
}
}
export function getJsDocComments(node: Declaration, sourceFileOfNode: SourceFile) {
return filter(getLeadingCommentsOfNode(node, sourceFileOfNode), comment => isJsDocComment(comment));
return filter(getLeadingCommentRangesOfNode(node, sourceFileOfNode), comment => isJsDocComment(comment));
function isJsDocComment(comment: Comment) {
function isJsDocComment(comment: CommentRange) {
// True if the comment starts with '/**' but not if it is '/**/'
return sourceFileOfNode.text.charCodeAt(comment.pos + 1) === CharacterCodes.asterisk &&
sourceFileOfNode.text.charCodeAt(comment.pos + 2) === CharacterCodes.asterisk &&
@@ -649,6 +651,7 @@ module ts {
switch (token) {
case SyntaxKind.PublicKeyword:
case SyntaxKind.PrivateKeyword:
case SyntaxKind.ProtectedKeyword:
case SyntaxKind.StaticKeyword:
case SyntaxKind.ExportKeyword:
case SyntaxKind.DeclareKeyword:
@@ -811,7 +814,7 @@ module ts {
// applying some stricter checks on that node.
function grammarErrorOnNode(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): void {
var span = getErrorSpanForNode(node);
var start = skipTrivia(file.text, span.pos);
var start = span.end > span.pos ? skipTrivia(file.text, span.pos) : span.pos;
var length = span.end - start;
file.syntacticErrors.push(createFileDiagnostic(file, start, length, message, arg0, arg1, arg2));
@@ -2977,6 +2980,7 @@ module ts {
}
case SyntaxKind.PublicKeyword:
case SyntaxKind.PrivateKeyword:
case SyntaxKind.ProtectedKeyword:
case SyntaxKind.StaticKeyword:
// When followed by an identifier or keyword, these do not start a statement but
// might instead be following type members
@@ -3295,6 +3299,8 @@ module ts {
var lastDeclareModifierLength: number;
var lastPrivateModifierStart: number;
var lastPrivateModifierLength: number;
var lastProtectedModifierStart: number;
var lastProtectedModifierLength: number;
while (true) {
var modifierStart = scanner.getTokenPos();
@@ -3334,6 +3340,21 @@ module ts {
flags |= NodeFlags.Private;
break;
case SyntaxKind.ProtectedKeyword:
if (flags & NodeFlags.Public || flags & NodeFlags.Private || flags & NodeFlags.Protected) {
grammarErrorAtPos(modifierStart, modifierLength, Diagnostics.Accessibility_modifier_already_seen);
}
else if (flags & NodeFlags.Static) {
grammarErrorAtPos(modifierStart, modifierLength, Diagnostics._0_modifier_must_precede_1_modifier, "protected", "static");
}
else if (context === ModifierContext.ModuleElements || context === ModifierContext.SourceElements) {
grammarErrorAtPos(modifierStart, modifierLength, Diagnostics._0_modifier_cannot_appear_on_a_module_element, "protected");
}
lastProtectedModifierStart = modifierStart;
lastProtectedModifierLength = modifierLength;
flags |= NodeFlags.Protected;
break;
case SyntaxKind.StaticKeyword:
if (flags & NodeFlags.Static) {
grammarErrorAtPos(modifierStart, modifierLength, Diagnostics._0_modifier_already_seen, "static");
@@ -3391,6 +3412,9 @@ module ts {
else if (token === SyntaxKind.ConstructorKeyword && flags & NodeFlags.Private) {
grammarErrorAtPos(lastPrivateModifierStart, lastPrivateModifierLength, Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "private");
}
else if (token === SyntaxKind.ConstructorKeyword && flags & NodeFlags.Protected) {
grammarErrorAtPos(lastProtectedModifierStart, lastProtectedModifierLength, Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "protected");
}
else if (token === SyntaxKind.ImportKeyword) {
if (flags & NodeFlags.Ambient) {
grammarErrorAtPos(lastDeclareModifierStart, lastDeclareModifierLength, Diagnostics.A_declare_modifier_cannot_be_used_with_an_import_declaration, "declare");
@@ -3667,6 +3691,7 @@ module ts {
case SyntaxKind.DeclareKeyword:
case SyntaxKind.PublicKeyword:
case SyntaxKind.PrivateKeyword:
case SyntaxKind.ProtectedKeyword:
case SyntaxKind.StaticKeyword:
// Check for modifier on source element
return lookAhead(() => { nextToken(); return isDeclaration(); });
+4 -4
View File
@@ -371,8 +371,8 @@ module ts {
// between the given position and the next line break are returned. The return value is an array containing a TextRange for each
// comment. Single-line comment ranges include the beginning '//' characters but not the ending line break. Multi-line comment
// ranges include the beginning '/* and ending '*/' characters. The return value is undefined if no comments were found.
function getCommentRanges(text: string, pos: number, trailing: boolean): Comment[] {
var result: Comment[];
function getCommentRanges(text: string, pos: number, trailing: boolean): CommentRange[] {
var result: CommentRange[];
var collecting = trailing || pos === 0;
while (true) {
var ch = text.charCodeAt(pos);
@@ -440,11 +440,11 @@ module ts {
}
}
export function getLeadingComments(text: string, pos: number): Comment[] {
export function getLeadingCommentRanges(text: string, pos: number): CommentRange[] {
return getCommentRanges(text, pos, /*trailing*/ false);
}
export function getTrailingComments(text: string, pos: number): Comment[] {
export function getTrailingCommentRanges(text: string, pos: number): CommentRange[] {
return getCommentRanges(text, pos, /*trailing*/ true);
}
+32 -15
View File
@@ -199,8 +199,14 @@ module ts {
export function executeCommandLine(args: string[]): void {
var commandLine = parseCommandLine(args);
var compilerOptions = commandLine.options;
if (compilerOptions.locale) {
if (typeof JSON === "undefined") {
reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--locale"));
return sys.exit(1);
}
if (commandLine.options.locale) {
validateLocaleAndSetLanguage(commandLine.options.locale, commandLine.errors);
}
@@ -208,32 +214,38 @@ module ts {
// setting up localization, report them and quit.
if (commandLine.errors.length > 0) {
reportDiagnostics(commandLine.errors);
return sys.exit(1);
return sys.exit(EmitReturnStatus.CompilerOptionsErrors);
}
if (commandLine.options.version) {
if (compilerOptions.version) {
reportDiagnostic(createCompilerDiagnostic(Diagnostics.Version_0, version));
return sys.exit(0);
return sys.exit(EmitReturnStatus.Succeeded);
}
if (commandLine.options.help || commandLine.filenames.length === 0) {
if (compilerOptions.help) {
printVersion();
printHelp();
return sys.exit(0);
return sys.exit(EmitReturnStatus.Succeeded);
}
var defaultCompilerHost = createCompilerHost(commandLine.options);
if (commandLine.filenames.length === 0) {
printVersion();
printHelp();
return sys.exit(EmitReturnStatus.CompilerOptionsErrors);
}
var defaultCompilerHost = createCompilerHost(compilerOptions);
if (commandLine.options.watch) {
if (compilerOptions.watch) {
if (!sys.watchFile) {
reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--watch"));
return sys.exit(1);
return sys.exit(EmitReturnStatus.CompilerOptionsErrors);
}
watchProgram(commandLine, defaultCompilerHost);
}
else {
var result = compile(commandLine, defaultCompilerHost).errors.length > 0 ? 1 : 0;
var result = compile(commandLine, defaultCompilerHost).exitStatus
return sys.exit(result);
}
}
@@ -328,21 +340,27 @@ module ts {
function compile(commandLine: ParsedCommandLine, compilerHost: CompilerHost) {
var parseStart = new Date().getTime();
var program = createProgram(commandLine.filenames, commandLine.options, compilerHost);
var compilerOptions = commandLine.options;
var program = createProgram(commandLine.filenames, compilerOptions, compilerHost);
var bindStart = new Date().getTime();
var errors = program.getDiagnostics();
var errors: Diagnostic[] = program.getDiagnostics();
var exitStatus: EmitReturnStatus;
if (errors.length) {
var checkStart = bindStart;
var emitStart = bindStart;
var reportStart = bindStart;
exitStatus = EmitReturnStatus.AllOutputGenerationSkipped;
}
else {
var checker = program.getTypeChecker(/*fullTypeCheckMode*/ true);
var checkStart = new Date().getTime();
var semanticErrors = checker.getDiagnostics();
var emitStart = new Date().getTime();
var emitErrors = checker.emitFiles().errors;
var emitOutput = checker.emitFiles();
var emitErrors = emitOutput.errors;
exitStatus = emitOutput.emitResultStatus;
var reportStart = new Date().getTime();
errors = concatenate(semanticErrors, emitErrors);
}
@@ -366,8 +384,7 @@ module ts {
reportTimeStatistic("Total time", reportStart - parseStart);
}
return { program: program, errors: errors };
return { program: program, exitStatus: exitStatus }
}
function printVersion() {
+74 -19
View File
@@ -238,13 +238,14 @@ module ts {
Rest = 0x00000008, // Parameter
Public = 0x00000010, // Property/Method
Private = 0x00000020, // Property/Method
Static = 0x00000040, // Property/Method
MultiLine = 0x00000080, // Multi-line array or object literal
Synthetic = 0x00000100, // Synthetic node (for full fidelity)
DeclarationFile = 0x00000200, // Node is a .d.ts file
Protected = 0x00000040, // Property/Method
Static = 0x00000080, // Property/Method
MultiLine = 0x00000100, // Multi-line array or object literal
Synthetic = 0x00000200, // Synthetic node (for full fidelity)
DeclarationFile = 0x00000400, // Node is a .d.ts file
Modifier = Export | Ambient | Public | Private | Static,
AccessibilityModifier = Public | Private
Modifier = Export | Ambient | Public | Private | Protected | Static,
AccessibilityModifier = Public | Private | Protected
}
export interface Node extends TextRange {
@@ -528,7 +529,7 @@ module ts {
filename: string;
}
export interface Comment extends TextRange {
export interface CommentRange extends TextRange {
hasTrailingNewLine?: boolean;
}
@@ -603,10 +604,11 @@ module ts {
// Return code used by getEmitOutput function to indicate status of the function
export enum EmitReturnStatus {
Succeeded = 0, // All outputs generated as requested (.js, .map, .d.ts), no errors reported
AllOutputGenerationSkipped = 1, // No .js generated because of syntax errors, or compiler options errors, nothing generated
AllOutputGenerationSkipped = 1, // No .js generated because of syntax errors, nothing generated
JSGeneratedWithSemanticErrors = 2, // .js and .map generated with semantic errors
DeclarationGenerationSkipped = 3, // .d.ts generation skipped because of semantic errors or declaration emitter specific errors; Output .js with semantic errors
EmitErrorsEncountered = 4 // Emitter errors occurred during emitting process
EmitErrorsEncountered = 4, // Emitter errors occurred during emitting process
CompilerOptionsErrors = 5, // Errors occurred in parsing compiler options, nothing generated
}
export interface EmitResult {
@@ -638,15 +640,21 @@ module ts {
getApparentType(type: Type): ApparentType;
typeToString(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string;
symbolToString(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): string;
typeToDisplayParts(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): SymbolDisplayPart[];
symbolToDisplayParts(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): SymbolDisplayPart[];
getFullyQualifiedName(symbol: Symbol): string;
getAugmentedPropertiesOfApparentType(type: Type): Symbol[];
getRootSymbol(symbol: Symbol): Symbol;
getContextualType(node: Node): Type;
// Returns the constant value of this enum member, or 'undefined' if the enum member has a
// computed value.
getEnumMemberValue(node: EnumMember): number;
}
export interface TextWriter {
write(s: string): void;
writeSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): void;
trackSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): void;
writeLine(): void;
increaseIndent(): void;
decreaseIndent(): void;
@@ -677,7 +685,6 @@ module ts {
getProgram(): Program;
getLocalNameOfContainer(container: Declaration): string;
getExpressionNamePrefix(node: Identifier): string;
getPropertyAccessSubstitution(node: PropertyAccess): string;
getExportAssignmentName(node: SourceFile): string;
isReferencedImportDeclaration(node: ImportDeclaration): boolean;
isTopLevelValueImportedViaEntityName(node: ImportDeclaration): boolean;
@@ -688,9 +695,12 @@ module ts {
isImplementationOfOverload(node: FunctionDeclaration): boolean;
writeTypeAtLocation(location: Node, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: TextWriter): void;
writeReturnTypeOfSignatureDeclaration(signatureDeclaration: SignatureDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: TextWriter): void;
writeSymbol(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags, writer: TextWriter): void;
isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags): SymbolAccessiblityResult;
isImportDeclarationEntityNameReferenceDeclarationVisibile(entityName: EntityName): SymbolAccessiblityResult;
// Returns the constant value this property access resolves to, or 'undefined' if it does
// resolve to a constant.
getConstantValue(node: PropertyAccess): number;
}
export enum SymbolFlags {
@@ -792,13 +802,16 @@ 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
ContextChecked = 0x00000040, // Contextual types have been assigned
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
// Values for enum members have been computed, and any errors have been reported for them.
EnumValuesComputed = 0x00000080,
}
export interface NodeLinks {
@@ -1169,6 +1182,48 @@ module ts {
verticalTab = 0x0B, // \v
}
export class SymbolDisplayPart {
constructor(public text: string,
public kind: SymbolDisplayPartKind,
public symbol: Symbol) {
}
public toJSON() {
return {
text: this.text,
kind: SymbolDisplayPartKind[this.kind]
};
}
}
export enum SymbolDisplayPartKind {
aliasName,
className,
enumName,
fieldName,
interfaceName,
keyword,
labelName,
lineBreak,
numericLiteral,
stringLiteral,
localName,
methodName,
moduleName,
namespaceName,
operator,
parameterName,
propertyName,
punctuation,
space,
anonymousTypeIndicator,
text,
typeParameterName,
enumMemberName,
functionName,
regularExpressionLiteral,
}
export interface CancellationToken {
isCancellationRequested(): boolean;
}
-225
View File
@@ -1,225 +0,0 @@
if (!String.prototype.trim) {
String.prototype.trim = function () {
return this.replace(/^\s+|\s+$/g, '');
};
}
if (!Array.prototype.indexOf) {
Array.prototype.indexOf = function (searchElement, fromIndex) {
"use strict";
if (this == null) {
throw new TypeError();
}
var t = Object(this);
var len = t.length >>> 0;
if (len === 0) {
return -1;
}
var n = 0;
if (arguments.length > 0) {
n = Number(arguments[1]);
if (n != n) {
n = 0;
} else if (n != 0 && n != Infinity && n != -Infinity) {
n = (n > 0 || -1) * Math.floor(Math.abs(n));
}
}
if (n >= len) {
return -1;
}
var k = n >= 0 ? n : Math.max(len - Math.abs(n), 0);
for (; k < len; k++) {
if (k in t && t[k] === searchElement) {
return k;
}
}
return -1;
};
}
if (!Array.prototype.filter) {
Array.prototype.filter = function (fun, thisp) {
"use strict";
if (this == null)
throw new TypeError();
var t = Object(this);
var len = t.length >>> 0;
if (typeof fun != "function")
throw new TypeError();
var res = [];
for (var i = 0; i < len; i++) {
if (i in t) {
var val = t[i];
if (fun.call(thisp, val, i, t))
res.push(val);
}
}
return res;
};
}
if (!Array.prototype.map) {
Array.prototype.map = function (callback, thisArg) {
var T = undefined, A, k;
if (this == null) {
throw new TypeError(" this is null or not defined");
}
// 1. Let O be the result of calling ToObject passing the |this| value as the argument.
var O = Object(this);
// 2. Let lenValue be the result of calling the Get internal method of O with the argument "length".
// 3. Let len be ToUint32(lenValue).
var len = O.length >>> 0;
if ({}.toString.call(callback) != "[object Function]") {
throw new TypeError(callback + " is not a function");
}
if (thisArg) {
T = thisArg;
}
// 6. Let A be a new array created as if by the expression new Array(len) where Array is
// the standard built-in constructor with that name and len is the value of len.
A = new Array(len);
// 7. Let k be 0
k = 0;
while (k < len) {
var kValue, mappedValue;
if (k in O) {
// i. Let kValue be the result of calling the Get internal method of O with argument Pk.
kValue = O[k];
// ii. Let mappedValue be the result of calling the Call internal method of callback
// with T as the this value and argument list containing kValue, k, and O.
mappedValue = callback.call(T, kValue, k, O);
// iii. Call the DefineOwnProperty internal method of A with arguments
// Pk, Property Descriptor {Value: mappedValue, : true, Enumerable: true, Configurable: true},
// and false.
// In browsers that support Object.defineProperty, use the following:
// Object.defineProperty(A, Pk, { value: mappedValue, writable: true, enumerable: true, configurable: true });
// For best browser support, use the following:
A[k] = mappedValue;
}
// d. Increase k by 1.
k++;
}
// 9. return A
return A;
};
}
if (!Array.prototype.reduce) {
Array.prototype.reduce = function reduce(accumulator) {
if (this === null || this === undefined)
throw new TypeError("Object is null or undefined");
var i = 0, l = this.length >> 0, curr;
if (typeof accumulator !== "function")
throw new TypeError("First argument is not callable");
if (arguments.length < 2) {
if (l === 0)
throw new TypeError("Array length is 0 and no second argument");
curr = this[0];
i = 1;
} else
curr = arguments[1];
while (i < l) {
if (i in this)
curr = accumulator.call(undefined, curr, this[i], i, this);
++i;
}
return curr;
};
}
if (!Array.prototype.forEach) {
Array.prototype.forEach = function (callback, thisArg) {
var T, k;
if (this == null) {
throw new TypeError(" this is null or not defined");
}
// 1. Let O be the result of calling ToObject passing the |this| value as the argument.
var O = Object(this);
// 2. Let lenValue be the result of calling the Get internal method of O with the argument "length".
// 3. Let len be ToUint32(lenValue).
var len = O.length >>> 0;
if ({}.toString.call(callback) != "[object Function]") {
throw new TypeError(callback + " is not a function");
}
if (thisArg) {
T = thisArg;
} else {
T = undefined;
}
// 6. Let k be 0
k = 0;
while (k < len) {
var kValue;
if (k in O) {
// i. Let kValue be the result of calling the Get internal method of O with argument Pk.
kValue = O[k];
// ii. Call the Call internal method of callback with T as the this value and
// argument list containing kValue, k, and O.
callback.call(T, kValue, k, O);
}
// d. Increase k by 1.
k++;
}
// 8. return undefined
};
}
if (!Date.now) {
Date.now = function () {
return (new Date()).getTime();
};
}
if (!Array.prototype.some) {
Array.prototype.some = function (fun/*, thisp */ ) {
"use strict";
if (this == null)
throw new TypeError();
var t = Object(this);
var len = t.length >>> 0;
if (typeof fun != "function")
throw new TypeError();
var thisp = arguments[1];
for (var i = 0; i < len; i++) {
var idx = i.toString();
if (idx in t && fun.call(thisp, t[i], i, t))
return true;
}
return false;
};
}
-354
View File
@@ -1,354 +0,0 @@
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
/*----------------- ThirdPartyNotices -------------------------------------------------------
This file is based on or incorporates material from the projects listed below
(collectively "Third Party Code"). Microsoft is not the original author of the
Third Party Code. The original copyright notice and the license, under which
Microsoft received such Third Party Code, are set forth below. Such license and
notices are provided for informational purposes only. Microsoft licenses the Third
Party Code to you under the terms of the Apache 2.0 License.
--
Array filter Compatibility Method,
Available at https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/filter
Array forEach Compatibility Method,
Available at https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/forEach
Array indexOf Compatibility Method,
Available at https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/indexOf
Array map Compatibility Method,
Available at https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/map
Array Reduce Compatibility Method,
Available at https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/Reduce
Array some Compatibility Method,
Available at https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/some
String Trim Compatibility Method,
Available at https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/Trim
Date now Compatibility Method,
Available at https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/now
Copyright (c) 2007 - 2012 Mozilla Developer Network and individual contributors
Licensed by Microsoft under the Apache License, Version 2.0 (the "License"); you
may not use this file except in compliance with the License. You may obtain a copy
of the License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR
CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions and
limitations under the License.
--
Original License provided for Informational Purposes Only
MIT License
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
------------- End of ThirdPartyNotices --------------------------------------------------- */
// Compatibility with non ES5 compliant engines
if (!String.prototype.trim) {
String.prototype.trim = function() {
return this.replace(/^\s+|\s+$/g, '');
};
}
// Compatibility with non ES5 compliant engines
if (!Array.prototype.indexOf) {
Array.prototype.indexOf = function (searchElement: any, fromIndex?: any) {
"use strict";
if (this == null) {
throw new TypeError();
}
var t = Object(this);
var len: any = t.length >>> 0;
if (len === 0) {
return -1;
}
var n: any = 0;
if (arguments.length > 0) {
n = Number(arguments[1]);
if (n != n) { // shortcut for verifying if it's NaN
n = 0;
}
else if (n != 0 && n != Infinity && n != -Infinity) {
n = (n > 0 || <any>-1) * Math.floor(Math.abs(n));
}
}
if (n >= len) {
return -1;
}
var k: any = n >= 0 ? n : Math.max(len - Math.abs(n), 0);
for (; k < len; k++) {
if (k in t && t[k] === searchElement) {
return k;
}
}
return -1;
}
}
if (!Array.prototype.filter)
{
Array.prototype.filter = function(fun: any, thisp?: any)
{
"use strict";
if (this == null)
throw new TypeError();
var t = Object(this);
var len = t.length >>> 0;
if (typeof fun != "function")
throw new TypeError();
var res: any[] = [];
for (var i = 0; i < len; i++)
{
if (<any>i in t)
{
var val = t[i]; // in case fun mutates this
if (fun.call(thisp, val, i, t))
res.push(val);
}
}
return res;
};
}
// Production steps of ECMA-262, Edition 5, 15.4.4.19
// Reference: http://es5.github.com/#x15.4.4.19
if (!Array.prototype.map) {
Array.prototype.map = function(callback: any, thisArg?: any) {
var T: any = undefined, A: any, k: any;
if (this == null) {
throw new TypeError(" this is null or not defined");
}
// 1. Let O be the result of calling ToObject passing the |this| value as the argument.
var O = Object(this);
// 2. Let lenValue be the result of calling the Get internal method of O with the argument "length".
// 3. Let len be ToUint32(lenValue).
var len = O.length >>> 0;
// 4. If IsCallable(callback) is false, throw a TypeError exception.
// See: http://es5.github.com/#x9.11
if ({}.toString.call(callback) != "[object Function]") {
throw new TypeError(callback + " is not a function");
}
// 5. If thisArg was supplied, let T be thisArg; else let T be undefined.
if (thisArg) {
T = thisArg;
}
// 6. Let A be a new array created as if by the expression new Array(len) where Array is
// the standard built-in constructor with that name and len is the value of len.
A = new Array(len);
// 7. Let k be 0
k = 0;
// 8. Repeat, while k < len
while(k < len) {
var kValue: any, mappedValue: any;
// a. Let Pk be ToString(k).
// This is implicit for LHS operands of the in operator
// b. Let kPresent be the result of calling the HasProperty internal method of O with argument Pk.
// This step can be combined with c
// c. If kPresent is true, then
if (k in O) {
// i. Let kValue be the result of calling the Get internal method of O with argument Pk.
kValue = O[ k ];
// ii. Let mappedValue be the result of calling the Call internal method of callback
// with T as the this value and argument list containing kValue, k, and O.
mappedValue = callback.call(T, kValue, k, O);
// iii. Call the DefineOwnProperty internal method of A with arguments
// Pk, Property Descriptor {Value: mappedValue, : true, Enumerable: true, Configurable: true},
// and false.
// In browsers that support Object.defineProperty, use the following:
// Object.defineProperty(A, Pk, { value: mappedValue, writable: true, enumerable: true, configurable: true });
// For best browser support, use the following:
A[ k ] = mappedValue;
}
// d. Increase k by 1.
k++;
}
// 9. return A
return A;
};
}
if (!Array.prototype.reduce) {
Array.prototype.reduce = function reduce(accumulator: any){
if (this===null || this===undefined) throw new TypeError("Object is null or undefined");
var i = 0, l = this.length >> 0, curr: any;
if(typeof accumulator !== "function") // ES5 : "If IsCallable(callbackfn) is false, throw a TypeError exception."
throw new TypeError("First argument is not callable");
if(arguments.length < 2) {
if (l === 0) throw new TypeError("Array length is 0 and no second argument");
curr = this[0];
i = 1; // start accumulating at the second element
}
else
curr = arguments[1];
while (i < l) {
if(<any>i in this) curr = accumulator.call(undefined, curr, this[i], i, this);
++i;
}
return curr;
};
}
// Compatibility with non ES5 compliant engines
// Production steps of ECMA-262, Edition 5, 15.4.4.18
// Reference: http://es5.github.com/#x15.4.4.18
if (!Array.prototype.forEach) {
Array.prototype.forEach = function(callback: any, thisArg?: any) {
var T: any, k: any;
if (this == null) {
throw new TypeError(" this is null or not defined");
}
// 1. Let O be the result of calling ToObject passing the |this| value as the argument.
var O = Object(this);
// 2. Let lenValue be the result of calling the Get internal method of O with the argument "length".
// 3. Let len be ToUint32(lenValue).
var len = O.length >>> 0; // Hack to convert O.length to a UInt32
// 4. If IsCallable(callback) is false, throw a TypeError exception.
// See: http://es5.github.com/#x9.11
if ({ }.toString.call(callback) != "[object Function]") {
throw new TypeError(callback + " is not a function");
}
// 5. If thisArg was supplied, let T be thisArg; else let T be undefined.
if (thisArg) {
T = thisArg;
}
else {
T = undefined; // added to stop definite assignment error
}
// 6. Let k be 0
k = 0;
// 7. Repeat, while k < len
while (k < len) {
var kValue: any;
// a. Let Pk be ToString(k).
// This is implicit for LHS operands of the in operator
// b. Let kPresent be the result of calling the HasProperty internal method of O with argument Pk.
// This step can be combined with c
// c. If kPresent is true, then
if (k in O) {
// i. Let kValue be the result of calling the Get internal method of O with argument Pk.
kValue = O[k];
// ii. Call the Call internal method of callback with T as the this value and
// argument list containing kValue, k, and O.
callback.call(T, kValue, k, O);
}
// d. Increase k by 1.
k++;
}
// 8. return undefined
};
}
// Compatibility with non ES5 compliant engines
if (!Date.now) {
Date.now = function() {
return (new Date()).getTime();
};
}
// Compatibility with non ES5 compliant engines
// Production steps of ECMA-262, Edition 5.1, 15.4.4.17
if (!Array.prototype.some)
{
Array.prototype.some = function(fun: any /*, thisp */)
{
"use strict";
if (this == null)
throw new TypeError();
var t = Object(this);
var len = t.length >>> 0;
if (typeof fun != "function")
throw new TypeError();
var thisp = arguments[1];
for (var i = 0; i < len; i++)
{
var idx = i.toString(); // REVIEW: this line is not from the Mozilla page, necessary to avoid our compile time checks against non-string/any types in an in expression
if (idx in t && fun.call(thisp, t[i], i, t))
return true;
}
return false;
};
}
-486
View File
@@ -1,486 +0,0 @@
/*
json2.js
2013-05-26
Public Domain.
NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
See http://www.JSON.org/js.html
This code should be minified before deployment.
See http://javascript.crockford.com/jsmin.html
USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
NOT CONTROL.
This file creates a global JSON object containing two methods: stringify
and parse.
JSON.stringify(value, replacer, space)
value any JavaScript value, usually an object or array.
replacer an optional parameter that determines how object
values are stringified for objects. It can be a
function or an array of strings.
space an optional parameter that specifies the indentation
of nested structures. If it is omitted, the text will
be packed without extra whitespace. If it is a number,
it will specify the number of spaces to indent at each
level. If it is a string (such as '\t' or '&nbsp;'),
it contains the characters used to indent at each level.
This method produces a JSON text from a JavaScript value.
When an object value is found, if the object contains a toJSON
method, its toJSON method will be called and the result will be
stringified. A toJSON method does not serialize: it returns the
value represented by the name/value pair that should be serialized,
or undefined if nothing should be serialized. The toJSON method
will be passed the key associated with the value, and this will be
bound to the value
For example, this would serialize Dates as ISO strings.
Date.prototype.toJSON = function (key) {
function f(n) {
// Format integers to have at least two digits.
return n < 10 ? '0' + n : n;
}
return this.getUTCFullYear() + '-' +
f(this.getUTCMonth() + 1) + '-' +
f(this.getUTCDate()) + 'T' +
f(this.getUTCHours()) + ':' +
f(this.getUTCMinutes()) + ':' +
f(this.getUTCSeconds()) + 'Z';
};
You can provide an optional replacer method. It will be passed the
key and value of each member, with this bound to the containing
object. The value that is returned from your method will be
serialized. If your method returns undefined, then the member will
be excluded from the serialization.
If the replacer parameter is an array of strings, then it will be
used to select the members to be serialized. It filters the results
such that only members with keys listed in the replacer array are
stringified.
Values that do not have JSON representations, such as undefined or
functions, will not be serialized. Such values in objects will be
dropped; in arrays they will be replaced with null. You can use
a replacer function to replace those with JSON values.
JSON.stringify(undefined) returns undefined.
The optional space parameter produces a stringification of the
value that is filled with line breaks and indentation to make it
easier to read.
If the space parameter is a non-empty string, then that string will
be used for indentation. If the space parameter is a number, then
the indentation will be that many spaces.
Example:
text = JSON.stringify(['e', {pluribus: 'unum'}]);
// text is '["e",{"pluribus":"unum"}]'
text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t');
// text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]'
text = JSON.stringify([new Date()], function (key, value) {
return this[key] instanceof Date ?
'Date(' + this[key] + ')' : value;
});
// text is '["Date(---current time---)"]'
JSON.parse(text, reviver)
This method parses a JSON text to produce an object or array.
It can throw a SyntaxError exception.
The optional reviver parameter is a function that can filter and
transform the results. It receives each of the keys and values,
and its return value is used instead of the original value.
If it returns what it received, then the structure is not modified.
If it returns undefined then the member is deleted.
Example:
// Parse the text. Values that look like ISO date strings will
// be converted to Date objects.
myData = JSON.parse(text, function (key, value) {
var a;
if (typeof value === 'string') {
a =
/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);
if (a) {
return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],
+a[5], +a[6]));
}
}
return value;
});
myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) {
var d;
if (typeof value === 'string' &&
value.slice(0, 5) === 'Date(' &&
value.slice(-1) === ')') {
d = new Date(value.slice(5, -1));
if (d) {
return d;
}
}
return value;
});
This is a reference implementation. You are free to copy, modify, or
redistribute.
*/
/*jslint evil: true, regexp: true */
/*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,
lastIndex, length, parse, prototype, push, replace, slice, stringify,
test, toJSON, toString, valueOf
*/
// Create a JSON object only if one does not already exist. We create the
// methods in a closure to avoid creating global variables.
if (typeof JSON !== 'object') {
JSON = {};
}
(function () {
'use strict';
function f(n) {
// Format integers to have at least two digits.
return n < 10 ? '0' + n : n;
}
if (typeof Date.prototype.toJSON !== 'function') {
Date.prototype.toJSON = function () {
return isFinite(this.valueOf())
? this.getUTCFullYear() + '-' +
f(this.getUTCMonth() + 1) + '-' +
f(this.getUTCDate()) + 'T' +
f(this.getUTCHours()) + ':' +
f(this.getUTCMinutes()) + ':' +
f(this.getUTCSeconds()) + 'Z'
: null;
};
String.prototype.toJSON =
Number.prototype.toJSON =
Boolean.prototype.toJSON = function () {
return this.valueOf();
};
}
var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
gap,
indent,
meta = { // table of character substitutions
'\b': '\\b',
'\t': '\\t',
'\n': '\\n',
'\f': '\\f',
'\r': '\\r',
'"' : '\\"',
'\\': '\\\\'
},
rep;
function quote(string) {
// If the string contains no control characters, no quote characters, and no
// backslash characters, then we can safely slap some quotes around it.
// Otherwise we must also replace the offending characters with safe escape
// sequences.
escapable.lastIndex = 0;
return escapable.test(string) ? '"' + string.replace(escapable, function (a) {
var c = meta[a];
return typeof c === 'string'
? c
: '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
}) + '"' : '"' + string + '"';
}
function str(key, holder) {
// Produce a string from holder[key].
var i, // The loop counter.
k, // The member key.
v, // The member value.
length,
mind = gap,
partial,
value = holder[key];
// If the value has a toJSON method, call it to obtain a replacement value.
if (value && typeof value === 'object' &&
typeof value.toJSON === 'function') {
value = value.toJSON(key);
}
// If we were called with a replacer function, then call the replacer to
// obtain a replacement value.
if (typeof rep === 'function') {
value = rep.call(holder, key, value);
}
// What happens next depends on the value's type.
switch (typeof value) {
case 'string':
return quote(value);
case 'number':
// JSON numbers must be finite. Encode non-finite numbers as null.
return isFinite(value) ? String(value) : 'null';
case 'boolean':
case 'null':
// If the value is a boolean or null, convert it to a string. Note:
// typeof null does not produce 'null'. The case is included here in
// the remote chance that this gets fixed someday.
return String(value);
// If the type is 'object', we might be dealing with an object or an array or
// null.
case 'object':
// Due to a specification blunder in ECMAScript, typeof null is 'object',
// so watch out for that case.
if (!value) {
return 'null';
}
// Make an array to hold the partial results of stringifying this object value.
gap += indent;
partial = [];
// Is the value an array?
if (Object.prototype.toString.apply(value) === '[object Array]') {
// The value is an array. Stringify every element. Use null as a placeholder
// for non-JSON values.
length = value.length;
for (i = 0; i < length; i += 1) {
partial[i] = str(i, value) || 'null';
}
// Join all of the elements together, separated with commas, and wrap them in
// brackets.
v = partial.length === 0
? '[]'
: gap
? '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']'
: '[' + partial.join(',') + ']';
gap = mind;
return v;
}
// If the replacer is an array, use it to select the members to be stringified.
if (rep && typeof rep === 'object') {
length = rep.length;
for (i = 0; i < length; i += 1) {
if (typeof rep[i] === 'string') {
k = rep[i];
v = str(k, value);
if (v) {
partial.push(quote(k) + (gap ? ': ' : ':') + v);
}
}
}
} else {
// Otherwise, iterate through all of the keys in the object.
for (k in value) {
if (Object.prototype.hasOwnProperty.call(value, k)) {
v = str(k, value);
if (v) {
partial.push(quote(k) + (gap ? ': ' : ':') + v);
}
}
}
}
// Join all of the member texts together, separated with commas,
// and wrap them in braces.
v = partial.length === 0
? '{}'
: gap
? '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}'
: '{' + partial.join(',') + '}';
gap = mind;
return v;
}
}
// If the JSON object does not yet have a stringify method, give it one.
if (typeof JSON.stringify !== 'function') {
JSON.stringify = function (value, replacer, space) {
// The stringify method takes a value and an optional replacer, and an optional
// space parameter, and returns a JSON text. The replacer can be a function
// that can replace values, or an array of strings that will select the keys.
// A default replacer method can be provided. Use of the space parameter can
// produce text that is more easily readable.
var i;
gap = '';
indent = '';
// If the space parameter is a number, make an indent string containing that
// many spaces.
if (typeof space === 'number') {
for (i = 0; i < space; i += 1) {
indent += ' ';
}
// If the space parameter is a string, it will be used as the indent string.
} else if (typeof space === 'string') {
indent = space;
}
// If there is a replacer, it must be a function or an array.
// Otherwise, throw an error.
rep = replacer;
if (replacer && typeof replacer !== 'function' &&
(typeof replacer !== 'object' ||
typeof replacer.length !== 'number')) {
throw new Error('JSON.stringify');
}
// Make a fake root object containing our value under the key of ''.
// Return the result of stringifying the value.
return str('', {'': value});
};
}
// If the JSON object does not yet have a parse method, give it one.
if (typeof JSON.parse !== 'function') {
JSON.parse = function (text, reviver) {
// The parse method takes a text and an optional reviver function, and returns
// a JavaScript value if the text is a valid JSON text.
var j;
function walk(holder, key) {
// The walk method is used to recursively walk the resulting structure so
// that modifications can be made.
var k, v, value = holder[key];
if (value && typeof value === 'object') {
for (k in value) {
if (Object.prototype.hasOwnProperty.call(value, k)) {
v = walk(value, k);
if (v !== undefined) {
value[k] = v;
} else {
delete value[k];
}
}
}
}
return reviver.call(holder, key, value);
}
// Parsing happens in four stages. In the first stage, we replace certain
// Unicode characters with escape sequences. JavaScript handles many characters
// incorrectly, either silently deleting them, or treating them as line endings.
text = String(text);
cx.lastIndex = 0;
if (cx.test(text)) {
text = text.replace(cx, function (a) {
return '\\u' +
('0000' + a.charCodeAt(0).toString(16)).slice(-4);
});
}
// In the second stage, we run the text against regular expressions that look
// for non-JSON patterns. We are especially concerned with '()' and 'new'
// because they can cause invocation, and '=' because it can cause mutation.
// But just to be safe, we want to reject all unexpected forms.
// We split the second stage into 4 regexp operations in order to work around
// crippling inefficiencies in IE's and Safari's regexp engines. First we
// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we
// replace all simple value tokens with ']' characters. Third, we delete all
// open brackets that follow a colon or comma or that begin the text. Finally,
// we look to see that the remaining characters are only whitespace or ']' or
// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.
if (/^[\],:{}\s]*$/
.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@')
.replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']')
.replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
// In the third stage we use the eval function to compile the text into a
// JavaScript structure. The '{' operator is subject to a syntactic ambiguity
// in JavaScript: it can begin a block or an object literal. We wrap the text
// in parens to eliminate the ambiguity.
j = eval('(' + text + ')');
// In the optional fourth stage, we recursively walk the new structure, passing
// each name/value pair to a reviver function for possible transformation.
return typeof reviver === 'function'
? walk({'': j}, '')
: j;
}
// If the text is not JSON parseable, then a SyntaxError is thrown.
throw new SyntaxError('JSON.parse');
};
}
}());
-486
View File
@@ -1,486 +0,0 @@
/*
json2.js
2013-05-26
Public Domain.
NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
See http://www.JSON.org/js.html
This code should be minified before deployment.
See http://javascript.crockford.com/jsmin.html
USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
NOT CONTROL.
This file creates a global JSON object containing two methods: stringify
and parse.
JSON.stringify(value, replacer, space)
value any JavaScript value, usually an object or array.
replacer an optional parameter that determines how object
values are stringified for objects. It can be a
function or an array of strings.
space an optional parameter that specifies the indentation
of nested structures. If it is omitted, the text will
be packed without extra whitespace. If it is a number,
it will specify the number of spaces to indent at each
level. If it is a string (such as '\t' or '&nbsp;'),
it contains the characters used to indent at each level.
This method produces a JSON text from a JavaScript value.
When an object value is found, if the object contains a toJSON
method, its toJSON method will be called and the result will be
stringified. A toJSON method does not serialize: it returns the
value represented by the name/value pair that should be serialized,
or undefined if nothing should be serialized. The toJSON method
will be passed the key associated with the value, and this will be
bound to the value
For example, this would serialize Dates as ISO strings.
Date.prototype.toJSON = function (key) {
function f(n) {
// Format integers to have at least two digits.
return n < 10 ? '0' + n : n;
}
return this.getUTCFullYear() + '-' +
f(this.getUTCMonth() + 1) + '-' +
f(this.getUTCDate()) + 'T' +
f(this.getUTCHours()) + ':' +
f(this.getUTCMinutes()) + ':' +
f(this.getUTCSeconds()) + 'Z';
};
You can provide an optional replacer method. It will be passed the
key and value of each member, with this bound to the containing
object. The value that is returned from your method will be
serialized. If your method returns undefined, then the member will
be excluded from the serialization.
If the replacer parameter is an array of strings, then it will be
used to select the members to be serialized. It filters the results
such that only members with keys listed in the replacer array are
stringified.
Values that do not have JSON representations, such as undefined or
functions, will not be serialized. Such values in objects will be
dropped; in arrays they will be replaced with null. You can use
a replacer function to replace those with JSON values.
JSON.stringify(undefined) returns undefined.
The optional space parameter produces a stringification of the
value that is filled with line breaks and indentation to make it
easier to read.
If the space parameter is a non-empty string, then that string will
be used for indentation. If the space parameter is a number, then
the indentation will be that many spaces.
Example:
text = JSON.stringify(['e', {pluribus: 'unum'}]);
// text is '["e",{"pluribus":"unum"}]'
text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t');
// text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]'
text = JSON.stringify([new Date()], function (key, value) {
return this[key] instanceof Date ?
'Date(' + this[key] + ')' : value;
});
// text is '["Date(---current time---)"]'
JSON.parse(text, reviver)
This method parses a JSON text to produce an object or array.
It can throw a SyntaxError exception.
The optional reviver parameter is a function that can filter and
transform the results. It receives each of the keys and values,
and its return value is used instead of the original value.
If it returns what it received, then the structure is not modified.
If it returns undefined then the member is deleted.
Example:
// Parse the text. Values that look like ISO date strings will
// be converted to Date objects.
myData = JSON.parse(text, function (key, value) {
var a;
if (typeof value === 'string') {
a =
/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);
if (a) {
return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],
+a[5], +a[6]));
}
}
return value;
});
myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) {
var d;
if (typeof value === 'string' &&
value.slice(0, 5) === 'Date(' &&
value.slice(-1) === ')') {
d = new Date(value.slice(5, -1));
if (d) {
return d;
}
}
return value;
});
This is a reference implementation. You are free to copy, modify, or
redistribute.
*/
/*jslint evil: true, regexp: true */
/*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,
lastIndex, length, parse, prototype, push, replace, slice, stringify,
test, toJSON, toString, valueOf
*/
// Create a JSON object only if one does not already exist. We create the
// methods in a closure to avoid creating global variables.
if (typeof JSON !== 'object') {
JSON = <any>{};
}
(function () {
'use strict';
function f(n: any) {
// Format integers to have at least two digits.
return n < 10 ? '0' + n : n;
}
if (typeof Date.prototype.toJSON !== 'function') {
Date.prototype.toJSON = function () {
return isFinite(this.valueOf())
? this.getUTCFullYear() + '-' +
f(this.getUTCMonth() + 1) + '-' +
f(this.getUTCDate()) + 'T' +
f(this.getUTCHours()) + ':' +
f(this.getUTCMinutes()) + ':' +
f(this.getUTCSeconds()) + 'Z'
: null;
};
(<any>String.prototype).toJSON =
(<any>Number.prototype).toJSON =
(<any>Boolean.prototype).toJSON = function () {
return this.valueOf();
};
}
var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
gap: any,
indent: any,
meta = <any>{ // table of character substitutions
'\b': '\\b',
'\t': '\\t',
'\n': '\\n',
'\f': '\\f',
'\r': '\\r',
'"' : '\\"',
'\\': '\\\\'
},
rep: any;
function quote(string: string) {
// If the string contains no control characters, no quote characters, and no
// backslash characters, then we can safely slap some quotes around it.
// Otherwise we must also replace the offending characters with safe escape
// sequences.
escapable.lastIndex = 0;
return escapable.test(string) ? '"' + string.replace(escapable, function (a) {
var c = meta[a];
return typeof c === 'string'
? c
: '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
}) + '"' : '"' + string + '"';
}
function str(key: any, holder: any) {
// Produce a string from holder[key].
var i: any, // The loop counter.
k: any, // The member key.
v: any, // The member value.
length: number,
mind = gap,
partial: any,
value = holder[key];
// If the value has a toJSON method, call it to obtain a replacement value.
if (value && typeof value === 'object' &&
typeof value.toJSON === 'function') {
value = value.toJSON(key);
}
// If we were called with a replacer function, then call the replacer to
// obtain a replacement value.
if (typeof rep === 'function') {
value = rep.call(holder, key, value);
}
// What happens next depends on the value's type.
switch (typeof value) {
case 'string':
return quote(value);
case 'number':
// JSON numbers must be finite. Encode non-finite numbers as null.
return isFinite(value) ? String(value) : 'null';
case 'boolean':
case 'null':
// If the value is a boolean or null, convert it to a string. Note:
// typeof null does not produce 'null'. The case is included here in
// the remote chance that this gets fixed someday.
return String(value);
// If the type is 'object', we might be dealing with an object or an array or
// null.
case 'object':
// Due to a specification blunder in ECMAScript, typeof null is 'object',
// so watch out for that case.
if (!value) {
return 'null';
}
// Make an array to hold the partial results of stringifying this object value.
gap += indent;
partial = [];
// Is the value an array?
if (Object.prototype.toString.apply(value) === '[object Array]') {
// The value is an array. Stringify every element. Use null as a placeholder
// for non-JSON values.
length = value.length;
for (i = 0; i < length; i += 1) {
partial[i] = str(i, value) || 'null';
}
// Join all of the elements together, separated with commas, and wrap them in
// brackets.
v = partial.length === 0
? '[]'
: gap
? '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']'
: '[' + partial.join(',') + ']';
gap = mind;
return v;
}
// If the replacer is an array, use it to select the members to be stringified.
if (rep && typeof rep === 'object') {
length = rep.length;
for (i = 0; i < length; i += 1) {
if (typeof rep[i] === 'string') {
k = rep[i];
v = str(k, value);
if (v) {
partial.push(quote(k) + (gap ? ': ' : ':') + v);
}
}
}
} else {
// Otherwise, iterate through all of the keys in the object.
for (k in value) {
if (Object.prototype.hasOwnProperty.call(value, k)) {
v = str(k, value);
if (v) {
partial.push(quote(k) + (gap ? ': ' : ':') + v);
}
}
}
}
// Join all of the member texts together, separated with commas,
// and wrap them in braces.
v = partial.length === 0
? '{}'
: gap
? '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}'
: '{' + partial.join(',') + '}';
gap = mind;
return v;
}
}
// If the JSON object does not yet have a stringify method, give it one.
if (typeof JSON.stringify !== 'function') {
JSON.stringify = <any>function (value: any, replacer: any, space: any) {
// The stringify method takes a value and an optional replacer, and an optional
// space parameter, and returns a JSON text. The replacer can be a function
// that can replace values, or an array of strings that will select the keys.
// A default replacer method can be provided. Use of the space parameter can
// produce text that is more easily readable.
var i: any;
gap = '';
indent = '';
// If the space parameter is a number, make an indent string containing that
// many spaces.
if (typeof space === 'number') {
for (i = 0; i < space; i += 1) {
indent += ' ';
}
// If the space parameter is a string, it will be used as the indent string.
} else if (typeof space === 'string') {
indent = space;
}
// If there is a replacer, it must be a function or an array.
// Otherwise, throw an error.
rep = replacer;
if (replacer && typeof replacer !== 'function' &&
(typeof replacer !== 'object' ||
typeof replacer.length !== 'number')) {
throw new Error('JSON.stringify');
}
// Make a fake root object containing our value under the key of ''.
// Return the result of stringifying the value.
return str('', {'': value});
};
}
// If the JSON object does not yet have a parse method, give it one.
if (typeof JSON.parse !== 'function') {
JSON.parse = function (text, reviver) {
// The parse method takes a text and an optional reviver function, and returns
// a JavaScript value if the text is a valid JSON text.
var j: any;
function walk(holder: any, key: any) {
// The walk method is used to recursively walk the resulting structure so
// that modifications can be made.
var k: any, v: any, value = holder[key];
if (value && typeof value === 'object') {
for (k in value) {
if (Object.prototype.hasOwnProperty.call(value, k)) {
v = walk(value, k);
if (v !== undefined) {
value[k] = v;
} else {
delete value[k];
}
}
}
}
return reviver.call(holder, key, value);
}
// Parsing happens in four stages. In the first stage, we replace certain
// Unicode characters with escape sequences. JavaScript handles many characters
// incorrectly, either silently deleting them, or treating them as line endings.
text = String(text);
cx.lastIndex = 0;
if (cx.test(text)) {
text = text.replace(cx, function (a) {
return '\\u' +
('0000' + a.charCodeAt(0).toString(16)).slice(-4);
});
}
// In the second stage, we run the text against regular expressions that look
// for non-JSON patterns. We are especially concerned with '()' and 'new'
// because they can cause invocation, and '=' because it can cause mutation.
// But just to be safe, we want to reject all unexpected forms.
// We split the second stage into 4 regexp operations in order to work around
// crippling inefficiencies in IE's and Safari's regexp engines. First we
// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we
// replace all simple value tokens with ']' characters. Third, we delete all
// open brackets that follow a colon or comma or that begin the text. Finally,
// we look to see that the remaining characters are only whitespace or ']' or
// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.
if (/^[\],:{}\s]*$/
.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@')
.replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']')
.replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
// In the third stage we use the eval function to compile the text into a
// JavaScript structure. The '{' operator is subject to a syntactic ambiguity
// in JavaScript: it can begin a block or an object literal. We wrap the text
// in parens to eliminate the ambiguity.
j = eval('(' + text + ')');
// In the optional fourth stage, we recursively walk the new structure, passing
// each name/value pair to a reviver function for possible transformation.
return typeof reviver === 'function'
? walk({'': j}, '')
: j;
}
// If the text is not JSON parseable, then a SyntaxError is thrown.
throw new SyntaxError('JSON.parse');
};
}
}());
+2 -2
View File
@@ -1661,9 +1661,9 @@ module FourSlash {
}
var actualMatchPosition = -1;
if (bracePosition >= actual[0].start() && bracePosition <= actual[0].end()) {
if (bracePosition === actual[0].start()) {
actualMatchPosition = actual[1].start();
} else if (bracePosition >= actual[1].start() && bracePosition <= actual[1].end()) {
} else if (bracePosition === actual[1].start()) {
actualMatchPosition = actual[0].start();
} else {
throw new Error('verifyMatchingBracePosition failed - could not find the brace position: ' + bracePosition + ' in the returned list: (' + actual[0].start() + ',' + actual[0].end() + ') and (' + actual[1].start() + ',' + actual[1].end() + ')');
-73
View File
@@ -1,73 +0,0 @@
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
///<reference path='references.ts' />
module TypeScript.Services {
export class BraceMatcher {
// Given a script name and position in the script, return a pair of text range if the
// position corresponds to a "brace matchin" characters (e.g. "{" or "(", etc.)
// If the position is not on any range, return an empty set.
public static getMatchSpans(syntaxTree: TypeScript.SyntaxTree, position: number): TypeScript.TextSpan[] {
var result: TypeScript.TextSpan[] = [];
var token = findToken(syntaxTree.sourceUnit(), position);
if (start(token) === position) {
var matchKind = BraceMatcher.getMatchingTokenKind(token);
if (matchKind !== null) {
var parentElement = token.parent;
for (var i = 0, n = childCount(parentElement); i < n; i++) {
var current = childAt(parentElement, i);
if (current !== null && fullWidth(current) > 0) {
if (current.kind() === matchKind) {
var range1 = new TypeScript.TextSpan(start(token), width(token));
var range2 = new TypeScript.TextSpan(start(current), width(current));
if (range1.start() < range2.start()) {
result.push(range1, range2);
}
else {
result.push(range2, range1);
}
break;
}
}
}
}
}
return result;
}
private static getMatchingTokenKind(token: TypeScript.ISyntaxToken): TypeScript.SyntaxKind {
switch (token.kind()) {
case TypeScript.SyntaxKind.OpenBraceToken: return TypeScript.SyntaxKind.CloseBraceToken
case TypeScript.SyntaxKind.OpenParenToken: return TypeScript.SyntaxKind.CloseParenToken;
case TypeScript.SyntaxKind.OpenBracketToken: return TypeScript.SyntaxKind.CloseBracketToken;
case TypeScript.SyntaxKind.LessThanToken: return TypeScript.SyntaxKind.GreaterThanToken;
case TypeScript.SyntaxKind.CloseBraceToken: return TypeScript.SyntaxKind.OpenBraceToken
case TypeScript.SyntaxKind.CloseParenToken: return TypeScript.SyntaxKind.OpenParenToken;
case TypeScript.SyntaxKind.CloseBracketToken: return TypeScript.SyntaxKind.OpenBracketToken;
case TypeScript.SyntaxKind.GreaterThanToken: return TypeScript.SyntaxKind.LessThanToken;
}
return null;
}
}
}
+5
View File
@@ -42,6 +42,10 @@ module TypeScript {
walker.walk(preAst.typeArguments);
}
function walkTupleTypeChildren(preAst: TupleTypeSyntax, walker: AstWalker): void {
walker.walk(preAst.types);
}
function walkTypeOfExpressionChildren(preAst: TypeOfExpressionSyntax, walker: AstWalker): void {
walker.walk(preAst.expression);
}
@@ -561,6 +565,7 @@ module TypeScript {
childrenWalkers[SyntaxKind.TriviaList] = null;
childrenWalkers[SyntaxKind.TrueKeyword] = null;
childrenWalkers[SyntaxKind.TryStatement] = walkTryStatementChildren;
childrenWalkers[SyntaxKind.TupleType] = walkTupleTypeChildren;
childrenWalkers[SyntaxKind.TypeAnnotation] = walkTypeAnnotationChildren;
childrenWalkers[SyntaxKind.TypeArgumentList] = walkTypeArgumentListChildren;
childrenWalkers[SyntaxKind.TypeOfExpression] = walkTypeOfExpressionChildren;
+344 -16
View File
@@ -7,7 +7,6 @@
/// <reference path='syntax\incrementalParser.ts' />
/// <reference path='outliningElementsCollector.ts' />
/// <reference path='getScriptLexicalStructureWalker.ts' />
/// <reference path='braceMatcher.ts' />
/// <reference path='breakpoints.ts' />
/// <reference path='indentation.ts' />
/// <reference path='formatting\formatting.ts' />
@@ -46,6 +45,7 @@ module ts {
getFlags(): SymbolFlags;
getName(): string;
getDeclarations(): Declaration[];
getDocumentationComment(): string;
}
export interface Type {
@@ -97,9 +97,7 @@ module ts {
private _children: Node[];
public getSourceFile(): SourceFile {
var node: Node = this;
while (node.kind !== SyntaxKind.SourceFile) node = node.parent;
return <SourceFile>node;
return getSourceFileOfNode(this);
}
public getStart(sourceFile?: SourceFile): number {
@@ -225,19 +223,176 @@ module ts {
flags: SymbolFlags;
name: string;
declarations: Declaration[];
// Undefined is used to indicate the value has not been computed. If, after computing, the
// symbol has no doc comment, then the empty string will be returned.
documentationComment: string;
constructor(flags: SymbolFlags, name: string) {
this.flags = flags;
this.name = name;
}
getFlags(): SymbolFlags {
return this.flags;
}
getName(): string {
return this.name;
}
getDeclarations(): Declaration[] {
return this.declarations;
}
getDocumentationComment(): string {
if (this.documentationComment === undefined) {
var lines: string[] = [];
// Get the doc comments from all the declarations of this symbol, and merge them
// into one single doc comment.
var declarations = this.getDeclarations();
if (declarations) {
for (var i = 0, n = declarations.length; i < n; i++) {
this.processDocumentationCommentDeclaration(lines, declarations[0]);
}
}
// TODO: get the newline info from the host.
this.documentationComment = lines.join("\r\n");
}
return this.documentationComment;
}
private processDocumentationCommentDeclaration(lines: string[], declaration: Node) {
var commentRanges = getLeadingCommentRangesOfNode(declaration);
if (commentRanges) {
var sourceFile = declaration.getSourceFile();
for (var i = 0, n = commentRanges.length; i < n; i++) {
this.processDocumentationCommentRange(
lines, sourceFile, commentRanges[0]);
}
}
}
private processDocumentationCommentRange(lines: string[], sourceFile: SourceFile, commentRange: CommentRange) {
// We only care about well-formed /** */ comments
if (commentRange.end - commentRange.pos > "/**/".length &&
sourceFile.text.substr(commentRange.pos, "/**".length) === "/**" &&
sourceFile.text.substr(commentRange.end - "*/".length, "*/".length) === "*/") {
// Put a newline between each converted comment we join together.
if (lines.length) {
lines.push("");
}
var startLineAndChar = sourceFile.getLineAndCharacterFromPosition(commentRange.pos);
var endLineAndChar = sourceFile.getLineAndCharacterFromPosition(commentRange.end);
if (startLineAndChar.line === endLineAndChar.line) {
// A single line doc comment. Just extract the text between the
// comment markers and add that to the doc comment we're building
// up.
lines.push(sourceFile.text.substring(commentRange.pos + "/**".length, commentRange.end - "*/".length).trim());
}
else {
this.processMultiLineDocumentationCommentRange(sourceFile, commentRange, startLineAndChar, endLineAndChar, lines);
}
}
}
private processMultiLineDocumentationCommentRange(
sourceFile: SourceFile, commentRange: CommentRange,
startLineAndChar: { line: number; character: number },
endLineAndChar: { line: number; character: number },
lines: string[]) {
// Comment spanned multiple lines. Find the leftmost character
// position in each line, and use that to determine what we should
// trim off, and what part of the line to keep.
// i.e. if the comment looks like:
//
// /** Foo
// * Bar
// * Baz
// */
//
// Then we'll want to add:
// Foo
// Bar
// Baz
var trimLength: number = undefined;
for (var iLine = startLineAndChar.line + 1; iLine <= endLineAndChar.line; iLine++) {
var lineStart = sourceFile.getPositionFromLineAndCharacter(iLine, /*character:*/ 1);
var lineEnd = iLine === endLineAndChar.line
? commentRange.end - "*/".length
: sourceFile.getPositionFromLineAndCharacter(iLine + 1, 1);
var docCommentTriviaLength = this.skipDocumentationCommentTrivia(sourceFile.text, lineStart, lineEnd);
if (trimLength === undefined || (docCommentTriviaLength && docCommentTriviaLength < trimLength)) {
trimLength = docCommentTriviaLength;
}
}
// Add the first line in.
var firstLine = sourceFile.text.substring(
commentRange.pos + "/**".length,
sourceFile.getPositionFromLineAndCharacter(startLineAndChar.line + 1, /*character:*/ 1)).trim();
if (firstLine !== "") {
lines.push(firstLine);
}
// For all the lines up to the last (but not including the last), add the contents
// of the line (with the length up to the
for (var iLine = startLineAndChar.line + 1; iLine < endLineAndChar.line; iLine++) {
var line = this.trimRight(sourceFile.text.substring(
sourceFile.getPositionFromLineAndCharacter(iLine, /*character*/ 1),
sourceFile.getPositionFromLineAndCharacter(iLine + 1, /*character*/ 1))).substr(trimLength);
lines.push(line);
}
// Add the last line if there is any actual text before the */
var lastLine = this.trimRight(sourceFile.text.substring(
sourceFile.getPositionFromLineAndCharacter(endLineAndChar.line, /*character:*/ 1),
commentRange.end - "*/".length)).substr(trimLength);
if (lastLine !== "") {
lines.push(lastLine);
}
}
private trimRight(val: string) {
return val.replace(/(\n|\r|\s)+$/, '');
}
private skipDocumentationCommentTrivia(text: string, lineStart: number, lineEnd: number): number {
var seenAsterisk = false;
var lineLength = lineEnd - lineStart;
for (var i = 0; i < lineLength; i++) {
var char = text.charCodeAt(i + lineStart);
if (char === CharacterCodes.asterisk && !seenAsterisk) {
// Ignore the first asterisk we see. We want to trim out the line of *'s
// commonly seen at the start of a doc comment.
seenAsterisk = true;
continue;
}
else if (isLineBreak(char)) {
// This was a blank line. Just ignore it wrt computing the leading whitespace to
// trim.
break;
}
else if (!isWhiteSpace(char)) {
// Found a real doc comment character. Keep track of it so we can determine how
// much of the doc comment leading trivia to trim off.
return i;
}
}
return undefined;
}
}
class TypeObject implements Type {
@@ -495,6 +650,7 @@ module ts {
getCompletionEntryDetails(fileName: string, position: number, entryName: string): CompletionEntryDetails;
getTypeAtPosition(fileName: string, position: number): TypeInfo;
getQuickInfoAtPosition(fileName: string, position: number): QuickInfo;
getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): TypeScript.TextSpan;
@@ -652,6 +808,15 @@ module ts {
text: string;
}
export class QuickInfo {
constructor(public kind: string,
public kindModifiers: string,
public textSpan: TypeScript.TextSpan,
public displayParts: SymbolDisplayPart[],
public documentation: SymbolDisplayPart[]) {
}
}
export class TypeInfo {
constructor(
public memberName: TypeScript.MemberName,
@@ -1481,11 +1646,14 @@ module ts {
var formattingRulesProvider: TypeScript.Services.Formatting.RulesProvider;
var hostCache: HostCache; // A cache of all the information about the files on the host side.
var program: Program;
// this checker is used to answer all LS questions except errors
var typeInfoResolver: TypeChecker;
// the sole purpose of this checker is to return semantic diagnostics
// creation is deferred - use getFullTypeCheckChecker to get instance
var fullTypeCheckChecker_doNotAccessDirectly: TypeChecker;
var useCaseSensitivefilenames = false;
var sourceFilesByName: Map<SourceFile> = {};
var documentRegistry = documentRegistry;
@@ -1726,11 +1894,10 @@ module ts {
return undefined;
}
var declarations = symbol.getDeclarations();
return {
name: displayName,
kind: getSymbolKind(symbol),
kindModifiers: declarations ? getNodeModifiers(declarations[0]) : ScriptElementKindModifier.none
kindModifiers: getSymbolModifiers(symbol)
};
}
@@ -2124,7 +2291,7 @@ module ts {
if (child.getFullStart() <= position && position < child.getEnd()) {
current = child;
continue outer;
}
}
}
return current;
}
@@ -2211,7 +2378,120 @@ module ts {
}
}
/// QuickInfo
function getSymbolModifiers(symbol: Symbol): string {
return symbol && symbol.declarations && symbol.declarations.length > 0
? getNodeModifiers(symbol.declarations[0])
: ScriptElementKindModifier.none;
}
function getQuickInfoAtPosition(fileName: string, position: number): QuickInfo {
synchronizeHostData();
fileName = TypeScript.switchToForwardSlashes(fileName);
var sourceFile = getSourceFile(fileName);
var node = getNodeAtPosition(sourceFile, position);
if (!node) {
return undefined;
}
var symbol = typeInfoResolver.getSymbolInfo(node);
if (!symbol) {
return undefined;
}
var documentation = symbol.getDocumentationComment();
var documentationParts = documentation === "" ? [] : [new SymbolDisplayPart(documentation, SymbolDisplayPartKind.text, /*symbol:*/ null)];
// Having all this logic here is pretty unclean. Consider moving to the roslyn model
// where all symbol display logic is encapsulated into visitors and options.
var totalParts: SymbolDisplayPart[] = [];
if (symbol.flags & SymbolFlags.Class) {
totalParts.push(new SymbolDisplayPart("class", SymbolDisplayPartKind.keyword, undefined));
totalParts.push(new SymbolDisplayPart(" ", SymbolDisplayPartKind.space, undefined));
totalParts.push.apply(totalParts, typeInfoResolver.symbolToDisplayParts(symbol, sourceFile));
}
else if (symbol.flags & SymbolFlags.Interface) {
totalParts.push(new SymbolDisplayPart("interface", SymbolDisplayPartKind.keyword, undefined));
totalParts.push(new SymbolDisplayPart(" ", SymbolDisplayPartKind.space, undefined));
totalParts.push.apply(totalParts, typeInfoResolver.symbolToDisplayParts(symbol, sourceFile));
}
else if (symbol.flags & SymbolFlags.Enum) {
totalParts.push(new SymbolDisplayPart("enum", SymbolDisplayPartKind.keyword, undefined));
totalParts.push(new SymbolDisplayPart(" ", SymbolDisplayPartKind.space, undefined));
totalParts.push.apply(totalParts, typeInfoResolver.symbolToDisplayParts(symbol, sourceFile));
}
else if (symbol.flags & SymbolFlags.Module) {
totalParts.push(new SymbolDisplayPart("module", SymbolDisplayPartKind.keyword, undefined));
totalParts.push(new SymbolDisplayPart(" ", SymbolDisplayPartKind.space, undefined));
totalParts.push.apply(totalParts, typeInfoResolver.symbolToDisplayParts(symbol, sourceFile));
}
else if (symbol.flags & SymbolFlags.TypeParameter) {
totalParts.push(new SymbolDisplayPart("(", SymbolDisplayPartKind.punctuation, undefined));
totalParts.push(new SymbolDisplayPart("type parameter", SymbolDisplayPartKind.text, undefined));
totalParts.push(new SymbolDisplayPart(")", SymbolDisplayPartKind.punctuation, undefined));
totalParts.push(new SymbolDisplayPart(" ", SymbolDisplayPartKind.space, undefined));
totalParts.push.apply(totalParts, typeInfoResolver.symbolToDisplayParts(symbol));
}
else {
totalParts.push(new SymbolDisplayPart("(", SymbolDisplayPartKind.punctuation, undefined));
var text: string;
if (symbol.flags & SymbolFlags.Property) { text = "property" }
else if (symbol.flags & SymbolFlags.EnumMember) { text = "enum member" }
else if (symbol.flags & SymbolFlags.Function) { text = "function" }
else if (symbol.flags & SymbolFlags.Variable) { text = "variable" }
else if (symbol.flags & SymbolFlags.Method) { text = "method" }
if (!text) {
return undefined;
}
totalParts.push(new SymbolDisplayPart(text, SymbolDisplayPartKind.text, undefined));
totalParts.push(new SymbolDisplayPart(")", SymbolDisplayPartKind.punctuation, undefined));
totalParts.push(new SymbolDisplayPart(" ", SymbolDisplayPartKind.space, undefined));
totalParts.push.apply(totalParts, typeInfoResolver.symbolToDisplayParts(symbol, getContainerNode(node)));
var type = typeInfoResolver.getTypeOfSymbol(symbol);
if (symbol.flags & SymbolFlags.Property ||
symbol.flags & SymbolFlags.Variable) {
if (type) {
totalParts.push(new SymbolDisplayPart(":", SymbolDisplayPartKind.punctuation, undefined));
totalParts.push(new SymbolDisplayPart(" ", SymbolDisplayPartKind.space, undefined));
totalParts.push.apply(totalParts, typeInfoResolver.typeToDisplayParts(type, getContainerNode(node)));
}
}
else if (symbol.flags & SymbolFlags.Function ||
symbol.flags & SymbolFlags.Method) {
if (type) {
totalParts.push.apply(totalParts, typeInfoResolver.typeToDisplayParts(type, getContainerNode(node)));
}
}
else if (symbol.flags & SymbolFlags.EnumMember) {
var declaration = symbol.declarations[0];
if (declaration.kind === SyntaxKind.EnumMember) {
var constantValue = typeInfoResolver.getEnumMemberValue(<EnumMember>declaration);
if (constantValue !== undefined) {
totalParts.push(new SymbolDisplayPart(" ", SymbolDisplayPartKind.space, undefined));
totalParts.push(new SymbolDisplayPart("=", SymbolDisplayPartKind.operator, undefined));
totalParts.push(new SymbolDisplayPart(" ", SymbolDisplayPartKind.space, undefined));
totalParts.push(new SymbolDisplayPart(constantValue.toString(), SymbolDisplayPartKind.numericLiteral, undefined));
}
}
}
}
return new QuickInfo(
getSymbolKind(symbol),
getSymbolModifiers(symbol),
new TypeScript.TextSpan(node.getStart(), node.getWidth()),
totalParts,
documentationParts);
}
function getTypeAtPosition(fileName: string, position: number): TypeInfo {
synchronizeHostData();
@@ -3759,14 +4039,61 @@ module ts {
}
function getBraceMatchingAtPosition(filename: string, position: number) {
filename = TypeScript.switchToForwardSlashes(filename);
var syntaxTree = getSyntaxTree(filename);
return TypeScript.Services.BraceMatcher.getMatchSpans(syntaxTree, position);
var sourceFile = getCurrentSourceFile(filename);
var result: TypeScript.TextSpan[] = [];
var token = getTokenAtPosition(sourceFile, position);
if (token.getStart(sourceFile) === position) {
var matchKind = getMatchingTokenKind(token);
// Ensure that there is a corresponding token to match ours.
if (matchKind) {
var parentElement = token.parent;
var childNodes = parentElement.getChildren(sourceFile);
for (var i = 0, n = childNodes.length; i < n; i++) {
var current = childNodes[i];
if (current.kind === matchKind) {
var range1 = new TypeScript.TextSpan(token.getStart(sourceFile), token.getWidth(sourceFile));
var range2 = new TypeScript.TextSpan(current.getStart(sourceFile), current.getWidth(sourceFile));
// We want to order the braces when we return the result.
if (range1.start() < range2.start()) {
result.push(range1, range2);
}
else {
result.push(range2, range1);
}
break;
}
}
}
}
return result;
function getMatchingTokenKind(token: Node): ts.SyntaxKind {
switch (token.kind) {
case ts.SyntaxKind.OpenBraceToken: return ts.SyntaxKind.CloseBraceToken
case ts.SyntaxKind.OpenParenToken: return ts.SyntaxKind.CloseParenToken;
case ts.SyntaxKind.OpenBracketToken: return ts.SyntaxKind.CloseBracketToken;
case ts.SyntaxKind.LessThanToken: return ts.SyntaxKind.GreaterThanToken;
case ts.SyntaxKind.CloseBraceToken: return ts.SyntaxKind.OpenBraceToken
case ts.SyntaxKind.CloseParenToken: return ts.SyntaxKind.OpenParenToken;
case ts.SyntaxKind.CloseBracketToken: return ts.SyntaxKind.OpenBracketToken;
case ts.SyntaxKind.GreaterThanToken: return ts.SyntaxKind.LessThanToken;
}
return undefined;
}
}
function getIndentationAtPosition(filename: string, position: number, editorOptions: EditorOptions) {
filename = TypeScript.switchToForwardSlashes(filename);
var sourceFile = getCurrentSourceFile(filename);
var options = new TypeScript.FormattingOptions(!editorOptions.ConvertTabsToSpaces, editorOptions.TabSize, editorOptions.IndentSize, editorOptions.NewLineCharacter)
@@ -3880,8 +4207,8 @@ module ts {
}
// Looks to be within the trivia. See if we can find the comment containing it.
if (!getContainingComment(getTrailingComments(fileContents, token.getFullStart()), matchPosition) &&
!getContainingComment(getLeadingComments(fileContents, token.getFullStart()), matchPosition)) {
if (!getContainingComment(getTrailingCommentRanges(fileContents, token.getFullStart()), matchPosition) &&
!getContainingComment(getLeadingCommentRanges(fileContents, token.getFullStart()), matchPosition)) {
continue;
}
@@ -3968,7 +4295,7 @@ module ts {
return new RegExp(regExpString, "gim");
}
function getContainingComment(comments: Comment[], position: number): Comment {
function getContainingComment(comments: CommentRange[], position: number): CommentRange {
if (comments) {
for (var i = 0, n = comments.length; i < n; i++) {
var comment = comments[i];
@@ -4006,7 +4333,7 @@ module ts {
var kind = getSymbolKind(symbol);
if (kind) {
return RenameInfo.Create(symbol.name, typeInfoResolver.getFullyQualifiedName(symbol), kind,
getNodeModifiers(symbol.getDeclarations()[0]),
getSymbolModifiers(symbol),
new TypeScript.TextSpan(node.getStart(), node.getWidth()));
}
}
@@ -4026,6 +4353,7 @@ module ts {
getCompletionsAtPosition: getCompletionsAtPosition,
getCompletionEntryDetails: getCompletionEntryDetails,
getTypeAtPosition: getTypeAtPosition,
getQuickInfoAtPosition: getQuickInfoAtPosition,
getSignatureHelpItems: (filename, position): SignatureHelpItems => null,
getSignatureHelpCurrentArgumentState: (fileName, position, applicableSpanStart): SignatureHelpState => null,
getDefinitionAtPosition: getDefinitionAtPosition,
+12
View File
@@ -87,7 +87,9 @@ module ts {
getCompletionsAtPosition(fileName: string, position: number, isMemberCompletion: boolean): string;
getCompletionEntryDetails(fileName: string, position: number, entryName: string): string;
getQuickInfoAtPosition(fileName: string, position: number): string;
getTypeAtPosition(fileName: string, position: number): string;
getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): string;
getBreakpointStatementAtPosition(fileName: string, position: number): string;
@@ -540,6 +542,16 @@ module ts {
/// QUICKINFO
/// Computes a string representation of the type at the requested position
/// in the active file.
public getQuickInfoAtPosition(fileName: string, position: number): string {
return this.forwardJSONCall(
"getQuickInfoAtPosition('" + fileName + "', " + position + ")",
() => {
var quickInfo = this.languageService.getQuickInfoAtPosition(fileName, position);
return quickInfo;
});
}
public getTypeAtPosition(fileName: string, position: number): string {
return this.forwardJSONCall(
"getTypeAtPosition('" + fileName + "', " + position + ")",
@@ -42,6 +42,10 @@ module TypeScript {
return this.defaultVisit(node);
}
public visitTupleType(node: TupleTypeSyntax): any {
return this.defaultVisit(node);
}
public visitInterfaceDeclaration(node: InterfaceDeclarationSyntax): any {
return this.defaultVisit(node);
}
+40 -7
View File
@@ -1048,6 +1048,7 @@ module TypeScript.Parser {
case SyntaxKind.ExportKeyword:
case SyntaxKind.PublicKeyword:
case SyntaxKind.PrivateKeyword:
case SyntaxKind.ProtectedKeyword:
case SyntaxKind.StaticKeyword:
case SyntaxKind.DeclareKeyword:
return true;
@@ -1434,6 +1435,19 @@ module TypeScript.Parser {
return new syntaxFactory.ObjectTypeSyntax(parseNodeData, openBraceToken, typeMembers, eatToken(SyntaxKind.CloseBraceToken));
}
function parseTupleType(currentToken: ISyntaxToken): TupleTypeSyntax {
var openBracket = consumeToken(currentToken);
var types = Syntax.emptySeparatedList<ITypeSyntax>();
if (openBracket.fullWidth() > 0) {
var skippedTokens: ISyntaxToken[] = getArray();
types = parseSeparatedSyntaxList<ITypeSyntax>(ListParsingState.TupleType_Types, skippedTokens);
openBracket = addSkippedTokensAfterToken(openBracket, skippedTokens);
}
return new syntaxFactory.TupleTypeSyntax(parseNodeData, openBracket, types, eatToken(SyntaxKind.CloseBracketToken));
}
function isTypeMember(inErrorRecovery: boolean): boolean {
if (SyntaxUtilities.isTypeMember(currentNode())) {
return true;
@@ -1663,6 +1677,7 @@ module TypeScript.Parser {
// ERROR RECOVERY
case SyntaxKind.PublicKeyword:
case SyntaxKind.PrivateKeyword:
case SyntaxKind.ProtectedKeyword:
case SyntaxKind.StaticKeyword:
// None of the above are actually keywords. And they might show up in a real
// statement (i.e. "public();"). However, if we see 'public <identifier>' then
@@ -1731,6 +1746,7 @@ module TypeScript.Parser {
// ERROR RECOVERY
case SyntaxKind.PublicKeyword:
case SyntaxKind.PrivateKeyword:
case SyntaxKind.ProtectedKeyword:
case SyntaxKind.StaticKeyword:
// None of the above are actually keywords. And they might show up in a real
// statement (i.e. "public();"). However, if we see 'public <identifier>' then
@@ -3133,7 +3149,7 @@ module TypeScript.Parser {
token2 = peekToken(2);
token2Kind = token2.kind();
if (token1Kind === SyntaxKind.PublicKeyword || token1Kind === SyntaxKind.PrivateKeyword) {
if (SyntaxFacts.isAccessibilityModifier(token1Kind)) {
if (isIdentifier(token2)) {
// "(public id" or "(function id". Definitely an arrow function. Could never
// be a parenthesized expression. Note: this will be an *illegal* arrow
@@ -3557,11 +3573,12 @@ module TypeScript.Parser {
return consumeToken(_currentToken);
case SyntaxKind.OpenParenToken:
case SyntaxKind.LessThanToken: return tryParseFunctionType();
case SyntaxKind.VoidKeyword: return consumeToken(_currentToken);
case SyntaxKind.OpenBraceToken: return parseObjectType();
case SyntaxKind.NewKeyword: return parseConstructorType();
case SyntaxKind.TypeOfKeyword: return parseTypeQuery(_currentToken);
case SyntaxKind.LessThanToken: return tryParseFunctionType();
case SyntaxKind.VoidKeyword: return consumeToken(_currentToken);
case SyntaxKind.OpenBraceToken: return parseObjectType();
case SyntaxKind.NewKeyword: return parseConstructorType();
case SyntaxKind.TypeOfKeyword: return parseTypeQuery(_currentToken);
case SyntaxKind.OpenBracketToken: return parseTupleType(_currentToken);
}
return tryParseNameOrGenericType();
@@ -3973,6 +3990,7 @@ module TypeScript.Parser {
case ListParsingState.IndexSignature_Parameters: return isExpectedIndexSignature_ParametersTerminator();
case ListParsingState.TypeArgumentList_Types: return isExpectedTypeArgumentList_TypesTerminator();
case ListParsingState.TypeParameterList_TypeParameters: return isExpectedTypeParameterList_TypeParametersTerminator();
case ListParsingState.TupleType_Types: return isExpectedTupleType_TypesTerminator();
default:
throw Errors.invalidOperation();
}
@@ -4019,6 +4037,17 @@ module TypeScript.Parser {
return false;
}
function isExpectedTupleType_TypesTerminator(): boolean {
var token = currentToken();
var tokenKind = token.kind();
if (tokenKind === SyntaxKind.CloseBracketToken) {
return true;
}
// TODO: add more cases as necessary for error tolerance.
return false;
}
function isExpectedTypeParameterList_TypeParametersTerminator(): boolean {
var tokenKind = currentToken().kind();
if (tokenKind === SyntaxKind.GreaterThanToken) {
@@ -4187,6 +4216,7 @@ module TypeScript.Parser {
case ListParsingState.IndexSignature_Parameters: return isParameter();
case ListParsingState.TypeArgumentList_Types: return isType();
case ListParsingState.TypeParameterList_TypeParameters: return isTypeParameter();
case ListParsingState.TupleType_Types: return isType();
default: throw Errors.invalidOperation();
}
}
@@ -4230,6 +4260,7 @@ module TypeScript.Parser {
case ListParsingState.IndexSignature_Parameters: return tryParseParameter();
case ListParsingState.TypeArgumentList_Types: return tryParseType();
case ListParsingState.TypeParameterList_TypeParameters: return tryParseTypeParameter();
case ListParsingState.TupleType_Types: return tryParseType();
default: throw Errors.invalidOperation();
}
}
@@ -4254,6 +4285,7 @@ module TypeScript.Parser {
case ListParsingState.IndexSignature_Parameters: return getLocalizedText(DiagnosticCode.parameter, null);
case ListParsingState.TypeArgumentList_Types: return getLocalizedText(DiagnosticCode.type, null);
case ListParsingState.TypeParameterList_TypeParameters: return getLocalizedText(DiagnosticCode.type_parameter, null);
case ListParsingState.TupleType_Types: return getLocalizedText(DiagnosticCode.type, null);
case ListParsingState.ArrayLiteralExpression_AssignmentExpressions: return getLocalizedText(DiagnosticCode.expression, null);
default: throw Errors.invalidOperation();
}
@@ -4376,9 +4408,10 @@ module TypeScript.Parser {
IndexSignature_Parameters = 18,
TypeArgumentList_Types = 19,
TypeParameterList_TypeParameters = 20,
TupleType_Types = 21,
FirstListParsingState = SourceUnit_ModuleElements,
LastListParsingState = TypeParameterList_TypeParameters,
LastListParsingState = TupleType_Types,
}
// We keep the parser around as a singleton. This is because calling createParser is actually
+6
View File
@@ -421,6 +421,12 @@ module TypeScript.PrettyPrinter {
this.appendToken(node.greaterThanToken);
}
public visitTupleType(node: TupleTypeSyntax): void {
this.appendToken(node.openBracketToken);
this.appendSeparatorSpaceList(node.types);
this.appendToken(node.closeBracketToken);
}
public visitConstructorType(node: ConstructorTypeSyntax): void {
this.appendToken(node.newKeyword);
this.ensureSpace();
+11
View File
@@ -26,4 +26,15 @@ module TypeScript.SyntaxFacts {
var tokenKind = token.kind();
return tokenKind === SyntaxKind.IdentifierName || SyntaxFacts.isAnyKeyword(tokenKind);
}
export function isAccessibilityModifier(kind: SyntaxKind): boolean {
switch (kind) {
case SyntaxKind.PublicKeyword:
case SyntaxKind.PrivateKeyword:
case SyntaxKind.ProtectedKeyword:
return true;
}
return false;
}
}
+11
View File
@@ -354,6 +354,17 @@ var definitions:ITypeDefinition[] = [
],
isTypeScriptSpecific: true
},
<any> {
name: 'TupleTypeSyntax',
baseType: 'ISyntaxNode',
interfaces: ['ITypeSyntax'],
children: [
<any>{ name: 'openBracketToken', isToken: true, excludeFromAST: true },
<any>{ name: 'types', isSeparatedList: true, elementType: 'ITypeSyntax' },
<any>{ name: 'closeBracketToken', isToken: true, excludeFromAST: true }
],
isTypeScriptSpecific: true
},
<any>{
name: 'TypeAnnotationSyntax',
baseType: 'ISyntaxNode',
+1
View File
@@ -158,6 +158,7 @@ module TypeScript {
ConstructorType,
GenericType,
TypeQuery,
TupleType,
// Module elements.
InterfaceDeclaration,
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+13 -6
View File
@@ -84,6 +84,7 @@ module TypeScript {
private cacheSyntaxTreeInfo(): void {
// If we're not keeping around the syntax tree, store the diagnostics and line
// map so they don't have to be recomputed.
var sourceUnit = this.sourceUnit();
var firstToken = firstSyntaxTreeToken(this);
var leadingTrivia = firstToken.leadingTrivia(this.text);
@@ -238,7 +239,7 @@ module TypeScript {
}
private checkParameterAccessibilityModifier(parameterList: ParameterListSyntax, modifier: ISyntaxToken, modifierIndex: number): boolean {
if (modifier.kind() !== SyntaxKind.PublicKeyword && modifier.kind() !== SyntaxKind.PrivateKeyword) {
if (!SyntaxFacts.isAccessibilityModifier(modifier.kind())) {
this.pushDiagnostic(modifier, DiagnosticCode._0_modifier_cannot_appear_on_a_parameter, [modifier.text()]);
return true;
}
@@ -320,6 +321,15 @@ module TypeScript {
super.visitTypeArgumentList(node);
}
public visitTupleType(node: TupleTypeSyntax): void {
if (this.checkForTrailingComma(node.types) ||
this.checkForAtLeastOneElement(node, node.types, node.openBracketToken, getLocalizedText(DiagnosticCode.type, null))) {
return
}
super.visitTupleType(node);
}
public visitTypeParameterList(node: TypeParameterListSyntax): void {
if (this.checkForTrailingComma(node.typeParameters) ||
this.checkForAtLeastOneElement(node, node.typeParameters, node.lessThanToken, getLocalizedText(DiagnosticCode.type_parameter, null))) {
@@ -514,9 +524,7 @@ module TypeScript {
for (var i = 0, n = list.length; i < n; i++) {
var modifier = list[i];
if (modifier.kind() === SyntaxKind.PublicKeyword ||
modifier.kind() === SyntaxKind.PrivateKeyword) {
if (SyntaxFacts.isAccessibilityModifier(modifier.kind())) {
if (seenAccessibilityModifier) {
this.pushDiagnostic(modifier, DiagnosticCode.Accessibility_modifier_already_seen);
return true;
@@ -751,8 +759,7 @@ module TypeScript {
for (var i = 0, n = modifiers.length; i < n; i++) {
var modifier = modifiers[i];
if (modifier.kind() === SyntaxKind.PublicKeyword ||
modifier.kind() === SyntaxKind.PrivateKeyword ||
if (SyntaxFacts.isAccessibilityModifier(modifier.kind()) ||
modifier.kind() === SyntaxKind.StaticKeyword) {
this.pushDiagnostic(modifier, DiagnosticCode._0_modifier_cannot_appear_on_a_module_element, [modifier.text()]);
return true;
@@ -13,6 +13,7 @@ module TypeScript {
case SyntaxKind.ConstructorType: return visitor.visitConstructorType(<ConstructorTypeSyntax>element);
case SyntaxKind.GenericType: return visitor.visitGenericType(<GenericTypeSyntax>element);
case SyntaxKind.TypeQuery: return visitor.visitTypeQuery(<TypeQuerySyntax>element);
case SyntaxKind.TupleType: return visitor.visitTupleType(<TupleTypeSyntax>element);
case SyntaxKind.InterfaceDeclaration: return visitor.visitInterfaceDeclaration(<InterfaceDeclarationSyntax>element);
case SyntaxKind.FunctionDeclaration: return visitor.visitFunctionDeclaration(<FunctionDeclarationSyntax>element);
case SyntaxKind.ModuleDeclaration: return visitor.visitModuleDeclaration(<ModuleDeclarationSyntax>element);
@@ -109,6 +110,7 @@ module TypeScript {
visitConstructorType(node: ConstructorTypeSyntax): any;
visitGenericType(node: GenericTypeSyntax): any;
visitTypeQuery(node: TypeQuerySyntax): any;
visitTupleType(node: TupleTypeSyntax): any;
visitInterfaceDeclaration(node: InterfaceDeclarationSyntax): any;
visitFunctionDeclaration(node: FunctionDeclarationSyntax): any;
visitModuleDeclaration(node: ModuleDeclarationSyntax): any;
@@ -103,6 +103,12 @@ module TypeScript {
this.visitNodeOrToken(node.name);
}
public visitTupleType(node: TupleTypeSyntax): void {
this.visitToken(node.openBracketToken);
this.visitSeparatedList(node.types);
this.visitToken(node.closeBracketToken);
}
public visitInterfaceDeclaration(node: InterfaceDeclarationSyntax): void {
this.visitList(node.modifiers);
this.visitToken(node.interfaceKeyword);
@@ -1,4 +1,4 @@
tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithModulesExportedStaticFunctionUsingClassPrivateStatics.ts(11,16): error TS2341: Property 'clodule.sfn' is inaccessible.
tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithModulesExportedStaticFunctionUsingClassPrivateStatics.ts(11,16): error TS2341: Property 'sfn' is private and only accessible within class 'clodule<T>'.
==== tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithModulesExportedStaticFunctionUsingClassPrivateStatics.ts (1 errors) ====
@@ -14,7 +14,7 @@ tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMer
export function fn<T>(x: T, y: T): number {
return clodule.sfn('a');
~~~~~~~~~~~
!!! error TS2341: Property 'clodule.sfn' is inaccessible.
!!! error TS2341: Property 'sfn' is private and only accessible within class 'clodule<T>'.
}
}
@@ -0,0 +1,8 @@
tests/cases/conformance/parser/ecmascript5/Protected/Protected1.ts(1,1): error TS1044: 'protected' modifier cannot appear on a module element.
==== tests/cases/conformance/parser/ecmascript5/Protected/Protected1.ts (1 errors) ====
protected class C {
~~~~~~~~~
!!! error TS1044: 'protected' modifier cannot appear on a module element.
}
@@ -0,0 +1,8 @@
tests/cases/conformance/parser/ecmascript5/Protected/Protected2.ts(1,1): error TS1044: 'protected' modifier cannot appear on a module element.
==== tests/cases/conformance/parser/ecmascript5/Protected/Protected2.ts (1 errors) ====
protected module M {
~~~~~~~~~
!!! error TS1044: 'protected' modifier cannot appear on a module element.
}
@@ -0,0 +1,9 @@
tests/cases/conformance/parser/ecmascript5/Protected/Protected3.ts(2,3): error TS1089: 'protected' modifier cannot appear on a constructor declaration.
==== tests/cases/conformance/parser/ecmascript5/Protected/Protected3.ts (1 errors) ====
class C {
protected constructor() { }
~~~~~~~~~
!!! error TS1089: 'protected' modifier cannot appear on a constructor declaration.
}
@@ -0,0 +1,9 @@
tests/cases/conformance/parser/ecmascript5/Protected/Protected4.ts(2,13): error TS1028: Accessibility modifier already seen.
==== tests/cases/conformance/parser/ecmascript5/Protected/Protected4.ts (1 errors) ====
class C {
protected public m() { }
~~~~~~
!!! error TS1028: Accessibility modifier already seen.
}
+13
View File
@@ -0,0 +1,13 @@
//// [Protected5.ts]
class C {
protected static m() { }
}
//// [Protected5.js]
var C = (function () {
function C() {
}
C.m = function () {
};
return C;
})();
@@ -0,0 +1,7 @@
=== tests/cases/conformance/parser/ecmascript5/Protected/Protected5.ts ===
class C {
>C : C
protected static m() { }
>m : () => void
}
@@ -0,0 +1,9 @@
tests/cases/conformance/parser/ecmascript5/Protected/Protected6.ts(2,10): error TS1029: 'protected' modifier must precede 'static' modifier.
==== tests/cases/conformance/parser/ecmascript5/Protected/Protected6.ts (1 errors) ====
class C {
static protected m() { }
~~~~~~~~~
!!! error TS1029: 'protected' modifier must precede 'static' modifier.
}
@@ -0,0 +1,9 @@
tests/cases/conformance/parser/ecmascript5/Protected/Protected7.ts(2,13): error TS1028: Accessibility modifier already seen.
==== tests/cases/conformance/parser/ecmascript5/Protected/Protected7.ts (1 errors) ====
class C {
protected private m() { }
~~~~~~~
!!! error TS1028: Accessibility modifier already seen.
}
+7
View File
@@ -0,0 +1,7 @@
//// [Protected8.ts]
interface I {
protected
p
}
//// [Protected8.js]
@@ -0,0 +1,10 @@
=== tests/cases/conformance/parser/ecmascript5/Protected/Protected8.ts ===
interface I {
>I : I
protected
>protected : any
p
>p : any
}
+12
View File
@@ -0,0 +1,12 @@
//// [Protected9.ts]
class C {
constructor(protected p) { }
}
//// [Protected9.js]
var C = (function () {
function C(p) {
this.p = p;
}
return C;
})();
@@ -0,0 +1,7 @@
=== tests/cases/conformance/parser/ecmascript5/Protected/Protected9.ts ===
class C {
>C : C
constructor(protected p) { }
>p : any
}
+5
View File
@@ -0,0 +1,5 @@
//// [TupleType1.ts]
var v: [number]
//// [TupleType1.js]
var v;
@@ -0,0 +1,4 @@
=== tests/cases/conformance/parser/ecmascript5/TupleTypes/TupleType1.ts ===
var v: [number]
>v : [number]
+5
View File
@@ -0,0 +1,5 @@
//// [TupleType2.ts]
var v: [number, string]
//// [TupleType2.js]
var v;
@@ -0,0 +1,4 @@
=== tests/cases/conformance/parser/ecmascript5/TupleTypes/TupleType2.ts ===
var v: [number, string]
>v : [number, string]
@@ -0,0 +1,7 @@
tests/cases/conformance/parser/ecmascript5/TupleTypes/TupleType3.ts(1,8): error TS1122: A tuple type element list cannot be empty.
==== tests/cases/conformance/parser/ecmascript5/TupleTypes/TupleType3.ts (1 errors) ====
var v: []
~~
!!! error TS1122: A tuple type element list cannot be empty.
@@ -0,0 +1,7 @@
tests/cases/conformance/parser/ecmascript5/TupleTypes/TupleType4.ts(1,9): error TS1005: ']' expected.
==== tests/cases/conformance/parser/ecmascript5/TupleTypes/TupleType4.ts (1 errors) ====
var v: [
!!! error TS1005: ']' expected.
@@ -0,0 +1,7 @@
tests/cases/conformance/parser/ecmascript5/TupleTypes/TupleType5.ts(1,15): error TS1009: Trailing comma not allowed.
==== tests/cases/conformance/parser/ecmascript5/TupleTypes/TupleType5.ts (1 errors) ====
var v: [number,]
~
!!! error TS1009: Trailing comma not allowed.
@@ -0,0 +1,99 @@
tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(22,12): error TS1029: 'private' modifier must precede 'static' modifier.
tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(23,12): error TS1029: 'private' modifier must precede 'static' modifier.
tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(24,12): error TS1029: 'private' modifier must precede 'static' modifier.
tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(25,12): error TS1029: 'private' modifier must precede 'static' modifier.
tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(27,12): error TS1029: 'protected' modifier must precede 'static' modifier.
tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(28,12): error TS1029: 'protected' modifier must precede 'static' modifier.
tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(29,12): error TS1029: 'protected' modifier must precede 'static' modifier.
tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(30,12): error TS1029: 'protected' modifier must precede 'static' modifier.
tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(32,12): error TS1029: 'public' modifier must precede 'static' modifier.
tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(33,12): error TS1029: 'public' modifier must precede 'static' modifier.
tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(34,12): error TS1029: 'public' modifier must precede 'static' modifier.
tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(35,12): error TS1029: 'public' modifier must precede 'static' modifier.
tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(40,13): error TS1028: Accessibility modifier already seen.
tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(40,20): error TS1028: Accessibility modifier already seen.
tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(41,12): error TS1028: Accessibility modifier already seen.
tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(42,13): error TS1028: Accessibility modifier already seen.
tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(43,12): error TS1028: Accessibility modifier already seen.
==== tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts (17 errors) ====
// No errors
class C {
private static privateProperty;
private static privateMethod() { }
private static get privateGetter() { return 0; }
private static set privateSetter(a: number) { }
protected static protectedProperty;
protected static protectedMethod() { }
protected static get protectedGetter() { return 0; }
protected static set protectedSetter(a: number) { }
public static publicProperty;
public static publicMethod() { }
public static get publicGetter() { return 0; }
public static set publicSetter(a: number) { }
}
// Errors, accessibility modifiers must precede static
class D {
static private privateProperty;
~~~~~~~
!!! error TS1029: 'private' modifier must precede 'static' modifier.
static private privateMethod() { }
~~~~~~~
!!! error TS1029: 'private' modifier must precede 'static' modifier.
static private get privateGetter() { return 0; }
~~~~~~~
!!! error TS1029: 'private' modifier must precede 'static' modifier.
static private set privateSetter(a: number) { }
~~~~~~~
!!! error TS1029: 'private' modifier must precede 'static' modifier.
static protected protectedProperty;
~~~~~~~~~
!!! error TS1029: 'protected' modifier must precede 'static' modifier.
static protected protectedMethod() { }
~~~~~~~~~
!!! error TS1029: 'protected' modifier must precede 'static' modifier.
static protected get protectedGetter() { return 0; }
~~~~~~~~~
!!! error TS1029: 'protected' modifier must precede 'static' modifier.
static protected set protectedSetter(a: number) { }
~~~~~~~~~
!!! error TS1029: 'protected' modifier must precede 'static' modifier.
static public publicProperty;
~~~~~~
!!! error TS1029: 'public' modifier must precede 'static' modifier.
static public publicMethod() { }
~~~~~~
!!! error TS1029: 'public' modifier must precede 'static' modifier.
static public get publicGetter() { return 0; }
~~~~~~
!!! error TS1029: 'public' modifier must precede 'static' modifier.
static public set publicSetter(a: number) { }
~~~~~~
!!! error TS1029: 'public' modifier must precede 'static' modifier.
}
// Errors, multiple accessibility modifier
class E {
private public protected property;
~~~~~~
!!! error TS1028: Accessibility modifier already seen.
~~~~~~~~~
!!! error TS1028: Accessibility modifier already seen.
public protected method() { }
~~~~~~~~~
!!! error TS1028: Accessibility modifier already seen.
private protected get getter() { return 0; }
~~~~~~~~~
!!! error TS1028: Accessibility modifier already seen.
public public set setter(a: number) { }
~~~~~~
!!! error TS1028: Accessibility modifier already seen.
}
@@ -0,0 +1,59 @@
tests/cases/conformance/classes/propertyMemberDeclarations/memberAccessorDeclarations/accessorWithMismatchedAccessibilityModifiers.ts(3,9): error TS2379: Getter and setter accessors do not agree in visibility.
tests/cases/conformance/classes/propertyMemberDeclarations/memberAccessorDeclarations/accessorWithMismatchedAccessibilityModifiers.ts(6,17): error TS2379: Getter and setter accessors do not agree in visibility.
tests/cases/conformance/classes/propertyMemberDeclarations/memberAccessorDeclarations/accessorWithMismatchedAccessibilityModifiers.ts(11,19): error TS2379: Getter and setter accessors do not agree in visibility.
tests/cases/conformance/classes/propertyMemberDeclarations/memberAccessorDeclarations/accessorWithMismatchedAccessibilityModifiers.ts(14,17): error TS2379: Getter and setter accessors do not agree in visibility.
tests/cases/conformance/classes/propertyMemberDeclarations/memberAccessorDeclarations/accessorWithMismatchedAccessibilityModifiers.ts(19,19): error TS2379: Getter and setter accessors do not agree in visibility.
tests/cases/conformance/classes/propertyMemberDeclarations/memberAccessorDeclarations/accessorWithMismatchedAccessibilityModifiers.ts(21,9): error TS2379: Getter and setter accessors do not agree in visibility.
tests/cases/conformance/classes/propertyMemberDeclarations/memberAccessorDeclarations/accessorWithMismatchedAccessibilityModifiers.ts(27,26): error TS2379: Getter and setter accessors do not agree in visibility.
tests/cases/conformance/classes/propertyMemberDeclarations/memberAccessorDeclarations/accessorWithMismatchedAccessibilityModifiers.ts(29,16): error TS2379: Getter and setter accessors do not agree in visibility.
==== tests/cases/conformance/classes/propertyMemberDeclarations/memberAccessorDeclarations/accessorWithMismatchedAccessibilityModifiers.ts (8 errors) ====
class C {
get x() {
~
!!! error TS2379: Getter and setter accessors do not agree in visibility.
return 1;
}
private set x(v) {
~
!!! error TS2379: Getter and setter accessors do not agree in visibility.
}
}
class D {
protected get x() {
~
!!! error TS2379: Getter and setter accessors do not agree in visibility.
return 1;
}
private set x(v) {
~
!!! error TS2379: Getter and setter accessors do not agree in visibility.
}
}
class E {
protected set x(v) {
~
!!! error TS2379: Getter and setter accessors do not agree in visibility.
}
get x() {
~
!!! error TS2379: Getter and setter accessors do not agree in visibility.
return 1;
}
}
class F {
protected static set x(v) {
~
!!! error TS2379: Getter and setter accessors do not agree in visibility.
}
static get x() {
~
!!! error TS2379: Getter and setter accessors do not agree in visibility.
return 1;
}
}
@@ -0,0 +1,91 @@
//// [accessorWithMismatchedAccessibilityModifiers.ts]
class C {
get x() {
return 1;
}
private set x(v) {
}
}
class D {
protected get x() {
return 1;
}
private set x(v) {
}
}
class E {
protected set x(v) {
}
get x() {
return 1;
}
}
class F {
protected static set x(v) {
}
static get x() {
return 1;
}
}
//// [accessorWithMismatchedAccessibilityModifiers.js]
var C = (function () {
function C() {
}
Object.defineProperty(C.prototype, "x", {
get: function () {
return 1;
},
set: function (v) {
},
enumerable: true,
configurable: true
});
return C;
})();
var D = (function () {
function D() {
}
Object.defineProperty(D.prototype, "x", {
get: function () {
return 1;
},
set: function (v) {
},
enumerable: true,
configurable: true
});
return D;
})();
var E = (function () {
function E() {
}
Object.defineProperty(E.prototype, "x", {
get: function () {
return 1;
},
set: function (v) {
},
enumerable: true,
configurable: true
});
return E;
})();
var F = (function () {
function F() {
}
Object.defineProperty(F, "x", {
get: function () {
return 1;
},
set: function (v) {
},
enumerable: true,
configurable: true
});
return F;
})();
@@ -1,51 +1,51 @@
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersAccessibility.ts(31,5): error TS2322: Type 'E' is not assignable to type '{ foo: string; }':
Private property 'foo' cannot be reimplemented.
Property 'foo' is private in type 'E' but not in type '{ foo: string; }'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersAccessibility.ts(36,5): error TS2322: Type 'E' is not assignable to type 'Base':
Private property 'foo' cannot be reimplemented.
Property 'foo' is private in type 'E' but not in type 'Base'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersAccessibility.ts(41,5): error TS2322: Type 'E' is not assignable to type 'I':
Private property 'foo' cannot be reimplemented.
Property 'foo' is private in type 'E' but not in type 'I'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersAccessibility.ts(46,5): error TS2322: Type 'E' is not assignable to type 'D':
Private property 'foo' cannot be reimplemented.
Property 'foo' is private in type 'E' but not in type 'D'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersAccessibility.ts(48,5): error TS2322: Type '{ foo: string; }' is not assignable to type 'E':
Private property 'foo' cannot be reimplemented.
Property 'foo' is private in type 'E' but not in type '{ foo: string; }'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersAccessibility.ts(49,5): error TS2322: Type 'Base' is not assignable to type 'E':
Private property 'foo' cannot be reimplemented.
Property 'foo' is private in type 'E' but not in type 'Base'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersAccessibility.ts(50,5): error TS2322: Type 'I' is not assignable to type 'E':
Private property 'foo' cannot be reimplemented.
Property 'foo' is private in type 'E' but not in type 'I'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersAccessibility.ts(51,5): error TS2322: Type 'D' is not assignable to type 'E':
Private property 'foo' cannot be reimplemented.
Property 'foo' is private in type 'E' but not in type 'D'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersAccessibility.ts(81,5): error TS2322: Type 'Base' is not assignable to type '{ foo: string; }':
Private property 'foo' cannot be reimplemented.
Property 'foo' is private in type 'Base' but not in type '{ foo: string; }'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersAccessibility.ts(82,5): error TS2322: Type 'I' is not assignable to type '{ foo: string; }':
Private property 'foo' cannot be reimplemented.
Property 'foo' is private in type 'I' but not in type '{ foo: string; }'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersAccessibility.ts(84,5): error TS2322: Type 'E' is not assignable to type '{ foo: string; }':
Private property 'foo' cannot be reimplemented.
Property 'foo' is private in type 'E' but not in type '{ foo: string; }'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersAccessibility.ts(86,5): error TS2322: Type '{ foo: string; }' is not assignable to type 'Base':
Private property 'foo' cannot be reimplemented.
Property 'foo' is private in type 'Base' but not in type '{ foo: string; }'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersAccessibility.ts(88,5): error TS2322: Type 'D' is not assignable to type 'Base':
Private property 'foo' cannot be reimplemented.
Property 'foo' is private in type 'Base' but not in type 'D'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersAccessibility.ts(89,5): error TS2322: Type 'E' is not assignable to type 'Base':
Private property 'foo' cannot be reimplemented.
Types have separate declarations of a private property 'foo'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersAccessibility.ts(92,5): error TS2322: Type '{ foo: string; }' is not assignable to type 'I':
Private property 'foo' cannot be reimplemented.
Property 'foo' is private in type 'I' but not in type '{ foo: string; }'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersAccessibility.ts(94,5): error TS2322: Type 'D' is not assignable to type 'I':
Private property 'foo' cannot be reimplemented.
Property 'foo' is private in type 'I' but not in type 'D'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersAccessibility.ts(95,5): error TS2322: Type 'E' is not assignable to type 'I':
Private property 'foo' cannot be reimplemented.
Types have separate declarations of a private property 'foo'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersAccessibility.ts(99,5): error TS2322: Type 'Base' is not assignable to type 'D':
Private property 'foo' cannot be reimplemented.
Property 'foo' is private in type 'Base' but not in type 'D'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersAccessibility.ts(100,5): error TS2322: Type 'I' is not assignable to type 'D':
Private property 'foo' cannot be reimplemented.
Property 'foo' is private in type 'I' but not in type 'D'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersAccessibility.ts(101,5): error TS2322: Type 'E' is not assignable to type 'D':
Private property 'foo' cannot be reimplemented.
Property 'foo' is private in type 'E' but not in type 'D'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersAccessibility.ts(103,5): error TS2322: Type '{ foo: string; }' is not assignable to type 'E':
Private property 'foo' cannot be reimplemented.
Property 'foo' is private in type 'E' but not in type '{ foo: string; }'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersAccessibility.ts(104,5): error TS2322: Type 'Base' is not assignable to type 'E':
Private property 'foo' cannot be reimplemented.
Types have separate declarations of a private property 'foo'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersAccessibility.ts(105,5): error TS2322: Type 'I' is not assignable to type 'E':
Private property 'foo' cannot be reimplemented.
Types have separate declarations of a private property 'foo'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersAccessibility.ts(106,5): error TS2322: Type 'D' is not assignable to type 'E':
Private property 'foo' cannot be reimplemented.
Property 'foo' is private in type 'E' but not in type 'D'.
==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersAccessibility.ts (24 errors) ====
@@ -82,7 +82,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
a = e; // error
~
!!! error TS2322: Type 'E' is not assignable to type '{ foo: string; }':
!!! error TS2322: Private property 'foo' cannot be reimplemented.
!!! error TS2322: Property 'foo' is private in type 'E' but not in type '{ foo: string; }'.
b = a;
b = i;
@@ -90,7 +90,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
b = e; // error
~
!!! error TS2322: Type 'E' is not assignable to type 'Base':
!!! error TS2322: Private property 'foo' cannot be reimplemented.
!!! error TS2322: Property 'foo' is private in type 'E' but not in type 'Base'.
i = a;
i = b;
@@ -98,7 +98,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
i = e; // error
~
!!! error TS2322: Type 'E' is not assignable to type 'I':
!!! error TS2322: Private property 'foo' cannot be reimplemented.
!!! error TS2322: Property 'foo' is private in type 'E' but not in type 'I'.
d = a;
d = b;
@@ -106,24 +106,24 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
d = e; // error
~
!!! error TS2322: Type 'E' is not assignable to type 'D':
!!! error TS2322: Private property 'foo' cannot be reimplemented.
!!! error TS2322: Property 'foo' is private in type 'E' but not in type 'D'.
e = a; // errror
~
!!! error TS2322: Type '{ foo: string; }' is not assignable to type 'E':
!!! error TS2322: Private property 'foo' cannot be reimplemented.
!!! error TS2322: Property 'foo' is private in type 'E' but not in type '{ foo: string; }'.
e = b; // errror
~
!!! error TS2322: Type 'Base' is not assignable to type 'E':
!!! error TS2322: Private property 'foo' cannot be reimplemented.
!!! error TS2322: Property 'foo' is private in type 'E' but not in type 'Base'.
e = i; // errror
~
!!! error TS2322: Type 'I' is not assignable to type 'E':
!!! error TS2322: Private property 'foo' cannot be reimplemented.
!!! error TS2322: Property 'foo' is private in type 'E' but not in type 'I'.
e = d; // errror
~
!!! error TS2322: Type 'D' is not assignable to type 'E':
!!! error TS2322: Private property 'foo' cannot be reimplemented.
!!! error TS2322: Property 'foo' is private in type 'E' but not in type 'D'.
e = e;
}
@@ -156,77 +156,77 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
a = b; // error
~
!!! error TS2322: Type 'Base' is not assignable to type '{ foo: string; }':
!!! error TS2322: Private property 'foo' cannot be reimplemented.
!!! error TS2322: Property 'foo' is private in type 'Base' but not in type '{ foo: string; }'.
a = i; // error
~
!!! error TS2322: Type 'I' is not assignable to type '{ foo: string; }':
!!! error TS2322: Private property 'foo' cannot be reimplemented.
!!! error TS2322: Property 'foo' is private in type 'I' but not in type '{ foo: string; }'.
a = d;
a = e; // error
~
!!! error TS2322: Type 'E' is not assignable to type '{ foo: string; }':
!!! error TS2322: Private property 'foo' cannot be reimplemented.
!!! error TS2322: Property 'foo' is private in type 'E' but not in type '{ foo: string; }'.
b = a; // error
~
!!! error TS2322: Type '{ foo: string; }' is not assignable to type 'Base':
!!! error TS2322: Private property 'foo' cannot be reimplemented.
!!! error TS2322: Property 'foo' is private in type 'Base' but not in type '{ foo: string; }'.
b = i;
b = d; // error
~
!!! error TS2322: Type 'D' is not assignable to type 'Base':
!!! error TS2322: Private property 'foo' cannot be reimplemented.
!!! error TS2322: Property 'foo' is private in type 'Base' but not in type 'D'.
b = e; // error
~
!!! error TS2322: Type 'E' is not assignable to type 'Base':
!!! error TS2322: Private property 'foo' cannot be reimplemented.
!!! error TS2322: Types have separate declarations of a private property 'foo'.
b = b;
i = a; // error
~
!!! error TS2322: Type '{ foo: string; }' is not assignable to type 'I':
!!! error TS2322: Private property 'foo' cannot be reimplemented.
!!! error TS2322: Property 'foo' is private in type 'I' but not in type '{ foo: string; }'.
i = b;
i = d; // error
~
!!! error TS2322: Type 'D' is not assignable to type 'I':
!!! error TS2322: Private property 'foo' cannot be reimplemented.
!!! error TS2322: Property 'foo' is private in type 'I' but not in type 'D'.
i = e; // error
~
!!! error TS2322: Type 'E' is not assignable to type 'I':
!!! error TS2322: Private property 'foo' cannot be reimplemented.
!!! error TS2322: Types have separate declarations of a private property 'foo'.
i = i;
d = a;
d = b; // error
~
!!! error TS2322: Type 'Base' is not assignable to type 'D':
!!! error TS2322: Private property 'foo' cannot be reimplemented.
!!! error TS2322: Property 'foo' is private in type 'Base' but not in type 'D'.
d = i; // error
~
!!! error TS2322: Type 'I' is not assignable to type 'D':
!!! error TS2322: Private property 'foo' cannot be reimplemented.
!!! error TS2322: Property 'foo' is private in type 'I' but not in type 'D'.
d = e; // error
~
!!! error TS2322: Type 'E' is not assignable to type 'D':
!!! error TS2322: Private property 'foo' cannot be reimplemented.
!!! error TS2322: Property 'foo' is private in type 'E' but not in type 'D'.
e = a; // errror
~
!!! error TS2322: Type '{ foo: string; }' is not assignable to type 'E':
!!! error TS2322: Private property 'foo' cannot be reimplemented.
!!! error TS2322: Property 'foo' is private in type 'E' but not in type '{ foo: string; }'.
e = b; // errror
~
!!! error TS2322: Type 'Base' is not assignable to type 'E':
!!! error TS2322: Private property 'foo' cannot be reimplemented.
!!! error TS2322: Types have separate declarations of a private property 'foo'.
e = i; // errror
~
!!! error TS2322: Type 'I' is not assignable to type 'E':
!!! error TS2322: Private property 'foo' cannot be reimplemented.
!!! error TS2322: Types have separate declarations of a private property 'foo'.
e = d; // errror
~
!!! error TS2322: Type 'D' is not assignable to type 'E':
!!! error TS2322: Private property 'foo' cannot be reimplemented.
!!! error TS2322: Property 'foo' is private in type 'E' but not in type 'D'.
e = e;
}
@@ -1,15 +1,15 @@
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersOptionality.ts(73,5): error TS2322: Type 'D' is not assignable to type 'C':
Required property 'opt' cannot be reimplemented with optional property in 'D'.
Property 'opt' is optional in type 'D' but required in type 'C'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersOptionality.ts(74,5): error TS2322: Type 'E' is not assignable to type 'C':
Required property 'opt' cannot be reimplemented with optional property in 'E'.
Property 'opt' is optional in type 'E' but required in type 'C'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersOptionality.ts(78,5): error TS2322: Type 'D' is not assignable to type '{ opt: Base; }':
Required property 'opt' cannot be reimplemented with optional property in 'D'.
Property 'opt' is optional in type 'D' but required in type '{ opt: Base; }'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersOptionality.ts(79,5): error TS2322: Type 'E' is not assignable to type '{ opt: Base; }':
Required property 'opt' cannot be reimplemented with optional property in 'E'.
Property 'opt' is optional in type 'E' but required in type '{ opt: Base; }'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersOptionality.ts(83,5): error TS2322: Type 'D' is not assignable to type '{ opt: Base; }':
Required property 'opt' cannot be reimplemented with optional property in 'D'.
Property 'opt' is optional in type 'D' but required in type '{ opt: Base; }'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersOptionality.ts(84,5): error TS2322: Type 'E' is not assignable to type '{ opt: Base; }':
Required property 'opt' cannot be reimplemented with optional property in 'E'.
Property 'opt' is optional in type 'E' but required in type '{ opt: Base; }'.
==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersOptionality.ts (6 errors) ====
@@ -88,33 +88,33 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
c = d; // error
~
!!! error TS2322: Type 'D' is not assignable to type 'C':
!!! error TS2322: Required property 'opt' cannot be reimplemented with optional property in 'D'.
!!! error TS2322: Property 'opt' is optional in type 'D' but required in type 'C'.
c = e; // error
~
!!! error TS2322: Type 'E' is not assignable to type 'C':
!!! error TS2322: Required property 'opt' cannot be reimplemented with optional property in 'E'.
!!! error TS2322: Property 'opt' is optional in type 'E' but required in type 'C'.
c = f; // ok
c = a; // ok
a = d; // error
~
!!! error TS2322: Type 'D' is not assignable to type '{ opt: Base; }':
!!! error TS2322: Required property 'opt' cannot be reimplemented with optional property in 'D'.
!!! error TS2322: Property 'opt' is optional in type 'D' but required in type '{ opt: Base; }'.
a = e; // error
~
!!! error TS2322: Type 'E' is not assignable to type '{ opt: Base; }':
!!! error TS2322: Required property 'opt' cannot be reimplemented with optional property in 'E'.
!!! error TS2322: Property 'opt' is optional in type 'E' but required in type '{ opt: Base; }'.
a = f; // ok
a = c; // ok
b = d; // error
~
!!! error TS2322: Type 'D' is not assignable to type '{ opt: Base; }':
!!! error TS2322: Required property 'opt' cannot be reimplemented with optional property in 'D'.
!!! error TS2322: Property 'opt' is optional in type 'D' but required in type '{ opt: Base; }'.
b = e; // error
~
!!! error TS2322: Type 'E' is not assignable to type '{ opt: Base; }':
!!! error TS2322: Required property 'opt' cannot be reimplemented with optional property in 'E'.
!!! error TS2322: Property 'opt' is optional in type 'E' but required in type '{ opt: Base; }'.
b = f; // ok
b = a; // ok
b = c; // ok
@@ -1,5 +1,5 @@
tests/cases/compiler/assignmentCompatability10.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type 'classWithPublicAndOptional<number, string>':
Required property 'two' cannot be reimplemented with optional property in 'interfaceWithPublicAndOptional<number, string>'.
Property 'two' is optional in type 'interfaceWithPublicAndOptional<number, string>' but required in type 'classWithPublicAndOptional<number, string>'.
==== tests/cases/compiler/assignmentCompatability10.ts (1 errors) ====
@@ -14,4 +14,4 @@ tests/cases/compiler/assignmentCompatability10.ts(9,1): error TS2322: Type 'inte
__test2__.__val__x4 = __test1__.__val__obj4
~~~~~~~~~~~~~~~~~~~
!!! error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type 'classWithPublicAndOptional<number, string>':
!!! error TS2322: Required property 'two' cannot be reimplemented with optional property in 'interfaceWithPublicAndOptional<number, string>'.
!!! error TS2322: Property 'two' is optional in type 'interfaceWithPublicAndOptional<number, string>' but required in type 'classWithPublicAndOptional<number, string>'.
@@ -1,5 +1,5 @@
tests/cases/compiler/assignmentCompatability13.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '{ two: string; }':
Required property 'two' cannot be reimplemented with optional property in 'interfaceWithPublicAndOptional<number, string>'.
Property 'two' is optional in type 'interfaceWithPublicAndOptional<number, string>' but required in type '{ two: string; }'.
==== tests/cases/compiler/assignmentCompatability13.ts (1 errors) ====
@@ -14,4 +14,4 @@ tests/cases/compiler/assignmentCompatability13.ts(9,1): error TS2322: Type 'inte
__test2__.__val__obj = __test1__.__val__obj4
~~~~~~~~~~~~~~~~~~~~
!!! error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '{ two: string; }':
!!! error TS2322: Required property 'two' cannot be reimplemented with optional property in 'interfaceWithPublicAndOptional<number, string>'.
!!! error TS2322: Property 'two' is optional in type 'interfaceWithPublicAndOptional<number, string>' but required in type '{ two: string; }'.
@@ -1,5 +1,5 @@
tests/cases/compiler/assignmentCompatability27.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '{ two: string; }':
Required property 'two' cannot be reimplemented with optional property in 'interfaceWithPublicAndOptional<number, string>'.
Property 'two' is optional in type 'interfaceWithPublicAndOptional<number, string>' but required in type '{ two: string; }'.
==== tests/cases/compiler/assignmentCompatability27.ts (1 errors) ====
@@ -14,4 +14,4 @@ tests/cases/compiler/assignmentCompatability27.ts(9,1): error TS2322: Type 'inte
__test2__.__val__aa = __test1__.__val__obj4
~~~~~~~~~~~~~~~~~~~
!!! error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '{ two: string; }':
!!! error TS2322: Required property 'two' cannot be reimplemented with optional property in 'interfaceWithPublicAndOptional<number, string>'.
!!! error TS2322: Property 'two' is optional in type 'interfaceWithPublicAndOptional<number, string>' but required in type '{ two: string; }'.
@@ -1,5 +1,5 @@
tests/cases/compiler/assignmentCompatability39.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type 'classWithTwoPublic<number, string>':
Required property 'two' cannot be reimplemented with optional property in 'interfaceWithPublicAndOptional<number, string>'.
Property 'two' is optional in type 'interfaceWithPublicAndOptional<number, string>' but required in type 'classWithTwoPublic<number, string>'.
==== tests/cases/compiler/assignmentCompatability39.ts (1 errors) ====
@@ -14,4 +14,4 @@ tests/cases/compiler/assignmentCompatability39.ts(9,1): error TS2322: Type 'inte
__test2__.__val__x2 = __test1__.__val__obj4
~~~~~~~~~~~~~~~~~~~
!!! error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type 'classWithTwoPublic<number, string>':
!!! error TS2322: Required property 'two' cannot be reimplemented with optional property in 'interfaceWithPublicAndOptional<number, string>'.
!!! error TS2322: Property 'two' is optional in type 'interfaceWithPublicAndOptional<number, string>' but required in type 'classWithTwoPublic<number, string>'.
@@ -1,5 +1,5 @@
tests/cases/compiler/assignmentCompatability40.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type 'classWithPrivate<number>':
Private property 'one' cannot be reimplemented.
Property 'one' is private in type 'classWithPrivate<number>' but not in type 'interfaceWithPublicAndOptional<number, string>'.
==== tests/cases/compiler/assignmentCompatability40.ts (1 errors) ====
@@ -14,4 +14,4 @@ tests/cases/compiler/assignmentCompatability40.ts(9,1): error TS2322: Type 'inte
__test2__.__val__x5 = __test1__.__val__obj4
~~~~~~~~~~~~~~~~~~~
!!! error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type 'classWithPrivate<number>':
!!! error TS2322: Private property 'one' cannot be reimplemented.
!!! error TS2322: Property 'one' is private in type 'classWithPrivate<number>' but not in type 'interfaceWithPublicAndOptional<number, string>'.
@@ -1,5 +1,5 @@
tests/cases/compiler/assignmentCompatability41.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type 'classWithTwoPrivate<number, string>':
Private property 'one' cannot be reimplemented.
Property 'one' is private in type 'classWithTwoPrivate<number, string>' but not in type 'interfaceWithPublicAndOptional<number, string>'.
==== tests/cases/compiler/assignmentCompatability41.ts (1 errors) ====
@@ -14,4 +14,4 @@ tests/cases/compiler/assignmentCompatability41.ts(9,1): error TS2322: Type 'inte
__test2__.__val__x6 = __test1__.__val__obj4
~~~~~~~~~~~~~~~~~~~
!!! error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type 'classWithTwoPrivate<number, string>':
!!! error TS2322: Private property 'one' cannot be reimplemented.
!!! error TS2322: Property 'one' is private in type 'classWithTwoPrivate<number, string>' but not in type 'interfaceWithPublicAndOptional<number, string>'.
@@ -1,5 +1,5 @@
tests/cases/compiler/assignmentCompatability42.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type 'classWithPublicPrivate<number, string>':
Private property 'two' cannot be reimplemented.
Property 'two' is private in type 'classWithPublicPrivate<number, string>' but not in type 'interfaceWithPublicAndOptional<number, string>'.
==== tests/cases/compiler/assignmentCompatability42.ts (1 errors) ====
@@ -14,4 +14,4 @@ tests/cases/compiler/assignmentCompatability42.ts(9,1): error TS2322: Type 'inte
__test2__.__val__x7 = __test1__.__val__obj4
~~~~~~~~~~~~~~~~~~~
!!! error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type 'classWithPublicPrivate<number, string>':
!!! error TS2322: Private property 'two' cannot be reimplemented.
!!! error TS2322: Property 'two' is private in type 'classWithPublicPrivate<number, string>' but not in type 'interfaceWithPublicAndOptional<number, string>'.
@@ -1,5 +1,5 @@
tests/cases/compiler/assignmentCompatability43.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type 'interfaceTwo<number, string>':
Required property 'two' cannot be reimplemented with optional property in 'interfaceWithPublicAndOptional<number, string>'.
Property 'two' is optional in type 'interfaceWithPublicAndOptional<number, string>' but required in type 'interfaceTwo<number, string>'.
==== tests/cases/compiler/assignmentCompatability43.ts (1 errors) ====
@@ -14,4 +14,4 @@ tests/cases/compiler/assignmentCompatability43.ts(9,1): error TS2322: Type 'inte
__test2__.__val__obj2 = __test1__.__val__obj4
~~~~~~~~~~~~~~~~~~~~~
!!! error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type 'interfaceTwo<number, string>':
!!! error TS2322: Required property 'two' cannot be reimplemented with optional property in 'interfaceWithPublicAndOptional<number, string>'.
!!! error TS2322: Property 'two' is optional in type 'interfaceWithPublicAndOptional<number, string>' but required in type 'interfaceTwo<number, string>'.
@@ -1,8 +1,10 @@
tests/cases/conformance/classes/constructorDeclarations/classConstructorAccessibility.ts(6,5): error TS1089: 'private' modifier cannot appear on a constructor declaration.
tests/cases/conformance/classes/constructorDeclarations/classConstructorAccessibility.ts(18,9): error TS1089: 'private' modifier cannot appear on a constructor declaration.
tests/cases/conformance/classes/constructorDeclarations/classConstructorAccessibility.ts(10,5): error TS1089: 'protected' modifier cannot appear on a constructor declaration.
tests/cases/conformance/classes/constructorDeclarations/classConstructorAccessibility.ts(23,9): error TS1089: 'private' modifier cannot appear on a constructor declaration.
tests/cases/conformance/classes/constructorDeclarations/classConstructorAccessibility.ts(27,9): error TS1089: 'protected' modifier cannot appear on a constructor declaration.
==== tests/cases/conformance/classes/constructorDeclarations/classConstructorAccessibility.ts (2 errors) ====
==== tests/cases/conformance/classes/constructorDeclarations/classConstructorAccessibility.ts (4 errors) ====
class C {
public constructor(public x: number) { }
}
@@ -13,8 +15,15 @@ tests/cases/conformance/classes/constructorDeclarations/classConstructorAccessib
!!! error TS1089: 'private' modifier cannot appear on a constructor declaration.
}
class E {
protected constructor(public x: number) { } // error
~~~~~~~~~
!!! error TS1089: 'protected' modifier cannot appear on a constructor declaration.
}
var c = new C(1);
var d = new D(1);
var e = new E(1);
module Generic {
class C<T> {
@@ -27,7 +36,14 @@ tests/cases/conformance/classes/constructorDeclarations/classConstructorAccessib
!!! error TS1089: 'private' modifier cannot appear on a constructor declaration.
}
class E<T> {
protected constructor(public x: T) { } // error
~~~~~~~~~
!!! error TS1089: 'protected' modifier cannot appear on a constructor declaration.
}
var c = new C(1);
var d = new D(1);
var e = new E(1);
}
@@ -0,0 +1,35 @@
tests/cases/conformance/classes/constructorDeclarations/classConstructorParametersAccessibility.ts(12,1): error TS2341: Property 'p' is private and only accessible within class 'C2'.
tests/cases/conformance/classes/constructorDeclarations/classConstructorParametersAccessibility.ts(19,1): error TS2445: Property 'p' is protected and only accessible within class 'C3' and its subclasses.
==== tests/cases/conformance/classes/constructorDeclarations/classConstructorParametersAccessibility.ts (2 errors) ====
class C1 {
constructor(public x: number) { }
}
var c1: C1;
c1.x // OK
class C2 {
constructor(private p: number) { }
}
var c2: C2;
c2.p // private, error
~~~~
!!! error TS2341: Property 'p' is private and only accessible within class 'C2'.
class C3 {
constructor(protected p: number) { }
}
var c3: C3;
c3.p // protected, error
~~~~
!!! error TS2445: Property 'p' is protected and only accessible within class 'C3' and its subclasses.
class Derived extends C3 {
constructor(p: number) {
super(p);
this.p; // OK
}
}
@@ -0,0 +1,67 @@
//// [classConstructorParametersAccessibility.ts]
class C1 {
constructor(public x: number) { }
}
var c1: C1;
c1.x // OK
class C2 {
constructor(private p: number) { }
}
var c2: C2;
c2.p // private, error
class C3 {
constructor(protected p: number) { }
}
var c3: C3;
c3.p // protected, error
class Derived extends C3 {
constructor(p: number) {
super(p);
this.p; // OK
}
}
//// [classConstructorParametersAccessibility.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 C1 = (function () {
function C1(x) {
this.x = x;
}
return C1;
})();
var c1;
c1.x; // OK
var C2 = (function () {
function C2(p) {
this.p = p;
}
return C2;
})();
var c2;
c2.p; // private, error
var C3 = (function () {
function C3(p) {
this.p = p;
}
return C3;
})();
var c3;
c3.p; // protected, error
var Derived = (function (_super) {
__extends(Derived, _super);
function Derived(p) {
_super.call(this, p);
this.p; // OK
}
return Derived;
})(C3);
@@ -0,0 +1,35 @@
tests/cases/conformance/classes/constructorDeclarations/classConstructorParametersAccessibility2.ts(12,1): error TS2341: Property 'p' is private and only accessible within class 'C2'.
tests/cases/conformance/classes/constructorDeclarations/classConstructorParametersAccessibility2.ts(19,1): error TS2445: Property 'p' is protected and only accessible within class 'C3' and its subclasses.
==== tests/cases/conformance/classes/constructorDeclarations/classConstructorParametersAccessibility2.ts (2 errors) ====
class C1 {
constructor(public x?: number) { }
}
var c1: C1;
c1.x // OK
class C2 {
constructor(private p?: number) { }
}
var c2: C2;
c2.p // private, error
~~~~
!!! error TS2341: Property 'p' is private and only accessible within class 'C2'.
class C3 {
constructor(protected p?: number) { }
}
var c3: C3;
c3.p // protected, error
~~~~
!!! error TS2445: Property 'p' is protected and only accessible within class 'C3' and its subclasses.
class Derived extends C3 {
constructor(p: number) {
super(p);
this.p; // OK
}
}
@@ -0,0 +1,67 @@
//// [classConstructorParametersAccessibility2.ts]
class C1 {
constructor(public x?: number) { }
}
var c1: C1;
c1.x // OK
class C2 {
constructor(private p?: number) { }
}
var c2: C2;
c2.p // private, error
class C3 {
constructor(protected p?: number) { }
}
var c3: C3;
c3.p // protected, error
class Derived extends C3 {
constructor(p: number) {
super(p);
this.p; // OK
}
}
//// [classConstructorParametersAccessibility2.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 C1 = (function () {
function C1(x) {
this.x = x;
}
return C1;
})();
var c1;
c1.x; // OK
var C2 = (function () {
function C2(p) {
this.p = p;
}
return C2;
})();
var c2;
c2.p; // private, error
var C3 = (function () {
function C3(p) {
this.p = p;
}
return C3;
})();
var c3;
c3.p; // protected, error
var Derived = (function (_super) {
__extends(Derived, _super);
function Derived(p) {
_super.call(this, p);
this.p; // OK
}
return Derived;
})(C3);
@@ -0,0 +1,39 @@
//// [classConstructorParametersAccessibility3.ts]
class Base {
constructor(protected p: number) { }
}
class Derived extends Base {
constructor(public p: number) {
super(p);
this.p; // OK
}
}
var d: Derived;
d.p; // public, OK
//// [classConstructorParametersAccessibility3.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 Base = (function () {
function Base(p) {
this.p = p;
}
return Base;
})();
var Derived = (function (_super) {
__extends(Derived, _super);
function Derived(p) {
_super.call(this, p);
this.p = p;
this.p; // OK
}
return Derived;
})(Base);
var d;
d.p; // public, OK
@@ -0,0 +1,36 @@
=== tests/cases/conformance/classes/constructorDeclarations/classConstructorParametersAccessibility3.ts ===
class Base {
>Base : Base
constructor(protected p: number) { }
>p : number
}
class Derived extends Base {
>Derived : Derived
>Base : Base
constructor(public p: number) {
>p : number
super(p);
>super(p) : void
>super : typeof Base
>p : number
this.p; // OK
>this.p : number
>this : Derived
>p : number
}
}
var d: Derived;
>d : Derived
>Derived : Derived
d.p; // public, OK
>d.p : number
>d : Derived
>p : number
@@ -1,5 +1,5 @@
tests/cases/compiler/classExtendsInterfaceThatExtendsClassWithPrivates1.ts(10,7): error TS2421: Class 'D2' incorrectly implements interface 'I':
Private property 'x' cannot be reimplemented.
Types have separate declarations of a private property 'x'.
==== tests/cases/compiler/classExtendsInterfaceThatExtendsClassWithPrivates1.ts (1 errors) ====
@@ -15,7 +15,7 @@ tests/cases/compiler/classExtendsInterfaceThatExtendsClassWithPrivates1.ts(10,7)
class D2 implements I {
~~
!!! error TS2421: Class 'D2' incorrectly implements interface 'I':
!!! error TS2421: Private property 'x' cannot be reimplemented.
!!! error TS2421: Types have separate declarations of a private property 'x'.
public foo(x: any) { return x }
private x = 3;
other(x: any) { return x }
@@ -1,9 +1,9 @@
tests/cases/compiler/classImplementsClass5.ts(5,7): error TS2421: Class 'C' incorrectly implements interface 'A':
Private property 'x' cannot be reimplemented.
Types have separate declarations of a private property 'x'.
tests/cases/compiler/classImplementsClass5.ts(16,1): error TS2322: Type 'C2' is not assignable to type 'C':
Private property 'x' cannot be reimplemented.
Types have separate declarations of a private property 'x'.
tests/cases/compiler/classImplementsClass5.ts(17,1): error TS2322: Type 'C' is not assignable to type 'C2':
Private property 'x' cannot be reimplemented.
Types have separate declarations of a private property 'x'.
==== tests/cases/compiler/classImplementsClass5.ts (3 errors) ====
@@ -14,7 +14,7 @@ tests/cases/compiler/classImplementsClass5.ts(17,1): error TS2322: Type 'C' is n
class C implements A {
~
!!! error TS2421: Class 'C' incorrectly implements interface 'A':
!!! error TS2421: Private property 'x' cannot be reimplemented.
!!! error TS2421: Types have separate declarations of a private property 'x'.
private x = 1;
foo() {
return 1;
@@ -28,8 +28,8 @@ tests/cases/compiler/classImplementsClass5.ts(17,1): error TS2322: Type 'C' is n
c = c2;
~
!!! error TS2322: Type 'C2' is not assignable to type 'C':
!!! error TS2322: Private property 'x' cannot be reimplemented.
!!! error TS2322: Types have separate declarations of a private property 'x'.
c2 = c;
~~
!!! error TS2322: Type 'C' is not assignable to type 'C2':
!!! error TS2322: Private property 'x' cannot be reimplemented.
!!! error TS2322: Types have separate declarations of a private property 'x'.
@@ -1,7 +1,7 @@
tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classIsSubtypeOfBaseType.ts(11,7): error TS2416: Class 'Derived2' incorrectly extends base class 'Base<{ bar: string; }>':
Types of property 'foo' are incompatible:
Type '{ bar?: string; }' is not assignable to type '{ bar: string; }':
Required property 'bar' cannot be reimplemented with optional property in '{ bar?: string; }'.
Property 'bar' is optional in type '{ bar?: string; }' but required in type '{ bar: string; }'.
==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classIsSubtypeOfBaseType.ts (1 errors) ====
@@ -20,7 +20,7 @@ tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/cla
!!! error TS2416: Class 'Derived2' incorrectly extends base class 'Base<{ bar: string; }>':
!!! error TS2416: Types of property 'foo' are incompatible:
!!! error TS2416: Type '{ bar?: string; }' is not assignable to type '{ bar: string; }':
!!! error TS2416: Required property 'bar' cannot be reimplemented with optional property in '{ bar?: string; }'.
!!! error TS2416: Property 'bar' is optional in type '{ bar?: string; }' but required in type '{ bar: string; }'.
foo: {
bar?: string; // error
}
@@ -2,14 +2,14 @@ tests/cases/conformance/classes/members/accessibility/classPropertyAsPrivate.ts(
tests/cases/conformance/classes/members/accessibility/classPropertyAsPrivate.ts(4,17): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/conformance/classes/members/accessibility/classPropertyAsPrivate.ts(8,24): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/conformance/classes/members/accessibility/classPropertyAsPrivate.ts(9,24): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/conformance/classes/members/accessibility/classPropertyAsPrivate.ts(15,1): error TS2341: Property 'C.x' is inaccessible.
tests/cases/conformance/classes/members/accessibility/classPropertyAsPrivate.ts(16,1): error TS2341: Property 'C.y' is inaccessible.
tests/cases/conformance/classes/members/accessibility/classPropertyAsPrivate.ts(17,1): error TS2341: Property 'C.y' is inaccessible.
tests/cases/conformance/classes/members/accessibility/classPropertyAsPrivate.ts(18,1): error TS2341: Property 'C.foo' is inaccessible.
tests/cases/conformance/classes/members/accessibility/classPropertyAsPrivate.ts(20,1): error TS2341: Property 'C.a' is inaccessible.
tests/cases/conformance/classes/members/accessibility/classPropertyAsPrivate.ts(21,1): error TS2341: Property 'C.b' is inaccessible.
tests/cases/conformance/classes/members/accessibility/classPropertyAsPrivate.ts(22,1): error TS2341: Property 'C.b' is inaccessible.
tests/cases/conformance/classes/members/accessibility/classPropertyAsPrivate.ts(23,1): error TS2341: Property 'C.foo' is inaccessible.
tests/cases/conformance/classes/members/accessibility/classPropertyAsPrivate.ts(15,1): error TS2341: Property 'x' is private and only accessible within class 'C'.
tests/cases/conformance/classes/members/accessibility/classPropertyAsPrivate.ts(16,1): error TS2341: Property 'y' is private and only accessible within class 'C'.
tests/cases/conformance/classes/members/accessibility/classPropertyAsPrivate.ts(17,1): error TS2341: Property 'y' is private and only accessible within class 'C'.
tests/cases/conformance/classes/members/accessibility/classPropertyAsPrivate.ts(18,1): error TS2341: Property 'foo' is private and only accessible within class 'C'.
tests/cases/conformance/classes/members/accessibility/classPropertyAsPrivate.ts(20,1): error TS2341: Property 'a' is private and only accessible within class 'C'.
tests/cases/conformance/classes/members/accessibility/classPropertyAsPrivate.ts(21,1): error TS2341: Property 'b' is private and only accessible within class 'C'.
tests/cases/conformance/classes/members/accessibility/classPropertyAsPrivate.ts(22,1): error TS2341: Property 'b' is private and only accessible within class 'C'.
tests/cases/conformance/classes/members/accessibility/classPropertyAsPrivate.ts(23,1): error TS2341: Property 'foo' is private and only accessible within class 'C'.
==== tests/cases/conformance/classes/members/accessibility/classPropertyAsPrivate.ts (12 errors) ====
@@ -37,26 +37,26 @@ tests/cases/conformance/classes/members/accessibility/classPropertyAsPrivate.ts(
// all errors
c.x;
~~~
!!! error TS2341: Property 'C.x' is inaccessible.
!!! error TS2341: Property 'x' is private and only accessible within class 'C'.
c.y;
~~~
!!! error TS2341: Property 'C.y' is inaccessible.
!!! error TS2341: Property 'y' is private and only accessible within class 'C'.
c.y = 1;
~~~
!!! error TS2341: Property 'C.y' is inaccessible.
!!! error TS2341: Property 'y' is private and only accessible within class 'C'.
c.foo();
~~~~~
!!! error TS2341: Property 'C.foo' is inaccessible.
!!! error TS2341: Property 'foo' is private and only accessible within class 'C'.
C.a;
~~~
!!! error TS2341: Property 'C.a' is inaccessible.
!!! error TS2341: Property 'a' is private and only accessible within class 'C'.
C.b();
~~~
!!! error TS2341: Property 'C.b' is inaccessible.
!!! error TS2341: Property 'b' is private and only accessible within class 'C'.
C.b = 1;
~~~
!!! error TS2341: Property 'C.b' is inaccessible.
!!! error TS2341: Property 'b' is private and only accessible within class 'C'.
C.foo();
~~~~~
!!! error TS2341: Property 'C.foo' is inaccessible.
!!! error TS2341: Property 'foo' is private and only accessible within class 'C'.
@@ -0,0 +1,62 @@
tests/cases/conformance/classes/members/accessibility/classPropertyAsProtected.ts(3,19): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/conformance/classes/members/accessibility/classPropertyAsProtected.ts(4,19): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/conformance/classes/members/accessibility/classPropertyAsProtected.ts(8,26): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/conformance/classes/members/accessibility/classPropertyAsProtected.ts(9,26): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/conformance/classes/members/accessibility/classPropertyAsProtected.ts(15,1): error TS2445: Property 'x' is protected and only accessible within class 'C' and its subclasses.
tests/cases/conformance/classes/members/accessibility/classPropertyAsProtected.ts(16,1): error TS2445: Property 'y' is protected and only accessible within class 'C' and its subclasses.
tests/cases/conformance/classes/members/accessibility/classPropertyAsProtected.ts(17,1): error TS2445: Property 'y' is protected and only accessible within class 'C' and its subclasses.
tests/cases/conformance/classes/members/accessibility/classPropertyAsProtected.ts(18,1): error TS2445: Property 'foo' is protected and only accessible within class 'C' and its subclasses.
tests/cases/conformance/classes/members/accessibility/classPropertyAsProtected.ts(20,1): error TS2445: Property 'a' is protected and only accessible within class 'C' and its subclasses.
tests/cases/conformance/classes/members/accessibility/classPropertyAsProtected.ts(21,1): error TS2445: Property 'b' is protected and only accessible within class 'C' and its subclasses.
tests/cases/conformance/classes/members/accessibility/classPropertyAsProtected.ts(22,1): error TS2445: Property 'b' is protected and only accessible within class 'C' and its subclasses.
tests/cases/conformance/classes/members/accessibility/classPropertyAsProtected.ts(23,1): error TS2445: Property 'foo' is protected and only accessible within class 'C' and its subclasses.
==== tests/cases/conformance/classes/members/accessibility/classPropertyAsProtected.ts (12 errors) ====
class C {
protected x: string;
protected get y() { return null; }
~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
protected set y(x) { }
~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
protected foo() { }
protected static a: string;
protected static get b() { return null; }
~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
protected static set b(x) { }
~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
protected static foo() { }
}
var c: C;
// all errors
c.x;
~~~
!!! error TS2445: Property 'x' is protected and only accessible within class 'C' and its subclasses.
c.y;
~~~
!!! error TS2445: Property 'y' is protected and only accessible within class 'C' and its subclasses.
c.y = 1;
~~~
!!! error TS2445: Property 'y' is protected and only accessible within class 'C' and its subclasses.
c.foo();
~~~~~
!!! error TS2445: Property 'foo' is protected and only accessible within class 'C' and its subclasses.
C.a;
~~~
!!! error TS2445: Property 'a' is protected and only accessible within class 'C' and its subclasses.
C.b();
~~~
!!! error TS2445: Property 'b' is protected and only accessible within class 'C' and its subclasses.
C.b = 1;
~~~
!!! error TS2445: Property 'b' is protected and only accessible within class 'C' and its subclasses.
C.foo();
~~~~~
!!! error TS2445: Property 'foo' is protected and only accessible within class 'C' and its subclasses.
@@ -10,9 +10,9 @@ tests/cases/compiler/classUpdateTests.ts(46,17): error TS2311: A class may only
tests/cases/compiler/classUpdateTests.ts(47,18): error TS2335: 'super' can only be referenced in a derived class.
tests/cases/compiler/classUpdateTests.ts(57,2): error TS2376: A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties.
tests/cases/compiler/classUpdateTests.ts(63,7): error TS2416: Class 'L' incorrectly extends base class 'G':
Private property 'p1' cannot be reimplemented.
Property 'p1' is private in type 'L' but not in type 'G'.
tests/cases/compiler/classUpdateTests.ts(69,7): error TS2416: Class 'M' incorrectly extends base class 'G':
Private property 'p1' cannot be reimplemented.
Property 'p1' is private in type 'M' but not in type 'G'.
tests/cases/compiler/classUpdateTests.ts(70,2): error TS2376: A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties.
tests/cases/compiler/classUpdateTests.ts(105,15): error TS2339: Property 'p1' does not exist on type 'Q'.
tests/cases/compiler/classUpdateTests.ts(111,16): error TS2339: Property 'p1' does not exist on type 'R'.
@@ -97,7 +97,7 @@ tests/cases/compiler/classUpdateTests.ts(111,16): error TS2339: Property 'p1' do
class L extends G {
~
!!! error TS2416: Class 'L' incorrectly extends base class 'G':
!!! error TS2416: Private property 'p1' cannot be reimplemented.
!!! error TS2416: Property 'p1' is private in type 'L' but not in type 'G'.
constructor(private p1:number) {
super(); // NO ERROR
}
@@ -106,7 +106,7 @@ tests/cases/compiler/classUpdateTests.ts(111,16): error TS2339: Property 'p1' do
class M extends G {
~
!!! error TS2416: Class 'M' incorrectly extends base class 'G':
!!! error TS2416: Private property 'p1' cannot be reimplemented.
!!! error TS2416: Property 'p1' is private in type 'M' but not in type 'G'.
constructor(private p1:number) { // ERROR
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var i = 0;
@@ -1,11 +1,11 @@
tests/cases/conformance/types/members/classWithPrivateProperty.ts(15,18): error TS2341: Property 'C.x' is inaccessible.
tests/cases/conformance/types/members/classWithPrivateProperty.ts(16,18): error TS2341: Property 'C.a' is inaccessible.
tests/cases/conformance/types/members/classWithPrivateProperty.ts(17,18): error TS2341: Property 'C.b' is inaccessible.
tests/cases/conformance/types/members/classWithPrivateProperty.ts(18,18): error TS2341: Property 'C.c' is inaccessible.
tests/cases/conformance/types/members/classWithPrivateProperty.ts(19,18): error TS2341: Property 'C.d' is inaccessible.
tests/cases/conformance/types/members/classWithPrivateProperty.ts(20,18): error TS2341: Property 'C.e' is inaccessible.
tests/cases/conformance/types/members/classWithPrivateProperty.ts(21,18): error TS2341: Property 'C.f' is inaccessible.
tests/cases/conformance/types/members/classWithPrivateProperty.ts(22,18): error TS2341: Property 'C.g' is inaccessible.
tests/cases/conformance/types/members/classWithPrivateProperty.ts(15,18): error TS2341: Property 'x' is private and only accessible within class 'C'.
tests/cases/conformance/types/members/classWithPrivateProperty.ts(16,18): error TS2341: Property 'a' is private and only accessible within class 'C'.
tests/cases/conformance/types/members/classWithPrivateProperty.ts(17,18): error TS2341: Property 'b' is private and only accessible within class 'C'.
tests/cases/conformance/types/members/classWithPrivateProperty.ts(18,18): error TS2341: Property 'c' is private and only accessible within class 'C'.
tests/cases/conformance/types/members/classWithPrivateProperty.ts(19,18): error TS2341: Property 'd' is private and only accessible within class 'C'.
tests/cases/conformance/types/members/classWithPrivateProperty.ts(20,18): error TS2341: Property 'e' is private and only accessible within class 'C'.
tests/cases/conformance/types/members/classWithPrivateProperty.ts(21,18): error TS2341: Property 'f' is private and only accessible within class 'C'.
tests/cases/conformance/types/members/classWithPrivateProperty.ts(22,18): error TS2341: Property 'g' is private and only accessible within class 'C'.
==== tests/cases/conformance/types/members/classWithPrivateProperty.ts (8 errors) ====
@@ -25,25 +25,25 @@ tests/cases/conformance/types/members/classWithPrivateProperty.ts(22,18): error
var c = new C();
var r1: string = c.x;
~~~
!!! error TS2341: Property 'C.x' is inaccessible.
!!! error TS2341: Property 'x' is private and only accessible within class 'C'.
var r2: string = c.a;
~~~
!!! error TS2341: Property 'C.a' is inaccessible.
!!! error TS2341: Property 'a' is private and only accessible within class 'C'.
var r3: string = c.b;
~~~
!!! error TS2341: Property 'C.b' is inaccessible.
!!! error TS2341: Property 'b' is private and only accessible within class 'C'.
var r4: string = c.c();
~~~
!!! error TS2341: Property 'C.c' is inaccessible.
!!! error TS2341: Property 'c' is private and only accessible within class 'C'.
var r5: string = c.d();
~~~
!!! error TS2341: Property 'C.d' is inaccessible.
!!! error TS2341: Property 'd' is private and only accessible within class 'C'.
var r6: string = C.e;
~~~
!!! error TS2341: Property 'C.e' is inaccessible.
!!! error TS2341: Property 'e' is private and only accessible within class 'C'.
var r7: string = C.f();
~~~
!!! error TS2341: Property 'C.f' is inaccessible.
!!! error TS2341: Property 'f' is private and only accessible within class 'C'.
var r8: string = C.g();
~~~
!!! error TS2341: Property 'C.g' is inaccessible.
!!! error TS2341: Property 'g' is private and only accessible within class 'C'.
@@ -0,0 +1,71 @@
//// [classWithProtectedProperty.ts]
// accessing any protected outside the class is an error
class C {
protected x;
protected a = '';
protected b: string = '';
protected c() { return '' }
protected d = () => '';
protected static e;
protected static f() { return '' }
protected static g = () => '';
}
class D extends C {
method() {
// No errors
var d = new D();
var r1: string = d.x;
var r2: string = d.a;
var r3: string = d.b;
var r4: string = d.c();
var r5: string = d.d();
var r6: string = C.e;
var r7: string = C.f();
var r8: string = C.g();
}
}
//// [classWithProtectedProperty.js]
// accessing any protected outside the class is an error
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 C = (function () {
function C() {
this.a = '';
this.b = '';
this.d = function () { return ''; };
}
C.prototype.c = function () {
return '';
};
C.f = function () {
return '';
};
C.g = function () { return ''; };
return C;
})();
var D = (function (_super) {
__extends(D, _super);
function D() {
_super.apply(this, arguments);
}
D.prototype.method = function () {
// No errors
var d = new D();
var r1 = d.x;
var r2 = d.a;
var r3 = d.b;
var r4 = d.c();
var r5 = d.d();
var r6 = C.e;
var r7 = C.f();
var r8 = C.g();
};
return D;
})(C);
@@ -0,0 +1,99 @@
=== tests/cases/conformance/types/members/classWithProtectedProperty.ts ===
// accessing any protected outside the class is an error
class C {
>C : C
protected x;
>x : any
protected a = '';
>a : string
protected b: string = '';
>b : string
protected c() { return '' }
>c : () => string
protected d = () => '';
>d : () => string
>() => '' : () => string
protected static e;
>e : any
protected static f() { return '' }
>f : () => string
protected static g = () => '';
>g : () => string
>() => '' : () => string
}
class D extends C {
>D : D
>C : C
method() {
>method : () => void
// No errors
var d = new D();
>d : D
>new D() : D
>D : typeof D
var r1: string = d.x;
>r1 : string
>d.x : any
>d : D
>x : any
var r2: string = d.a;
>r2 : string
>d.a : string
>d : D
>a : string
var r3: string = d.b;
>r3 : string
>d.b : string
>d : D
>b : string
var r4: string = d.c();
>r4 : string
>d.c() : string
>d.c : () => string
>d : D
>c : () => string
var r5: string = d.d();
>r5 : string
>d.d() : string
>d.d : () => string
>d : D
>d : () => string
var r6: string = C.e;
>r6 : string
>C.e : any
>C : typeof C
>e : any
var r7: string = C.f();
>r7 : string
>C.f() : string
>C.f : () => string
>C : typeof C
>f : () => string
var r8: string = C.g();
>r8 : string
>C.g() : string
>C.g : () => string
>C : typeof C
>g : () => string
}
}
@@ -1,4 +1,4 @@
tests/cases/compiler/cloduleStaticMembers.ts(6,13): error TS2341: Property 'Clod.x' is inaccessible.
tests/cases/compiler/cloduleStaticMembers.ts(6,13): error TS2341: Property 'x' is private and only accessible within class 'Clod'.
tests/cases/compiler/cloduleStaticMembers.ts(7,13): error TS2304: Cannot find name 'x'.
tests/cases/compiler/cloduleStaticMembers.ts(10,13): error TS2304: Cannot find name 'y'.
@@ -11,7 +11,7 @@ tests/cases/compiler/cloduleStaticMembers.ts(10,13): error TS2304: Cannot find n
module Clod {
var p = Clod.x;
~~~~~~
!!! error TS2341: Property 'Clod.x' is inaccessible.
!!! error TS2341: Property 'x' is private and only accessible within class 'Clod'.
var q = x;
~
!!! error TS2304: Cannot find name 'x'.
@@ -1,30 +1,39 @@
tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties.ts(8,10): error TS2341: Property 'C.x' is inaccessible.
tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties.ts(17,10): error TS2341: Property 'D.x' is inaccessible.
tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties.ts(18,12): error TS2339: Property 'a' does not exist on type 'D<string>'.
tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties.ts(8,10): error TS2341: Property 'x' is private and only accessible within class 'C'.
tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties.ts(9,10): error TS2445: Property 'z' is protected and only accessible within class 'C' and its subclasses.
tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties.ts(18,10): error TS2341: Property 'x' is private and only accessible within class 'D<T>'.
tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties.ts(19,12): error TS2339: Property 'a' does not exist on type 'D<string>'.
tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties.ts(20,10): error TS2445: Property 'z' is protected and only accessible within class 'D<T>' and its subclasses.
==== tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties.ts (3 errors) ====
==== tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties.ts (5 errors) ====
class C {
y: string;
constructor(private x: string) { }
constructor(private x: string, protected z: string) { }
}
var c: C;
var r = c.y;
var r2 = c.x; // error
~~~
!!! error TS2341: Property 'C.x' is inaccessible.
!!! error TS2341: Property 'x' is private and only accessible within class 'C'.
var r3 = c.z; // error
~~~
!!! error TS2445: Property 'z' is protected and only accessible within class 'C' and its subclasses.
class D<T> {
y: T;
constructor(a: T, private x: T) { }
constructor(a: T, private x: T, protected z: T) { }
}
var d: D<string>;
var r = d.y;
var r2 = d.x; // error
~~~
!!! error TS2341: Property 'D.x' is inaccessible.
!!! error TS2341: Property 'x' is private and only accessible within class 'D<T>'.
var r3 = d.a; // error
~
!!! error TS2339: Property 'a' does not exist on type 'D<string>'.
!!! error TS2339: Property 'a' does not exist on type 'D<string>'.
var r4 = d.z; // error
~~~
!!! error TS2445: Property 'z' is protected and only accessible within class 'D<T>' and its subclasses.
@@ -1,36 +1,42 @@
//// [constructorParameterProperties.ts]
class C {
y: string;
constructor(private x: string) { }
constructor(private x: string, protected z: string) { }
}
var c: C;
var r = c.y;
var r2 = c.x; // error
var r3 = c.z; // error
class D<T> {
y: T;
constructor(a: T, private x: T) { }
constructor(a: T, private x: T, protected z: T) { }
}
var d: D<string>;
var r = d.y;
var r2 = d.x; // error
var r3 = d.a; // error
var r3 = d.a; // error
var r4 = d.z; // error
//// [constructorParameterProperties.js]
var C = (function () {
function C(x) {
function C(x, z) {
this.x = x;
this.z = z;
}
return C;
})();
var c;
var r = c.y;
var r2 = c.x; // error
var r3 = c.z; // error
var D = (function () {
function D(a, x) {
function D(a, x, z) {
this.x = x;
this.z = z;
}
return D;
})();
@@ -38,3 +44,4 @@ var d;
var r = d.y;
var r2 = d.x; // error
var r3 = d.a; // error
var r4 = d.z; // error
@@ -1,8 +1,9 @@
tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties2.ts(11,24): error TS2300: Duplicate identifier 'y'.
tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties2.ts(19,25): error TS2300: Duplicate identifier 'y'.
tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties2.ts(27,27): error TS2300: Duplicate identifier 'y'.
==== tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties2.ts (2 errors) ====
==== tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties2.ts (3 errors) ====
class C {
y: number;
constructor(y: number) { } // ok
@@ -29,4 +30,15 @@ tests/cases/conformance/classes/constructorDeclarations/constructorParameters/co
}
var e: E;
var r3 = e.y; // error
var r3 = e.y; // error
class F {
y: number;
constructor(protected y: number) { } // error
~
!!! error TS2300: Duplicate identifier 'y'.
}
var f: F;
var r4 = f.y; // error
@@ -21,7 +21,16 @@ class E {
}
var e: E;
var r3 = e.y; // error
var r3 = e.y; // error
class F {
y: number;
constructor(protected y: number) { } // error
}
var f: F;
var r4 = f.y; // error
//// [constructorParameterProperties2.js]
var C = (function () {
@@ -47,3 +56,11 @@ var E = (function () {
})();
var e;
var r3 = e.y; // error
var F = (function () {
function F(y) {
this.y = y;
} // error
return F;
})();
var f;
var r4 = f.y; // error
@@ -0,0 +1,579 @@
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(11,19): error TS1005: ';' expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(22,35): error TS1005: ')' expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(24,28): error TS1005: ':' expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(24,29): error TS1005: ',' expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(27,18): error TS1129: Statement expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(28,30): error TS1005: ',' expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(28,33): error TS1138: Parameter declaration expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(28,34): error TS1005: ';' expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(28,36): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(30,21): error TS1108: A 'return' statement can only be used within a function body.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(31,18): error TS1129: Statement expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(38,17): error TS1109: Expression expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(40,41): error TS1005: ';' expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(40,45): error TS1002: Unterminated string literal.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(43,21): error TS1108: A 'return' statement can only be used within a function body.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(46,13): error TS1005: 'try' expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(55,13): error TS1108: A 'return' statement can only be used within a function body.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(58,5): error TS1128: Declaration or statement expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(69,13): error TS1109: Expression expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(72,37): error TS1127: Invalid character.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(81,13): error TS1109: Expression expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(90,13): error TS1109: Expression expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(105,29): error TS1109: Expression expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(106,13): error TS1109: Expression expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(138,13): error TS1109: Expression expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(141,32): error TS1005: '{' expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(143,13): error TS1005: 'try' expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(159,24): error TS1109: Expression expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(159,30): error TS1005: '(' expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(205,28): error TS1109: Expression expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(218,10): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(218,36): error TS1005: ';' expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(219,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(227,13): error TS1109: Expression expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(234,14): error TS1005: '{' expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(235,9): error TS1128: Declaration or statement expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(235,27): error TS1005: ',' expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(235,36): error TS1005: ';' expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(236,13): error TS1108: A 'return' statement can only be used within a function body.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(238,9): error TS1128: Declaration or statement expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(238,26): error TS1005: ';' expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(239,13): error TS1108: A 'return' statement can only be used within a function body.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(241,5): error TS1128: Declaration or statement expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(254,67): error TS1093: Type annotation cannot appear on a constructor declaration.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(254,69): error TS1110: Type expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(256,9): error TS1128: Declaration or statement expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(256,31): error TS1005: ',' expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(257,9): error TS1128: Declaration or statement expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(257,27): error TS1135: Argument expression expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(257,33): error TS1005: '(' expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(257,43): error TS1109: Expression expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(257,59): error TS1109: Expression expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(257,60): error TS1005: ';' expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(257,65): error TS1129: Statement expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(259,9): error TS1129: Statement expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(259,35): error TS1109: Expression expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(259,55): error TS1005: ';' expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(261,1): error TS1128: Declaration or statement expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(11,1): error TS2304: Cannot find name 'module'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(22,39): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(27,26): error TS2304: Cannot find name 'bfs'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(28,17): error TS2391: Function implementation is missing or not immediately following the declaration.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(34,17): error TS2304: Cannot find name 'retValue'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(34,28): error TS2304: Cannot find name 'bfs'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(35,21): error TS2304: Cannot find name 'retValue'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(40,17): error TS2304: Cannot find name 'retValue'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(40,28): error TS2304: Cannot find name 'bfs'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(41,21): error TS2304: Cannot find name 'retValue'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(47,17): error TS2304: Cannot find name 'console'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(53,13): error TS2304: Cannot find name 'console'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(76,26): error TS2358: The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(76,44): error TS2359: The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(89,23): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(108,24): error TS2365: Operator '+' cannot be applied to types 'number' and 'boolean'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(159,31): error TS2304: Cannot find name 'Property'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(166,13): error TS2365: Operator '+=' cannot be applied to types 'number' and 'void'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(180,40): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(180,47): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(213,16): error TS2304: Cannot find name 'bool'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(218,29): error TS2304: Cannot find name 'yield'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(223,23): error TS2304: Cannot find name 'bool'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(235,16): error TS2304: Cannot find name 'method1'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(235,24): error TS2304: Cannot find name 'val'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(235,28): error TS2304: Cannot find name 'number'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(238,16): error TS2304: Cannot find name 'method2'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(246,25): error TS2339: Property 'method1' does not exist on type 'B'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(254,9): error TS2390: Constructor implementation is missing.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(254,21): error TS2369: A parameter property is only allowed in a constructor implementation.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(254,44): error TS2369: A parameter property is only allowed in a constructor implementation.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(256,16): error TS2304: Cannot find name 'Overloads'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(256,26): error TS2304: Cannot find name 'value'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(256,33): error TS2304: Cannot find name 'string'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(257,16): error TS2304: Cannot find name 'Overloads'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(257,35): error TS2304: Cannot find name 'string'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(257,52): error TS2304: Cannot find name 'string'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(259,16): error TS2304: Cannot find name 'DefaultValue'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(259,29): error TS2304: Cannot find name 'value'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(259,37): error TS2304: Cannot find name 'string'.
==== tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts (98 errors) ====
declare module "fs" {
export class File {
constructor(filename: string);
public ReadAllText(): string;
}
export interface IFile {
[index: number]: string;
}
}
import fs = module("fs");
~
!!! error TS1005: ';' expected.
~~~~~~~~~~~~~~~~~~
!!! error TS2304: Cannot find name 'module'.
module TypeScriptAllInOne {
export class Program {
static Main(...args: string[]) {
try {
var bfs = new BasicFeatures();
var retValue: number = 0;
retValue = bfs.VARIABLES();
if (retValue != 0 ^= {
~~
!!! error TS1005: ')' expected.
~
return 1;
~
!!! error TS1005: ':' expected.
~
!!! error TS1005: ',' expected.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
}
~~~~~~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
case = bfs.STATEMENTS(4);
~~~~
!!! error TS1129: Statement expected.
~~~
!!! error TS2304: Cannot find name 'bfs'.
if (retValue != 0) {
~~
!!! error TS1005: ',' expected.
~
!!! error TS1138: Parameter declaration expected.
~
!!! error TS1005: ';' expected.
~
!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
~~
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
return 1;
~~~~~~
!!! error TS1108: A 'return' statement can only be used within a function body.
^
~
!!! error TS1129: Statement expected.
retValue = bfs.TYPES();
~~~~~~~~
!!! error TS2304: Cannot find name 'retValue'.
~~~
!!! error TS2304: Cannot find name 'bfs'.
if (retValue != 0) {
~~~~~~~~
!!! error TS2304: Cannot find name 'retValue'.
return 1 &&
}
~
!!! error TS1109: Expression expected.
retValue = bfs.OPERATOR ' );
~~~~
!!! error TS1005: ';' expected.
!!! error TS1002: Unterminated string literal.
~~~~~~~~
!!! error TS2304: Cannot find name 'retValue'.
~~~
!!! error TS2304: Cannot find name 'bfs'.
if (retValue != 0) {
~~~~~~~~
!!! error TS2304: Cannot find name 'retValue'.
return 1;
~~~~~~
!!! error TS1108: A 'return' statement can only be used within a function body.
}
}
catch (e) {
~~~~~
!!! error TS1005: 'try' expected.
console.log(e);
~~~~~~~
!!! error TS2304: Cannot find name 'console'.
}
finally {
}
console.log('Done');
~~~~~~~
!!! error TS2304: Cannot find name 'console'.
return 0;
~~~~~~
!!! error TS1108: A 'return' statement can only be used within a function body.
}
}
~
!!! error TS1128: Declaration or statement expected.
class BasicFeatures {
/// <summary>
/// Test various of variables. Including nullable,key world as variable,special format
/// </summary>
/// <returns></returns>
public VARIABLES(): number {
var local = Number.MAX_VALUE;
var min = Number.MIN_VALUE;
var inf = Number.NEGATIVE_INFINITY -
var nan = Number.NaN;
~~~
!!! error TS1109: Expression expected.
var undef = undefined;
var _\uD4A5\u7204\uC316\uE59F = local;
!!! error TS1127: Invalid character.
var мир = local;
var local5 = <fs.File>null;
var local6 = local5 instanceof fs.File;
~~~~~~
!!! error TS2358: The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.
~~~~~~~
!!! error TS2359: The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type.
var hex = 0xBADC0DE, Hex = 0XDEADBEEF;
var float = 6.02e23, float2 = 6.02E-23
var char = 'c', \u0066 = '\u0066', hexchar = '\x42' !=
var quoted = '"', quoted2 = "'";
~~~
!!! error TS1109: Expression expected.
var reg = /\w*/;
var objLit = { "var": number = 42, equals: function (x) { return x["var"] === 42; }, instanceof : () => 'objLit{42}' };
var weekday = Weekdays.Monday;
var con = char + f + hexchar + float.toString() + float2.toString() + reg.toString() + objLit + weekday;
//
var any = 0 ^=
~
!!! error TS2364: Invalid left-hand side of assignment expression.
var bool = 0;
~~~
!!! error TS1109: Expression expected.
var declare = 0;
var constructor = 0;
var get = 0;
var implements = 0;
var interface = 0;
var let = 0;
var module = 0;
var number = 0;
var package = 0;
var private = 0;
var protected = 0;
var public = 0;
var set = 0;
var static = 0;
var string = 0 />
~
!!! error TS1109: Expression expected.
var yield = 0;
~~~
!!! error TS1109: Expression expected.
var sum3 = any + bool + declare + constructor + get + implements + interface + let + module + number + package + private + protected + public + set + static + string + yield;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'number' and 'boolean'.
return 0;
}
/// <summary>
/// Test different statements. Including if-else,swith,foreach,(un)checked,lock,using,try-catch-finally
/// </summary>
/// <param name="i"></param>
/// <returns></returns>
STATEMENTS(i: number): number {
var retVal = 0;
if (i == 1)
retVal = 1;
else
retVal = 0;
switch (i) {
case 2:
retVal = 1;
break;
case 3:
retVal = 1;
break;
default:
break;
}
for (var x in { x: 0, y: 1 }) {
!
try {
~~~
!!! error TS1109: Expression expected.
throw null;
}
catch (Exception) ?
~
!!! error TS1005: '{' expected.
}
finally {
~~~~~~~
!!! error TS1005: 'try' expected.
try { }
catch (Exception) { }
}
return retVal;
}
/// <summary>
/// Test types in ts language. Including class,struct,interface,delegate,anonymous type
/// </summary>
/// <returns></returns>
public TYPES(): number {
var retVal = 0;
var c = new CLASS();
var xx: IF = c;
retVal += catch .Property;
~~~~~
!!! error TS1109: Expression expected.
~
!!! error TS1005: '(' expected.
~~~~~~~~
!!! error TS2304: Cannot find name 'Property'.
retVal += c.Member();
retVal += xx.Foo() ? 0 : 1;
//anonymous type
var anony = { a: new CLASS() };
retVal += anony.a.d();
~~~~~~~~~~~~~~~~~~~~~
!!! error TS2365: Operator '+=' cannot be applied to types 'number' and 'void'.
return retVal;
}
///// <summary>
///// Test different operators
///// </summary>
///// <returns></returns>
public OPERATOR(): number {
var a: number[] = [1, 2, 3, 4, 5, ];/*[] bug*/ // YES []
var i = a[1];/*[]*/
i = i + i - i * i / i % i & i | i ^ i;/*+ - * / % & | ^*/
var b = true && false || true ^ false;/*& | ^*/
~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
b = !b;/*!*/
i = ~i;/*~i*/
b = i < (i - 1) && (i + 1) > i;/*< && >*/
var f = true ? 1 : 0;/*? :*/ // YES :
i++;/*++*/
i--;/*--*/
b = true && false || true;/*&& ||*/
i = i << 5;/*<<*/
i = i >> 5;/*>>*/
var j = i;
b = i == j && i != j && i <= j && i >= j;/*= == && != <= >=*/
i += <number>5.0;/*+=*/
i -= i;/*-=*/
i *= i;/**=*/
if (i == 0)
i++;
i /= i;/*/=*/
i %= i;/*%=*/
i &= i;/*&=*/
i |= i;/*|=*/
i ^= i;/*^=*/
i <<= i;/*<<=*/
i >>= i;/*>>=*/
if (i == 0 && != b && f == 1)
~~
!!! error TS1109: Expression expected.
return 0;
else return 1;
}
}
interface IF {
Foo(): bool;
~~~~
!!! error TS2304: Cannot find name 'bool'.
}
class CLASS implements IF {
case d = () => { yield 0; };
~~~~
!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
~
!!! error TS1005: ';' expected.
~~~~~
!!! error TS2304: Cannot find name 'yield'.
public get Property() { return 0; }
~~~~~~~~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
public Member() {
return 0;
}
public Foo(): bool {
~~~~
!!! error TS2304: Cannot find name 'bool'.
var myEvent = () => { return 1; };
if (myEvent() == 1)
return true ?
else
~~~~
!!! error TS1109: Expression expected.
return false;
}
}
// todo: use these
class A .
~
!!! error TS1005: '{' expected.
public method1(val:number) {
~~~~~~
!!! error TS1128: Declaration or statement expected.
~
!!! error TS1005: ',' expected.
~
!!! error TS1005: ';' expected.
~~~~~~~
!!! error TS2304: Cannot find name 'method1'.
~~~
!!! error TS2304: Cannot find name 'val'.
~~~~~~
!!! error TS2304: Cannot find name 'number'.
return val;
~~~~~~
!!! error TS1108: A 'return' statement can only be used within a function body.
}
public method2() {
~~~~~~
!!! error TS1128: Declaration or statement expected.
~
!!! error TS1005: ';' expected.
~~~~~~~
!!! error TS2304: Cannot find name 'method2'.
return 2 * this.method1(2);
~~~~~~
!!! error TS1108: A 'return' statement can only be used within a function body.
}
}
~
!!! error TS1128: Declaration or statement expected.
class B extends A {
public method2() {
return this.method1(2);
~~~~~~~
!!! error TS2339: Property 'method1' does not exist on type 'B'.
}
}
class Overloading {
private otherValue = 42;
constructor(private value: number, public name: string) : }
!!! error TS1093: Type annotation cannot appear on a constructor declaration.
~
!!! error TS1110: Type expected.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2390: Constructor implementation is missing.
~~~~~~~~~~~~~~~~~~~~~
!!! error TS2369: A parameter property is only allowed in a constructor implementation.
~~~~~~~~~~~~~~~~~~~
!!! error TS2369: A parameter property is only allowed in a constructor implementation.
public Overloads(value: string);
~~~~~~
!!! error TS1128: Declaration or statement expected.
~
!!! error TS1005: ',' expected.
~~~~~~~~~
!!! error TS2304: Cannot find name 'Overloads'.
~~~~~
!!! error TS2304: Cannot find name 'value'.
~~~~~~
!!! error TS2304: Cannot find name 'string'.
public Overloads( while : string, ...rest: string[]) { &
~~~~~~
!!! error TS1128: Declaration or statement expected.
~~~~~
!!! error TS1135: Argument expression expected.
~
!!! error TS1005: '(' expected.
~~~
!!! error TS1109: Expression expected.
~
!!! error TS1109: Expression expected.
~
!!! error TS1005: ';' expected.
~
!!! error TS1129: Statement expected.
~~~~~~~~~
!!! error TS2304: Cannot find name 'Overloads'.
~~~~~~
!!! error TS2304: Cannot find name 'string'.
~~~~~~
!!! error TS2304: Cannot find name 'string'.
public DefaultValue(value?: string = "Hello") { }
~~~~~~
!!! error TS1129: Statement expected.
~
!!! error TS1109: Expression expected.
~
!!! error TS1005: ';' expected.
~~~~~~~~~~~~
!!! error TS2304: Cannot find name 'DefaultValue'.
~~~~~
!!! error TS2304: Cannot find name 'value'.
~~~~~~
!!! error TS2304: Cannot find name 'string'.
}
}
~
!!! error TS1128: Declaration or statement expected.
enum Weekdays {
Monday,
Tuesday,
Weekend,
}
enum Fruit {
Apple,
Pear
}
interface IDisposable {
Dispose(): void;
}
TypeScriptAllInOne.Program.Main();
@@ -0,0 +1,164 @@
//// [declarationEmit_protectedMembers.ts]
// Class with protected members
class C1 {
protected x: number;
protected f() {
return this.x;
}
protected set accessor(a: number) { }
protected get accessor() { return 0; }
protected static sx: number;
protected static sf() {
return this.sx;
}
protected static set staticSetter(a: number) { }
protected static get staticGetter() { return 0; }
}
// Derived class overriding protected members
class C2 extends C1 {
protected f() {
return super.f() + this.x;
}
protected static sf() {
return super.sf() + this.sx;
}
}
// Derived class making protected members public
class C3 extends C2 {
x: number;
static sx: number;
f() {
return super.f();
}
static sf() {
return super.sf();
}
static get staticGetter() { return 1; }
}
// Protected properties in constructors
class C4 {
constructor(protected a: number, protected b) { }
}
//// [declarationEmit_protectedMembers.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 __();
};
// Class with protected members
var C1 = (function () {
function C1() {
}
C1.prototype.f = function () {
return this.x;
};
Object.defineProperty(C1.prototype, "accessor", {
get: function () {
return 0;
},
set: function (a) {
},
enumerable: true,
configurable: true
});
C1.sf = function () {
return this.sx;
};
Object.defineProperty(C1, "staticSetter", {
set: function (a) {
},
enumerable: true,
configurable: true
});
Object.defineProperty(C1, "staticGetter", {
get: function () {
return 0;
},
enumerable: true,
configurable: true
});
return C1;
})();
// Derived class overriding protected members
var C2 = (function (_super) {
__extends(C2, _super);
function C2() {
_super.apply(this, arguments);
}
C2.prototype.f = function () {
return _super.prototype.f.call(this) + this.x;
};
C2.sf = function () {
return _super.sf.call(this) + this.sx;
};
return C2;
})(C1);
// Derived class making protected members public
var C3 = (function (_super) {
__extends(C3, _super);
function C3() {
_super.apply(this, arguments);
}
C3.prototype.f = function () {
return _super.prototype.f.call(this);
};
C3.sf = function () {
return _super.sf.call(this);
};
Object.defineProperty(C3, "staticGetter", {
get: function () {
return 1;
},
enumerable: true,
configurable: true
});
return C3;
})(C2);
// Protected properties in constructors
var C4 = (function () {
function C4(a, b) {
this.a = a;
this.b = b;
}
return C4;
})();
//// [declarationEmit_protectedMembers.d.ts]
declare class C1 {
protected x: number;
protected f(): number;
protected accessor: number;
protected static sx: number;
protected static sf(): number;
protected static staticSetter: number;
protected static staticGetter: number;
}
declare class C2 extends C1 {
protected f(): number;
protected static sf(): number;
}
declare class C3 extends C2 {
x: number;
static sx: number;
f(): number;
static sf(): number;
static staticGetter: number;
}
declare class C4 {
protected a: number;
protected b: any;
constructor(a: number, b: any);
}
@@ -0,0 +1,120 @@
=== tests/cases/compiler/declarationEmit_protectedMembers.ts ===
// Class with protected members
class C1 {
>C1 : C1
protected x: number;
>x : number
protected f() {
>f : () => number
return this.x;
>this.x : number
>this : C1
>x : number
}
protected set accessor(a: number) { }
>accessor : number
>a : number
protected get accessor() { return 0; }
>accessor : number
protected static sx: number;
>sx : number
protected static sf() {
>sf : () => number
return this.sx;
>this.sx : number
>this : typeof C1
>sx : number
}
protected static set staticSetter(a: number) { }
>staticSetter : number
>a : number
protected static get staticGetter() { return 0; }
>staticGetter : number
}
// Derived class overriding protected members
class C2 extends C1 {
>C2 : C2
>C1 : C1
protected f() {
>f : () => number
return super.f() + this.x;
>super.f() + this.x : number
>super.f() : number
>super.f : () => number
>super : C1
>f : () => number
>this.x : number
>this : C2
>x : number
}
protected static sf() {
>sf : () => number
return super.sf() + this.sx;
>super.sf() + this.sx : number
>super.sf() : number
>super.sf : () => number
>super : typeof C1
>sf : () => number
>this.sx : number
>this : typeof C2
>sx : number
}
}
// Derived class making protected members public
class C3 extends C2 {
>C3 : C3
>C2 : C2
x: number;
>x : number
static sx: number;
>sx : number
f() {
>f : () => number
return super.f();
>super.f() : number
>super.f : () => number
>super : C2
>f : () => number
}
static sf() {
>sf : () => number
return super.sf();
>super.sf() : number
>super.sf : () => number
>super : typeof C2
>sf : () => number
}
static get staticGetter() { return 1; }
>staticGetter : number
}
// Protected properties in constructors
class C4 {
>C4 : C4
constructor(protected a: number, protected b) { }
>a : number
>b : any
}
@@ -1,5 +1,5 @@
tests/cases/compiler/derivedClassOverridesPrivateFunction1.ts(8,7): error TS2416: Class 'DerivedClass' incorrectly extends base class 'BaseClass':
Private property '_init' cannot be reimplemented.
Types have separate declarations of a private property '_init'.
==== tests/cases/compiler/derivedClassOverridesPrivateFunction1.ts (1 errors) ====
@@ -13,7 +13,7 @@ tests/cases/compiler/derivedClassOverridesPrivateFunction1.ts(8,7): error TS2416
class DerivedClass extends BaseClass {
~~~~~~~~~~~~
!!! error TS2416: Class 'DerivedClass' incorrectly extends base class 'BaseClass':
!!! error TS2416: Private property '_init' cannot be reimplemented.
!!! error TS2416: Types have separate declarations of a private property '_init'.
constructor() {
super();
}

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