mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge branch 'master' into sourceFileUpdate
Conflicts: src/compiler/parser.ts src/services/formatting/tokenSpan.ts src/services/text.ts
This commit is contained in:
@@ -35,6 +35,7 @@ var compilerSources = [
|
||||
"types.ts",
|
||||
"scanner.ts",
|
||||
"parser.ts",
|
||||
"utilities.ts",
|
||||
"binder.ts",
|
||||
"checker.ts",
|
||||
"emitter.ts",
|
||||
@@ -47,26 +48,53 @@ var compilerSources = [
|
||||
|
||||
var servicesSources = [
|
||||
"core.ts",
|
||||
"sys.ts",
|
||||
"types.ts",
|
||||
"scanner.ts",
|
||||
"parser.ts",
|
||||
"utilities.ts",
|
||||
"binder.ts",
|
||||
"checker.ts",
|
||||
"emitter.ts"
|
||||
"emitter.ts",
|
||||
"diagnosticInformationMap.generated.ts"
|
||||
].map(function (f) {
|
||||
return path.join(compilerDirectory, f);
|
||||
}).concat([
|
||||
"breakpoints.ts",
|
||||
"navigationBar.ts",
|
||||
"outliningElementsCollector.ts",
|
||||
"services.ts",
|
||||
"shims.ts",
|
||||
"signatureHelp.ts",
|
||||
"utilities.ts",
|
||||
"navigationBar.ts",
|
||||
"outliningElementsCollector.ts"
|
||||
"formatting/formatting.ts",
|
||||
"formatting/formattingContext.ts",
|
||||
"formatting/formattingRequestKind.ts",
|
||||
"formatting/formattingScanner.ts",
|
||||
"formatting/references.ts",
|
||||
"formatting/rule.ts",
|
||||
"formatting/ruleAction.ts",
|
||||
"formatting/ruleDescriptor.ts",
|
||||
"formatting/ruleFlag.ts",
|
||||
"formatting/ruleOperation.ts",
|
||||
"formatting/ruleOperationContext.ts",
|
||||
"formatting/rules.ts",
|
||||
"formatting/rulesMap.ts",
|
||||
"formatting/rulesProvider.ts",
|
||||
"formatting/smartIndenter.ts",
|
||||
"formatting/tokenRange.ts"
|
||||
].map(function (f) {
|
||||
return path.join(servicesDirectory, f);
|
||||
}));
|
||||
|
||||
var definitionsRoots = [
|
||||
"compiler/types.d.ts",
|
||||
"compiler/scanner.d.ts",
|
||||
"compiler/parser.d.ts",
|
||||
"compiler/checker.d.ts",
|
||||
"services/services.d.ts",
|
||||
];
|
||||
|
||||
var harnessSources = [
|
||||
"harness.ts",
|
||||
"sourceMapRecorder.ts",
|
||||
@@ -149,25 +177,48 @@ var compilerFilename = "tsc.js";
|
||||
* @param prefixes: a list of files to prepend to the target file
|
||||
* @param useBuiltCompiler: true to use the built compiler, false to use the LKG
|
||||
* @param noOutFile: true to compile without using --out
|
||||
* @param generateDeclarations: true to compile using --declaration
|
||||
* @param outDir: true to compile using --outDir
|
||||
* @param keepComments: false to compile using --removeComments
|
||||
* @param callback: a function to execute after the compilation process ends
|
||||
*/
|
||||
function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, noOutFile, generateDeclarations, callback) {
|
||||
function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, noOutFile, generateDeclarations, outDir, keepComments, noResolve, callback) {
|
||||
file(outFile, prereqs, function() {
|
||||
var dir = useBuiltCompiler ? builtLocalDirectory : LKGDirectory;
|
||||
var options = "-removeComments --module commonjs -noImplicitAny ";
|
||||
var options = "--module commonjs -noImplicitAny";
|
||||
|
||||
if (!keepComments) {
|
||||
options += " -removeComments";
|
||||
}
|
||||
|
||||
if (generateDeclarations) {
|
||||
options += "--declaration ";
|
||||
options += " --declaration";
|
||||
}
|
||||
|
||||
if (useDebugMode) {
|
||||
options += "--preserveConstEnums ";
|
||||
options += " --preserveConstEnums";
|
||||
}
|
||||
|
||||
if (outDir) {
|
||||
options += " --outDir " + outDir;
|
||||
}
|
||||
|
||||
if (!noOutFile) {
|
||||
options += " --out " + outFile;
|
||||
}
|
||||
|
||||
if(noResolve) {
|
||||
options += " --noResolve";
|
||||
}
|
||||
|
||||
if (useDebugMode) {
|
||||
options += " -sourcemap -mapRoot file:///" + path.resolve(path.dirname(outFile));
|
||||
}
|
||||
|
||||
var cmd = host + " " + dir + compilerFilename + " " + options + " ";
|
||||
cmd = cmd + sources.join(" ") + (!noOutFile ? " -out " + outFile : "");
|
||||
if (useDebugMode) {
|
||||
cmd = cmd + " -sourcemap -mapRoot file:///" + path.resolve(path.dirname(outFile));
|
||||
}
|
||||
cmd = cmd + sources.join(" ");
|
||||
console.log(cmd + "\n");
|
||||
|
||||
var ex = jake.createExec([cmd]);
|
||||
// Add listeners for output and error
|
||||
ex.addListener("stdout", function(output) {
|
||||
@@ -260,24 +311,38 @@ var tscFile = path.join(builtLocalDirectory, compilerFilename);
|
||||
compileFile(tscFile, compilerSources, [builtLocalDirectory, copyright].concat(compilerSources), [copyright], /*useBuiltCompiler:*/ false);
|
||||
|
||||
var servicesFile = path.join(builtLocalDirectory, "typescriptServices.js");
|
||||
var servicesDefinitionsFile = path.join(builtLocalDirectory, "typescriptServices.d.ts");
|
||||
compileFile(servicesFile, servicesSources,[builtLocalDirectory, copyright].concat(servicesSources), [copyright], /*useBuiltCompiler*/ true);
|
||||
|
||||
compileFile(servicesFile,
|
||||
servicesSources,
|
||||
[builtLocalDirectory, copyright].concat(servicesSources),
|
||||
[copyright],
|
||||
var nodeDefinitionsFile = path.join(builtLocalDirectory, "typescript.d.ts");
|
||||
var standaloneDefinitionsFile = path.join(builtLocalDirectory, "typescriptServices.d.ts");
|
||||
var tempDirPath = path.join(builtLocalDirectory, "temptempdir");
|
||||
compileFile(nodeDefinitionsFile, servicesSources,[builtLocalDirectory, copyright].concat(servicesSources),
|
||||
/*prefixes*/ undefined,
|
||||
/*useBuiltCompiler*/ true,
|
||||
/*noOutFile*/ false,
|
||||
/*noOutFile*/ true,
|
||||
/*generateDeclarations*/ true,
|
||||
/*callback*/ fixDeclarationFile);
|
||||
/*outDir*/ tempDirPath,
|
||||
/*keepComments*/ true,
|
||||
/*noResolve*/ true,
|
||||
/*callback*/ function () {
|
||||
concatenateFiles(standaloneDefinitionsFile, definitionsRoots.map(function (f) {
|
||||
return path.join(tempDirPath, f);
|
||||
}));
|
||||
prependFile(copyright, standaloneDefinitionsFile);
|
||||
|
||||
function fixDeclarationFile() {
|
||||
fs.appendFileSync(servicesDefinitionsFile, os.EOL + "export = ts;")
|
||||
}
|
||||
// Create the node definition file by replacing 'ts' module with '"typescript"' as a module.
|
||||
jake.cpR(standaloneDefinitionsFile, nodeDefinitionsFile, {silent: true});
|
||||
var definitionFileContents = fs.readFileSync(nodeDefinitionsFile).toString();
|
||||
definitionFileContents = definitionFileContents.replace(/declare module ts/g, 'declare module "typescript"');
|
||||
fs.writeFileSync(nodeDefinitionsFile, definitionFileContents);
|
||||
|
||||
// Delete the temp dir
|
||||
jake.rmRf(tempDirPath, {silent: true});
|
||||
});
|
||||
|
||||
// Local target to build the compiler and services
|
||||
desc("Builds the full compiler and services");
|
||||
task("local", ["generate-diagnostics", "lib", tscFile, servicesFile]);
|
||||
task("local", ["generate-diagnostics", "lib", tscFile, servicesFile, nodeDefinitionsFile]);
|
||||
|
||||
// Local target to build the compiler and services
|
||||
desc("Sets release mode flag");
|
||||
@@ -328,7 +393,7 @@ task("generate-spec", [specMd])
|
||||
// Makes a new LKG. This target does not build anything, but errors if not all the outputs are present in the built/local directory
|
||||
desc("Makes a new LKG out of the built js files");
|
||||
task("LKG", ["clean", "release", "local"].concat(libraryTargets), function() {
|
||||
var expectedFiles = [tscFile, servicesFile, servicesDefinitionsFile].concat(libraryTargets);
|
||||
var expectedFiles = [tscFile, servicesFile, nodeDefinitionsFile, standaloneDefinitionsFile].concat(libraryTargets);
|
||||
var missingFiles = expectedFiles.filter(function (f) {
|
||||
return !fs.existsSync(f);
|
||||
});
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@
|
||||
"url" : "https://github.com/Microsoft/TypeScript.git"
|
||||
},
|
||||
"preferGlobal" : true,
|
||||
"main" : "./bin/tsc.js",
|
||||
"main" : "./bin/typescriptServices.js",
|
||||
"bin" : {
|
||||
"tsc" : "./bin/tsc"
|
||||
},
|
||||
|
||||
+3
-53
@@ -4,57 +4,12 @@
|
||||
/// <reference path="parser.ts"/>
|
||||
/// <reference path="binder.ts"/>
|
||||
/// <reference path="emitter.ts"/>
|
||||
/// <reference path="utilities.ts"/>
|
||||
|
||||
module ts {
|
||||
var nextSymbolId = 1;
|
||||
var nextNodeId = 1;
|
||||
var nextMergeId = 1;
|
||||
|
||||
export function getDeclarationOfKind(symbol: Symbol, kind: SyntaxKind): Declaration {
|
||||
var declarations = symbol.declarations;
|
||||
for (var i = 0; i < declarations.length; i++) {
|
||||
var declaration = declarations[i];
|
||||
if (declaration.kind === kind) {
|
||||
return declaration;
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export interface StringSymbolWriter extends SymbolWriter {
|
||||
string(): string;
|
||||
}
|
||||
|
||||
// Pool writers to avoid needing to allocate them for every symbol we write.
|
||||
var stringWriters: StringSymbolWriter[] = [];
|
||||
export function getSingleLineStringWriter(): StringSymbolWriter {
|
||||
if (stringWriters.length == 0) {
|
||||
var str = "";
|
||||
|
||||
var writeText: (text: string) => void = text => str += text;
|
||||
return {
|
||||
string: () => str,
|
||||
writeKeyword: writeText,
|
||||
writeOperator: writeText,
|
||||
writePunctuation: writeText,
|
||||
writeSpace: writeText,
|
||||
writeStringLiteral: writeText,
|
||||
writeParameter: writeText,
|
||||
writeSymbol: writeText,
|
||||
|
||||
// Completely ignore indentation for string writers. And map newlines to
|
||||
// a single space.
|
||||
writeLine: () => str += " ",
|
||||
increaseIndent: () => { },
|
||||
decreaseIndent: () => { },
|
||||
clear: () => str = "",
|
||||
trackSymbol: () => { }
|
||||
};
|
||||
}
|
||||
|
||||
return stringWriters.pop();
|
||||
}
|
||||
var nextMergeId = 1;
|
||||
|
||||
/// fullTypeCheck denotes if this instance of the typechecker will be used to get semantic diagnostics.
|
||||
/// If fullTypeCheck === true, then the typechecker should do every possible check to produce all errors
|
||||
@@ -1012,11 +967,6 @@ module ts {
|
||||
};
|
||||
}
|
||||
|
||||
function releaseStringWriter(writer: StringSymbolWriter) {
|
||||
writer.clear()
|
||||
stringWriters.push(writer);
|
||||
}
|
||||
|
||||
function writeKeyword(writer: SymbolWriter, kind: SyntaxKind) {
|
||||
writer.writeKeyword(tokenToString(kind));
|
||||
}
|
||||
@@ -5595,7 +5545,7 @@ module ts {
|
||||
}
|
||||
|
||||
// Fall back to any.
|
||||
if (compilerOptions.noImplicitAny && objectType !== anyType) {
|
||||
if (compilerOptions.noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && objectType !== anyType) {
|
||||
error(node, Diagnostics.Index_signature_of_object_type_implicitly_has_an_any_type);
|
||||
}
|
||||
|
||||
|
||||
@@ -88,6 +88,11 @@ module ts {
|
||||
description: Diagnostics.Redirect_output_structure_to_the_directory,
|
||||
paramType: Diagnostics.DIRECTORY,
|
||||
},
|
||||
{
|
||||
name: "preserveConstEnums",
|
||||
type: "boolean",
|
||||
description: Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code
|
||||
},
|
||||
{
|
||||
name: "removeComments",
|
||||
type: "boolean",
|
||||
@@ -104,6 +109,11 @@ module ts {
|
||||
description: Diagnostics.Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations,
|
||||
paramType: Diagnostics.LOCATION,
|
||||
},
|
||||
{
|
||||
name: "suppressImplicitAnyIndexErrors",
|
||||
type: "boolean",
|
||||
description: Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures,
|
||||
},
|
||||
{
|
||||
name: "target",
|
||||
shortName: "t",
|
||||
@@ -123,14 +133,9 @@ module ts {
|
||||
shortName: "w",
|
||||
type: "boolean",
|
||||
description: Diagnostics.Watch_input_files,
|
||||
},
|
||||
{
|
||||
name: "preserveConstEnums",
|
||||
type: "boolean",
|
||||
description: Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
var shortOptionNames: Map<string> = {};
|
||||
var optionNameMap: Map<CommandLineOption> = {};
|
||||
|
||||
|
||||
@@ -15,10 +15,6 @@ module ts {
|
||||
True = -1
|
||||
}
|
||||
|
||||
export interface Map<T> {
|
||||
[index: string]: T;
|
||||
}
|
||||
|
||||
export const enum Comparison {
|
||||
LessThan = -1,
|
||||
EqualTo = 0,
|
||||
|
||||
@@ -417,6 +417,7 @@ module ts {
|
||||
Warn_on_expressions_and_declarations_with_an_implied_any_type: { code: 6052, category: DiagnosticCategory.Message, key: "Warn on expressions and declarations with an implied 'any' type." },
|
||||
File_0_not_found: { code: 6053, category: DiagnosticCategory.Error, key: "File '{0}' not found." },
|
||||
File_0_must_have_extension_ts_or_d_ts: { code: 6054, category: DiagnosticCategory.Error, key: "File '{0}' must have extension '.ts' or '.d.ts'." },
|
||||
Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures: { code: 6055, category: DiagnosticCategory.Message, key: "Suppress noImplicitAny errors for indexing objects lacking index signatures." },
|
||||
Variable_0_implicitly_has_an_1_type: { code: 7005, category: DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." },
|
||||
Parameter_0_implicitly_has_an_1_type: { code: 7006, category: DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." },
|
||||
Member_0_implicitly_has_an_1_type: { code: 7008, category: DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." },
|
||||
@@ -435,6 +436,7 @@ module ts {
|
||||
Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7024, category: DiagnosticCategory.Error, key: "Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." },
|
||||
You_cannot_rename_this_element: { code: 8000, category: DiagnosticCategory.Error, key: "You cannot rename this element." },
|
||||
yield_expressions_are_not_currently_supported: { code: 9000, category: DiagnosticCategory.Error, key: "'yield' expressions are not currently supported." },
|
||||
generators_are_not_currently_supported: { code: 9001, category: DiagnosticCategory.Error, key: "'generators' are not currently supported." },
|
||||
Generators_are_not_currently_supported: { code: 9001, category: DiagnosticCategory.Error, key: "Generators are not currently supported." },
|
||||
Computed_property_names_are_not_currently_supported: { code: 9002, category: DiagnosticCategory.Error, key: "Computed property names are not currently supported." },
|
||||
};
|
||||
}
|
||||
@@ -1667,6 +1667,10 @@
|
||||
"category": "Error",
|
||||
"code": 6054
|
||||
},
|
||||
"Suppress noImplicitAny errors for indexing objects lacking index signatures.": {
|
||||
"category": "Message",
|
||||
"code": 6055
|
||||
},
|
||||
|
||||
"Variable '{0}' implicitly has an '{1}' type.": {
|
||||
"category": "Error",
|
||||
@@ -1740,8 +1744,12 @@
|
||||
"category": "Error",
|
||||
"code": 9000
|
||||
},
|
||||
"'generators' are not currently supported.": {
|
||||
"Generators are not currently supported.": {
|
||||
"category": "Error",
|
||||
"code": 9001
|
||||
},
|
||||
"Computed property names are not currently supported.": {
|
||||
"category": "Error",
|
||||
"code": 9002
|
||||
}
|
||||
}
|
||||
|
||||
+76
-673
@@ -1,41 +1,11 @@
|
||||
/// <reference path="types.ts"/>
|
||||
/// <reference path="core.ts"/>
|
||||
/// <reference path="scanner.ts"/>
|
||||
/// <reference path="utilities.ts"/>
|
||||
|
||||
module ts {
|
||||
var nodeConstructors = new Array<new () => Node>(SyntaxKind.Count);
|
||||
|
||||
export function getFullWidth(node: Node) {
|
||||
return node.end - node.pos;
|
||||
}
|
||||
|
||||
function hasFlag(val: number, flag: number): boolean {
|
||||
return (val & flag) !== 0;
|
||||
}
|
||||
|
||||
// Returns true if this node contains a parse error anywhere underneath it.
|
||||
export function containsParseError(node: Node): boolean {
|
||||
if (!hasFlag(node.parserContextFlags, ParserContextFlags.HasPropagatedChildContainsErrorFlag)) {
|
||||
// A node is considered to contain a parse error if:
|
||||
// a) the parser explicitly marked that it had an error
|
||||
// b) any of it's children reported that it had an error.
|
||||
var val = hasFlag(node.parserContextFlags, ParserContextFlags.ContainsError) ||
|
||||
forEachChild(node, containsParseError);
|
||||
|
||||
// If so, mark ourselves accordingly.
|
||||
if (val) {
|
||||
node.parserContextFlags |= ParserContextFlags.ContainsError;
|
||||
}
|
||||
|
||||
// Also mark that we've propogated the child information to this node. This way we can
|
||||
// always consult the bit directly on this node without needing to check its children
|
||||
// again.
|
||||
node.parserContextFlags |= ParserContextFlags.HasPropagatedChildContainsErrorFlag;
|
||||
}
|
||||
|
||||
return hasFlag(node.parserContextFlags, ParserContextFlags.ContainsError);
|
||||
}
|
||||
|
||||
export function getNodeConstructor(kind: SyntaxKind): new () => Node {
|
||||
return nodeConstructors[kind] || (nodeConstructors[kind] = objectAllocator.getNodeConstructor(kind));
|
||||
}
|
||||
@@ -44,186 +14,6 @@ module ts {
|
||||
return new (getNodeConstructor(kind))();
|
||||
}
|
||||
|
||||
export function getSourceFileOfNode(node: Node): SourceFile {
|
||||
while (node && node.kind !== SyntaxKind.SourceFile) node = node.parent;
|
||||
return <SourceFile>node;
|
||||
}
|
||||
|
||||
// This is a useful function for debugging purposes.
|
||||
export function nodePosToString(node: Node): string {
|
||||
var file = getSourceFileOfNode(node);
|
||||
var loc = file.getLineAndCharacterFromPosition(node.pos);
|
||||
return file.filename + "(" + loc.line + "," + loc.character + ")";
|
||||
}
|
||||
|
||||
export function getStartPosOfNode(node: Node): number {
|
||||
return node.pos;
|
||||
}
|
||||
|
||||
export function isMissingNode(node: Node) {
|
||||
if (node === undefined) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return node.pos === node.end && node.kind !== SyntaxKind.EndOfFileToken;
|
||||
}
|
||||
|
||||
export function getTokenPosOfNode(node: Node, sourceFile?: SourceFile): number {
|
||||
// With nodes that have no width (i.e. 'Missing' nodes), we actually *don't*
|
||||
// want to skip trivia because this will launch us forward to the next token.
|
||||
if (isMissingNode(node)) {
|
||||
return node.pos;
|
||||
}
|
||||
|
||||
return skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos);
|
||||
}
|
||||
|
||||
export function getSourceTextOfNodeFromSourceFile(sourceFile: SourceFile, node: Node): string {
|
||||
if (isMissingNode(node)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
var text = sourceFile.text;
|
||||
return text.substring(skipTrivia(text, node.pos), node.end);
|
||||
}
|
||||
|
||||
export function getTextOfNodeFromSourceText(sourceText: string, node: Node): string {
|
||||
if (isMissingNode(node)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return sourceText.substring(skipTrivia(sourceText, node.pos), node.end);
|
||||
}
|
||||
|
||||
export function getTextOfNode(node: Node): string {
|
||||
return getSourceTextOfNodeFromSourceFile(getSourceFileOfNode(node), node);
|
||||
}
|
||||
|
||||
// Add an extra underscore to identifiers that start with two underscores to avoid issues with magic names like '__proto__'
|
||||
export function escapeIdentifier(identifier: string): string {
|
||||
return identifier.length >= 2 && identifier.charCodeAt(0) === CharacterCodes._ && identifier.charCodeAt(1) === CharacterCodes._ ? "_" + identifier : identifier;
|
||||
}
|
||||
|
||||
// Remove extra underscore from escaped identifier
|
||||
export function unescapeIdentifier(identifier: string): string {
|
||||
return identifier.length >= 3 && identifier.charCodeAt(0) === CharacterCodes._ && identifier.charCodeAt(1) === CharacterCodes._ && identifier.charCodeAt(2) === CharacterCodes._ ? identifier.substr(1) : identifier;
|
||||
}
|
||||
|
||||
// Return display name of an identifier
|
||||
// Computed property names will just be emitted as "[<expr>]", where <expr> is the source
|
||||
// text of the expression in the computed property.
|
||||
export function declarationNameToString(name: DeclarationName) {
|
||||
return getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name);
|
||||
}
|
||||
|
||||
export function createDiagnosticForNode(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): Diagnostic {
|
||||
node = getErrorSpanForNode(node);
|
||||
var file = getSourceFileOfNode(node);
|
||||
|
||||
var start = getFullWidth(node) === 0 ? node.pos : skipTrivia(file.text, node.pos);
|
||||
var length = node.end - start;
|
||||
|
||||
return createFileDiagnostic(file, start, length, message, arg0, arg1, arg2);
|
||||
}
|
||||
|
||||
export function createDiagnosticForNodeFromMessageChain(node: Node, messageChain: DiagnosticMessageChain, newLine: string): Diagnostic {
|
||||
node = getErrorSpanForNode(node);
|
||||
var file = getSourceFileOfNode(node);
|
||||
var start = skipTrivia(file.text, node.pos);
|
||||
var length = node.end - start;
|
||||
return flattenDiagnosticChain(file, start, length, messageChain, newLine);
|
||||
}
|
||||
|
||||
export function getErrorSpanForNode(node: Node): Node {
|
||||
var errorSpan: Node;
|
||||
switch (node.kind) {
|
||||
// This list is a work in progress. Add missing node kinds to improve their error
|
||||
// spans.
|
||||
case SyntaxKind.VariableDeclaration:
|
||||
case SyntaxKind.BindingElement:
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
case SyntaxKind.InterfaceDeclaration:
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
case SyntaxKind.EnumMember:
|
||||
errorSpan = (<Declaration>node).name;
|
||||
break;
|
||||
}
|
||||
|
||||
// We now have the ideal error span, but it may be a node that is optional and absent
|
||||
// (e.g. the name of a function expression), in which case errorSpan will be undefined.
|
||||
// Alternatively, it might be required and missing (e.g. the name of a module), in which
|
||||
// case its pos will equal its end (length 0). In either of these cases, we should fall
|
||||
// back to the original node that the error was issued on.
|
||||
return errorSpan && errorSpan.pos < errorSpan.end ? errorSpan : node;
|
||||
}
|
||||
|
||||
export function isExternalModule(file: SourceFile): boolean {
|
||||
return file.externalModuleIndicator !== undefined;
|
||||
}
|
||||
|
||||
export function isDeclarationFile(file: SourceFile): boolean {
|
||||
return (file.flags & NodeFlags.DeclarationFile) !== 0;
|
||||
}
|
||||
|
||||
export function isConstEnumDeclaration(node: Node): boolean {
|
||||
return node.kind === SyntaxKind.EnumDeclaration && isConst(node);
|
||||
}
|
||||
|
||||
export function isConst(node: Node): boolean {
|
||||
return !!(node.flags & NodeFlags.Const);
|
||||
}
|
||||
|
||||
export function isLet(node: Node): boolean {
|
||||
return !!(node.flags & NodeFlags.Let);
|
||||
}
|
||||
|
||||
export function isPrologueDirective(node: Node): boolean {
|
||||
return node.kind === SyntaxKind.ExpressionStatement && (<ExpressionStatement>node).expression.kind === SyntaxKind.StringLiteral;
|
||||
}
|
||||
|
||||
function isEvalOrArgumentsIdentifier(node: Node): boolean {
|
||||
return node.kind === SyntaxKind.Identifier &&
|
||||
(<Identifier>node).text &&
|
||||
((<Identifier>node).text === "eval" || (<Identifier>node).text === "arguments");
|
||||
}
|
||||
|
||||
/// Should be called only on prologue directives (isPrologueDirective(node) should be true)
|
||||
function isUseStrictPrologueDirective(node: Node): boolean {
|
||||
Debug.assert(isPrologueDirective(node));
|
||||
return (<Identifier>(<ExpressionStatement>node).expression).text === "use strict";
|
||||
}
|
||||
|
||||
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(getTrailingCommentRanges(sourceFileOfNode.text, node.pos),
|
||||
// e.g.: (
|
||||
// /** blah */ a,
|
||||
// /** blah */ b);
|
||||
getLeadingCommentRanges(sourceFileOfNode.text, node.pos));
|
||||
}
|
||||
else {
|
||||
return getLeadingCommentRanges(sourceFileOfNode.text, node.pos);
|
||||
}
|
||||
}
|
||||
|
||||
export function getJsDocComments(node: Node, sourceFileOfNode: SourceFile) {
|
||||
return filter(getLeadingCommentRangesOfNode(node, sourceFileOfNode), isJsDocComment);
|
||||
|
||||
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 &&
|
||||
sourceFileOfNode.text.charCodeAt(comment.pos + 3) !== CharacterCodes.slash;
|
||||
}
|
||||
}
|
||||
|
||||
export var fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*<reference\s+path\s*=\s*)('|")(.+?)\2.*?\/>/
|
||||
|
||||
// Invokes a callback for each child of the given node. The 'cbNode' callback is invoked for all child nodes
|
||||
// stored in properties. If a 'cbNodes' callback is specified, it is invoked for embedded arrays; otherwise,
|
||||
// embedded arrays are flattened and the 'cbNode' callback is invoked for each element. If a callback returns
|
||||
@@ -468,422 +258,78 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
// Warning: This has the same semantics as the forEach family of functions,
|
||||
// in that traversal terminates in the event that 'visitor' supplies a truthy value.
|
||||
export function forEachReturnStatement<T>(body: Block, visitor: (stmt: ReturnStatement) => T): T {
|
||||
// TODO (drosen, mhegazy): Move to a more appropriate file.
|
||||
export function createCompilerHost(options: CompilerOptions): CompilerHost {
|
||||
var currentDirectory: string;
|
||||
var existingDirectories: Map<boolean> = {};
|
||||
|
||||
return traverse(body);
|
||||
|
||||
function traverse(node: Node): T {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.ReturnStatement:
|
||||
return visitor(<ReturnStatement>node);
|
||||
case SyntaxKind.Block:
|
||||
case SyntaxKind.IfStatement:
|
||||
case SyntaxKind.DoStatement:
|
||||
case SyntaxKind.WhileStatement:
|
||||
case SyntaxKind.ForStatement:
|
||||
case SyntaxKind.ForInStatement:
|
||||
case SyntaxKind.WithStatement:
|
||||
case SyntaxKind.SwitchStatement:
|
||||
case SyntaxKind.CaseClause:
|
||||
case SyntaxKind.DefaultClause:
|
||||
case SyntaxKind.LabeledStatement:
|
||||
case SyntaxKind.TryStatement:
|
||||
case SyntaxKind.CatchClause:
|
||||
return forEachChild(node, traverse);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function isAnyFunction(node: Node): boolean {
|
||||
if (node) {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.Constructor:
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.ArrowFunction:
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.MethodSignature:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
case SyntaxKind.CallSignature:
|
||||
case SyntaxKind.ConstructSignature:
|
||||
case SyntaxKind.IndexSignature:
|
||||
case SyntaxKind.FunctionType:
|
||||
case SyntaxKind.ConstructorType:
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.ArrowFunction:
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
export function isFunctionBlock(node: Node) {
|
||||
return node && node.kind === SyntaxKind.Block && isAnyFunction(node.parent);
|
||||
}
|
||||
|
||||
export function isObjectLiteralMethod(node: Node) {
|
||||
return node && node.kind === SyntaxKind.MethodDeclaration && node.parent.kind === SyntaxKind.ObjectLiteralExpression;
|
||||
}
|
||||
|
||||
export function getContainingFunction(node: Node): FunctionLikeDeclaration {
|
||||
while (true) {
|
||||
node = node.parent;
|
||||
if (!node || isAnyFunction(node)) {
|
||||
return <FunctionLikeDeclaration>node;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function getThisContainer(node: Node, includeArrowFunctions: boolean): Node {
|
||||
while (true) {
|
||||
node = node.parent;
|
||||
if (!node) {
|
||||
return undefined;
|
||||
}
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.ArrowFunction:
|
||||
if (!includeArrowFunctions) {
|
||||
continue;
|
||||
}
|
||||
// Fall through
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
case SyntaxKind.PropertySignature:
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.MethodSignature:
|
||||
case SyntaxKind.Constructor:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
case SyntaxKind.SourceFile:
|
||||
return node;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function getSuperContainer(node: Node): Node {
|
||||
while (true) {
|
||||
node = node.parent;
|
||||
if (!node) {
|
||||
return undefined;
|
||||
}
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
case SyntaxKind.PropertySignature:
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.MethodSignature:
|
||||
case SyntaxKind.Constructor:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
return node;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function getInvokedExpression(node: CallLikeExpression): Expression {
|
||||
if (node.kind === SyntaxKind.TaggedTemplateExpression) {
|
||||
return (<TaggedTemplateExpression>node).tag;
|
||||
function getCanonicalFileName(fileName: string): string {
|
||||
// if underlying system can distinguish between two files whose names differs only in cases then file name already in canonical form.
|
||||
// otherwise use toLowerCase as a canonical form.
|
||||
return sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase();
|
||||
}
|
||||
|
||||
// Will either be a CallExpression or NewExpression.
|
||||
return (<CallExpression>node).expression;
|
||||
}
|
||||
// returned by CScript sys environment
|
||||
var unsupportedFileEncodingErrorCode = -2147024809;
|
||||
|
||||
export function isExpression(node: Node): boolean {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.ThisKeyword:
|
||||
case SyntaxKind.SuperKeyword:
|
||||
case SyntaxKind.NullKeyword:
|
||||
case SyntaxKind.TrueKeyword:
|
||||
case SyntaxKind.FalseKeyword:
|
||||
case SyntaxKind.RegularExpressionLiteral:
|
||||
case SyntaxKind.ArrayLiteralExpression:
|
||||
case SyntaxKind.ObjectLiteralExpression:
|
||||
case SyntaxKind.PropertyAccessExpression:
|
||||
case SyntaxKind.ElementAccessExpression:
|
||||
case SyntaxKind.CallExpression:
|
||||
case SyntaxKind.NewExpression:
|
||||
case SyntaxKind.TaggedTemplateExpression:
|
||||
case SyntaxKind.TypeAssertionExpression:
|
||||
case SyntaxKind.ParenthesizedExpression:
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.ArrowFunction:
|
||||
case SyntaxKind.VoidExpression:
|
||||
case SyntaxKind.DeleteExpression:
|
||||
case SyntaxKind.TypeOfExpression:
|
||||
case SyntaxKind.PrefixUnaryExpression:
|
||||
case SyntaxKind.PostfixUnaryExpression:
|
||||
case SyntaxKind.BinaryExpression:
|
||||
case SyntaxKind.ConditionalExpression:
|
||||
case SyntaxKind.TemplateExpression:
|
||||
case SyntaxKind.NoSubstitutionTemplateLiteral:
|
||||
case SyntaxKind.OmittedExpression:
|
||||
return true;
|
||||
case SyntaxKind.QualifiedName:
|
||||
while (node.parent.kind === SyntaxKind.QualifiedName) {
|
||||
node = node.parent;
|
||||
function getSourceFile(filename: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile {
|
||||
try {
|
||||
var text = sys.readFile(filename, options.charset);
|
||||
}
|
||||
catch (e) {
|
||||
if (onError) {
|
||||
onError(e.number === unsupportedFileEncodingErrorCode ?
|
||||
createCompilerDiagnostic(Diagnostics.Unsupported_file_encoding).messageText :
|
||||
e.message);
|
||||
}
|
||||
text = "";
|
||||
}
|
||||
|
||||
return node.parent.kind === SyntaxKind.TypeQuery;
|
||||
case SyntaxKind.Identifier:
|
||||
if (node.parent.kind === SyntaxKind.TypeQuery) {
|
||||
return text !== undefined ? createSourceFile(filename, text, languageVersion) : undefined;
|
||||
}
|
||||
|
||||
function writeFile(fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void) {
|
||||
function directoryExists(directoryPath: string): boolean {
|
||||
if (hasProperty(existingDirectories, directoryPath)) {
|
||||
return true;
|
||||
}
|
||||
// fall through
|
||||
case SyntaxKind.NumericLiteral:
|
||||
case SyntaxKind.StringLiteral:
|
||||
var parent = node.parent;
|
||||
switch (parent.kind) {
|
||||
case SyntaxKind.VariableDeclaration:
|
||||
case SyntaxKind.Parameter:
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
case SyntaxKind.PropertySignature:
|
||||
case SyntaxKind.EnumMember:
|
||||
case SyntaxKind.PropertyAssignment:
|
||||
case SyntaxKind.BindingElement:
|
||||
return (<VariableLikeDeclaration>parent).initializer === node;
|
||||
case SyntaxKind.ExpressionStatement:
|
||||
case SyntaxKind.IfStatement:
|
||||
case SyntaxKind.DoStatement:
|
||||
case SyntaxKind.WhileStatement:
|
||||
case SyntaxKind.ReturnStatement:
|
||||
case SyntaxKind.WithStatement:
|
||||
case SyntaxKind.SwitchStatement:
|
||||
case SyntaxKind.CaseClause:
|
||||
case SyntaxKind.ThrowStatement:
|
||||
case SyntaxKind.SwitchStatement:
|
||||
return (<ExpressionStatement>parent).expression === node;
|
||||
case SyntaxKind.ForStatement:
|
||||
return (<ForStatement>parent).initializer === node ||
|
||||
(<ForStatement>parent).condition === node ||
|
||||
(<ForStatement>parent).iterator === node;
|
||||
case SyntaxKind.ForInStatement:
|
||||
return (<ForInStatement>parent).variable === node ||
|
||||
(<ForInStatement>parent).expression === node;
|
||||
case SyntaxKind.TypeAssertionExpression:
|
||||
return node === (<TypeAssertion>parent).expression;
|
||||
case SyntaxKind.TemplateSpan:
|
||||
return node === (<TemplateSpan>parent).expression;
|
||||
default:
|
||||
if (isExpression(parent)) {
|
||||
return true;
|
||||
}
|
||||
if (sys.directoryExists(directoryPath)) {
|
||||
existingDirectories[directoryPath] = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export function isExternalModuleImportDeclaration(node: Node) {
|
||||
return node.kind === SyntaxKind.ImportDeclaration && (<ImportDeclaration>node).moduleReference.kind === SyntaxKind.ExternalModuleReference;
|
||||
}
|
||||
|
||||
export function getExternalModuleImportDeclarationExpression(node: Node) {
|
||||
Debug.assert(isExternalModuleImportDeclaration(node));
|
||||
return (<ExternalModuleReference>(<ImportDeclaration>node).moduleReference).expression;
|
||||
}
|
||||
|
||||
export function isInternalModuleImportDeclaration(node: Node) {
|
||||
return node.kind === SyntaxKind.ImportDeclaration && (<ImportDeclaration>node).moduleReference.kind !== SyntaxKind.ExternalModuleReference;
|
||||
}
|
||||
|
||||
export function hasDotDotDotToken(node: Node) {
|
||||
return node && node.kind === SyntaxKind.Parameter && (<ParameterDeclaration>node).dotDotDotToken !== undefined;
|
||||
}
|
||||
|
||||
export function hasQuestionToken(node: Node) {
|
||||
if (node) {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.Parameter:
|
||||
return (<ParameterDeclaration>node).questionToken !== undefined;
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.MethodSignature:
|
||||
return (<MethodDeclaration>node).questionToken !== undefined;
|
||||
case SyntaxKind.ShorthandPropertyAssignment:
|
||||
case SyntaxKind.PropertyAssignment:
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
case SyntaxKind.PropertySignature:
|
||||
return (<PropertyDeclaration>node).questionToken !== undefined;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
export function hasRestParameters(s: SignatureDeclaration): boolean {
|
||||
return s.parameters.length > 0 && s.parameters[s.parameters.length - 1].dotDotDotToken !== undefined;
|
||||
}
|
||||
|
||||
export function isLiteralKind(kind: SyntaxKind): boolean {
|
||||
return SyntaxKind.FirstLiteralToken <= kind && kind <= SyntaxKind.LastLiteralToken;
|
||||
}
|
||||
|
||||
export function isTextualLiteralKind(kind: SyntaxKind): boolean {
|
||||
return kind === SyntaxKind.StringLiteral || kind === SyntaxKind.NoSubstitutionTemplateLiteral;
|
||||
}
|
||||
|
||||
export function isTemplateLiteralKind(kind: SyntaxKind): boolean {
|
||||
return SyntaxKind.FirstTemplateToken <= kind && kind <= SyntaxKind.LastTemplateToken;
|
||||
}
|
||||
|
||||
export function isBindingPattern(node: Node) {
|
||||
return node.kind === SyntaxKind.ArrayBindingPattern || node.kind === SyntaxKind.ObjectBindingPattern;
|
||||
}
|
||||
|
||||
export function isInAmbientContext(node: Node): boolean {
|
||||
while (node) {
|
||||
if (node.flags & (NodeFlags.Ambient | NodeFlags.DeclarationFile)) return true;
|
||||
node = node.parent;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export function isDeclaration(node: Node): boolean {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.TypeParameter:
|
||||
case SyntaxKind.Parameter:
|
||||
case SyntaxKind.VariableDeclaration:
|
||||
case SyntaxKind.BindingElement:
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
case SyntaxKind.PropertySignature:
|
||||
case SyntaxKind.PropertyAssignment:
|
||||
case SyntaxKind.ShorthandPropertyAssignment:
|
||||
case SyntaxKind.EnumMember:
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.MethodSignature:
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
case SyntaxKind.Constructor:
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
case SyntaxKind.InterfaceDeclaration:
|
||||
case SyntaxKind.TypeAliasDeclaration:
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
case SyntaxKind.ImportDeclaration:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export function isStatement(n: Node): boolean {
|
||||
switch(n.kind) {
|
||||
case SyntaxKind.BreakStatement:
|
||||
case SyntaxKind.ContinueStatement:
|
||||
case SyntaxKind.DebuggerStatement:
|
||||
case SyntaxKind.DoStatement:
|
||||
case SyntaxKind.ExpressionStatement:
|
||||
case SyntaxKind.EmptyStatement:
|
||||
case SyntaxKind.ForInStatement:
|
||||
case SyntaxKind.ForStatement:
|
||||
case SyntaxKind.IfStatement:
|
||||
case SyntaxKind.LabeledStatement:
|
||||
case SyntaxKind.ReturnStatement:
|
||||
case SyntaxKind.SwitchStatement:
|
||||
case SyntaxKind.ThrowKeyword:
|
||||
case SyntaxKind.TryStatement:
|
||||
case SyntaxKind.VariableStatement:
|
||||
case SyntaxKind.WhileStatement:
|
||||
case SyntaxKind.WithStatement:
|
||||
case SyntaxKind.ExportAssignment:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// True if the given identifier, string literal, or number literal is the name of a declaration node
|
||||
export function isDeclarationOrFunctionExpressionOrCatchVariableName(name: Node): boolean {
|
||||
if (name.kind !== SyntaxKind.Identifier && name.kind !== SyntaxKind.StringLiteral && name.kind !== SyntaxKind.NumericLiteral) {
|
||||
return false;
|
||||
}
|
||||
function ensureDirectoriesExist(directoryPath: string) {
|
||||
if (directoryPath.length > getRootLength(directoryPath) && !directoryExists(directoryPath)) {
|
||||
var parentDirectory = getDirectoryPath(directoryPath);
|
||||
ensureDirectoriesExist(parentDirectory);
|
||||
sys.createDirectory(directoryPath);
|
||||
}
|
||||
}
|
||||
|
||||
var parent = name.parent;
|
||||
if (isDeclaration(parent) || parent.kind === SyntaxKind.FunctionExpression) {
|
||||
return (<Declaration>parent).name === name;
|
||||
}
|
||||
|
||||
if (parent.kind === SyntaxKind.CatchClause) {
|
||||
return (<CatchClause>parent).name === name;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
export function getClassBaseTypeNode(node: ClassDeclaration) {
|
||||
var heritageClause = getHeritageClause(node.heritageClauses, SyntaxKind.ExtendsKeyword);
|
||||
return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined;
|
||||
}
|
||||
|
||||
export function getClassImplementedTypeNodes(node: ClassDeclaration) {
|
||||
var heritageClause = getHeritageClause(node.heritageClauses, SyntaxKind.ImplementsKeyword);
|
||||
return heritageClause ? heritageClause.types : undefined;
|
||||
}
|
||||
|
||||
export function getInterfaceBaseTypeNodes(node: InterfaceDeclaration) {
|
||||
var heritageClause = getHeritageClause(node.heritageClauses, SyntaxKind.ExtendsKeyword);
|
||||
return heritageClause ? heritageClause.types : undefined;
|
||||
}
|
||||
|
||||
export function getHeritageClause(clauses: NodeArray<HeritageClause>, kind: SyntaxKind) {
|
||||
if (clauses) {
|
||||
for (var i = 0, n = clauses.length; i < n; i++) {
|
||||
if (clauses[i].token === kind) {
|
||||
return clauses[i];
|
||||
try {
|
||||
ensureDirectoriesExist(getDirectoryPath(normalizePath(fileName)));
|
||||
sys.writeFile(fileName, data, writeByteOrderMark);
|
||||
}
|
||||
catch (e) {
|
||||
if (onError) {
|
||||
onError(e.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
return {
|
||||
getSourceFile,
|
||||
getDefaultLibFilename: options => combinePaths(getDirectoryPath(normalizePath(sys.getExecutingFilePath())), options.target === ScriptTarget.ES6 ? "lib.es6.d.ts" : "lib.d.ts"),
|
||||
writeFile,
|
||||
getCurrentDirectory: () => currentDirectory || (currentDirectory = sys.getCurrentDirectory()),
|
||||
useCaseSensitiveFileNames: () => sys.useCaseSensitiveFileNames,
|
||||
getCanonicalFileName,
|
||||
getNewLine: () => sys.newLine
|
||||
};
|
||||
}
|
||||
|
||||
export function tryResolveScriptReference(program: Program, sourceFile: SourceFile, reference: FileReference) {
|
||||
if (!program.getCompilerOptions().noResolve) {
|
||||
var referenceFileName = isRootedDiskPath(reference.filename) ? reference.filename : combinePaths(getDirectoryPath(sourceFile.filename), reference.filename);
|
||||
referenceFileName = getNormalizedAbsolutePath(referenceFileName, program.getCompilerHost().getCurrentDirectory());
|
||||
return program.getSourceFile(referenceFileName);
|
||||
}
|
||||
}
|
||||
|
||||
export function getAncestor(node: Node, kind: SyntaxKind): Node {
|
||||
switch (kind) {
|
||||
// special-cases that can be come first
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
while (node) {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
return <ClassDeclaration>node;
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
case SyntaxKind.InterfaceDeclaration:
|
||||
case SyntaxKind.TypeAliasDeclaration:
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
case SyntaxKind.ImportDeclaration:
|
||||
// early exit cases - declarations cannot be nested in classes
|
||||
return undefined;
|
||||
default:
|
||||
node = node.parent;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
while (node) {
|
||||
if (node.kind === kind) {
|
||||
return node;
|
||||
}
|
||||
node = node.parent;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const enum ParsingContext {
|
||||
SourceElements, // Elements in source file
|
||||
@@ -940,68 +386,6 @@ module ts {
|
||||
}
|
||||
};
|
||||
|
||||
export interface ReferencePathMatchResult {
|
||||
fileReference?: FileReference
|
||||
diagnosticMessage?: DiagnosticMessage
|
||||
isNoDefaultLib?: boolean
|
||||
}
|
||||
|
||||
export function getFileReferenceFromReferencePath(comment: string, commentRange: CommentRange): ReferencePathMatchResult {
|
||||
var simpleReferenceRegEx = /^\/\/\/\s*<reference\s+/gim;
|
||||
var isNoDefaultLibRegEx = /^(\/\/\/\s*<reference\s+no-default-lib\s*=\s*)('|")(.+?)\2\s*\/>/gim;
|
||||
if (simpleReferenceRegEx.exec(comment)) {
|
||||
if (isNoDefaultLibRegEx.exec(comment)) {
|
||||
return {
|
||||
isNoDefaultLib: true
|
||||
}
|
||||
}
|
||||
else {
|
||||
var matchResult = fullTripleSlashReferencePathRegEx.exec(comment);
|
||||
if (matchResult) {
|
||||
var start = commentRange.pos;
|
||||
var end = commentRange.end;
|
||||
return {
|
||||
fileReference: {
|
||||
pos: start,
|
||||
end: end,
|
||||
filename: matchResult[3]
|
||||
},
|
||||
isNoDefaultLib: false
|
||||
};
|
||||
}
|
||||
else {
|
||||
return {
|
||||
diagnosticMessage: Diagnostics.Invalid_reference_directive_syntax,
|
||||
isNoDefaultLib: false
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function isKeyword(token: SyntaxKind): boolean {
|
||||
return SyntaxKind.FirstKeyword <= token && token <= SyntaxKind.LastKeyword;
|
||||
}
|
||||
|
||||
export function isTrivia(token: SyntaxKind) {
|
||||
return SyntaxKind.FirstTriviaToken <= token && token <= SyntaxKind.LastTriviaToken;
|
||||
}
|
||||
|
||||
export function isModifier(token: SyntaxKind): boolean {
|
||||
switch (token) {
|
||||
case SyntaxKind.PublicKeyword:
|
||||
case SyntaxKind.PrivateKeyword:
|
||||
case SyntaxKind.ProtectedKeyword:
|
||||
case SyntaxKind.StaticKeyword:
|
||||
case SyntaxKind.ExportKeyword:
|
||||
case SyntaxKind.DeclareKeyword:
|
||||
case SyntaxKind.ConstKeyword:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function modifierToFlag(token: SyntaxKind): NodeFlags {
|
||||
switch (token) {
|
||||
case SyntaxKind.StaticKeyword: return NodeFlags.Static;
|
||||
@@ -1037,6 +421,21 @@ module ts {
|
||||
forEachChild(sourceFile, walk);
|
||||
}
|
||||
|
||||
function isEvalOrArgumentsIdentifier(node: Node): boolean {
|
||||
return node.kind === SyntaxKind.Identifier &&
|
||||
((<Identifier>node).text === "eval" || (<Identifier>node).text === "arguments");
|
||||
}
|
||||
|
||||
/// Should be called only on prologue directives (isPrologueDirective(node) should be true)
|
||||
function isUseStrictPrologueDirective(sourceFile: SourceFile, node: Node): boolean {
|
||||
Debug.assert(isPrologueDirective(node));
|
||||
var nodeText = getSourceTextOfNodeFromSourceFile(sourceFile,(<ExpressionStatement>node).expression);
|
||||
|
||||
// Note: the node text must be exactly "use strict" or 'use strict'. It is not ok for the
|
||||
// string to contain unicode escapes (as per ES5).
|
||||
return nodeText === '"use strict"' || nodeText === "'use strict'";
|
||||
}
|
||||
|
||||
interface IncrementalElement extends TextRange {
|
||||
intersectsChange: boolean
|
||||
length?: number;
|
||||
@@ -2012,7 +1411,7 @@ module ts {
|
||||
// test elements only if we are not already in strict mode
|
||||
if (checkForStrictMode && !inStrictModeContext()) {
|
||||
if (isPrologueDirective(element)) {
|
||||
if (isUseStrictPrologueDirective(element)) {
|
||||
if (isUseStrictPrologueDirective(sourceFile, element)) {
|
||||
setStrictModeContext(true);
|
||||
checkForStrictMode = false;
|
||||
}
|
||||
@@ -5723,7 +5122,7 @@ module ts {
|
||||
|
||||
function checkForGenerator(node: FunctionLikeDeclaration) {
|
||||
if (node.asteriskToken) {
|
||||
return grammarErrorOnNode(node.asteriskToken, Diagnostics.generators_are_not_currently_supported);
|
||||
return grammarErrorOnNode(node.asteriskToken, Diagnostics.Generators_are_not_currently_supported);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6227,6 +5626,10 @@ module ts {
|
||||
}
|
||||
|
||||
function checkComputedPropertyName(node: ComputedPropertyName) {
|
||||
// Since computed properties are not supported in the type checker, disallow them in TypeScript 1.4
|
||||
// Once full support is added, remove this error.
|
||||
return grammarErrorOnNode(node, Diagnostics.Computed_property_names_are_not_currently_supported);
|
||||
|
||||
if (languageVersion < ScriptTarget.ES6) {
|
||||
return grammarErrorOnNode(node, Diagnostics.Computed_property_names_are_only_available_when_targeting_ECMAScript_6_and_higher);
|
||||
}
|
||||
|
||||
+234
-231
@@ -1,252 +1,255 @@
|
||||
|
||||
interface System {
|
||||
args: string[];
|
||||
newLine: string;
|
||||
useCaseSensitiveFileNames: boolean;
|
||||
write(s: string): void;
|
||||
readFile(fileName: string, encoding?: string): string;
|
||||
writeFile(fileName: string, data: string, writeByteOrderMark?: boolean): void;
|
||||
watchFile?(fileName: string, callback: (fileName: string) => void): FileWatcher;
|
||||
resolvePath(path: string): string;
|
||||
fileExists(path: string): boolean;
|
||||
directoryExists(path: string): boolean;
|
||||
createDirectory(directoryName: string): void;
|
||||
getExecutingFilePath(): string;
|
||||
getCurrentDirectory(): string;
|
||||
getMemoryUsage?(): number;
|
||||
exit(exitCode?: number): void;
|
||||
}
|
||||
module ts {
|
||||
export interface System {
|
||||
args: string[];
|
||||
newLine: string;
|
||||
useCaseSensitiveFileNames: boolean;
|
||||
write(s: string): void;
|
||||
readFile(fileName: string, encoding?: string): string;
|
||||
writeFile(fileName: string, data: string, writeByteOrderMark?: boolean): void;
|
||||
watchFile? (fileName: string, callback: (fileName: string) => void): FileWatcher;
|
||||
resolvePath(path: string): string;
|
||||
fileExists(path: string): boolean;
|
||||
directoryExists(path: string): boolean;
|
||||
createDirectory(directoryName: string): void;
|
||||
getExecutingFilePath(): string;
|
||||
getCurrentDirectory(): string;
|
||||
getMemoryUsage? (): number;
|
||||
exit(exitCode?: number): void;
|
||||
}
|
||||
|
||||
interface FileWatcher {
|
||||
close(): void;
|
||||
}
|
||||
export interface FileWatcher {
|
||||
close(): void;
|
||||
}
|
||||
|
||||
declare var require: any;
|
||||
declare var module: any;
|
||||
declare var process: any;
|
||||
declare var global: any;
|
||||
declare var require: any;
|
||||
declare var module: any;
|
||||
declare var process: any;
|
||||
declare var global: any;
|
||||
declare var __filename: string;
|
||||
|
||||
var sys: System = (function () {
|
||||
export var sys: System = (function () {
|
||||
|
||||
function getWScriptSystem(): System {
|
||||
function getWScriptSystem(): System {
|
||||
|
||||
var fso = new ActiveXObject("Scripting.FileSystemObject");
|
||||
var fso = new ActiveXObject("Scripting.FileSystemObject");
|
||||
|
||||
var fileStream = new ActiveXObject("ADODB.Stream");
|
||||
fileStream.Type = 2 /*text*/;
|
||||
var fileStream = new ActiveXObject("ADODB.Stream");
|
||||
fileStream.Type = 2 /*text*/;
|
||||
|
||||
var binaryStream = new ActiveXObject("ADODB.Stream");
|
||||
binaryStream.Type = 1 /*binary*/;
|
||||
var binaryStream = new ActiveXObject("ADODB.Stream");
|
||||
binaryStream.Type = 1 /*binary*/;
|
||||
|
||||
var args: string[] = [];
|
||||
for (var i = 0; i < WScript.Arguments.length; i++) {
|
||||
args[i] = WScript.Arguments.Item(i);
|
||||
}
|
||||
|
||||
function readFile(fileName: string, encoding?: string): string {
|
||||
if (!fso.FileExists(fileName)) {
|
||||
return undefined;
|
||||
var args: string[] = [];
|
||||
for (var i = 0; i < WScript.Arguments.length; i++) {
|
||||
args[i] = WScript.Arguments.Item(i);
|
||||
}
|
||||
fileStream.Open();
|
||||
try {
|
||||
if (encoding) {
|
||||
fileStream.Charset = encoding;
|
||||
fileStream.LoadFromFile(fileName);
|
||||
|
||||
function readFile(fileName: string, encoding?: string): string {
|
||||
if (!fso.FileExists(fileName)) {
|
||||
return undefined;
|
||||
}
|
||||
else {
|
||||
// Load file and read the first two bytes into a string with no interpretation
|
||||
fileStream.Charset = "x-ansi";
|
||||
fileStream.LoadFromFile(fileName);
|
||||
var bom = fileStream.ReadText(2) || "";
|
||||
// Position must be at 0 before encoding can be changed
|
||||
fileStream.Position = 0;
|
||||
// [0xFF,0xFE] and [0xFE,0xFF] mean utf-16 (little or big endian), otherwise default to utf-8
|
||||
fileStream.Charset = bom.length >= 2 && (bom.charCodeAt(0) === 0xFF && bom.charCodeAt(1) === 0xFE || bom.charCodeAt(0) === 0xFE && bom.charCodeAt(1) === 0xFF) ? "unicode" : "utf-8";
|
||||
}
|
||||
// ReadText method always strips byte order mark from resulting string
|
||||
return fileStream.ReadText();
|
||||
}
|
||||
catch (e) {
|
||||
throw e;
|
||||
}
|
||||
finally {
|
||||
fileStream.Close();
|
||||
}
|
||||
}
|
||||
|
||||
function writeFile(fileName: string, data: string, writeByteOrderMark?: boolean): void {
|
||||
fileStream.Open();
|
||||
binaryStream.Open();
|
||||
try {
|
||||
// Write characters in UTF-8 encoding
|
||||
fileStream.Charset = "utf-8";
|
||||
fileStream.WriteText(data);
|
||||
// If we don't want the BOM, then skip it by setting the starting location to 3 (size of BOM).
|
||||
// If not, start from position 0, as the BOM will be added automatically when charset==utf8.
|
||||
if (writeByteOrderMark) {
|
||||
fileStream.Position = 0;
|
||||
}
|
||||
else {
|
||||
fileStream.Position = 3;
|
||||
}
|
||||
fileStream.CopyTo(binaryStream);
|
||||
binaryStream.SaveToFile(fileName, 2 /*overwrite*/);
|
||||
}
|
||||
finally {
|
||||
binaryStream.Close();
|
||||
fileStream.Close();
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
args,
|
||||
newLine: "\r\n",
|
||||
useCaseSensitiveFileNames: false,
|
||||
write(s: string): void {
|
||||
WScript.StdOut.Write(s);
|
||||
},
|
||||
readFile,
|
||||
writeFile,
|
||||
resolvePath(path: string): string {
|
||||
return fso.GetAbsolutePathName(path);
|
||||
},
|
||||
fileExists(path: string): boolean {
|
||||
return fso.FileExists(path);
|
||||
},
|
||||
directoryExists(path: string) {
|
||||
return fso.FolderExists(path);
|
||||
},
|
||||
createDirectory(directoryName: string) {
|
||||
if (!this.directoryExists(directoryName)) {
|
||||
fso.CreateFolder(directoryName);
|
||||
}
|
||||
},
|
||||
getExecutingFilePath() {
|
||||
return WScript.ScriptFullName;
|
||||
},
|
||||
getCurrentDirectory() {
|
||||
return new ActiveXObject("WScript.Shell").CurrentDirectory;
|
||||
},
|
||||
exit(exitCode?: number): void {
|
||||
fileStream.Open();
|
||||
try {
|
||||
WScript.Quit(exitCode);
|
||||
if (encoding) {
|
||||
fileStream.Charset = encoding;
|
||||
fileStream.LoadFromFile(fileName);
|
||||
}
|
||||
else {
|
||||
// Load file and read the first two bytes into a string with no interpretation
|
||||
fileStream.Charset = "x-ansi";
|
||||
fileStream.LoadFromFile(fileName);
|
||||
var bom = fileStream.ReadText(2) || "";
|
||||
// Position must be at 0 before encoding can be changed
|
||||
fileStream.Position = 0;
|
||||
// [0xFF,0xFE] and [0xFE,0xFF] mean utf-16 (little or big endian), otherwise default to utf-8
|
||||
fileStream.Charset = bom.length >= 2 && (bom.charCodeAt(0) === 0xFF && bom.charCodeAt(1) === 0xFE || bom.charCodeAt(0) === 0xFE && bom.charCodeAt(1) === 0xFF) ? "unicode" : "utf-8";
|
||||
}
|
||||
// ReadText method always strips byte order mark from resulting string
|
||||
return fileStream.ReadText();
|
||||
}
|
||||
catch (e) {
|
||||
throw e;
|
||||
}
|
||||
finally {
|
||||
fileStream.Close();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
function getNodeSystem(): System {
|
||||
var _fs = require("fs");
|
||||
var _path = require("path");
|
||||
var _os = require('os');
|
||||
|
||||
var platform: string = _os.platform();
|
||||
// win32\win64 are case insensitive platforms, MacOS (darwin) by default is also case insensitive
|
||||
var useCaseSensitiveFileNames = platform !== "win32" && platform !== "win64" && platform !== "darwin";
|
||||
|
||||
function readFile(fileName: string, encoding?: string): string {
|
||||
if (!_fs.existsSync(fileName)) {
|
||||
return undefined;
|
||||
}
|
||||
var buffer = _fs.readFileSync(fileName);
|
||||
var len = buffer.length;
|
||||
if (len >= 2 && buffer[0] === 0xFE && buffer[1] === 0xFF) {
|
||||
// Big endian UTF-16 byte order mark detected. Since big endian is not supported by node.js,
|
||||
// flip all byte pairs and treat as little endian.
|
||||
len &= ~1;
|
||||
for (var i = 0; i < len; i += 2) {
|
||||
var temp = buffer[i];
|
||||
buffer[i] = buffer[i + 1];
|
||||
buffer[i + 1] = temp;
|
||||
}
|
||||
return buffer.toString("utf16le", 2);
|
||||
}
|
||||
if (len >= 2 && buffer[0] === 0xFF && buffer[1] === 0xFE) {
|
||||
// Little endian UTF-16 byte order mark detected
|
||||
return buffer.toString("utf16le", 2);
|
||||
}
|
||||
if (len >= 3 && buffer[0] === 0xEF && buffer[1] === 0xBB && buffer[2] === 0xBF) {
|
||||
// UTF-8 byte order mark detected
|
||||
return buffer.toString("utf8", 3);
|
||||
}
|
||||
// Default is UTF-8 with no byte order mark
|
||||
return buffer.toString("utf8");
|
||||
}
|
||||
|
||||
function writeFile(fileName: string, data: string, writeByteOrderMark?: boolean): void {
|
||||
// If a BOM is required, emit one
|
||||
if (writeByteOrderMark) {
|
||||
data = '\uFEFF' + data;
|
||||
}
|
||||
|
||||
_fs.writeFileSync(fileName, data, "utf8");
|
||||
}
|
||||
|
||||
return {
|
||||
args: process.argv.slice(2),
|
||||
newLine: _os.EOL,
|
||||
useCaseSensitiveFileNames: useCaseSensitiveFileNames,
|
||||
write(s: string): void {
|
||||
// 1 is a standard descriptor for stdout
|
||||
_fs.writeSync(1, s);
|
||||
},
|
||||
readFile,
|
||||
writeFile,
|
||||
watchFile: (fileName, callback) => {
|
||||
// watchFile polls a file every 250ms, picking up file notifications.
|
||||
_fs.watchFile(fileName, { persistent: true, interval: 250 }, fileChanged);
|
||||
|
||||
return {
|
||||
close() { _fs.unwatchFile(fileName, fileChanged); }
|
||||
};
|
||||
|
||||
function fileChanged(curr: any, prev: any) {
|
||||
if (+curr.mtime <= +prev.mtime) {
|
||||
return;
|
||||
function writeFile(fileName: string, data: string, writeByteOrderMark?: boolean): void {
|
||||
fileStream.Open();
|
||||
binaryStream.Open();
|
||||
try {
|
||||
// Write characters in UTF-8 encoding
|
||||
fileStream.Charset = "utf-8";
|
||||
fileStream.WriteText(data);
|
||||
// If we don't want the BOM, then skip it by setting the starting location to 3 (size of BOM).
|
||||
// If not, start from position 0, as the BOM will be added automatically when charset==utf8.
|
||||
if (writeByteOrderMark) {
|
||||
fileStream.Position = 0;
|
||||
}
|
||||
|
||||
callback(fileName);
|
||||
};
|
||||
},
|
||||
resolvePath: function (path: string): string {
|
||||
return _path.resolve(path);
|
||||
},
|
||||
fileExists(path: string): boolean {
|
||||
return _fs.existsSync(path);
|
||||
},
|
||||
directoryExists(path: string) {
|
||||
return _fs.existsSync(path) && _fs.statSync(path).isDirectory();
|
||||
},
|
||||
createDirectory(directoryName: string) {
|
||||
if (!this.directoryExists(directoryName)) {
|
||||
_fs.mkdirSync(directoryName);
|
||||
else {
|
||||
fileStream.Position = 3;
|
||||
}
|
||||
fileStream.CopyTo(binaryStream);
|
||||
binaryStream.SaveToFile(fileName, 2 /*overwrite*/);
|
||||
}
|
||||
},
|
||||
getExecutingFilePath() {
|
||||
return process.mainModule.filename;
|
||||
},
|
||||
getCurrentDirectory() {
|
||||
return (<any>process).cwd();
|
||||
},
|
||||
getMemoryUsage() {
|
||||
if (global.gc) {
|
||||
global.gc();
|
||||
finally {
|
||||
binaryStream.Close();
|
||||
fileStream.Close();
|
||||
}
|
||||
return process.memoryUsage().heapUsed;
|
||||
},
|
||||
exit(exitCode?: number): void {
|
||||
process.exit(exitCode);
|
||||
}
|
||||
};
|
||||
}
|
||||
if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") {
|
||||
return getWScriptSystem();
|
||||
}
|
||||
else if (typeof module !== "undefined" && module.exports) {
|
||||
return getNodeSystem();
|
||||
}
|
||||
else {
|
||||
return undefined; // Unsupported host
|
||||
}
|
||||
})();
|
||||
|
||||
return {
|
||||
args,
|
||||
newLine: "\r\n",
|
||||
useCaseSensitiveFileNames: false,
|
||||
write(s: string): void {
|
||||
WScript.StdOut.Write(s);
|
||||
},
|
||||
readFile,
|
||||
writeFile,
|
||||
resolvePath(path: string): string {
|
||||
return fso.GetAbsolutePathName(path);
|
||||
},
|
||||
fileExists(path: string): boolean {
|
||||
return fso.FileExists(path);
|
||||
},
|
||||
directoryExists(path: string) {
|
||||
return fso.FolderExists(path);
|
||||
},
|
||||
createDirectory(directoryName: string) {
|
||||
if (!this.directoryExists(directoryName)) {
|
||||
fso.CreateFolder(directoryName);
|
||||
}
|
||||
},
|
||||
getExecutingFilePath() {
|
||||
return WScript.ScriptFullName;
|
||||
},
|
||||
getCurrentDirectory() {
|
||||
return new ActiveXObject("WScript.Shell").CurrentDirectory;
|
||||
},
|
||||
exit(exitCode?: number): void {
|
||||
try {
|
||||
WScript.Quit(exitCode);
|
||||
}
|
||||
catch (e) {
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
function getNodeSystem(): System {
|
||||
var _fs = require("fs");
|
||||
var _path = require("path");
|
||||
var _os = require('os');
|
||||
|
||||
var platform: string = _os.platform();
|
||||
// win32\win64 are case insensitive platforms, MacOS (darwin) by default is also case insensitive
|
||||
var useCaseSensitiveFileNames = platform !== "win32" && platform !== "win64" && platform !== "darwin";
|
||||
|
||||
function readFile(fileName: string, encoding?: string): string {
|
||||
if (!_fs.existsSync(fileName)) {
|
||||
return undefined;
|
||||
}
|
||||
var buffer = _fs.readFileSync(fileName);
|
||||
var len = buffer.length;
|
||||
if (len >= 2 && buffer[0] === 0xFE && buffer[1] === 0xFF) {
|
||||
// Big endian UTF-16 byte order mark detected. Since big endian is not supported by node.js,
|
||||
// flip all byte pairs and treat as little endian.
|
||||
len &= ~1;
|
||||
for (var i = 0; i < len; i += 2) {
|
||||
var temp = buffer[i];
|
||||
buffer[i] = buffer[i + 1];
|
||||
buffer[i + 1] = temp;
|
||||
}
|
||||
return buffer.toString("utf16le", 2);
|
||||
}
|
||||
if (len >= 2 && buffer[0] === 0xFF && buffer[1] === 0xFE) {
|
||||
// Little endian UTF-16 byte order mark detected
|
||||
return buffer.toString("utf16le", 2);
|
||||
}
|
||||
if (len >= 3 && buffer[0] === 0xEF && buffer[1] === 0xBB && buffer[2] === 0xBF) {
|
||||
// UTF-8 byte order mark detected
|
||||
return buffer.toString("utf8", 3);
|
||||
}
|
||||
// Default is UTF-8 with no byte order mark
|
||||
return buffer.toString("utf8");
|
||||
}
|
||||
|
||||
function writeFile(fileName: string, data: string, writeByteOrderMark?: boolean): void {
|
||||
// If a BOM is required, emit one
|
||||
if (writeByteOrderMark) {
|
||||
data = '\uFEFF' + data;
|
||||
}
|
||||
|
||||
_fs.writeFileSync(fileName, data, "utf8");
|
||||
}
|
||||
|
||||
return {
|
||||
args: process.argv.slice(2),
|
||||
newLine: _os.EOL,
|
||||
useCaseSensitiveFileNames: useCaseSensitiveFileNames,
|
||||
write(s: string): void {
|
||||
// 1 is a standard descriptor for stdout
|
||||
_fs.writeSync(1, s);
|
||||
},
|
||||
readFile,
|
||||
writeFile,
|
||||
watchFile: (fileName, callback) => {
|
||||
// watchFile polls a file every 250ms, picking up file notifications.
|
||||
_fs.watchFile(fileName, { persistent: true, interval: 250 }, fileChanged);
|
||||
|
||||
return {
|
||||
close() { _fs.unwatchFile(fileName, fileChanged); }
|
||||
};
|
||||
|
||||
function fileChanged(curr: any, prev: any) {
|
||||
if (+curr.mtime <= +prev.mtime) {
|
||||
return;
|
||||
}
|
||||
|
||||
callback(fileName);
|
||||
};
|
||||
},
|
||||
resolvePath: function (path: string): string {
|
||||
return _path.resolve(path);
|
||||
},
|
||||
fileExists(path: string): boolean {
|
||||
return _fs.existsSync(path);
|
||||
},
|
||||
directoryExists(path: string) {
|
||||
return _fs.existsSync(path) && _fs.statSync(path).isDirectory();
|
||||
},
|
||||
createDirectory(directoryName: string) {
|
||||
if (!this.directoryExists(directoryName)) {
|
||||
_fs.mkdirSync(directoryName);
|
||||
}
|
||||
},
|
||||
getExecutingFilePath() {
|
||||
return __filename;
|
||||
},
|
||||
getCurrentDirectory() {
|
||||
return process.cwd();
|
||||
},
|
||||
getMemoryUsage() {
|
||||
if (global.gc) {
|
||||
global.gc();
|
||||
}
|
||||
return process.memoryUsage().heapUsed;
|
||||
},
|
||||
exit(exitCode?: number): void {
|
||||
process.exit(exitCode);
|
||||
}
|
||||
};
|
||||
}
|
||||
if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") {
|
||||
return getWScriptSystem();
|
||||
}
|
||||
else if (typeof module !== "undefined" && module.exports) {
|
||||
return getNodeSystem();
|
||||
}
|
||||
else {
|
||||
return undefined; // Unsupported host
|
||||
}
|
||||
})();
|
||||
}
|
||||
+6
-75
@@ -133,75 +133,6 @@ module ts {
|
||||
reportStatisticalValue(name, (time / 1000).toFixed(2) + "s");
|
||||
}
|
||||
|
||||
function createCompilerHost(options: CompilerOptions): CompilerHost {
|
||||
var currentDirectory: string;
|
||||
var existingDirectories: Map<boolean> = {};
|
||||
|
||||
function getCanonicalFileName(fileName: string): string {
|
||||
// if underlying system can distinguish between two files whose names differs only in cases then file name already in canonical form.
|
||||
// otherwise use toLowerCase as a canonical form.
|
||||
return sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase();
|
||||
}
|
||||
|
||||
// returned by CScript sys environment
|
||||
var unsupportedFileEncodingErrorCode = -2147024809;
|
||||
|
||||
function getSourceFile(filename: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile {
|
||||
try {
|
||||
var text = sys.readFile(filename, options.charset);
|
||||
}
|
||||
catch (e) {
|
||||
if (onError) {
|
||||
onError(e.number === unsupportedFileEncodingErrorCode ?
|
||||
getDiagnosticText(Diagnostics.Unsupported_file_encoding) :
|
||||
e.message);
|
||||
}
|
||||
text = "";
|
||||
}
|
||||
return text !== undefined ? createSourceFile(filename, text, languageVersion) : undefined;
|
||||
}
|
||||
|
||||
function writeFile(fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void) {
|
||||
|
||||
function directoryExists(directoryPath: string): boolean {
|
||||
if (hasProperty(existingDirectories, directoryPath)) {
|
||||
return true;
|
||||
}
|
||||
if (sys.directoryExists(directoryPath)) {
|
||||
existingDirectories[directoryPath] = true;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function ensureDirectoriesExist(directoryPath: string) {
|
||||
if (directoryPath.length > getRootLength(directoryPath) && !directoryExists(directoryPath)) {
|
||||
var parentDirectory = getDirectoryPath(directoryPath);
|
||||
ensureDirectoriesExist(parentDirectory);
|
||||
sys.createDirectory(directoryPath);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
ensureDirectoriesExist(getDirectoryPath(normalizePath(fileName)));
|
||||
sys.writeFile(fileName, data, writeByteOrderMark);
|
||||
}
|
||||
catch (e) {
|
||||
if (onError) onError(e.message);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
getSourceFile,
|
||||
getDefaultLibFilename: options => combinePaths(getDirectoryPath(normalizePath(sys.getExecutingFilePath())), options.target === ScriptTarget.ES6 ? "lib.es6.d.ts" : "lib.d.ts"),
|
||||
writeFile,
|
||||
getCurrentDirectory: () => currentDirectory || (currentDirectory = sys.getCurrentDirectory()),
|
||||
useCaseSensitiveFileNames: () => sys.useCaseSensitiveFileNames,
|
||||
getCanonicalFileName,
|
||||
getNewLine: () => sys.newLine
|
||||
};
|
||||
}
|
||||
|
||||
export function executeCommandLine(args: string[]): void {
|
||||
var commandLine = parseCommandLine(args);
|
||||
var compilerOptions = commandLine.options;
|
||||
@@ -447,12 +378,12 @@ module ts {
|
||||
var usageText = " ";
|
||||
if (option.shortName) {
|
||||
usageText += "-" + option.shortName;
|
||||
usageText += getParamName(option);
|
||||
usageText += getParamType(option);
|
||||
usageText += ", ";
|
||||
}
|
||||
|
||||
usageText += "--" + option.name;
|
||||
usageText += getParamName(option);
|
||||
usageText += getParamType(option);
|
||||
|
||||
usageColumn.push(usageText);
|
||||
descriptionColumn.push(getDiagnosticText(option.description));
|
||||
@@ -477,9 +408,9 @@ module ts {
|
||||
sys.write(output);
|
||||
return;
|
||||
|
||||
function getParamName(option: CommandLineOption) {
|
||||
if (option.paramName !== undefined) {
|
||||
return " " + getDiagnosticText(option.paramName);
|
||||
function getParamType(option: CommandLineOption) {
|
||||
if (option.paramType !== undefined) {
|
||||
return " " + getDiagnosticText(option.paramType);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
@@ -490,4 +421,4 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
ts.executeCommandLine(sys.args);
|
||||
ts.executeCommandLine(ts.sys.args);
|
||||
|
||||
+13
-9
@@ -1,6 +1,9 @@
|
||||
/// <reference path="core.ts"/>
|
||||
|
||||
module ts {
|
||||
export interface Map<T> {
|
||||
[index: string]: T;
|
||||
}
|
||||
|
||||
export interface TextRange {
|
||||
pos: number;
|
||||
@@ -1403,6 +1406,7 @@ module ts {
|
||||
}
|
||||
|
||||
export interface CompilerOptions {
|
||||
allowNonTsExtensions?: boolean;
|
||||
charset?: string;
|
||||
codepage?: number;
|
||||
declaration?: boolean;
|
||||
@@ -1420,21 +1424,21 @@ module ts {
|
||||
noResolve?: boolean;
|
||||
out?: string;
|
||||
outDir?: string;
|
||||
preserveConstEnums?: boolean;
|
||||
removeComments?: boolean;
|
||||
sourceMap?: boolean;
|
||||
sourceRoot?: string;
|
||||
suppressImplicitAnyIndexErrors?: boolean;
|
||||
target?: ScriptTarget;
|
||||
version?: boolean;
|
||||
watch?: boolean;
|
||||
preserveConstEnums?: boolean;
|
||||
allowNonTsExtensions?: boolean;
|
||||
[option: string]: string | number | boolean;
|
||||
}
|
||||
|
||||
export const enum ModuleKind {
|
||||
None,
|
||||
CommonJS,
|
||||
AMD,
|
||||
None = 0,
|
||||
CommonJS = 1,
|
||||
AMD = 2,
|
||||
}
|
||||
|
||||
export interface LineAndCharacter {
|
||||
@@ -1446,9 +1450,9 @@ module ts {
|
||||
}
|
||||
|
||||
export const enum ScriptTarget {
|
||||
ES3,
|
||||
ES5,
|
||||
ES6,
|
||||
ES3 = 0,
|
||||
ES5 = 1,
|
||||
ES6 = 2,
|
||||
Latest = ES6,
|
||||
}
|
||||
|
||||
@@ -1463,7 +1467,7 @@ module ts {
|
||||
type: string | Map<number>; // "string", "number", "boolean", or an object literal mapping named values to actual values
|
||||
shortName?: string; // A short mnemonic for convenience - for instance, 'h' can be used in place of 'help'.
|
||||
description?: DiagnosticMessage; // The message describing what the command line switch does
|
||||
paramName?: DiagnosticMessage; // The name to be used for a non-boolean option's parameter.
|
||||
paramType?: DiagnosticMessage; // The name to be used for a non-boolean option's parameter.
|
||||
error?: DiagnosticMessage; // The error given when the argument does not fit a customized 'type'.
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,736 @@
|
||||
/// <reference path="types.ts" />
|
||||
|
||||
module ts {
|
||||
export interface ReferencePathMatchResult {
|
||||
fileReference?: FileReference
|
||||
diagnosticMessage?: DiagnosticMessage
|
||||
isNoDefaultLib?: boolean
|
||||
}
|
||||
|
||||
export function getDeclarationOfKind(symbol: Symbol, kind: SyntaxKind): Declaration {
|
||||
var declarations = symbol.declarations;
|
||||
for (var i = 0; i < declarations.length; i++) {
|
||||
var declaration = declarations[i];
|
||||
if (declaration.kind === kind) {
|
||||
return declaration;
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export interface StringSymbolWriter extends SymbolWriter {
|
||||
string(): string;
|
||||
}
|
||||
|
||||
// Pool writers to avoid needing to allocate them for every symbol we write.
|
||||
var stringWriters: StringSymbolWriter[] = [];
|
||||
export function getSingleLineStringWriter(): StringSymbolWriter {
|
||||
if (stringWriters.length == 0) {
|
||||
var str = "";
|
||||
|
||||
var writeText: (text: string) => void = text => str += text;
|
||||
return {
|
||||
string: () => str,
|
||||
writeKeyword: writeText,
|
||||
writeOperator: writeText,
|
||||
writePunctuation: writeText,
|
||||
writeSpace: writeText,
|
||||
writeStringLiteral: writeText,
|
||||
writeParameter: writeText,
|
||||
writeSymbol: writeText,
|
||||
|
||||
// Completely ignore indentation for string writers. And map newlines to
|
||||
// a single space.
|
||||
writeLine: () => str += " ",
|
||||
increaseIndent: () => { },
|
||||
decreaseIndent: () => { },
|
||||
clear: () => str = "",
|
||||
trackSymbol: () => { }
|
||||
};
|
||||
}
|
||||
|
||||
return stringWriters.pop();
|
||||
}
|
||||
|
||||
export function releaseStringWriter(writer: StringSymbolWriter) {
|
||||
writer.clear()
|
||||
stringWriters.push(writer);
|
||||
}
|
||||
|
||||
export function getFullWidth(node: Node) {
|
||||
return node.end - node.pos;
|
||||
}
|
||||
|
||||
export function hasFlag(val: number, flag: number): boolean {
|
||||
return (val & flag) !== 0;
|
||||
}
|
||||
|
||||
// Returns true if this node contains a parse error anywhere underneath it.
|
||||
export function containsParseError(node: Node): boolean {
|
||||
if (!hasFlag(node.parserContextFlags, ParserContextFlags.HasPropagatedChildContainsErrorFlag)) {
|
||||
// A node is considered to contain a parse error if:
|
||||
// a) the parser explicitly marked that it had an error
|
||||
// b) any of it's children reported that it had an error.
|
||||
var val = hasFlag(node.parserContextFlags, ParserContextFlags.ContainsError) ||
|
||||
forEachChild(node, containsParseError);
|
||||
|
||||
// If so, mark ourselves accordingly.
|
||||
if (val) {
|
||||
node.parserContextFlags |= ParserContextFlags.ContainsError;
|
||||
}
|
||||
|
||||
// Also mark that we've propogated the child information to this node. This way we can
|
||||
// always consult the bit directly on this node without needing to check its children
|
||||
// again.
|
||||
node.parserContextFlags |= ParserContextFlags.HasPropagatedChildContainsErrorFlag;
|
||||
}
|
||||
|
||||
return hasFlag(node.parserContextFlags, ParserContextFlags.ContainsError);
|
||||
}
|
||||
|
||||
export function getSourceFileOfNode(node: Node): SourceFile {
|
||||
while (node && node.kind !== SyntaxKind.SourceFile) {
|
||||
node = node.parent;
|
||||
}
|
||||
return <SourceFile>node;
|
||||
}
|
||||
|
||||
// This is a useful function for debugging purposes.
|
||||
export function nodePosToString(node: Node): string {
|
||||
var file = getSourceFileOfNode(node);
|
||||
var loc = file.getLineAndCharacterFromPosition(node.pos);
|
||||
return file.filename + "(" + loc.line + "," + loc.character + ")";
|
||||
}
|
||||
|
||||
export function getStartPosOfNode(node: Node): number {
|
||||
return node.pos;
|
||||
}
|
||||
|
||||
export function isMissingNode(node: Node) {
|
||||
if (!node) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return node.pos === node.end && node.kind !== SyntaxKind.EndOfFileToken;
|
||||
}
|
||||
|
||||
export function getTokenPosOfNode(node: Node, sourceFile?: SourceFile): number {
|
||||
// With nodes that have no width (i.e. 'Missing' nodes), we actually *don't*
|
||||
// want to skip trivia because this will launch us forward to the next token.
|
||||
if (isMissingNode(node)) {
|
||||
return node.pos;
|
||||
}
|
||||
|
||||
return skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos);
|
||||
}
|
||||
|
||||
export function getSourceTextOfNodeFromSourceFile(sourceFile: SourceFile, node: Node): string {
|
||||
if (isMissingNode(node)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
var text = sourceFile.text;
|
||||
return text.substring(skipTrivia(text, node.pos), node.end);
|
||||
}
|
||||
|
||||
export function getTextOfNodeFromSourceText(sourceText: string, node: Node): string {
|
||||
if (isMissingNode(node)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return sourceText.substring(skipTrivia(sourceText, node.pos), node.end);
|
||||
}
|
||||
|
||||
export function getTextOfNode(node: Node): string {
|
||||
return getSourceTextOfNodeFromSourceFile(getSourceFileOfNode(node), node);
|
||||
}
|
||||
|
||||
// Add an extra underscore to identifiers that start with two underscores to avoid issues with magic names like '__proto__'
|
||||
export function escapeIdentifier(identifier: string): string {
|
||||
return identifier.length >= 2 && identifier.charCodeAt(0) === CharacterCodes._ && identifier.charCodeAt(1) === CharacterCodes._ ? "_" + identifier : identifier;
|
||||
}
|
||||
|
||||
// Remove extra underscore from escaped identifier
|
||||
export function unescapeIdentifier(identifier: string): string {
|
||||
return identifier.length >= 3 && identifier.charCodeAt(0) === CharacterCodes._ && identifier.charCodeAt(1) === CharacterCodes._ && identifier.charCodeAt(2) === CharacterCodes._ ? identifier.substr(1) : identifier;
|
||||
}
|
||||
|
||||
// Return display name of an identifier
|
||||
// Computed property names will just be emitted as "[<expr>]", where <expr> is the source
|
||||
// text of the expression in the computed property.
|
||||
export function declarationNameToString(name: DeclarationName) {
|
||||
return getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name);
|
||||
}
|
||||
|
||||
export function createDiagnosticForNode(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): Diagnostic {
|
||||
node = getErrorSpanForNode(node);
|
||||
var file = getSourceFileOfNode(node);
|
||||
|
||||
var start = getTokenPosOfNode(node, file);
|
||||
var length = node.end - start;
|
||||
|
||||
return createFileDiagnostic(file, start, length, message, arg0, arg1, arg2);
|
||||
}
|
||||
|
||||
export function createDiagnosticForNodeFromMessageChain(node: Node, messageChain: DiagnosticMessageChain, newLine: string): Diagnostic {
|
||||
node = getErrorSpanForNode(node);
|
||||
var file = getSourceFileOfNode(node);
|
||||
var start = skipTrivia(file.text, node.pos);
|
||||
var length = node.end - start;
|
||||
return flattenDiagnosticChain(file, start, length, messageChain, newLine);
|
||||
}
|
||||
|
||||
export function getErrorSpanForNode(node: Node): Node {
|
||||
var errorSpan: Node;
|
||||
switch (node.kind) {
|
||||
// This list is a work in progress. Add missing node kinds to improve their error
|
||||
// spans.
|
||||
case SyntaxKind.VariableDeclaration:
|
||||
case SyntaxKind.BindingElement:
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
case SyntaxKind.InterfaceDeclaration:
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
case SyntaxKind.EnumMember:
|
||||
errorSpan = (<Declaration>node).name;
|
||||
break;
|
||||
}
|
||||
|
||||
// We now have the ideal error span, but it may be a node that is optional and absent
|
||||
// (e.g. the name of a function expression), in which case errorSpan will be undefined.
|
||||
// Alternatively, it might be required and missing (e.g. the name of a module), in which
|
||||
// case its pos will equal its end (length 0). In either of these cases, we should fall
|
||||
// back to the original node that the error was issued on.
|
||||
return errorSpan && errorSpan.pos < errorSpan.end ? errorSpan : node;
|
||||
}
|
||||
|
||||
export function isExternalModule(file: SourceFile): boolean {
|
||||
return file.externalModuleIndicator !== undefined;
|
||||
}
|
||||
|
||||
export function isDeclarationFile(file: SourceFile): boolean {
|
||||
return (file.flags & NodeFlags.DeclarationFile) !== 0;
|
||||
}
|
||||
|
||||
export function isConstEnumDeclaration(node: Node): boolean {
|
||||
return node.kind === SyntaxKind.EnumDeclaration && isConst(node);
|
||||
}
|
||||
|
||||
export function isConst(node: Node): boolean {
|
||||
return !!(node.flags & NodeFlags.Const);
|
||||
}
|
||||
|
||||
export function isLet(node: Node): boolean {
|
||||
return !!(node.flags & NodeFlags.Let);
|
||||
}
|
||||
|
||||
export function isPrologueDirective(node: Node): boolean {
|
||||
return node.kind === SyntaxKind.ExpressionStatement && (<ExpressionStatement>node).expression.kind === SyntaxKind.StringLiteral;
|
||||
}
|
||||
|
||||
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(getTrailingCommentRanges(sourceFileOfNode.text, node.pos),
|
||||
// e.g.: (
|
||||
// /** blah */ a,
|
||||
// /** blah */ b);
|
||||
getLeadingCommentRanges(sourceFileOfNode.text, node.pos));
|
||||
}
|
||||
else {
|
||||
return getLeadingCommentRanges(sourceFileOfNode.text, node.pos);
|
||||
}
|
||||
}
|
||||
|
||||
export function getJsDocComments(node: Node, sourceFileOfNode: SourceFile) {
|
||||
return filter(getLeadingCommentRangesOfNode(node, sourceFileOfNode), isJsDocComment);
|
||||
|
||||
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 &&
|
||||
sourceFileOfNode.text.charCodeAt(comment.pos + 3) !== CharacterCodes.slash;
|
||||
}
|
||||
}
|
||||
|
||||
export var fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*<reference\s+path\s*=\s*)('|")(.+?)\2.*?\/>/
|
||||
|
||||
|
||||
// Warning: This has the same semantics as the forEach family of functions,
|
||||
// in that traversal terminates in the event that 'visitor' supplies a truthy value.
|
||||
export function forEachReturnStatement<T>(body: Block, visitor: (stmt: ReturnStatement) => T): T {
|
||||
|
||||
return traverse(body);
|
||||
|
||||
function traverse(node: Node): T {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.ReturnStatement:
|
||||
return visitor(<ReturnStatement>node);
|
||||
case SyntaxKind.Block:
|
||||
case SyntaxKind.IfStatement:
|
||||
case SyntaxKind.DoStatement:
|
||||
case SyntaxKind.WhileStatement:
|
||||
case SyntaxKind.ForStatement:
|
||||
case SyntaxKind.ForInStatement:
|
||||
case SyntaxKind.WithStatement:
|
||||
case SyntaxKind.SwitchStatement:
|
||||
case SyntaxKind.CaseClause:
|
||||
case SyntaxKind.DefaultClause:
|
||||
case SyntaxKind.LabeledStatement:
|
||||
case SyntaxKind.TryStatement:
|
||||
case SyntaxKind.CatchClause:
|
||||
return forEachChild(node, traverse);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function isAnyFunction(node: Node): boolean {
|
||||
if (node) {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.Constructor:
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.ArrowFunction:
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.MethodSignature:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
case SyntaxKind.CallSignature:
|
||||
case SyntaxKind.ConstructSignature:
|
||||
case SyntaxKind.IndexSignature:
|
||||
case SyntaxKind.FunctionType:
|
||||
case SyntaxKind.ConstructorType:
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.ArrowFunction:
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
export function isFunctionBlock(node: Node) {
|
||||
return node && node.kind === SyntaxKind.Block && isAnyFunction(node.parent);
|
||||
}
|
||||
|
||||
export function isObjectLiteralMethod(node: Node) {
|
||||
return node && node.kind === SyntaxKind.MethodDeclaration && node.parent.kind === SyntaxKind.ObjectLiteralExpression;
|
||||
}
|
||||
|
||||
export function getContainingFunction(node: Node): FunctionLikeDeclaration {
|
||||
while (true) {
|
||||
node = node.parent;
|
||||
if (!node || isAnyFunction(node)) {
|
||||
return <FunctionLikeDeclaration>node;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function getThisContainer(node: Node, includeArrowFunctions: boolean): Node {
|
||||
while (true) {
|
||||
node = node.parent;
|
||||
if (!node) {
|
||||
return undefined;
|
||||
}
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.ArrowFunction:
|
||||
if (!includeArrowFunctions) {
|
||||
continue;
|
||||
}
|
||||
// Fall through
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
case SyntaxKind.PropertySignature:
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.MethodSignature:
|
||||
case SyntaxKind.Constructor:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
case SyntaxKind.SourceFile:
|
||||
return node;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function getSuperContainer(node: Node): Node {
|
||||
while (true) {
|
||||
node = node.parent;
|
||||
if (!node) {
|
||||
return undefined;
|
||||
}
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
case SyntaxKind.PropertySignature:
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.MethodSignature:
|
||||
case SyntaxKind.Constructor:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
return node;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function getInvokedExpression(node: CallLikeExpression): Expression {
|
||||
if (node.kind === SyntaxKind.TaggedTemplateExpression) {
|
||||
return (<TaggedTemplateExpression>node).tag;
|
||||
}
|
||||
|
||||
// Will either be a CallExpression or NewExpression.
|
||||
return (<CallExpression>node).expression;
|
||||
}
|
||||
|
||||
export function isExpression(node: Node): boolean {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.ThisKeyword:
|
||||
case SyntaxKind.SuperKeyword:
|
||||
case SyntaxKind.NullKeyword:
|
||||
case SyntaxKind.TrueKeyword:
|
||||
case SyntaxKind.FalseKeyword:
|
||||
case SyntaxKind.RegularExpressionLiteral:
|
||||
case SyntaxKind.ArrayLiteralExpression:
|
||||
case SyntaxKind.ObjectLiteralExpression:
|
||||
case SyntaxKind.PropertyAccessExpression:
|
||||
case SyntaxKind.ElementAccessExpression:
|
||||
case SyntaxKind.CallExpression:
|
||||
case SyntaxKind.NewExpression:
|
||||
case SyntaxKind.TaggedTemplateExpression:
|
||||
case SyntaxKind.TypeAssertionExpression:
|
||||
case SyntaxKind.ParenthesizedExpression:
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.ArrowFunction:
|
||||
case SyntaxKind.VoidExpression:
|
||||
case SyntaxKind.DeleteExpression:
|
||||
case SyntaxKind.TypeOfExpression:
|
||||
case SyntaxKind.PrefixUnaryExpression:
|
||||
case SyntaxKind.PostfixUnaryExpression:
|
||||
case SyntaxKind.BinaryExpression:
|
||||
case SyntaxKind.ConditionalExpression:
|
||||
case SyntaxKind.TemplateExpression:
|
||||
case SyntaxKind.NoSubstitutionTemplateLiteral:
|
||||
case SyntaxKind.OmittedExpression:
|
||||
return true;
|
||||
case SyntaxKind.QualifiedName:
|
||||
while (node.parent.kind === SyntaxKind.QualifiedName) {
|
||||
node = node.parent;
|
||||
}
|
||||
|
||||
return node.parent.kind === SyntaxKind.TypeQuery;
|
||||
case SyntaxKind.Identifier:
|
||||
if (node.parent.kind === SyntaxKind.TypeQuery) {
|
||||
return true;
|
||||
}
|
||||
// fall through
|
||||
case SyntaxKind.NumericLiteral:
|
||||
case SyntaxKind.StringLiteral:
|
||||
var parent = node.parent;
|
||||
switch (parent.kind) {
|
||||
case SyntaxKind.VariableDeclaration:
|
||||
case SyntaxKind.Parameter:
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
case SyntaxKind.PropertySignature:
|
||||
case SyntaxKind.EnumMember:
|
||||
case SyntaxKind.PropertyAssignment:
|
||||
case SyntaxKind.BindingElement:
|
||||
return (<VariableLikeDeclaration>parent).initializer === node;
|
||||
case SyntaxKind.ExpressionStatement:
|
||||
case SyntaxKind.IfStatement:
|
||||
case SyntaxKind.DoStatement:
|
||||
case SyntaxKind.WhileStatement:
|
||||
case SyntaxKind.ReturnStatement:
|
||||
case SyntaxKind.WithStatement:
|
||||
case SyntaxKind.SwitchStatement:
|
||||
case SyntaxKind.CaseClause:
|
||||
case SyntaxKind.ThrowStatement:
|
||||
case SyntaxKind.SwitchStatement:
|
||||
return (<ExpressionStatement>parent).expression === node;
|
||||
case SyntaxKind.ForStatement:
|
||||
return (<ForStatement>parent).initializer === node ||
|
||||
(<ForStatement>parent).condition === node ||
|
||||
(<ForStatement>parent).iterator === node;
|
||||
case SyntaxKind.ForInStatement:
|
||||
return (<ForInStatement>parent).variable === node ||
|
||||
(<ForInStatement>parent).expression === node;
|
||||
case SyntaxKind.TypeAssertionExpression:
|
||||
return node === (<TypeAssertion>parent).expression;
|
||||
case SyntaxKind.TemplateSpan:
|
||||
return node === (<TemplateSpan>parent).expression;
|
||||
default:
|
||||
if (isExpression(parent)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export function isExternalModuleImportDeclaration(node: Node) {
|
||||
return node.kind === SyntaxKind.ImportDeclaration && (<ImportDeclaration>node).moduleReference.kind === SyntaxKind.ExternalModuleReference;
|
||||
}
|
||||
|
||||
export function getExternalModuleImportDeclarationExpression(node: Node) {
|
||||
Debug.assert(isExternalModuleImportDeclaration(node));
|
||||
return (<ExternalModuleReference>(<ImportDeclaration>node).moduleReference).expression;
|
||||
}
|
||||
|
||||
export function isInternalModuleImportDeclaration(node: Node) {
|
||||
return node.kind === SyntaxKind.ImportDeclaration && (<ImportDeclaration>node).moduleReference.kind !== SyntaxKind.ExternalModuleReference;
|
||||
}
|
||||
|
||||
export function hasDotDotDotToken(node: Node) {
|
||||
return node && node.kind === SyntaxKind.Parameter && (<ParameterDeclaration>node).dotDotDotToken !== undefined;
|
||||
}
|
||||
|
||||
export function hasQuestionToken(node: Node) {
|
||||
if (node) {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.Parameter:
|
||||
return (<ParameterDeclaration>node).questionToken !== undefined;
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.MethodSignature:
|
||||
return (<MethodDeclaration>node).questionToken !== undefined;
|
||||
case SyntaxKind.ShorthandPropertyAssignment:
|
||||
case SyntaxKind.PropertyAssignment:
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
case SyntaxKind.PropertySignature:
|
||||
return (<PropertyDeclaration>node).questionToken !== undefined;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
export function hasRestParameters(s: SignatureDeclaration): boolean {
|
||||
return s.parameters.length > 0 && s.parameters[s.parameters.length - 1].dotDotDotToken !== undefined;
|
||||
}
|
||||
|
||||
export function isLiteralKind(kind: SyntaxKind): boolean {
|
||||
return SyntaxKind.FirstLiteralToken <= kind && kind <= SyntaxKind.LastLiteralToken;
|
||||
}
|
||||
|
||||
export function isTextualLiteralKind(kind: SyntaxKind): boolean {
|
||||
return kind === SyntaxKind.StringLiteral || kind === SyntaxKind.NoSubstitutionTemplateLiteral;
|
||||
}
|
||||
|
||||
export function isTemplateLiteralKind(kind: SyntaxKind): boolean {
|
||||
return SyntaxKind.FirstTemplateToken <= kind && kind <= SyntaxKind.LastTemplateToken;
|
||||
}
|
||||
|
||||
export function isBindingPattern(node: Node) {
|
||||
return node.kind === SyntaxKind.ArrayBindingPattern || node.kind === SyntaxKind.ObjectBindingPattern;
|
||||
}
|
||||
|
||||
export function isInAmbientContext(node: Node): boolean {
|
||||
while (node) {
|
||||
if (node.flags & (NodeFlags.Ambient | NodeFlags.DeclarationFile)) return true;
|
||||
node = node.parent;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export function isDeclaration(node: Node): boolean {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.TypeParameter:
|
||||
case SyntaxKind.Parameter:
|
||||
case SyntaxKind.VariableDeclaration:
|
||||
case SyntaxKind.BindingElement:
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
case SyntaxKind.PropertySignature:
|
||||
case SyntaxKind.PropertyAssignment:
|
||||
case SyntaxKind.ShorthandPropertyAssignment:
|
||||
case SyntaxKind.EnumMember:
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.MethodSignature:
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
case SyntaxKind.Constructor:
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
case SyntaxKind.InterfaceDeclaration:
|
||||
case SyntaxKind.TypeAliasDeclaration:
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
case SyntaxKind.ImportDeclaration:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export function isStatement(n: Node): boolean {
|
||||
switch (n.kind) {
|
||||
case SyntaxKind.BreakStatement:
|
||||
case SyntaxKind.ContinueStatement:
|
||||
case SyntaxKind.DebuggerStatement:
|
||||
case SyntaxKind.DoStatement:
|
||||
case SyntaxKind.ExpressionStatement:
|
||||
case SyntaxKind.EmptyStatement:
|
||||
case SyntaxKind.ForInStatement:
|
||||
case SyntaxKind.ForStatement:
|
||||
case SyntaxKind.IfStatement:
|
||||
case SyntaxKind.LabeledStatement:
|
||||
case SyntaxKind.ReturnStatement:
|
||||
case SyntaxKind.SwitchStatement:
|
||||
case SyntaxKind.ThrowKeyword:
|
||||
case SyntaxKind.TryStatement:
|
||||
case SyntaxKind.VariableStatement:
|
||||
case SyntaxKind.WhileStatement:
|
||||
case SyntaxKind.WithStatement:
|
||||
case SyntaxKind.ExportAssignment:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// True if the given identifier, string literal, or number literal is the name of a declaration node
|
||||
export function isDeclarationOrFunctionExpressionOrCatchVariableName(name: Node): boolean {
|
||||
if (name.kind !== SyntaxKind.Identifier && name.kind !== SyntaxKind.StringLiteral && name.kind !== SyntaxKind.NumericLiteral) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var parent = name.parent;
|
||||
if (isDeclaration(parent) || parent.kind === SyntaxKind.FunctionExpression) {
|
||||
return (<Declaration>parent).name === name;
|
||||
}
|
||||
|
||||
if (parent.kind === SyntaxKind.CatchClause) {
|
||||
return (<CatchClause>parent).name === name;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
export function getClassBaseTypeNode(node: ClassDeclaration) {
|
||||
var heritageClause = getHeritageClause(node.heritageClauses, SyntaxKind.ExtendsKeyword);
|
||||
return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined;
|
||||
}
|
||||
|
||||
export function getClassImplementedTypeNodes(node: ClassDeclaration) {
|
||||
var heritageClause = getHeritageClause(node.heritageClauses, SyntaxKind.ImplementsKeyword);
|
||||
return heritageClause ? heritageClause.types : undefined;
|
||||
}
|
||||
|
||||
export function getInterfaceBaseTypeNodes(node: InterfaceDeclaration) {
|
||||
var heritageClause = getHeritageClause(node.heritageClauses, SyntaxKind.ExtendsKeyword);
|
||||
return heritageClause ? heritageClause.types : undefined;
|
||||
}
|
||||
|
||||
export function getHeritageClause(clauses: NodeArray<HeritageClause>, kind: SyntaxKind) {
|
||||
if (clauses) {
|
||||
for (var i = 0, n = clauses.length; i < n; i++) {
|
||||
if (clauses[i].token === kind) {
|
||||
return clauses[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function tryResolveScriptReference(program: Program, sourceFile: SourceFile, reference: FileReference) {
|
||||
if (!program.getCompilerOptions().noResolve) {
|
||||
var referenceFileName = isRootedDiskPath(reference.filename) ? reference.filename : combinePaths(getDirectoryPath(sourceFile.filename), reference.filename);
|
||||
referenceFileName = getNormalizedAbsolutePath(referenceFileName, program.getCompilerHost().getCurrentDirectory());
|
||||
return program.getSourceFile(referenceFileName);
|
||||
}
|
||||
}
|
||||
|
||||
export function getAncestor(node: Node, kind: SyntaxKind): Node {
|
||||
switch (kind) {
|
||||
// special-cases that can be come first
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
while (node) {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
return <ClassDeclaration>node;
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
case SyntaxKind.InterfaceDeclaration:
|
||||
case SyntaxKind.TypeAliasDeclaration:
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
case SyntaxKind.ImportDeclaration:
|
||||
// early exit cases - declarations cannot be nested in classes
|
||||
return undefined;
|
||||
default:
|
||||
node = node.parent;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
while (node) {
|
||||
if (node.kind === kind) {
|
||||
return node;
|
||||
}
|
||||
node = node.parent;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function getFileReferenceFromReferencePath(comment: string, commentRange: CommentRange): ReferencePathMatchResult {
|
||||
var simpleReferenceRegEx = /^\/\/\/\s*<reference\s+/gim;
|
||||
var isNoDefaultLibRegEx = /^(\/\/\/\s*<reference\s+no-default-lib\s*=\s*)('|")(.+?)\2\s*\/>/gim;
|
||||
if (simpleReferenceRegEx.exec(comment)) {
|
||||
if (isNoDefaultLibRegEx.exec(comment)) {
|
||||
return {
|
||||
isNoDefaultLib: true
|
||||
}
|
||||
}
|
||||
else {
|
||||
var matchResult = fullTripleSlashReferencePathRegEx.exec(comment);
|
||||
if (matchResult) {
|
||||
var start = commentRange.pos;
|
||||
var end = commentRange.end;
|
||||
return {
|
||||
fileReference: {
|
||||
pos: start,
|
||||
end: end,
|
||||
filename: matchResult[3]
|
||||
},
|
||||
isNoDefaultLib: false
|
||||
};
|
||||
}
|
||||
else {
|
||||
return {
|
||||
diagnosticMessage: Diagnostics.Invalid_reference_directive_syntax,
|
||||
isNoDefaultLib: false
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function isKeyword(token: SyntaxKind): boolean {
|
||||
return SyntaxKind.FirstKeyword <= token && token <= SyntaxKind.LastKeyword;
|
||||
}
|
||||
|
||||
export function isTrivia(token: SyntaxKind) {
|
||||
return SyntaxKind.FirstTriviaToken <= token && token <= SyntaxKind.LastTriviaToken;
|
||||
}
|
||||
|
||||
export function isModifier(token: SyntaxKind): boolean {
|
||||
switch (token) {
|
||||
case SyntaxKind.PublicKeyword:
|
||||
case SyntaxKind.PrivateKeyword:
|
||||
case SyntaxKind.ProtectedKeyword:
|
||||
case SyntaxKind.StaticKeyword:
|
||||
case SyntaxKind.ExportKeyword:
|
||||
case SyntaxKind.DeclareKeyword:
|
||||
case SyntaxKind.ConstKeyword:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
+20
-19
@@ -145,14 +145,14 @@ module FourSlash {
|
||||
testOptMetadataNames.mapRoot, testOptMetadataNames.module, testOptMetadataNames.out,
|
||||
testOptMetadataNames.outDir, testOptMetadataNames.sourceMap, testOptMetadataNames.sourceRoot]
|
||||
|
||||
function convertGlobalOptionsToCompilationSettings(globalOptions: { [idx: string]: string }): ts.CompilationSettings {
|
||||
var settings: ts.CompilationSettings = {};
|
||||
function convertGlobalOptionsToCompilerOptions(globalOptions: { [idx: string]: string }): ts.CompilerOptions {
|
||||
var settings: ts.CompilerOptions = {};
|
||||
// Convert all property in globalOptions into ts.CompilationSettings
|
||||
for (var prop in globalOptions) {
|
||||
if (globalOptions.hasOwnProperty(prop)) {
|
||||
switch (prop) {
|
||||
case testOptMetadataNames.declaration:
|
||||
settings.generateDeclarationFiles = true;
|
||||
settings.declaration = true;
|
||||
break;
|
||||
case testOptMetadataNames.mapRoot:
|
||||
settings.mapRoot = globalOptions[prop];
|
||||
@@ -161,24 +161,25 @@ module FourSlash {
|
||||
// create appropriate external module target for CompilationSettings
|
||||
switch (globalOptions[prop]) {
|
||||
case "AMD":
|
||||
settings.moduleGenTarget = ts.ModuleGenTarget.Asynchronous;
|
||||
settings.module = ts.ModuleKind.AMD;
|
||||
break;
|
||||
case "CommonJS":
|
||||
settings.moduleGenTarget = ts.ModuleGenTarget.Synchronous;
|
||||
settings.module = ts.ModuleKind.CommonJS;
|
||||
break;
|
||||
default:
|
||||
settings.moduleGenTarget = ts.ModuleGenTarget.Unspecified;
|
||||
ts.Debug.assert(globalOptions[prop] === undefined || globalOptions[prop] === "None");
|
||||
settings.module = ts.ModuleKind.None;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case testOptMetadataNames.out:
|
||||
settings.outFileOption = globalOptions[prop];
|
||||
settings.out = globalOptions[prop];
|
||||
break;
|
||||
case testOptMetadataNames.outDir:
|
||||
settings.outDirOption = globalOptions[prop];
|
||||
settings.outDir = globalOptions[prop];
|
||||
break;
|
||||
case testOptMetadataNames.sourceMap:
|
||||
settings.mapSourceFiles = true;
|
||||
settings.sourceMap = true;
|
||||
break;
|
||||
case testOptMetadataNames.sourceRoot:
|
||||
settings.sourceRoot = globalOptions[prop];
|
||||
@@ -300,7 +301,7 @@ module FourSlash {
|
||||
this.cancellationToken = new TestCancellationToken();
|
||||
this.languageServiceShimHost = new Harness.LanguageService.TypeScriptLS(this.cancellationToken);
|
||||
|
||||
var compilationSettings = convertGlobalOptionsToCompilationSettings(this.testData.globalOptions);
|
||||
var compilationSettings = convertGlobalOptionsToCompilerOptions(this.testData.globalOptions);
|
||||
this.languageServiceShimHost.setCompilationSettings(compilationSettings);
|
||||
|
||||
var startResolveFileRef: FourSlashFile = undefined;
|
||||
@@ -363,7 +364,7 @@ module FourSlash {
|
||||
this.formatCodeOptions = {
|
||||
IndentSize: 4,
|
||||
TabSize: 4,
|
||||
NewLineCharacter: sys.newLine,
|
||||
NewLineCharacter: ts.sys.newLine,
|
||||
ConvertTabsToSpaces: true,
|
||||
InsertSpaceAfterCommaDelimiter: true,
|
||||
InsertSpaceAfterSemicolonInForStatements: true,
|
||||
@@ -750,11 +751,11 @@ module FourSlash {
|
||||
}
|
||||
|
||||
private getMemberListAtCaret() {
|
||||
return this.languageService.getCompletionsAtPosition(this.activeFile.fileName, this.currentCaretPosition, true);
|
||||
return this.languageService.getCompletionsAtPosition(this.activeFile.fileName, this.currentCaretPosition);
|
||||
}
|
||||
|
||||
private getCompletionListAtCaret() {
|
||||
return this.languageService.getCompletionsAtPosition(this.activeFile.fileName, this.currentCaretPosition, false);
|
||||
return this.languageService.getCompletionsAtPosition(this.activeFile.fileName, this.currentCaretPosition);
|
||||
}
|
||||
|
||||
private getCompletionEntryDetails(entryName: string) {
|
||||
@@ -1364,7 +1365,7 @@ module FourSlash {
|
||||
this.languageService.getSignatureHelpItems(this.activeFile.fileName, offset);
|
||||
} else if (prevChar === ' ' && /A-Za-z_/.test(ch)) {
|
||||
/* Completions */
|
||||
this.languageService.getCompletionsAtPosition(this.activeFile.fileName, offset, false);
|
||||
this.languageService.getCompletionsAtPosition(this.activeFile.fileName, offset);
|
||||
}
|
||||
|
||||
if (i % errorCadence === 0) {
|
||||
@@ -1747,9 +1748,9 @@ module FourSlash {
|
||||
}
|
||||
|
||||
function jsonMismatchString() {
|
||||
return sys.newLine +
|
||||
"expected: '" + sys.newLine + JSON.stringify(expected, (k,v) => v, 2) + "'" + sys.newLine +
|
||||
"actual: '" + sys.newLine + JSON.stringify(actual, (k, v) => v, 2) + "'";
|
||||
return ts.sys.newLine +
|
||||
"expected: '" + ts.sys.newLine + JSON.stringify(expected, (k,v) => v, 2) + "'" + ts.sys.newLine +
|
||||
"actual: '" + ts.sys.newLine + JSON.stringify(actual, (k, v) => v, 2) + "'";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2246,9 +2247,9 @@ module FourSlash {
|
||||
{ unitName: fileName, content: content }],
|
||||
(fn, contents) => result = contents,
|
||||
ts.ScriptTarget.Latest,
|
||||
sys.useCaseSensitiveFileNames);
|
||||
ts.sys.useCaseSensitiveFileNames);
|
||||
// TODO (drosen): We need to enforce checking on these tests.
|
||||
var program = ts.createProgram([Harness.Compiler.fourslashFilename, fileName], { out: "fourslashTestOutput.js", noResolve: true }, host);
|
||||
var program = ts.createProgram([Harness.Compiler.fourslashFilename, fileName], { out: "fourslashTestOutput.js", noResolve: true, target: ts.ScriptTarget.ES3 }, host);
|
||||
var checker = ts.createTypeChecker(program, /*fullTypeCheckMode*/ true);
|
||||
|
||||
var errors = program.getDiagnostics().concat(checker.getDiagnostics());
|
||||
|
||||
+30
-18
@@ -22,10 +22,13 @@
|
||||
/// <reference path='external\chai.d.ts'/>
|
||||
/// <reference path='sourceMapRecorder.ts'/>
|
||||
|
||||
declare var require: any;
|
||||
declare var process: any;
|
||||
|
||||
// this will work in the browser via browserify
|
||||
var _chai: typeof chai = require('chai');
|
||||
var assert: typeof _chai.assert = _chai.assert;
|
||||
declare var __dirname: any; // Node-specific
|
||||
declare var __dirname: string; // Node-specific
|
||||
var global = <any>Function("return this").call(null);
|
||||
|
||||
module Utils {
|
||||
@@ -41,7 +44,7 @@ module Utils {
|
||||
export function getExecutionEnvironment() {
|
||||
if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") {
|
||||
return ExecutionEnvironment.CScript;
|
||||
} else if (process && (<any>process).execPath && (<any>process).execPath.indexOf("node") !== -1) {
|
||||
} else if (process && process.execPath && process.execPath.indexOf("node") !== -1) {
|
||||
return ExecutionEnvironment.Node;
|
||||
} else {
|
||||
return ExecutionEnvironment.Browser;
|
||||
@@ -93,7 +96,7 @@ module Utils {
|
||||
}
|
||||
|
||||
try {
|
||||
var content = sys.readFile(Harness.userSpecifiedroot + path);
|
||||
var content = ts.sys.readFile(Harness.userSpecifiedroot + path);
|
||||
}
|
||||
catch (err) {
|
||||
return undefined;
|
||||
@@ -217,8 +220,8 @@ module Harness {
|
||||
fso = {};
|
||||
}
|
||||
|
||||
export var readFile: typeof IO.readFile = sys.readFile;
|
||||
export var writeFile: typeof IO.writeFile = sys.writeFile;
|
||||
export var readFile: typeof IO.readFile = ts.sys.readFile;
|
||||
export var writeFile: typeof IO.writeFile = ts.sys.writeFile;
|
||||
export var directoryName: typeof IO.directoryName = fso.GetParentFolderName;
|
||||
export var directoryExists: typeof IO.directoryExists = fso.FolderExists;
|
||||
export var fileExists: typeof IO.fileExists = fso.FileExists;
|
||||
@@ -279,8 +282,8 @@ module Harness {
|
||||
fs = pathModule = {};
|
||||
}
|
||||
|
||||
export var readFile: typeof IO.readFile = sys.readFile;
|
||||
export var writeFile: typeof IO.writeFile = sys.writeFile;
|
||||
export var readFile: typeof IO.readFile = ts.sys.readFile;
|
||||
export var writeFile: typeof IO.writeFile = ts.sys.writeFile;
|
||||
export var fileExists: typeof IO.fileExists = fs.existsSync;
|
||||
export var log: typeof IO.log = console.log;
|
||||
|
||||
@@ -608,7 +611,7 @@ module Harness {
|
||||
export var fourslashSourceFile: ts.SourceFile;
|
||||
|
||||
export function getCanonicalFileName(fileName: string): string {
|
||||
return sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase();
|
||||
return ts.sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase();
|
||||
}
|
||||
|
||||
export function createCompilerHost(inputFiles: { unitName: string; content: string; }[],
|
||||
@@ -632,8 +635,7 @@ module Harness {
|
||||
inputFiles.forEach(register);
|
||||
|
||||
return {
|
||||
getCurrentDirectory: sys.getCurrentDirectory,
|
||||
getCancellationToken: (): any => undefined,
|
||||
getCurrentDirectory: ts.sys.getCurrentDirectory,
|
||||
getSourceFile: (fn, languageVersion) => {
|
||||
if (Object.prototype.hasOwnProperty.call(filemap, getCanonicalFileName(fn))) {
|
||||
return filemap[getCanonicalFileName(fn)];
|
||||
@@ -655,7 +657,7 @@ module Harness {
|
||||
writeFile,
|
||||
getCanonicalFileName,
|
||||
useCaseSensitiveFileNames: () => useCaseSensitiveFileNames,
|
||||
getNewLine: ()=> sys.newLine
|
||||
getNewLine: ()=> ts.sys.newLine
|
||||
};
|
||||
}
|
||||
|
||||
@@ -725,7 +727,7 @@ module Harness {
|
||||
settingsCallback(null);
|
||||
}
|
||||
|
||||
var useCaseSensitiveFileNames = sys.useCaseSensitiveFileNames;
|
||||
var useCaseSensitiveFileNames = ts.sys.useCaseSensitiveFileNames;
|
||||
this.settings.forEach(setting => {
|
||||
switch (setting.flag.toLowerCase()) {
|
||||
// "filename", "comments", "declaration", "module", "nolib", "sourcemap", "target", "out", "outdir", "noimplicitany", "noresolve"
|
||||
@@ -803,7 +805,7 @@ module Harness {
|
||||
|
||||
case 'newline':
|
||||
case 'newlines':
|
||||
sys.newLine = setting.value;
|
||||
ts.sys.newLine = setting.value;
|
||||
break;
|
||||
|
||||
case 'comments':
|
||||
@@ -835,9 +837,19 @@ module Harness {
|
||||
case 'errortruncation':
|
||||
options.noErrorTruncation = setting.value === 'false';
|
||||
break;
|
||||
|
||||
case 'preserveconstenums':
|
||||
options.preserveConstEnums = setting.value === 'true';
|
||||
break;
|
||||
|
||||
case 'suppressimplicitanyindexerrors':
|
||||
options.suppressImplicitAnyIndexErrors = setting.value === 'true';
|
||||
break;
|
||||
|
||||
case 'includebuiltfile':
|
||||
inputFiles.push({ unitName: setting.value, content: IO.readFile(libFolder + setting.value)});
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new Error('Unsupported compiler setting ' + setting.flag);
|
||||
}
|
||||
@@ -878,11 +890,11 @@ module Harness {
|
||||
});
|
||||
this.lastErrors = errors;
|
||||
|
||||
var result = new CompilerResult(fileOutputs, errors, program, sys.getCurrentDirectory(), emitResult ? emitResult.sourceMaps : undefined);
|
||||
var result = new CompilerResult(fileOutputs, errors, program, ts.sys.getCurrentDirectory(), emitResult ? emitResult.sourceMaps : undefined);
|
||||
onComplete(result, checker);
|
||||
|
||||
// reset what newline means in case the last test changed it
|
||||
sys.newLine = '\r\n';
|
||||
ts.sys.newLine = '\r\n';
|
||||
return options;
|
||||
}
|
||||
|
||||
@@ -977,7 +989,7 @@ module Harness {
|
||||
errorOutput += diagnotic.filename + "(" + diagnotic.line + "," + diagnotic.character + "): ";
|
||||
}
|
||||
|
||||
errorOutput += diagnotic.category + " TS" + diagnotic.code + ": " + diagnotic.message + sys.newLine;
|
||||
errorOutput += diagnotic.category + " TS" + diagnotic.code + ": " + diagnotic.message + ts.sys.newLine;
|
||||
});
|
||||
|
||||
return errorOutput;
|
||||
@@ -1079,7 +1091,7 @@ module Harness {
|
||||
assert.equal(totalErrorsReported + numLibraryDiagnostics, diagnostics.length, 'total number of errors');
|
||||
|
||||
return minimalDiagnosticsToString(diagnostics) +
|
||||
sys.newLine + sys.newLine + outputLines.join('\r\n');
|
||||
ts.sys.newLine + ts.sys.newLine + outputLines.join('\r\n');
|
||||
}
|
||||
|
||||
export function collateOutputs(outputFiles: Harness.Compiler.GeneratedFile[], clean?: (s: string) => string) {
|
||||
@@ -1227,7 +1239,7 @@ module Harness {
|
||||
var optionRegex = /^[\/]{2}\s*@(\w+)\s*:\s*(\S*)/gm; // multiple matches on multiple lines
|
||||
|
||||
// List of allowed metadata names
|
||||
var fileMetadataNames = ["filename", "comments", "declaration", "module", "nolib", "sourcemap", "target", "out", "outdir", "noemitonerror","noimplicitany", "noresolve", "newline", "newlines", "emitbom", "errortruncation", "usecasesensitivefilenames", "preserveconstenums"];
|
||||
var fileMetadataNames = ["filename", "comments", "declaration", "module", "nolib", "sourcemap", "target", "out", "outdir", "noemitonerror", "noimplicitany", "noresolve", "newline", "newlines", "emitbom", "errortruncation", "usecasesensitivefilenames", "preserveconstenums", "includebuiltfile", "suppressimplicitanyindexerrors"];
|
||||
|
||||
function extractCompilerSettings(content: string): CompilerSetting[] {
|
||||
|
||||
|
||||
@@ -137,7 +137,7 @@ module Harness.LanguageService {
|
||||
private ls: ts.LanguageServiceShim = null;
|
||||
|
||||
private fileNameToScript: ts.Map<ScriptInfo> = {};
|
||||
private settings: ts.CompilationSettings = {};
|
||||
private settings: ts.CompilerOptions = {};
|
||||
|
||||
constructor(private cancellationToken: ts.CancellationToken = CancellationToken.None) {
|
||||
}
|
||||
@@ -251,7 +251,7 @@ module Harness.LanguageService {
|
||||
return this.ls;
|
||||
}
|
||||
|
||||
public setCompilationSettings(settings: ts.CompilationSettings) {
|
||||
public setCompilationSettings(settings: ts.CompilerOptions) {
|
||||
for (var key in settings) {
|
||||
if (settings.hasOwnProperty(key)) {
|
||||
this.settings[key] = settings[key];
|
||||
|
||||
@@ -91,7 +91,7 @@ module Playback {
|
||||
return run;
|
||||
}
|
||||
|
||||
export interface PlaybackSystem extends System, PlaybackControl { }
|
||||
export interface PlaybackSystem extends ts.System, PlaybackControl { }
|
||||
|
||||
function createEmptyLog(): IOLog {
|
||||
return {
|
||||
@@ -221,7 +221,7 @@ module Playback {
|
||||
//console.log("Swallowed write operation during replay: " + name);
|
||||
}
|
||||
|
||||
export function wrapSystem(underlying: System): PlaybackSystem {
|
||||
export function wrapSystem(underlying: ts.System): PlaybackSystem {
|
||||
var wrapper: PlaybackSystem = <any>{};
|
||||
initWrapper(wrapper, underlying);
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ class ProjectRunner extends RunnerBase {
|
||||
var testCase: ProjectRunnerTestCase;
|
||||
|
||||
try {
|
||||
var testFileText = sys.readFile(testCaseFileName);
|
||||
var testFileText = ts.sys.readFile(testCaseFileName);
|
||||
}
|
||||
catch (e) {
|
||||
assert(false, "Unable to open testcase file: " + testCaseFileName + ": " + e.message);
|
||||
@@ -96,7 +96,7 @@ class ProjectRunner extends RunnerBase {
|
||||
}
|
||||
|
||||
function cleanProjectUrl(url: string) {
|
||||
var diskProjectPath = ts.normalizeSlashes(sys.resolvePath(testCase.projectRoot));
|
||||
var diskProjectPath = ts.normalizeSlashes(ts.sys.resolvePath(testCase.projectRoot));
|
||||
var projectRootUrl = "file:///" + diskProjectPath;
|
||||
var normalizedProjectRoot = ts.normalizeSlashes(testCase.projectRoot);
|
||||
diskProjectPath = diskProjectPath.substr(0, diskProjectPath.lastIndexOf(normalizedProjectRoot));
|
||||
@@ -119,7 +119,7 @@ class ProjectRunner extends RunnerBase {
|
||||
}
|
||||
|
||||
function getCurrentDirectory() {
|
||||
return sys.resolvePath(testCase.projectRoot);
|
||||
return ts.sys.resolvePath(testCase.projectRoot);
|
||||
}
|
||||
|
||||
function compileProjectFiles(moduleKind: ts.ModuleKind, getInputFiles: ()=> string[],
|
||||
@@ -161,8 +161,8 @@ class ProjectRunner extends RunnerBase {
|
||||
sourceMap: !!testCase.sourceMap,
|
||||
out: testCase.out,
|
||||
outDir: testCase.outDir,
|
||||
mapRoot: testCase.resolveMapRoot && testCase.mapRoot ? sys.resolvePath(testCase.mapRoot) : testCase.mapRoot,
|
||||
sourceRoot: testCase.resolveSourceRoot && testCase.sourceRoot ? sys.resolvePath(testCase.sourceRoot) : testCase.sourceRoot,
|
||||
mapRoot: testCase.resolveMapRoot && testCase.mapRoot ? ts.sys.resolvePath(testCase.mapRoot) : testCase.mapRoot,
|
||||
sourceRoot: testCase.resolveSourceRoot && testCase.sourceRoot ? ts.sys.resolvePath(testCase.sourceRoot) : testCase.sourceRoot,
|
||||
module: moduleKind,
|
||||
noResolve: testCase.noResolve
|
||||
};
|
||||
@@ -190,8 +190,8 @@ class ProjectRunner extends RunnerBase {
|
||||
writeFile,
|
||||
getCurrentDirectory,
|
||||
getCanonicalFileName: Harness.Compiler.getCanonicalFileName,
|
||||
useCaseSensitiveFileNames: () => sys.useCaseSensitiveFileNames,
|
||||
getNewLine: () => sys.newLine
|
||||
useCaseSensitiveFileNames: () => ts.sys.useCaseSensitiveFileNames,
|
||||
getNewLine: () => ts.sys.newLine
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -213,7 +213,7 @@ class ProjectRunner extends RunnerBase {
|
||||
|
||||
function getSourceFileText(filename: string): string {
|
||||
try {
|
||||
var text = sys.readFile(ts.isRootedDiskPath(filename)
|
||||
var text = ts.sys.readFile(ts.isRootedDiskPath(filename)
|
||||
? filename
|
||||
: ts.normalizeSlashes(testCase.projectRoot) + "/" + ts.normalizeSlashes(filename));
|
||||
}
|
||||
@@ -260,14 +260,14 @@ class ProjectRunner extends RunnerBase {
|
||||
// Actual writing of file as in tc.ts
|
||||
function ensureDirectoryStructure(directoryname: string) {
|
||||
if (directoryname) {
|
||||
if (!sys.directoryExists(directoryname)) {
|
||||
if (!ts.sys.directoryExists(directoryname)) {
|
||||
ensureDirectoryStructure(ts.getDirectoryPath(directoryname));
|
||||
sys.createDirectory(directoryname);
|
||||
ts.sys.createDirectory(directoryname);
|
||||
}
|
||||
}
|
||||
}
|
||||
ensureDirectoryStructure(ts.getDirectoryPath(ts.normalizePath(outputFilePath)));
|
||||
sys.writeFile(outputFilePath, data, writeByteOrderMark);
|
||||
ts.sys.writeFile(outputFilePath, data, writeByteOrderMark);
|
||||
|
||||
outputFiles.push({ emittedFileName: filename, code: data, fileName: diskRelativeName, writeByteOrderMark: writeByteOrderMark });
|
||||
}
|
||||
@@ -374,7 +374,7 @@ class ProjectRunner extends RunnerBase {
|
||||
it('Baseline of emitted result (' + moduleNameToString(compilerResult.moduleKind) + '): ' + testCaseFileName, () => {
|
||||
Harness.Baseline.runBaseline('Baseline of emitted result (' + moduleNameToString(compilerResult.moduleKind) + '): ' + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + outputFile.fileName, () => {
|
||||
try {
|
||||
return sys.readFile(getProjectOutputFolder(outputFile.fileName, compilerResult.moduleKind));
|
||||
return ts.sys.readFile(getProjectOutputFolder(outputFile.fileName, compilerResult.moduleKind));
|
||||
}
|
||||
catch (e) {
|
||||
return undefined;
|
||||
|
||||
@@ -94,6 +94,6 @@ if (runners.length === 0) {
|
||||
//runners.push(new GeneratedFourslashRunner());
|
||||
}
|
||||
|
||||
sys.newLine = '\r\n';
|
||||
ts.sys.newLine = '\r\n';
|
||||
|
||||
runTests(runners);
|
||||
|
||||
@@ -6,17 +6,17 @@
|
||||
|
||||
module RWC {
|
||||
function runWithIOLog(ioLog: IOLog, fn: () => void) {
|
||||
var oldSys = sys;
|
||||
var oldSys = ts.sys;
|
||||
|
||||
var wrappedSys = Playback.wrapSystem(sys);
|
||||
var wrappedSys = Playback.wrapSystem(ts.sys);
|
||||
wrappedSys.startReplayFromData(ioLog);
|
||||
sys = wrappedSys;
|
||||
ts.sys = wrappedSys;
|
||||
|
||||
try {
|
||||
fn();
|
||||
} finally {
|
||||
wrappedSys.endReplay();
|
||||
sys = oldSys;
|
||||
ts.sys = oldSys;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ module RWC {
|
||||
}
|
||||
|
||||
ts.forEach(ioLog.filesRead, fileRead => {
|
||||
var resolvedPath = ts.normalizeSlashes(sys.resolvePath(fileRead.path));
|
||||
var resolvedPath = ts.normalizeSlashes(ts.sys.resolvePath(fileRead.path));
|
||||
var inInputList = ts.forEach(inputFiles, inputFile=> inputFile.unitName === resolvedPath);
|
||||
if (!inInputList) {
|
||||
// Add the file to other files
|
||||
@@ -92,9 +92,9 @@ module RWC {
|
||||
});
|
||||
|
||||
function getHarnessCompilerInputUnit(fileName: string) {
|
||||
var unitName = ts.normalizeSlashes(sys.resolvePath(fileName));
|
||||
var unitName = ts.normalizeSlashes(ts.sys.resolvePath(fileName));
|
||||
try {
|
||||
var content = sys.readFile(unitName);
|
||||
var content = ts.sys.readFile(unitName);
|
||||
}
|
||||
catch (e) {
|
||||
// Leave content undefined.
|
||||
@@ -160,7 +160,7 @@ module RWC {
|
||||
}
|
||||
|
||||
return Harness.Compiler.minimalDiagnosticsToString(declFileCompilationResult.declResult.errors) +
|
||||
sys.newLine + sys.newLine +
|
||||
ts.sys.newLine + ts.sys.newLine +
|
||||
Harness.Compiler.getErrorBaseline(declFileCompilationResult.declInputFiles.concat(declFileCompilationResult.declOtherFiles), declFileCompilationResult.declResult.errors);
|
||||
}, false, baselineOpts);
|
||||
}
|
||||
|
||||
@@ -1,152 +0,0 @@
|
||||
// Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0.
|
||||
// See LICENSE.txt in the project root for complete license information.
|
||||
|
||||
///<reference path='references.ts' />
|
||||
|
||||
module TypeScript.Services {
|
||||
export class FindReferenceHelpers {
|
||||
public static compareSymbolsForLexicalIdentity(firstSymbol: TypeScript.PullSymbol, secondSymbol: TypeScript.PullSymbol): boolean {
|
||||
// Unwrap modules so that we're always referring to the variable.
|
||||
if (!firstSymbol.isAlias() && firstSymbol.isContainer()) {
|
||||
var containerForFirstSymbol = (<TypeScript.PullContainerSymbol>firstSymbol);
|
||||
if (containerForFirstSymbol.getInstanceSymbol()) {
|
||||
firstSymbol = containerForFirstSymbol.getInstanceSymbol();
|
||||
}
|
||||
}
|
||||
|
||||
if (!secondSymbol.isAlias() && secondSymbol.isContainer()) {
|
||||
var containerForSecondSymbol = (<TypeScript.PullContainerSymbol>secondSymbol);
|
||||
if (containerForSecondSymbol.getInstanceSymbol()) {
|
||||
secondSymbol = containerForSecondSymbol.getInstanceSymbol();
|
||||
}
|
||||
}
|
||||
|
||||
if (firstSymbol.kind === secondSymbol.kind) {
|
||||
if (firstSymbol === secondSymbol) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// If we have two variables and they have the same name and the same parent, then
|
||||
// they are the same symbol.
|
||||
if (firstSymbol.kind === TypeScript.PullElementKind.Variable &&
|
||||
firstSymbol.name === secondSymbol.name &&
|
||||
firstSymbol.getDeclarations() && firstSymbol.getDeclarations().length >= 1 &&
|
||||
secondSymbol.getDeclarations() && secondSymbol.getDeclarations().length >= 1) {
|
||||
|
||||
var firstSymbolDecl = firstSymbol.getDeclarations()[0];
|
||||
var secondSymbolDecl = secondSymbol.getDeclarations()[0];
|
||||
|
||||
return firstSymbolDecl.getParentDecl() === secondSymbolDecl.getParentDecl();
|
||||
}
|
||||
|
||||
// If we have two properties that belong to an object literal, then we need ot see
|
||||
// if they came from teh same object literal ast.
|
||||
if (firstSymbol.kind === TypeScript.PullElementKind.Property &&
|
||||
firstSymbol.name === secondSymbol.name &&
|
||||
firstSymbol.getDeclarations() && firstSymbol.getDeclarations().length >= 1 &&
|
||||
secondSymbol.getDeclarations() && secondSymbol.getDeclarations().length >= 1) {
|
||||
|
||||
var firstSymbolDecl = firstSymbol.getDeclarations()[0];
|
||||
var secondSymbolDecl = secondSymbol.getDeclarations()[0];
|
||||
|
||||
var firstParentDecl = firstSymbolDecl.getParentDecl();
|
||||
var secondParentDecl = secondSymbolDecl.getParentDecl();
|
||||
|
||||
if (firstParentDecl.kind === TypeScript.PullElementKind.ObjectLiteral &&
|
||||
secondParentDecl.kind === TypeScript.PullElementKind.ObjectLiteral) {
|
||||
|
||||
return firstParentDecl.ast() === secondParentDecl.ast();
|
||||
}
|
||||
}
|
||||
|
||||
// check if we are dealing with the implementation of interface method or a method override
|
||||
if (firstSymbol.name === secondSymbol.name) {
|
||||
// at this point firstSymbol.kind === secondSymbol.kind so we can pick any of those
|
||||
switch (firstSymbol.kind) {
|
||||
case PullElementKind.Property:
|
||||
case PullElementKind.Method:
|
||||
case PullElementKind.GetAccessor:
|
||||
case PullElementKind.SetAccessor:
|
||||
// these kinds can only be defined in types
|
||||
var t1 = <PullTypeSymbol>firstSymbol.getContainer();
|
||||
var t2 = <PullTypeSymbol>secondSymbol.getContainer();
|
||||
t1._resolveDeclaredSymbol();
|
||||
t2._resolveDeclaredSymbol();
|
||||
|
||||
return t1.hasBase(t2) || t2.hasBase(t1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
switch (firstSymbol.kind) {
|
||||
case TypeScript.PullElementKind.Class: {
|
||||
return this.checkSymbolsForDeclarationEquality(firstSymbol, secondSymbol);
|
||||
}
|
||||
case TypeScript.PullElementKind.Property: {
|
||||
if (firstSymbol.isAccessor()) {
|
||||
var getterSymbol = (<TypeScript.PullAccessorSymbol>firstSymbol).getGetter();
|
||||
var setterSymbol = (<TypeScript.PullAccessorSymbol>firstSymbol).getSetter();
|
||||
|
||||
if (getterSymbol && getterSymbol === secondSymbol) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (setterSymbol && setterSymbol === secondSymbol) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
case TypeScript.PullElementKind.Function: {
|
||||
if (secondSymbol.isAccessor()) {
|
||||
var getterSymbol = (<TypeScript.PullAccessorSymbol>secondSymbol).getGetter();
|
||||
var setterSymbol = (<TypeScript.PullAccessorSymbol>secondSymbol).getSetter();
|
||||
|
||||
if (getterSymbol && getterSymbol === firstSymbol) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (setterSymbol && setterSymbol === firstSymbol) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
case TypeScript.PullElementKind.ConstructorMethod: {
|
||||
return this.checkSymbolsForDeclarationEquality(firstSymbol, secondSymbol);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return firstSymbol === secondSymbol;
|
||||
}
|
||||
|
||||
private static checkSymbolsForDeclarationEquality(firstSymbol: TypeScript.PullSymbol, secondSymbol: TypeScript.PullSymbol): boolean {
|
||||
var firstSymbolDeclarations: TypeScript.PullDecl[] = firstSymbol.getDeclarations();
|
||||
var secondSymbolDeclarations: TypeScript.PullDecl[] = secondSymbol.getDeclarations();
|
||||
for (var i = 0, iLen = firstSymbolDeclarations.length; i < iLen; i++) {
|
||||
for (var j = 0, jLen = secondSymbolDeclarations.length; j < jLen; j++) {
|
||||
if (this.declarationsAreSameOrParents(firstSymbolDeclarations[i], secondSymbolDeclarations[j])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static declarationsAreSameOrParents(firstDecl: TypeScript.PullDecl, secondDecl: TypeScript.PullDecl): boolean {
|
||||
var firstParent: TypeScript.PullDecl = firstDecl.getParentDecl();
|
||||
var secondParent: TypeScript.PullDecl = secondDecl.getParentDecl();
|
||||
if (firstDecl === secondDecl ||
|
||||
firstDecl === secondParent ||
|
||||
firstParent === secondDecl ||
|
||||
firstParent === secondParent) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
///<reference path='services.ts' />
|
||||
///<reference path='formatting\indentation.ts' />
|
||||
///<reference path='formatting\formattingScanner.ts' />
|
||||
///<reference path='formatting\rulesProvider.ts' />
|
||||
///<reference path='..\services.ts' />
|
||||
///<reference path='formattingScanner.ts' />
|
||||
///<reference path='rulesProvider.ts' />
|
||||
///<reference path='references.ts' />
|
||||
|
||||
module ts.formatting {
|
||||
|
||||
@@ -986,4 +986,56 @@ module ts.formatting {
|
||||
|
||||
return SyntaxKind.Unknown;
|
||||
}
|
||||
|
||||
var internedTabsIndentation: string[];
|
||||
var internedSpacesIndentation: string[];
|
||||
|
||||
export function getIndentationString(indentation: number, options: FormatCodeOptions): string {
|
||||
if (!options.ConvertTabsToSpaces) {
|
||||
var tabs = Math.floor(indentation / options.TabSize);
|
||||
var spaces = indentation - tabs * options.TabSize;
|
||||
|
||||
var tabString: string;
|
||||
if (!internedTabsIndentation) {
|
||||
internedTabsIndentation = [];
|
||||
}
|
||||
|
||||
if (internedTabsIndentation[tabs] === undefined) {
|
||||
internedTabsIndentation[tabs] = tabString = repeat('\t', tabs);
|
||||
}
|
||||
else {
|
||||
tabString = internedTabsIndentation[tabs];
|
||||
}
|
||||
|
||||
return spaces ? tabString + repeat(" ", spaces) : tabString;
|
||||
}
|
||||
else {
|
||||
var spacesString: string;
|
||||
var quotient = Math.floor(indentation / options.IndentSize);
|
||||
var remainder = indentation % options.IndentSize;
|
||||
if (!internedSpacesIndentation) {
|
||||
internedSpacesIndentation = [];
|
||||
}
|
||||
|
||||
if (internedSpacesIndentation[quotient] === undefined) {
|
||||
spacesString = repeat(" ", options.IndentSize * quotient);
|
||||
internedSpacesIndentation[quotient] = spacesString;
|
||||
}
|
||||
else {
|
||||
spacesString = internedSpacesIndentation[quotient];
|
||||
}
|
||||
|
||||
|
||||
return remainder ? spacesString + repeat(" ", remainder) : spacesString;
|
||||
}
|
||||
|
||||
function repeat(value: string, count: number): string {
|
||||
var s = "";
|
||||
for (var i = 0; i < count; ++i) {
|
||||
s += value;
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
/// <reference path="..\formatting.ts"/>
|
||||
/// <reference path="formatting.ts"/>
|
||||
/// <reference path="..\..\compiler\scanner.ts"/>
|
||||
|
||||
module ts.formatting {
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
///<reference path='..\text.ts' />
|
||||
///<reference path='..\services.ts' />
|
||||
///<reference path='formattingContext.ts' />
|
||||
///<reference path='formattingRequestKind.ts' />
|
||||
@@ -25,5 +24,4 @@
|
||||
///<reference path='ruleOperationContext.ts' />
|
||||
///<reference path='rules.ts' />
|
||||
///<reference path='rulesMap.ts' />
|
||||
///<reference path='tokenRange.ts' />
|
||||
///<reference path='tokenSpan.ts' />
|
||||
///<reference path='tokenRange.ts' />
|
||||
@@ -1,4 +1,4 @@
|
||||
///<reference path='services.ts' />
|
||||
///<reference path='..\services.ts' />
|
||||
|
||||
module ts.formatting {
|
||||
export module SmartIndenter {
|
||||
@@ -1,19 +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 ts.formatting {
|
||||
}
|
||||
@@ -14,22 +14,6 @@
|
||||
//
|
||||
|
||||
module ts {
|
||||
|
||||
export interface OutliningSpan {
|
||||
/**
|
||||
* @param textSpan The span of the document to actually collapse.
|
||||
* @param hintSpan The span of the document to display when the user hovers over the
|
||||
* collapsed span.
|
||||
* @param bannerText The text to display in the editor for the collapsed region.
|
||||
* @param autoCollapse Whether or not this region should be automatically collapsed when
|
||||
* the 'Collapse to Definitions' command is invoked.
|
||||
*/
|
||||
textSpan: TextSpan;
|
||||
hintSpan: TextSpan;
|
||||
bannerText: string;
|
||||
autoCollapse: boolean;
|
||||
}
|
||||
|
||||
export module OutliningElementsCollector {
|
||||
export function collectElements(sourceFile: SourceFile): OutliningSpan[] {
|
||||
var elements: OutliningSpan[] = [];
|
||||
|
||||
+32
-187
@@ -4,14 +4,13 @@
|
||||
/// <reference path="..\compiler\parser.ts"/>
|
||||
/// <reference path="..\compiler\checker.ts"/>
|
||||
|
||||
/// <reference path='text.ts' />
|
||||
/// <reference path='breakpoints.ts' />
|
||||
/// <reference path='outliningElementsCollector.ts' />
|
||||
/// <reference path='navigationBar.ts' />
|
||||
/// <reference path='breakpoints.ts' />
|
||||
/// <reference path='signatureHelp.ts' />
|
||||
/// <reference path='utilities.ts' />
|
||||
/// <reference path='smartIndenter.ts' />
|
||||
/// <reference path='formatting.ts' />
|
||||
/// <reference path='formatting\formatting.ts' />
|
||||
/// <reference path='formatting\smartIndenter.ts' />
|
||||
|
||||
module ts {
|
||||
|
||||
@@ -862,8 +861,8 @@ module ts {
|
||||
getScriptVersion(fileName: string): string;
|
||||
getScriptIsOpen(fileName: string): boolean;
|
||||
getScriptSnapshot(fileName: string): IScriptSnapshot;
|
||||
getLocalizedDiagnosticMessages(): any;
|
||||
getCancellationToken(): CancellationToken;
|
||||
getLocalizedDiagnosticMessages?(): any;
|
||||
getCancellationToken?(): CancellationToken;
|
||||
getCurrentDirectory(): string;
|
||||
getDefaultLibFilename(options: CompilerOptions): string;
|
||||
}
|
||||
@@ -882,7 +881,7 @@ module ts {
|
||||
getSyntacticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[];
|
||||
getSemanticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[];
|
||||
|
||||
getCompletionsAtPosition(fileName: string, position: number, isMemberCompletion: boolean): CompletionInfo;
|
||||
getCompletionsAtPosition(fileName: string, position: number): CompletionInfo;
|
||||
getCompletionEntryDetails(fileName: string, position: number, entryName: string): CompletionEntryDetails;
|
||||
|
||||
getQuickInfoAtPosition(fileName: string, position: number): QuickInfo;
|
||||
@@ -918,7 +917,7 @@ module ts {
|
||||
|
||||
dispose(): void;
|
||||
}
|
||||
|
||||
|
||||
export interface ClassifiedSpan {
|
||||
textSpan: TextSpan;
|
||||
classificationType: string; // ClassificationTypeNames
|
||||
@@ -1101,6 +1100,23 @@ module ts {
|
||||
documentation: SymbolDisplayPart[];
|
||||
}
|
||||
|
||||
export interface OutliningSpan {
|
||||
/** The span of the document to actually collapse. */
|
||||
textSpan: TextSpan;
|
||||
|
||||
/** The span of the document to display when the user hovers over the collapsed span. */
|
||||
hintSpan: TextSpan;
|
||||
|
||||
/** The text to display in the editor for the collapsed region. */
|
||||
bannerText: string;
|
||||
|
||||
/**
|
||||
* Whether or not this region should be automatically collapsed when
|
||||
* the 'Collapse to Definitions' command is invoked.
|
||||
*/
|
||||
autoCollapse: boolean;
|
||||
}
|
||||
|
||||
export interface EmitOutput {
|
||||
outputFiles: OutputFile[];
|
||||
emitOutputStatus: EmitReturnStatus;
|
||||
@@ -1318,6 +1334,10 @@ module ts {
|
||||
owners: string[];
|
||||
}
|
||||
|
||||
export interface DisplayPartsSymbolWriter extends SymbolWriter {
|
||||
displayParts(): SymbolDisplayPart[];
|
||||
}
|
||||
|
||||
export function displayPartsToString(displayParts: SymbolDisplayPart[]) {
|
||||
if (displayParts) {
|
||||
return map(displayParts, displayPart => displayPart.text).join("");
|
||||
@@ -1326,100 +1346,6 @@ module ts {
|
||||
return "";
|
||||
}
|
||||
|
||||
export interface DisplayPartsSymbolWriter extends SymbolWriter {
|
||||
displayParts(): SymbolDisplayPart[];
|
||||
}
|
||||
|
||||
var displayPartWriter = getDisplayPartWriter();
|
||||
function getDisplayPartWriter(): DisplayPartsSymbolWriter {
|
||||
var displayParts: SymbolDisplayPart[];
|
||||
var lineStart: boolean;
|
||||
var indent: number;
|
||||
|
||||
resetWriter();
|
||||
return {
|
||||
displayParts: () => displayParts,
|
||||
writeKeyword: text => writeKind(text, SymbolDisplayPartKind.keyword),
|
||||
writeOperator: text => writeKind(text, SymbolDisplayPartKind.operator),
|
||||
writePunctuation: text => writeKind(text, SymbolDisplayPartKind.punctuation),
|
||||
writeSpace: text => writeKind(text, SymbolDisplayPartKind.space),
|
||||
writeStringLiteral: text => writeKind(text, SymbolDisplayPartKind.stringLiteral),
|
||||
writeParameter: text => writeKind(text, SymbolDisplayPartKind.parameterName),
|
||||
writeSymbol,
|
||||
writeLine,
|
||||
increaseIndent: () => { indent++; },
|
||||
decreaseIndent: () => { indent--; },
|
||||
clear: resetWriter,
|
||||
trackSymbol: () => { }
|
||||
};
|
||||
|
||||
function writeIndent() {
|
||||
if (lineStart) {
|
||||
var indentString = getIndentString(indent);
|
||||
if (indentString) {
|
||||
displayParts.push(displayPart(indentString, SymbolDisplayPartKind.space));
|
||||
}
|
||||
lineStart = false;
|
||||
}
|
||||
}
|
||||
|
||||
function writeKind(text: string, kind: SymbolDisplayPartKind) {
|
||||
writeIndent();
|
||||
displayParts.push(displayPart(text, kind));
|
||||
}
|
||||
|
||||
function writeSymbol(text: string, symbol: Symbol) {
|
||||
writeIndent();
|
||||
displayParts.push(symbolPart(text, symbol));
|
||||
}
|
||||
|
||||
function writeLine() {
|
||||
displayParts.push(lineBreakPart());
|
||||
lineStart = true;
|
||||
}
|
||||
|
||||
function resetWriter() {
|
||||
displayParts = []
|
||||
lineStart = true;
|
||||
indent = 0;
|
||||
}
|
||||
}
|
||||
|
||||
function displayPart(text: string, kind: SymbolDisplayPartKind, symbol?: Symbol): SymbolDisplayPart {
|
||||
return <SymbolDisplayPart> {
|
||||
text: text,
|
||||
kind: SymbolDisplayPartKind[kind]
|
||||
};
|
||||
}
|
||||
|
||||
export function spacePart() {
|
||||
return displayPart(" ", SymbolDisplayPartKind.space);
|
||||
}
|
||||
|
||||
export function keywordPart(kind: SyntaxKind) {
|
||||
return displayPart(tokenToString(kind), SymbolDisplayPartKind.keyword);
|
||||
}
|
||||
|
||||
export function punctuationPart(kind: SyntaxKind) {
|
||||
return displayPart(tokenToString(kind), SymbolDisplayPartKind.punctuation);
|
||||
}
|
||||
|
||||
export function operatorPart(kind: SyntaxKind) {
|
||||
return displayPart(tokenToString(kind), SymbolDisplayPartKind.operator);
|
||||
}
|
||||
|
||||
export function textPart(text: string) {
|
||||
return displayPart(text, SymbolDisplayPartKind.text);
|
||||
}
|
||||
|
||||
export function lineBreakPart() {
|
||||
return displayPart("\n", SymbolDisplayPartKind.lineBreak);
|
||||
}
|
||||
|
||||
function isFirstDeclarationOfSymbolParameter(symbol: Symbol) {
|
||||
return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === SyntaxKind.Parameter;
|
||||
}
|
||||
|
||||
function isLocalVariableOrFunction(symbol: Symbol) {
|
||||
if (symbol.parent) {
|
||||
return false; // This is exported symbol
|
||||
@@ -1448,59 +1374,6 @@ module ts {
|
||||
});
|
||||
}
|
||||
|
||||
export function symbolPart(text: string, symbol: Symbol) {
|
||||
return displayPart(text, displayPartKind(symbol), symbol);
|
||||
|
||||
function displayPartKind(symbol: Symbol): SymbolDisplayPartKind {
|
||||
var flags = symbol.flags;
|
||||
|
||||
if (flags & SymbolFlags.Variable) {
|
||||
return isFirstDeclarationOfSymbolParameter(symbol) ? SymbolDisplayPartKind.parameterName : SymbolDisplayPartKind.localName;
|
||||
}
|
||||
else if (flags & SymbolFlags.Property) { return SymbolDisplayPartKind.propertyName; }
|
||||
else if (flags & SymbolFlags.GetAccessor) { return SymbolDisplayPartKind.propertyName; }
|
||||
else if (flags & SymbolFlags.SetAccessor) { return SymbolDisplayPartKind.propertyName; }
|
||||
else if (flags & SymbolFlags.EnumMember) { return SymbolDisplayPartKind.enumMemberName; }
|
||||
else if (flags & SymbolFlags.Function) { return SymbolDisplayPartKind.functionName; }
|
||||
else if (flags & SymbolFlags.Class) { return SymbolDisplayPartKind.className; }
|
||||
else if (flags & SymbolFlags.Interface) { return SymbolDisplayPartKind.interfaceName; }
|
||||
else if (flags & SymbolFlags.Enum) { return SymbolDisplayPartKind.enumName; }
|
||||
else if (flags & SymbolFlags.Module) { return SymbolDisplayPartKind.moduleName; }
|
||||
else if (flags & SymbolFlags.Method) { return SymbolDisplayPartKind.methodName; }
|
||||
else if (flags & SymbolFlags.TypeParameter) { return SymbolDisplayPartKind.typeParameterName; }
|
||||
else if (flags & SymbolFlags.TypeAlias) { return SymbolDisplayPartKind.aliasName; }
|
||||
else if (flags & SymbolFlags.Import) { return SymbolDisplayPartKind.aliasName; }
|
||||
|
||||
|
||||
return SymbolDisplayPartKind.text;
|
||||
}
|
||||
}
|
||||
|
||||
export function mapToDisplayParts(writeDisplayParts: (writer: DisplayPartsSymbolWriter) => void): SymbolDisplayPart[] {
|
||||
writeDisplayParts(displayPartWriter);
|
||||
var result = displayPartWriter.displayParts();
|
||||
displayPartWriter.clear();
|
||||
return result;
|
||||
}
|
||||
|
||||
export function typeToDisplayParts(typechecker: TypeChecker, type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): SymbolDisplayPart[] {
|
||||
return mapToDisplayParts(writer => {
|
||||
typechecker.getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags);
|
||||
});
|
||||
}
|
||||
|
||||
export function symbolToDisplayParts(typeChecker: TypeChecker, symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): SymbolDisplayPart[] {
|
||||
return mapToDisplayParts(writer => {
|
||||
typeChecker.getSymbolDisplayBuilder().buildSymbolDisplay(symbol, writer, enclosingDeclaration, meaning, flags);
|
||||
});
|
||||
}
|
||||
|
||||
function signatureToDisplayParts(typechecker: TypeChecker, signature: Signature, enclosingDeclaration?: Node, flags?: TypeFormatFlags): SymbolDisplayPart[]{
|
||||
return mapToDisplayParts(writer => {
|
||||
typechecker.getSymbolDisplayBuilder().buildSignatureDisplay(signature, writer, enclosingDeclaration, flags);
|
||||
});
|
||||
}
|
||||
|
||||
export function getDefaultCompilerOptions(): CompilerOptions {
|
||||
// Set "ScriptTarget.Latest" target by default for language service
|
||||
return {
|
||||
@@ -1509,20 +1382,6 @@ module ts {
|
||||
};
|
||||
}
|
||||
|
||||
export function compareDataObjects(dst: any, src: any): boolean {
|
||||
for (var e in dst) {
|
||||
if (typeof dst[e] === "object") {
|
||||
if (!compareDataObjects(dst[e], src[e]))
|
||||
return false;
|
||||
}
|
||||
else if (typeof dst[e] !== "function") {
|
||||
if (dst[e] !== src[e])
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
export class OperationCanceledException { }
|
||||
|
||||
export class CancellationTokenObject {
|
||||
@@ -1890,20 +1749,6 @@ module ts {
|
||||
}
|
||||
|
||||
/// Helpers
|
||||
export function getNodeModifiers(node: Node): string {
|
||||
var flags = node.flags;
|
||||
var result: string[] = [];
|
||||
|
||||
if (flags & NodeFlags.Private) result.push(ScriptElementKindModifier.privateMemberModifier);
|
||||
if (flags & NodeFlags.Protected) result.push(ScriptElementKindModifier.protectedMemberModifier);
|
||||
if (flags & NodeFlags.Public) result.push(ScriptElementKindModifier.publicMemberModifier);
|
||||
if (flags & NodeFlags.Static) result.push(ScriptElementKindModifier.staticModifier);
|
||||
if (flags & NodeFlags.Export) result.push(ScriptElementKindModifier.exportedModifier);
|
||||
if (isInAmbientContext(node)) result.push(ScriptElementKindModifier.ambientModifier);
|
||||
|
||||
return result.length > 0 ? result.join(',') : ScriptElementKindModifier.none;
|
||||
}
|
||||
|
||||
function getTargetLabel(referenceNode: Node, labelName: string): Identifier {
|
||||
while (referenceNode) {
|
||||
if (referenceNode.kind === SyntaxKind.LabeledStatement && (<LabeledStatement>referenceNode).label.text === labelName) {
|
||||
@@ -2083,12 +1928,12 @@ module ts {
|
||||
var useCaseSensitivefilenames = false;
|
||||
var sourceFilesByName: Map<SourceFile> = {};
|
||||
var documentRegistry = documentRegistry;
|
||||
var cancellationToken = new CancellationTokenObject(host.getCancellationToken());
|
||||
var cancellationToken = new CancellationTokenObject(host.getCancellationToken && host.getCancellationToken());
|
||||
var activeCompletionSession: CompletionSession; // The current active completion session, used to get the completion entry details
|
||||
var writer: (filename: string, data: string, writeByteOrderMark: boolean) => void = undefined;
|
||||
|
||||
// Check if the localized messages json is set, otherwise query the host for it
|
||||
if (!localizedDiagnosticMessages) {
|
||||
if (!localizedDiagnosticMessages && host.getLocalizedDiagnosticMessages) {
|
||||
localizedDiagnosticMessages = host.getLocalizedDiagnosticMessages();
|
||||
}
|
||||
|
||||
@@ -2354,7 +2199,7 @@ module ts {
|
||||
};
|
||||
}
|
||||
|
||||
function getCompletionsAtPosition(filename: string, position: number, isMemberCompletion: boolean) {
|
||||
function getCompletionsAtPosition(filename: string, position: number) {
|
||||
synchronizeHostData();
|
||||
|
||||
filename = normalizeSlashes(filename);
|
||||
@@ -2429,7 +2274,7 @@ module ts {
|
||||
if (isRightOfDot) {
|
||||
// Right of dot member completion list
|
||||
var symbols: Symbol[] = [];
|
||||
isMemberCompletion = true;
|
||||
var isMemberCompletion = true;
|
||||
|
||||
if (node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.QualifiedName || node.kind === SyntaxKind.PropertyAccessExpression) {
|
||||
var symbol = typeInfoResolver.getSymbolAtLocation(node);
|
||||
|
||||
+6
-133
@@ -88,7 +88,7 @@ module ts {
|
||||
|
||||
getSyntacticClassifications(fileName: string, start: number, length: number): string;
|
||||
|
||||
getCompletionsAtPosition(fileName: string, position: number, isMemberCompletion: boolean): string;
|
||||
getCompletionsAtPosition(fileName: string, position: number): string;
|
||||
getCompletionEntryDetails(fileName: string, position: number, entryName: string): string;
|
||||
|
||||
getQuickInfoAtPosition(fileName: string, position: number): string;
|
||||
@@ -169,131 +169,6 @@ module ts {
|
||||
getDefaultCompilationSettings(): string;
|
||||
}
|
||||
|
||||
/// TODO: delete this, it is only needed until the VS interface is updated
|
||||
export const enum LanguageVersion {
|
||||
EcmaScript3 = 0,
|
||||
EcmaScript5 = 1,
|
||||
EcmaScript6 = 2,
|
||||
}
|
||||
|
||||
export const enum ModuleGenTarget {
|
||||
Unspecified = 0,
|
||||
Synchronous = 1,
|
||||
Asynchronous = 2,
|
||||
}
|
||||
|
||||
export interface CompilationSettings {
|
||||
propagateEnumConstants?: boolean;
|
||||
removeComments?: boolean;
|
||||
watch?: boolean;
|
||||
noResolve?: boolean;
|
||||
allowAutomaticSemicolonInsertion?: boolean;
|
||||
noImplicitAny?: boolean;
|
||||
noLib?: boolean;
|
||||
codeGenTarget?: LanguageVersion;
|
||||
moduleGenTarget?: ModuleGenTarget;
|
||||
outFileOption?: string;
|
||||
outDirOption?: string;
|
||||
mapSourceFiles?: boolean;
|
||||
mapRoot?: string;
|
||||
sourceRoot?: string;
|
||||
generateDeclarationFiles?: boolean;
|
||||
useCaseSensitiveFileResolution?: boolean;
|
||||
gatherDiagnostics?: boolean;
|
||||
codepage?: number;
|
||||
emitBOM?: boolean;
|
||||
|
||||
// Declare indexer signature
|
||||
[index: string]: any;
|
||||
}
|
||||
|
||||
function languageVersionToScriptTarget(languageVersion: LanguageVersion): ScriptTarget {
|
||||
if (typeof languageVersion === "undefined") return undefined;
|
||||
|
||||
switch (languageVersion) {
|
||||
case LanguageVersion.EcmaScript3: return ScriptTarget.ES3
|
||||
case LanguageVersion.EcmaScript5: return ScriptTarget.ES5;
|
||||
case LanguageVersion.EcmaScript6: return ScriptTarget.ES6;
|
||||
default: throw Error("unsupported LanguageVersion value: " + languageVersion);
|
||||
}
|
||||
}
|
||||
|
||||
function moduleGenTargetToModuleKind(moduleGenTarget: ModuleGenTarget): ModuleKind {
|
||||
if (typeof moduleGenTarget === "undefined") return undefined;
|
||||
|
||||
switch (moduleGenTarget) {
|
||||
case ModuleGenTarget.Asynchronous: return ModuleKind.AMD;
|
||||
case ModuleGenTarget.Synchronous: return ModuleKind.CommonJS;
|
||||
case ModuleGenTarget.Unspecified: return ModuleKind.None;
|
||||
default: throw Error("unsupported ModuleGenTarget value: " + moduleGenTarget);
|
||||
}
|
||||
}
|
||||
|
||||
function scriptTargetTolanguageVersion(scriptTarget: ScriptTarget): LanguageVersion {
|
||||
if (typeof scriptTarget === "undefined") return undefined;
|
||||
|
||||
switch (scriptTarget) {
|
||||
case ScriptTarget.ES3: return LanguageVersion.EcmaScript3;
|
||||
case ScriptTarget.ES5: return LanguageVersion.EcmaScript5;
|
||||
case ScriptTarget.ES6: return LanguageVersion.EcmaScript6;
|
||||
default: throw Error("unsupported ScriptTarget value: " + scriptTarget);
|
||||
}
|
||||
}
|
||||
|
||||
function moduleKindToModuleGenTarget(moduleKind: ModuleKind): ModuleGenTarget {
|
||||
if (typeof moduleKind === "undefined") return undefined;
|
||||
|
||||
switch (moduleKind) {
|
||||
case ModuleKind.AMD: return ModuleGenTarget.Asynchronous;
|
||||
case ModuleKind.CommonJS: return ModuleGenTarget.Synchronous;
|
||||
case ModuleKind.None: return ModuleGenTarget.Unspecified;
|
||||
default: throw Error("unsupported ModuleKind value: " + moduleKind);
|
||||
}
|
||||
}
|
||||
|
||||
function compilationSettingsToCompilerOptions(settings: CompilationSettings): CompilerOptions {
|
||||
// TODO: we should not be converting, but use options all the way
|
||||
var options: CompilerOptions = {};
|
||||
//options.propagateEnumConstants = settings.propagateEnumConstants;
|
||||
options.removeComments = settings.removeComments;
|
||||
options.noResolve = settings.noResolve;
|
||||
options.noImplicitAny = settings.noImplicitAny;
|
||||
options.noLib = settings.noLib;
|
||||
options.target = languageVersionToScriptTarget(settings.codeGenTarget);
|
||||
options.module = moduleGenTargetToModuleKind(settings.moduleGenTarget);
|
||||
options.out = settings.outFileOption;
|
||||
options.outDir = settings.outDirOption;
|
||||
options.sourceMap = settings.mapSourceFiles;
|
||||
options.mapRoot = settings.mapRoot;
|
||||
options.sourceRoot = settings.sourceRoot;
|
||||
options.declaration = settings.generateDeclarationFiles;
|
||||
//options.useCaseSensitiveFileResolution = settings.useCaseSensitiveFileResolution;
|
||||
options.codepage = settings.codepage;
|
||||
options.emitBOM = settings.emitBOM;
|
||||
return options;
|
||||
}
|
||||
|
||||
function compilerOptionsToCompilationSettings(options: CompilerOptions): CompilationSettings {
|
||||
var settings: CompilationSettings = {};
|
||||
//options.propagateEnumConstants = settings.propagateEnumConstants;
|
||||
settings.removeComments = options.removeComments;
|
||||
settings.noResolve = options.noResolve;
|
||||
settings.noImplicitAny = options.noImplicitAny;
|
||||
settings.noLib = options.noLib;
|
||||
settings.codeGenTarget = scriptTargetTolanguageVersion(options.target);
|
||||
settings.moduleGenTarget = moduleKindToModuleGenTarget(options.module);
|
||||
settings.outFileOption = options.out;
|
||||
settings.outDirOption = options.outDir;
|
||||
settings.mapSourceFiles = options.sourceMap;
|
||||
settings.mapRoot = options.mapRoot;
|
||||
settings.sourceRoot = options.sourceRoot;
|
||||
settings.generateDeclarationFiles = options.declaration;
|
||||
// settings.useCaseSensitiveFileResolution = options.useCaseSensitiveFileResolution;
|
||||
settings.codepage = options.codepage;
|
||||
settings.emitBOM = options.emitBOM;
|
||||
return settings;
|
||||
}
|
||||
|
||||
function logInternalError(logger: Logger, err: Error) {
|
||||
logger.log("*INTERNAL ERROR* - Exception in typescript services: " + err.message);
|
||||
}
|
||||
@@ -355,9 +230,7 @@ module ts {
|
||||
throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings");
|
||||
return null;
|
||||
}
|
||||
var options = compilationSettingsToCompilerOptions(<CompilerOptions>JSON.parse(<any>settingsJson));
|
||||
|
||||
return options;
|
||||
return <CompilerOptions>JSON.parse(settingsJson);
|
||||
}
|
||||
|
||||
public getScriptFileNames(): string[] {
|
||||
@@ -694,11 +567,11 @@ module ts {
|
||||
* to provide at the given source position and providing a member completion
|
||||
* list if requested.
|
||||
*/
|
||||
public getCompletionsAtPosition(fileName: string, position: number, isMemberCompletion: boolean) {
|
||||
public getCompletionsAtPosition(fileName: string, position: number) {
|
||||
return this.forwardJSONCall(
|
||||
"getCompletionsAtPosition('" + fileName + "', " + position + ", " + isMemberCompletion + ")",
|
||||
"getCompletionsAtPosition('" + fileName + "', " + position + ")",
|
||||
() => {
|
||||
var completion = this.languageService.getCompletionsAtPosition(fileName, position, isMemberCompletion);
|
||||
var completion = this.languageService.getCompletionsAtPosition(fileName, position);
|
||||
return completion;
|
||||
});
|
||||
}
|
||||
@@ -858,7 +731,7 @@ module ts {
|
||||
return this.forwardJSONCall(
|
||||
"getDefaultCompilationSettings()",
|
||||
() => {
|
||||
return compilerOptionsToCompilationSettings(getDefaultCompilerOptions());
|
||||
return getDefaultCompilerOptions();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
module ts {
|
||||
}
|
||||
+177
-1
@@ -270,7 +270,21 @@ module ts {
|
||||
return n.getWidth() !== 0;
|
||||
}
|
||||
|
||||
export function getTypeArgumentOrTypeParameterList(node: Node): NodeArray<Node> {
|
||||
export function getNodeModifiers(node: Node): string {
|
||||
var flags = node.flags;
|
||||
var result: string[] = [];
|
||||
|
||||
if (flags & NodeFlags.Private) result.push(ScriptElementKindModifier.privateMemberModifier);
|
||||
if (flags & NodeFlags.Protected) result.push(ScriptElementKindModifier.protectedMemberModifier);
|
||||
if (flags & NodeFlags.Public) result.push(ScriptElementKindModifier.publicMemberModifier);
|
||||
if (flags & NodeFlags.Static) result.push(ScriptElementKindModifier.staticModifier);
|
||||
if (flags & NodeFlags.Export) result.push(ScriptElementKindModifier.exportedModifier);
|
||||
if (isInAmbientContext(node)) result.push(ScriptElementKindModifier.ambientModifier);
|
||||
|
||||
return result.length > 0 ? result.join(',') : ScriptElementKindModifier.none;
|
||||
}
|
||||
|
||||
export function getTypeArgumentOrTypeParameterList(node: Node): NodeArray<Node> {
|
||||
if (node.kind === SyntaxKind.TypeReference || node.kind === SyntaxKind.CallExpression) {
|
||||
return (<CallExpression>node).typeArguments;
|
||||
}
|
||||
@@ -306,4 +320,166 @@ module ts {
|
||||
return isTemplateLiteralKind(node.kind)
|
||||
&& (node.getStart() < position && position < node.getEnd()) || (!!node.isUnterminated && position === node.getEnd());
|
||||
}
|
||||
|
||||
export function compareDataObjects(dst: any, src: any): boolean {
|
||||
for (var e in dst) {
|
||||
if (typeof dst[e] === "object") {
|
||||
if (!compareDataObjects(dst[e], src[e])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (typeof dst[e] !== "function") {
|
||||
if (dst[e] !== src[e]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Display-part writer helpers
|
||||
module ts {
|
||||
export function isFirstDeclarationOfSymbolParameter(symbol: Symbol) {
|
||||
return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === SyntaxKind.Parameter;
|
||||
}
|
||||
|
||||
var displayPartWriter = getDisplayPartWriter();
|
||||
function getDisplayPartWriter(): DisplayPartsSymbolWriter {
|
||||
var displayParts: SymbolDisplayPart[];
|
||||
var lineStart: boolean;
|
||||
var indent: number;
|
||||
|
||||
resetWriter();
|
||||
return {
|
||||
displayParts: () => displayParts,
|
||||
writeKeyword: text => writeKind(text, SymbolDisplayPartKind.keyword),
|
||||
writeOperator: text => writeKind(text, SymbolDisplayPartKind.operator),
|
||||
writePunctuation: text => writeKind(text, SymbolDisplayPartKind.punctuation),
|
||||
writeSpace: text => writeKind(text, SymbolDisplayPartKind.space),
|
||||
writeStringLiteral: text => writeKind(text, SymbolDisplayPartKind.stringLiteral),
|
||||
writeParameter: text => writeKind(text, SymbolDisplayPartKind.parameterName),
|
||||
writeSymbol,
|
||||
writeLine,
|
||||
increaseIndent: () => { indent++; },
|
||||
decreaseIndent: () => { indent--; },
|
||||
clear: resetWriter,
|
||||
trackSymbol: () => { }
|
||||
};
|
||||
|
||||
function writeIndent() {
|
||||
if (lineStart) {
|
||||
var indentString = getIndentString(indent);
|
||||
if (indentString) {
|
||||
displayParts.push(displayPart(indentString, SymbolDisplayPartKind.space));
|
||||
}
|
||||
lineStart = false;
|
||||
}
|
||||
}
|
||||
|
||||
function writeKind(text: string, kind: SymbolDisplayPartKind) {
|
||||
writeIndent();
|
||||
displayParts.push(displayPart(text, kind));
|
||||
}
|
||||
|
||||
function writeSymbol(text: string, symbol: Symbol) {
|
||||
writeIndent();
|
||||
displayParts.push(symbolPart(text, symbol));
|
||||
}
|
||||
|
||||
function writeLine() {
|
||||
displayParts.push(lineBreakPart());
|
||||
lineStart = true;
|
||||
}
|
||||
|
||||
function resetWriter() {
|
||||
displayParts = []
|
||||
lineStart = true;
|
||||
indent = 0;
|
||||
}
|
||||
}
|
||||
|
||||
export function symbolPart(text: string, symbol: Symbol) {
|
||||
return displayPart(text, displayPartKind(symbol), symbol);
|
||||
|
||||
function displayPartKind(symbol: Symbol): SymbolDisplayPartKind {
|
||||
var flags = symbol.flags;
|
||||
|
||||
if (flags & SymbolFlags.Variable) {
|
||||
return isFirstDeclarationOfSymbolParameter(symbol) ? SymbolDisplayPartKind.parameterName : SymbolDisplayPartKind.localName;
|
||||
}
|
||||
else if (flags & SymbolFlags.Property) { return SymbolDisplayPartKind.propertyName; }
|
||||
else if (flags & SymbolFlags.GetAccessor) { return SymbolDisplayPartKind.propertyName; }
|
||||
else if (flags & SymbolFlags.SetAccessor) { return SymbolDisplayPartKind.propertyName; }
|
||||
else if (flags & SymbolFlags.EnumMember) { return SymbolDisplayPartKind.enumMemberName; }
|
||||
else if (flags & SymbolFlags.Function) { return SymbolDisplayPartKind.functionName; }
|
||||
else if (flags & SymbolFlags.Class) { return SymbolDisplayPartKind.className; }
|
||||
else if (flags & SymbolFlags.Interface) { return SymbolDisplayPartKind.interfaceName; }
|
||||
else if (flags & SymbolFlags.Enum) { return SymbolDisplayPartKind.enumName; }
|
||||
else if (flags & SymbolFlags.Module) { return SymbolDisplayPartKind.moduleName; }
|
||||
else if (flags & SymbolFlags.Method) { return SymbolDisplayPartKind.methodName; }
|
||||
else if (flags & SymbolFlags.TypeParameter) { return SymbolDisplayPartKind.typeParameterName; }
|
||||
else if (flags & SymbolFlags.TypeAlias) { return SymbolDisplayPartKind.aliasName; }
|
||||
else if (flags & SymbolFlags.Import) { return SymbolDisplayPartKind.aliasName; }
|
||||
|
||||
|
||||
return SymbolDisplayPartKind.text;
|
||||
}
|
||||
}
|
||||
|
||||
export function displayPart(text: string, kind: SymbolDisplayPartKind, symbol?: Symbol): SymbolDisplayPart {
|
||||
return <SymbolDisplayPart> {
|
||||
text: text,
|
||||
kind: SymbolDisplayPartKind[kind]
|
||||
};
|
||||
}
|
||||
|
||||
export function spacePart() {
|
||||
return displayPart(" ", SymbolDisplayPartKind.space);
|
||||
}
|
||||
|
||||
export function keywordPart(kind: SyntaxKind) {
|
||||
return displayPart(tokenToString(kind), SymbolDisplayPartKind.keyword);
|
||||
}
|
||||
|
||||
export function punctuationPart(kind: SyntaxKind) {
|
||||
return displayPart(tokenToString(kind), SymbolDisplayPartKind.punctuation);
|
||||
}
|
||||
|
||||
export function operatorPart(kind: SyntaxKind) {
|
||||
return displayPart(tokenToString(kind), SymbolDisplayPartKind.operator);
|
||||
}
|
||||
|
||||
export function textPart(text: string) {
|
||||
return displayPart(text, SymbolDisplayPartKind.text);
|
||||
}
|
||||
|
||||
export function lineBreakPart() {
|
||||
return displayPart("\n", SymbolDisplayPartKind.lineBreak);
|
||||
}
|
||||
|
||||
export function mapToDisplayParts(writeDisplayParts: (writer: DisplayPartsSymbolWriter) => void): SymbolDisplayPart[] {
|
||||
writeDisplayParts(displayPartWriter);
|
||||
var result = displayPartWriter.displayParts();
|
||||
displayPartWriter.clear();
|
||||
return result;
|
||||
}
|
||||
|
||||
export function typeToDisplayParts(typechecker: TypeChecker, type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): SymbolDisplayPart[] {
|
||||
return mapToDisplayParts(writer => {
|
||||
typechecker.getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags);
|
||||
});
|
||||
}
|
||||
|
||||
export function symbolToDisplayParts(typeChecker: TypeChecker, symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): SymbolDisplayPart[] {
|
||||
return mapToDisplayParts(writer => {
|
||||
typeChecker.getSymbolDisplayBuilder().buildSymbolDisplay(symbol, writer, enclosingDeclaration, meaning, flags);
|
||||
});
|
||||
}
|
||||
|
||||
export function signatureToDisplayParts(typechecker: TypeChecker, signature: Signature, enclosingDeclaration?: Node, flags?: TypeFormatFlags): SymbolDisplayPart[] {
|
||||
return mapToDisplayParts(writer => {
|
||||
typechecker.getSymbolDisplayBuilder().buildSignatureDisplay(signature, writer, enclosingDeclaration, flags);
|
||||
});
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,8 +1,8 @@
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts(1,10): error TS9001: 'generators' are not currently supported.
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts(1,10): error TS9001: Generators are not currently supported.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts (1 errors) ====
|
||||
function * foo(a = yield => yield) {
|
||||
~
|
||||
!!! error TS9001: 'generators' are not currently supported.
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration11_es6.ts(1,10): error TS9001: 'generators' are not currently supported.
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration11_es6.ts(1,10): error TS9001: Generators are not currently supported.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration11_es6.ts (1 errors) ====
|
||||
function * yield() {
|
||||
~
|
||||
!!! error TS9001: 'generators' are not currently supported.
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration13_es6.ts(1,10): error TS9001: 'generators' are not currently supported.
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration13_es6.ts(1,10): error TS9001: Generators are not currently supported.
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration13_es6.ts(3,11): error TS2304: Cannot find name 'yield'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration13_es6.ts (2 errors) ====
|
||||
function * foo() {
|
||||
~
|
||||
!!! error TS9001: 'generators' are not currently supported.
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
// Legal to use 'yield' in a type context.
|
||||
var v: yield;
|
||||
~~~~~
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration1_es6.ts(1,10): error TS9001: 'generators' are not currently supported.
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration1_es6.ts(1,10): error TS9001: Generators are not currently supported.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration1_es6.ts (1 errors) ====
|
||||
function * foo() {
|
||||
~
|
||||
!!! error TS9001: 'generators' are not currently supported.
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts(1,9): error TS9001: 'generators' are not currently supported.
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts(1,9): error TS9001: Generators are not currently supported.
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts(1,18): error TS2304: Cannot find name 'yield'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts (2 errors) ====
|
||||
function*foo(a = yield) {
|
||||
~
|
||||
!!! error TS9001: 'generators' are not currently supported.
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
~~~~~
|
||||
!!! error TS2304: Cannot find name 'yield'.
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(1,9): error TS9001: 'generators' are not currently supported.
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(1,9): error TS9001: Generators are not currently supported.
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(3,20): error TS2304: Cannot find name 'yield'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts (2 errors) ====
|
||||
function*bar() {
|
||||
~
|
||||
!!! error TS9001: 'generators' are not currently supported.
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
// 'yield' here is an identifier, and not a yield expression.
|
||||
function*foo(a = yield) {
|
||||
~~~~~
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration8_es6.ts(1,11): error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration8_es6.ts(1,11): error TS9002: Computed property names are not currently supported.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration8_es6.ts (1 errors) ====
|
||||
var v = { [yield]: foo }
|
||||
~~~~~~~
|
||||
!!! error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher.
|
||||
!!! error TS9002: Computed property names are not currently supported.
|
||||
@@ -1,9 +1,9 @@
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts(1,10): error TS9001: 'generators' are not currently supported.
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts(1,10): error TS9001: Generators are not currently supported.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts (1 errors) ====
|
||||
function * foo() {
|
||||
~
|
||||
!!! error TS9001: 'generators' are not currently supported.
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
var v = { [yield]: foo }
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
tests/cases/conformance/es6/functionExpressions/FunctionExpression1_es6.ts(1,18): error TS9001: 'generators' are not currently supported.
|
||||
tests/cases/conformance/es6/functionExpressions/FunctionExpression1_es6.ts(1,18): error TS9001: Generators are not currently supported.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/functionExpressions/FunctionExpression1_es6.ts (1 errors) ====
|
||||
var v = function * () { }
|
||||
~
|
||||
!!! error TS9001: 'generators' are not currently supported.
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
@@ -1,7 +1,7 @@
|
||||
tests/cases/conformance/es6/functionExpressions/FunctionExpression2_es6.ts(1,18): error TS9001: 'generators' are not currently supported.
|
||||
tests/cases/conformance/es6/functionExpressions/FunctionExpression2_es6.ts(1,18): error TS9001: Generators are not currently supported.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/functionExpressions/FunctionExpression2_es6.ts (1 errors) ====
|
||||
var v = function * foo() { }
|
||||
~
|
||||
!!! error TS9001: 'generators' are not currently supported.
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
@@ -1,7 +1,7 @@
|
||||
tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments1_es6.ts(1,11): error TS9001: 'generators' are not currently supported.
|
||||
tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments1_es6.ts(1,11): error TS9001: Generators are not currently supported.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments1_es6.ts (1 errors) ====
|
||||
var v = { *foo() { } }
|
||||
~
|
||||
!!! error TS9001: 'generators' are not currently supported.
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
@@ -1,7 +1,7 @@
|
||||
tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts(1,11): error TS9001: 'generators' are not currently supported.
|
||||
tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts(1,11): error TS9001: Generators are not currently supported.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts (1 errors) ====
|
||||
var v = { *[foo()]() { } }
|
||||
~
|
||||
!!! error TS9001: 'generators' are not currently supported.
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
@@ -1,9 +1,9 @@
|
||||
tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration1_es6.ts(2,4): error TS9001: 'generators' are not currently supported.
|
||||
tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration1_es6.ts(2,4): error TS9001: Generators are not currently supported.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration1_es6.ts (1 errors) ====
|
||||
class C {
|
||||
*foo() { }
|
||||
~
|
||||
!!! error TS9001: 'generators' are not currently supported.
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration2_es6.ts(2,11): error TS9001: 'generators' are not currently supported.
|
||||
tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration2_es6.ts(2,11): error TS9001: Generators are not currently supported.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration2_es6.ts (1 errors) ====
|
||||
class C {
|
||||
public * foo() { }
|
||||
~
|
||||
!!! error TS9001: 'generators' are not currently supported.
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration3_es6.ts(2,4): error TS9001: 'generators' are not currently supported.
|
||||
tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration3_es6.ts(2,4): error TS9001: Generators are not currently supported.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration3_es6.ts (1 errors) ====
|
||||
class C {
|
||||
*[foo]() { }
|
||||
~
|
||||
!!! error TS9001: 'generators' are not currently supported.
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration7_es6.ts(2,4): error TS9001: 'generators' are not currently supported.
|
||||
tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration7_es6.ts(2,4): error TS9001: Generators are not currently supported.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration7_es6.ts (1 errors) ====
|
||||
class C {
|
||||
*foo<T>() { }
|
||||
~
|
||||
!!! error TS9001: 'generators' are not currently supported.
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression10_es6.ts(1,11): error TS9001: 'generators' are not currently supported.
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression10_es6.ts(1,11): error TS9001: Generators are not currently supported.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression10_es6.ts (1 errors) ====
|
||||
var v = { * foo() {
|
||||
~
|
||||
!!! error TS9001: 'generators' are not currently supported.
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
yield(foo);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression11_es6.ts(2,3): error TS9001: 'generators' are not currently supported.
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression11_es6.ts(2,3): error TS9001: Generators are not currently supported.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression11_es6.ts (1 errors) ====
|
||||
class C {
|
||||
*foo() {
|
||||
~
|
||||
!!! error TS9001: 'generators' are not currently supported.
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
yield(foo);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression13_es6.ts(1,9): error TS9001: 'generators' are not currently supported.
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression13_es6.ts(1,9): error TS9001: Generators are not currently supported.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression13_es6.ts (1 errors) ====
|
||||
function* foo() { yield }
|
||||
~
|
||||
!!! error TS9001: 'generators' are not currently supported.
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
@@ -1,10 +1,10 @@
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression16_es6.ts(1,9): error TS9001: 'generators' are not currently supported.
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression16_es6.ts(1,9): error TS9001: Generators are not currently supported.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression16_es6.ts (1 errors) ====
|
||||
function* foo() {
|
||||
~
|
||||
!!! error TS9001: 'generators' are not currently supported.
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
function bar() {
|
||||
yield foo;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression19_es6.ts(1,9): error TS9001: 'generators' are not currently supported.
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression19_es6.ts(1,9): error TS9001: Generators are not currently supported.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression19_es6.ts (1 errors) ====
|
||||
function*foo() {
|
||||
~
|
||||
!!! error TS9001: 'generators' are not currently supported.
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
function bar() {
|
||||
function* quux() {
|
||||
yield(foo);
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression3_es6.ts(1,9): error TS9001: 'generators' are not currently supported.
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression3_es6.ts(1,9): error TS9001: Generators are not currently supported.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression3_es6.ts (1 errors) ====
|
||||
function* foo() {
|
||||
~
|
||||
!!! error TS9001: 'generators' are not currently supported.
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
yield
|
||||
yield
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression4_es6.ts(1,9): error TS9001: 'generators' are not currently supported.
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression4_es6.ts(1,9): error TS9001: Generators are not currently supported.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression4_es6.ts (1 errors) ====
|
||||
function* foo() {
|
||||
~
|
||||
!!! error TS9001: 'generators' are not currently supported.
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
yield;
|
||||
yield;
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression6_es6.ts(1,9): error TS9001: 'generators' are not currently supported.
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression6_es6.ts(1,9): error TS9001: Generators are not currently supported.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression6_es6.ts (1 errors) ====
|
||||
function* foo() {
|
||||
~
|
||||
!!! error TS9001: 'generators' are not currently supported.
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
yield*foo
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression7_es6.ts(1,9): error TS9001: 'generators' are not currently supported.
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression7_es6.ts(1,9): error TS9001: Generators are not currently supported.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression7_es6.ts (1 errors) ====
|
||||
function* foo() {
|
||||
~
|
||||
!!! error TS9001: 'generators' are not currently supported.
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
yield foo
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression8_es6.ts(2,9): error TS9001: 'generators' are not currently supported.
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression8_es6.ts(2,9): error TS9001: Generators are not currently supported.
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression8_es6.ts(1,1): error TS2304: Cannot find name 'yield'.
|
||||
|
||||
|
||||
@@ -8,6 +8,6 @@ tests/cases/conformance/es6/yieldExpressions/YieldExpression8_es6.ts(1,1): error
|
||||
!!! error TS2304: Cannot find name 'yield'.
|
||||
function* foo() {
|
||||
~
|
||||
!!! error TS9001: 'generators' are not currently supported.
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
yield(foo);
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression9_es6.ts(1,17): error TS9001: 'generators' are not currently supported.
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression9_es6.ts(1,17): error TS9001: Generators are not currently supported.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression9_es6.ts (1 errors) ====
|
||||
var v = function*() {
|
||||
~
|
||||
!!! error TS9001: 'generators' are not currently supported.
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
yield(foo);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames1.ts(2,9): error TS9002: Computed property names are not currently supported.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames1.ts(3,9): error TS9002: Computed property names are not currently supported.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames1.ts (2 errors) ====
|
||||
var v = {
|
||||
get [0 + 1]() { return 0 },
|
||||
~~~~~~~
|
||||
!!! error TS9002: Computed property names are not currently supported.
|
||||
set [0 + 1](v: string) { } //No error
|
||||
~~~~~~~
|
||||
!!! error TS9002: Computed property names are not currently supported.
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
//// [computedPropertyNames1.ts]
|
||||
var v = {
|
||||
get [0 + 1]() { return 0 },
|
||||
set [0 + 1](v: string) { } //No error
|
||||
}
|
||||
|
||||
//// [computedPropertyNames1.js]
|
||||
var v = {
|
||||
get [0 + 1]() {
|
||||
return 0;
|
||||
},
|
||||
set [0 + 1](v) {
|
||||
} //No error
|
||||
};
|
||||
@@ -1,12 +0,0 @@
|
||||
=== tests/cases/conformance/es6/computedProperties/computedPropertyNames1.ts ===
|
||||
var v = {
|
||||
>v : {}
|
||||
>{ get [0 + 1]() { return 0 }, set [0 + 1](v: string) { } //No error} : {}
|
||||
|
||||
get [0 + 1]() { return 0 },
|
||||
>0 + 1 : number
|
||||
|
||||
set [0 + 1](v: string) { } //No error
|
||||
>0 + 1 : number
|
||||
>v : string
|
||||
}
|
||||
@@ -1,19 +1,37 @@
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames2.ts(4,5): error TS9002: Computed property names are not currently supported.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames2.ts(5,12): error TS9002: Computed property names are not currently supported.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames2.ts(6,9): error TS9002: Computed property names are not currently supported.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames2.ts(7,9): error TS9002: Computed property names are not currently supported.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames2.ts(8,16): error TS9002: Computed property names are not currently supported.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames2.ts(9,16): error TS9002: Computed property names are not currently supported.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames2.ts(6,9): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames2.ts(8,16): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames2.ts (2 errors) ====
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames2.ts (8 errors) ====
|
||||
var methodName = "method";
|
||||
var accessorName = "accessor";
|
||||
class C {
|
||||
[methodName]() { }
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS9002: Computed property names are not currently supported.
|
||||
static [methodName]() { }
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS9002: Computed property names are not currently supported.
|
||||
get [accessorName]() { }
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS9002: Computed property names are not currently supported.
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement.
|
||||
set [accessorName](v) { }
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS9002: Computed property names are not currently supported.
|
||||
static get [accessorName]() { }
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS9002: Computed property names are not currently supported.
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement.
|
||||
static set [accessorName](v) { }
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS9002: Computed property names are not currently supported.
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
//// [computedPropertyNames2.ts]
|
||||
var methodName = "method";
|
||||
var accessorName = "accessor";
|
||||
class C {
|
||||
[methodName]() { }
|
||||
static [methodName]() { }
|
||||
get [accessorName]() { }
|
||||
set [accessorName](v) { }
|
||||
static get [accessorName]() { }
|
||||
static set [accessorName](v) { }
|
||||
}
|
||||
|
||||
//// [computedPropertyNames2.js]
|
||||
var methodName = "method";
|
||||
var accessorName = "accessor";
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype[methodName] = function () {
|
||||
};
|
||||
C[methodName] = function () {
|
||||
};
|
||||
Object.defineProperty(C.prototype, accessorName, {
|
||||
get: function () {
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(C.prototype, accessorName, {
|
||||
set: function (v) {
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(C, accessorName, {
|
||||
get: function () {
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(C, accessorName, {
|
||||
set: function (v) {
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
return C;
|
||||
})();
|
||||
@@ -1,18 +1,36 @@
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts(3,5): error TS9002: Computed property names are not currently supported.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts(4,12): error TS9002: Computed property names are not currently supported.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts(5,9): error TS9002: Computed property names are not currently supported.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts(6,9): error TS9002: Computed property names are not currently supported.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts(7,16): error TS9002: Computed property names are not currently supported.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts(8,16): error TS9002: Computed property names are not currently supported.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts(5,9): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts(7,16): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts (2 errors) ====
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts (8 errors) ====
|
||||
var id;
|
||||
class C {
|
||||
[0 + 1]() { }
|
||||
~~~~~~~
|
||||
!!! error TS9002: Computed property names are not currently supported.
|
||||
static [() => { }]() { }
|
||||
~~~~~~~~~~~
|
||||
!!! error TS9002: Computed property names are not currently supported.
|
||||
get [delete id]() { }
|
||||
~~~~~~~~~~~
|
||||
!!! error TS9002: Computed property names are not currently supported.
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement.
|
||||
set [[0, 1]](v) { }
|
||||
~~~~~~~~
|
||||
!!! error TS9002: Computed property names are not currently supported.
|
||||
static get [<String>""]() { }
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS9002: Computed property names are not currently supported.
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement.
|
||||
static set [id.toString()](v) { }
|
||||
~~~~~~~~~~~~~~~
|
||||
!!! error TS9002: Computed property names are not currently supported.
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
//// [computedPropertyNames3.ts]
|
||||
var id;
|
||||
class C {
|
||||
[0 + 1]() { }
|
||||
static [() => { }]() { }
|
||||
get [delete id]() { }
|
||||
set [[0, 1]](v) { }
|
||||
static get [<String>""]() { }
|
||||
static set [id.toString()](v) { }
|
||||
}
|
||||
|
||||
//// [computedPropertyNames3.js]
|
||||
var id;
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype[0 + 1] = function () {
|
||||
};
|
||||
C[function () {
|
||||
}] = function () {
|
||||
};
|
||||
Object.defineProperty(C.prototype, delete id, {
|
||||
get: function () {
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(C.prototype, [0, 1], {
|
||||
set: function (v) {
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(C, "", {
|
||||
get: function () {
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(C, id.toString(), {
|
||||
set: function (v) {
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
return C;
|
||||
})();
|
||||
@@ -1,8 +1,9 @@
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads.ts(4,5): error TS1168: Computed property names are not allowed in method overloads.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads.ts(5,5): error TS1168: Computed property names are not allowed in method overloads.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads.ts(6,5): error TS9002: Computed property names are not currently supported.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads.ts (2 errors) ====
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads.ts (3 errors) ====
|
||||
var methodName = "method";
|
||||
var accessorName = "accessor";
|
||||
class C {
|
||||
@@ -13,4 +14,6 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads.
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS1168: Computed property names are not allowed in method overloads.
|
||||
[methodName](v?: string) { }
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS9002: Computed property names are not currently supported.
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
//// [noImplicitAnyIndexingSuppressed.ts]
|
||||
|
||||
enum MyEmusEnum {
|
||||
emu
|
||||
}
|
||||
|
||||
// Should be okay; should be a string.
|
||||
var strRepresentation1 = MyEmusEnum[0]
|
||||
|
||||
// Should be okay; should be a string.
|
||||
var strRepresentation2 = MyEmusEnum[MyEmusEnum.emu]
|
||||
|
||||
// Should be okay, as we suppress implicit 'any' property access checks
|
||||
var strRepresentation3 = MyEmusEnum["monehh"];
|
||||
|
||||
// Should be okay; should be a MyEmusEnum
|
||||
var strRepresentation4 = MyEmusEnum["emu"];
|
||||
|
||||
|
||||
// Should be okay, as we suppress implicit 'any' property access checks
|
||||
var x = {}["hi"];
|
||||
|
||||
// Should be okay, as we suppress implicit 'any' property access checks
|
||||
var y = {}[10];
|
||||
|
||||
var hi: any = "hi";
|
||||
|
||||
var emptyObj = {};
|
||||
|
||||
// Should be okay, as we suppress implicit 'any' property access checks
|
||||
var z1 = emptyObj[hi];
|
||||
var z2 = (<any>emptyObj)[hi];
|
||||
|
||||
interface MyMap<T> {
|
||||
[key: string]: T;
|
||||
}
|
||||
|
||||
var m: MyMap<number> = {
|
||||
"0": 0,
|
||||
"1": 1,
|
||||
"2": 2,
|
||||
"Okay that's enough for today.": NaN
|
||||
};
|
||||
|
||||
var mResult1 = m[MyEmusEnum.emu];
|
||||
var mResult2 = m[MyEmusEnum[MyEmusEnum.emu]];
|
||||
var mResult3 = m[hi];
|
||||
|
||||
|
||||
|
||||
//// [noImplicitAnyIndexingSuppressed.js]
|
||||
var MyEmusEnum;
|
||||
(function (MyEmusEnum) {
|
||||
MyEmusEnum[MyEmusEnum["emu"] = 0] = "emu";
|
||||
})(MyEmusEnum || (MyEmusEnum = {}));
|
||||
// Should be okay; should be a string.
|
||||
var strRepresentation1 = MyEmusEnum[0];
|
||||
// Should be okay; should be a string.
|
||||
var strRepresentation2 = MyEmusEnum[0 /* emu */];
|
||||
// Should be okay, as we suppress implicit 'any' property access checks
|
||||
var strRepresentation3 = MyEmusEnum["monehh"];
|
||||
// Should be okay; should be a MyEmusEnum
|
||||
var strRepresentation4 = 0 /* "emu" */;
|
||||
// Should be okay, as we suppress implicit 'any' property access checks
|
||||
var x = {}["hi"];
|
||||
// Should be okay, as we suppress implicit 'any' property access checks
|
||||
var y = {}[10];
|
||||
var hi = "hi";
|
||||
var emptyObj = {};
|
||||
// Should be okay, as we suppress implicit 'any' property access checks
|
||||
var z1 = emptyObj[hi];
|
||||
var z2 = emptyObj[hi];
|
||||
var m = {
|
||||
"0": 0,
|
||||
"1": 1,
|
||||
"2": 2,
|
||||
"Okay that's enough for today.": NaN
|
||||
};
|
||||
var mResult1 = m[0 /* emu */];
|
||||
var mResult2 = m[MyEmusEnum[0 /* emu */]];
|
||||
var mResult3 = m[hi];
|
||||
@@ -0,0 +1,118 @@
|
||||
=== tests/cases/compiler/noImplicitAnyIndexingSuppressed.ts ===
|
||||
|
||||
enum MyEmusEnum {
|
||||
>MyEmusEnum : MyEmusEnum
|
||||
|
||||
emu
|
||||
>emu : MyEmusEnum
|
||||
}
|
||||
|
||||
// Should be okay; should be a string.
|
||||
var strRepresentation1 = MyEmusEnum[0]
|
||||
>strRepresentation1 : string
|
||||
>MyEmusEnum[0] : string
|
||||
>MyEmusEnum : typeof MyEmusEnum
|
||||
|
||||
// Should be okay; should be a string.
|
||||
var strRepresentation2 = MyEmusEnum[MyEmusEnum.emu]
|
||||
>strRepresentation2 : string
|
||||
>MyEmusEnum[MyEmusEnum.emu] : string
|
||||
>MyEmusEnum : typeof MyEmusEnum
|
||||
>MyEmusEnum.emu : MyEmusEnum
|
||||
>MyEmusEnum : typeof MyEmusEnum
|
||||
>emu : MyEmusEnum
|
||||
|
||||
// Should be okay, as we suppress implicit 'any' property access checks
|
||||
var strRepresentation3 = MyEmusEnum["monehh"];
|
||||
>strRepresentation3 : any
|
||||
>MyEmusEnum["monehh"] : any
|
||||
>MyEmusEnum : typeof MyEmusEnum
|
||||
|
||||
// Should be okay; should be a MyEmusEnum
|
||||
var strRepresentation4 = MyEmusEnum["emu"];
|
||||
>strRepresentation4 : MyEmusEnum
|
||||
>MyEmusEnum["emu"] : MyEmusEnum
|
||||
>MyEmusEnum : typeof MyEmusEnum
|
||||
|
||||
|
||||
// Should be okay, as we suppress implicit 'any' property access checks
|
||||
var x = {}["hi"];
|
||||
>x : any
|
||||
>{}["hi"] : any
|
||||
>{} : {}
|
||||
|
||||
// Should be okay, as we suppress implicit 'any' property access checks
|
||||
var y = {}[10];
|
||||
>y : any
|
||||
>{}[10] : any
|
||||
>{} : {}
|
||||
|
||||
var hi: any = "hi";
|
||||
>hi : any
|
||||
|
||||
var emptyObj = {};
|
||||
>emptyObj : {}
|
||||
>{} : {}
|
||||
|
||||
// Should be okay, as we suppress implicit 'any' property access checks
|
||||
var z1 = emptyObj[hi];
|
||||
>z1 : any
|
||||
>emptyObj[hi] : any
|
||||
>emptyObj : {}
|
||||
>hi : any
|
||||
|
||||
var z2 = (<any>emptyObj)[hi];
|
||||
>z2 : any
|
||||
>(<any>emptyObj)[hi] : any
|
||||
>(<any>emptyObj) : any
|
||||
><any>emptyObj : any
|
||||
>emptyObj : {}
|
||||
>hi : any
|
||||
|
||||
interface MyMap<T> {
|
||||
>MyMap : MyMap<T>
|
||||
>T : T
|
||||
|
||||
[key: string]: T;
|
||||
>key : string
|
||||
>T : T
|
||||
}
|
||||
|
||||
var m: MyMap<number> = {
|
||||
>m : MyMap<number>
|
||||
>MyMap : MyMap<T>
|
||||
>{ "0": 0, "1": 1, "2": 2, "Okay that's enough for today.": NaN} : { [x: string]: number; "0": number; "1": number; "2": number; "Okay that's enough for today.": number; }
|
||||
|
||||
"0": 0,
|
||||
"1": 1,
|
||||
"2": 2,
|
||||
"Okay that's enough for today.": NaN
|
||||
>NaN : number
|
||||
|
||||
};
|
||||
|
||||
var mResult1 = m[MyEmusEnum.emu];
|
||||
>mResult1 : number
|
||||
>m[MyEmusEnum.emu] : number
|
||||
>m : MyMap<number>
|
||||
>MyEmusEnum.emu : MyEmusEnum
|
||||
>MyEmusEnum : typeof MyEmusEnum
|
||||
>emu : MyEmusEnum
|
||||
|
||||
var mResult2 = m[MyEmusEnum[MyEmusEnum.emu]];
|
||||
>mResult2 : number
|
||||
>m[MyEmusEnum[MyEmusEnum.emu]] : number
|
||||
>m : MyMap<number>
|
||||
>MyEmusEnum[MyEmusEnum.emu] : string
|
||||
>MyEmusEnum : typeof MyEmusEnum
|
||||
>MyEmusEnum.emu : MyEmusEnum
|
||||
>MyEmusEnum : typeof MyEmusEnum
|
||||
>emu : MyEmusEnum
|
||||
|
||||
var mResult3 = m[hi];
|
||||
>mResult3 : number
|
||||
>m[hi] : number
|
||||
>m : MyMap<number>
|
||||
>hi : any
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName12.ts(2,4): error TS9002: Computed property names are not currently supported.
|
||||
|
||||
|
||||
==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName12.ts (1 errors) ====
|
||||
class C {
|
||||
[e]() { }
|
||||
~~~
|
||||
!!! error TS9002: Computed property names are not currently supported.
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
//// [parserComputedPropertyName12.ts]
|
||||
class C {
|
||||
[e]() { }
|
||||
}
|
||||
|
||||
//// [parserComputedPropertyName12.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype[e] = function () {
|
||||
};
|
||||
return C;
|
||||
})();
|
||||
@@ -1,7 +0,0 @@
|
||||
=== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName12.ts ===
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
[e]() { }
|
||||
>e : unknown
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName17.ts(1,15): error TS9002: Computed property names are not currently supported.
|
||||
|
||||
|
||||
==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName17.ts (1 errors) ====
|
||||
var v = { set [e](v) { } }
|
||||
~~~
|
||||
!!! error TS9002: Computed property names are not currently supported.
|
||||
@@ -1,6 +0,0 @@
|
||||
//// [parserComputedPropertyName17.ts]
|
||||
var v = { set [e](v) { } }
|
||||
|
||||
//// [parserComputedPropertyName17.js]
|
||||
var v = { set [e](v) {
|
||||
} };
|
||||
@@ -1,7 +0,0 @@
|
||||
=== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName17.ts ===
|
||||
var v = { set [e](v) { } }
|
||||
>v : {}
|
||||
>{ set [e](v) { } } : {}
|
||||
>e : unknown
|
||||
>v : any
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName2.ts(1,11): error TS9002: Computed property names are not currently supported.
|
||||
|
||||
|
||||
==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName2.ts (1 errors) ====
|
||||
var v = { [e]: 1 };
|
||||
~~~
|
||||
!!! error TS9002: Computed property names are not currently supported.
|
||||
@@ -1,5 +0,0 @@
|
||||
//// [parserComputedPropertyName2.ts]
|
||||
var v = { [e]: 1 };
|
||||
|
||||
//// [parserComputedPropertyName2.js]
|
||||
var v = { [e]: 1 };
|
||||
@@ -1,6 +0,0 @@
|
||||
=== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName2.ts ===
|
||||
var v = { [e]: 1 };
|
||||
>v : {}
|
||||
>{ [e]: 1 } : {}
|
||||
>e : unknown
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName24.ts(2,9): error TS9002: Computed property names are not currently supported.
|
||||
|
||||
|
||||
==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName24.ts (1 errors) ====
|
||||
class C {
|
||||
set [e](v) { }
|
||||
~~~
|
||||
!!! error TS9002: Computed property names are not currently supported.
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
//// [parserComputedPropertyName24.ts]
|
||||
class C {
|
||||
set [e](v) { }
|
||||
}
|
||||
|
||||
//// [parserComputedPropertyName24.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
Object.defineProperty(C.prototype, e, {
|
||||
set: function (v) {
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
return C;
|
||||
})();
|
||||
@@ -1,8 +0,0 @@
|
||||
=== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName24.ts ===
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
set [e](v) { }
|
||||
>e : unknown
|
||||
>v : any
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName3.ts(1,11): error TS9002: Computed property names are not currently supported.
|
||||
|
||||
|
||||
==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName3.ts (1 errors) ====
|
||||
var v = { [e]() { } };
|
||||
~~~
|
||||
!!! error TS9002: Computed property names are not currently supported.
|
||||
@@ -1,6 +0,0 @@
|
||||
//// [parserComputedPropertyName3.ts]
|
||||
var v = { [e]() { } };
|
||||
|
||||
//// [parserComputedPropertyName3.js]
|
||||
var v = { [e]() {
|
||||
} };
|
||||
@@ -1,6 +0,0 @@
|
||||
=== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName3.ts ===
|
||||
var v = { [e]() { } };
|
||||
>v : {}
|
||||
>{ [e]() { } } : {}
|
||||
>e : unknown
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName35.ts(2,6): error TS1171: A comma expression is not allowed in a computed property name.
|
||||
tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName35.ts(2,5): error TS9002: Computed property names are not currently supported.
|
||||
|
||||
|
||||
==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName35.ts (1 errors) ====
|
||||
var x = {
|
||||
[0, 1]: { }
|
||||
~~~~
|
||||
!!! error TS1171: A comma expression is not allowed in a computed property name.
|
||||
~~~~~~
|
||||
!!! error TS9002: Computed property names are not currently supported.
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName37.ts(2,5): error TS9002: Computed property names are not currently supported.
|
||||
|
||||
|
||||
==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName37.ts (1 errors) ====
|
||||
var v = {
|
||||
[public]: 0
|
||||
~~~~~~~~
|
||||
!!! error TS9002: Computed property names are not currently supported.
|
||||
};
|
||||
@@ -1,9 +0,0 @@
|
||||
//// [parserComputedPropertyName37.ts]
|
||||
var v = {
|
||||
[public]: 0
|
||||
};
|
||||
|
||||
//// [parserComputedPropertyName37.js]
|
||||
var v = {
|
||||
[public]: 0
|
||||
};
|
||||
@@ -1,9 +0,0 @@
|
||||
=== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName37.ts ===
|
||||
var v = {
|
||||
>v : {}
|
||||
>{ [public]: 0} : {}
|
||||
|
||||
[public]: 0
|
||||
>public : unknown
|
||||
|
||||
};
|
||||
@@ -0,0 +1,9 @@
|
||||
tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName38.ts(2,5): error TS9002: Computed property names are not currently supported.
|
||||
|
||||
|
||||
==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName38.ts (1 errors) ====
|
||||
class C {
|
||||
[public]() { }
|
||||
~~~~~~~~
|
||||
!!! error TS9002: Computed property names are not currently supported.
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
//// [parserComputedPropertyName38.ts]
|
||||
class C {
|
||||
[public]() { }
|
||||
}
|
||||
|
||||
//// [parserComputedPropertyName38.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype[public] = function () {
|
||||
};
|
||||
return C;
|
||||
})();
|
||||
@@ -1,7 +0,0 @@
|
||||
=== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName38.ts ===
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
[public]() { }
|
||||
>public : unknown
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName4.ts(1,15): error TS9002: Computed property names are not currently supported.
|
||||
|
||||
|
||||
==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName4.ts (1 errors) ====
|
||||
var v = { get [e]() { } };
|
||||
~~~
|
||||
!!! error TS9002: Computed property names are not currently supported.
|
||||
@@ -1,6 +0,0 @@
|
||||
//// [parserComputedPropertyName4.ts]
|
||||
var v = { get [e]() { } };
|
||||
|
||||
//// [parserComputedPropertyName4.js]
|
||||
var v = { get [e]() {
|
||||
} };
|
||||
@@ -1,6 +0,0 @@
|
||||
=== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName4.ts ===
|
||||
var v = { get [e]() { } };
|
||||
>v : {}
|
||||
>{ get [e]() { } } : {}
|
||||
>e : unknown
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName40.ts(2,5): error TS9002: Computed property names are not currently supported.
|
||||
|
||||
|
||||
==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName40.ts (1 errors) ====
|
||||
class C {
|
||||
[a ? "" : ""]() {}
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS9002: Computed property names are not currently supported.
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
//// [parserComputedPropertyName40.ts]
|
||||
class C {
|
||||
[a ? "" : ""]() {}
|
||||
}
|
||||
|
||||
//// [parserComputedPropertyName40.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype[a ? "" : ""] = function () {
|
||||
};
|
||||
return C;
|
||||
})();
|
||||
@@ -1,8 +0,0 @@
|
||||
=== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName40.ts ===
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
[a ? "" : ""]() {}
|
||||
>a ? "" : "" : string
|
||||
>a : unknown
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName41.ts(2,5): error TS9002: Computed property names are not currently supported.
|
||||
|
||||
|
||||
==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName41.ts (1 errors) ====
|
||||
var v = {
|
||||
[0 in []]: true
|
||||
~~~~~~~~~
|
||||
!!! error TS9002: Computed property names are not currently supported.
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user