Merge branch 'master' into decorators_types

This commit is contained in:
Ron Buckton 2015-04-06 11:06:38 -07:00
commit 1a1813363e
125 changed files with 2716 additions and 1528 deletions

View file

@ -144,7 +144,8 @@ var harnessSources = [
"services/colorization.ts",
"services/documentRegistry.ts",
"services/preProcessFile.ts",
"services/patternMatcher.ts"
"services/patternMatcher.ts",
"versionCache.ts"
].map(function (f) {
return path.join(unittestsDirectory, f);
})).concat([

View file

@ -388,23 +388,28 @@ module ts {
bindChildren(node, /*symbolKind:*/ 0, /*isBlockScopeContainer:*/ true);
}
function bindBlockScopedVariableDeclaration(node: Declaration) {
function bindBlockScopedDeclaration(node: Declaration, symbolKind: SymbolFlags, symbolExcludes: SymbolFlags) {
switch (blockScopeContainer.kind) {
case SyntaxKind.ModuleDeclaration:
declareModuleMember(node, SymbolFlags.BlockScopedVariable, SymbolFlags.BlockScopedVariableExcludes);
declareModuleMember(node, symbolKind, symbolExcludes);
break;
case SyntaxKind.SourceFile:
if (isExternalModule(<SourceFile>container)) {
declareModuleMember(node, SymbolFlags.BlockScopedVariable, SymbolFlags.BlockScopedVariableExcludes);
declareModuleMember(node, symbolKind, symbolExcludes);
break;
}
// fall through.
default:
if (!blockScopeContainer.locals) {
blockScopeContainer.locals = {};
}
declareSymbol(blockScopeContainer.locals, undefined, node, SymbolFlags.BlockScopedVariable, SymbolFlags.BlockScopedVariableExcludes);
declareSymbol(blockScopeContainer.locals, undefined, node, symbolKind, symbolExcludes);
}
bindChildren(node, SymbolFlags.BlockScopedVariable, /*isBlockScopeContainer*/ false);
bindChildren(node, symbolKind, /*isBlockScopeContainer*/ false);
}
function bindBlockScopedVariableDeclaration(node: Declaration) {
bindBlockScopedDeclaration(node, SymbolFlags.BlockScopedVariable, SymbolFlags.BlockScopedVariableExcludes);
}
function getDestructuringParameterName(node: Declaration) {
@ -493,7 +498,7 @@ module ts {
bindCatchVariableDeclaration(<CatchClause>node);
break;
case SyntaxKind.ClassDeclaration:
bindDeclaration(<Declaration>node, SymbolFlags.Class, SymbolFlags.ClassExcludes, /*isBlockScopeContainer*/ false);
bindBlockScopedDeclaration(<Declaration>node, SymbolFlags.Class, SymbolFlags.ClassExcludes);
break;
case SyntaxKind.InterfaceDeclaration:
bindDeclaration(<Declaration>node, SymbolFlags.Interface, SymbolFlags.InterfaceExcludes, /*isBlockScopeContainer*/ false);

View file

@ -74,7 +74,7 @@ module ts {
isImplementationOfOverload,
getAliasedSymbol: resolveAlias,
getEmitResolver,
getExportsOfExternalModule,
getExportsOfModule: getExportsOfModuleAsArray,
};
let unknownSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Transient, "unknown");
@ -899,6 +899,10 @@ module ts {
return moduleSymbol.exports["export="];
}
function getExportsOfModuleAsArray(moduleSymbol: Symbol): Symbol[] {
return symbolsToArray(getExportsOfModule(moduleSymbol));
}
function getExportsOfSymbol(symbol: Symbol): SymbolTable {
return symbol.flags & SymbolFlags.Module ? getExportsOfModule(symbol) : symbol.exports || emptySymbols;
}
@ -3043,17 +3047,6 @@ module ts {
return result;
}
function getExportsOfExternalModule(node: ImportDeclaration): Symbol[] {
if (!node.moduleSpecifier) {
return emptyArray;
}
let module = resolveExternalModuleName(node, node.moduleSpecifier);
if (!module) {
return emptyArray;
}
return symbolsToArray(getExportsOfModule(module));
}
function getSignatureFromDeclaration(declaration: SignatureDeclaration): Signature {
let links = getNodeLinks(declaration);
if (!links.resolvedSignature) {
@ -9846,6 +9839,10 @@ module ts {
grammarErrorOnNode(node, Diagnostics.class_declarations_are_only_supported_directly_inside_a_module_or_as_a_top_level_declaration);
}
if (!node.name && !(node.flags & NodeFlags.Default)) {
grammarErrorOnFirstToken(node, Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name);
}
checkGrammarClassDeclarationHeritageClauses(node);
checkDecorators(node);
if (node.name) {
@ -12729,7 +12726,16 @@ module ts {
let identifier = <Identifier>name;
if (contextNode && (contextNode.parserContextFlags & ParserContextFlags.StrictMode) && isEvalOrArgumentsIdentifier(identifier)) {
let nameText = declarationNameToString(identifier);
return grammarErrorOnNode(identifier, Diagnostics.Invalid_use_of_0_in_strict_mode, nameText);
// We are checking if this name is inside class declaration or class expression (which are under class definitions inside ES6 spec.)
// if so, we would like to give more explicit invalid usage error.
// This will be particularly helpful in the case of "arguments" as such case is very common mistake.
if (getAncestor(name, SyntaxKind.ClassDeclaration) || getAncestor(name, SyntaxKind.ClassExpression)) {
return grammarErrorOnNode(identifier, Diagnostics.Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode, nameText);
}
else {
return grammarErrorOnNode(identifier, Diagnostics.Invalid_use_of_0_in_strict_mode, nameText);
}
}
}
}

View file

@ -167,6 +167,8 @@ module ts {
Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: { code: 1207, category: DiagnosticCategory.Error, key: "Decorators cannot be applied to multiple get/set accessors of the same name." },
Cannot_compile_non_external_modules_when_the_separateCompilation_flag_is_provided: { code: 1208, category: DiagnosticCategory.Error, key: "Cannot compile non-external modules when the '--separateCompilation' flag is provided." },
Ambient_const_enums_are_not_allowed_when_the_separateCompilation_flag_is_provided: { code: 1209, category: DiagnosticCategory.Error, key: "Ambient const enums are not allowed when the '--separateCompilation' flag is provided." },
Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: { code: 1210, category: DiagnosticCategory.Error, key: "Invalid use of '{0}'. Class definitions are automatically in strict mode." },
A_class_declaration_without_the_default_modifier_must_have_a_name: { code: 1211, category: DiagnosticCategory.Error, key: "A class declaration without the 'default' modifier must have a name" },
Duplicate_identifier_0: { code: 2300, category: DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." },
Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." },
Static_members_cannot_reference_class_type_parameters: { code: 2302, category: DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." },
@ -505,6 +507,22 @@ 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." },
You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: { code: 8001, category: DiagnosticCategory.Error, key: "You cannot rename elements that are defined in the standard TypeScript library." },
import_can_only_be_used_in_a_ts_file: { code: 8002, category: DiagnosticCategory.Error, key: "'import ... =' can only be used in a .ts file." },
export_can_only_be_used_in_a_ts_file: { code: 8003, category: DiagnosticCategory.Error, key: "'export=' can only be used in a .ts file." },
type_parameter_declarations_can_only_be_used_in_a_ts_file: { code: 8004, category: DiagnosticCategory.Error, key: "'type parameter declarations' can only be used in a .ts file." },
implements_clauses_can_only_be_used_in_a_ts_file: { code: 8005, category: DiagnosticCategory.Error, key: "'implements clauses' can only be used in a .ts file." },
interface_declarations_can_only_be_used_in_a_ts_file: { code: 8006, category: DiagnosticCategory.Error, key: "'interface declarations' can only be used in a .ts file." },
module_declarations_can_only_be_used_in_a_ts_file: { code: 8007, category: DiagnosticCategory.Error, key: "'module declarations' can only be used in a .ts file." },
type_aliases_can_only_be_used_in_a_ts_file: { code: 8008, category: DiagnosticCategory.Error, key: "'type aliases' can only be used in a .ts file." },
_0_can_only_be_used_in_a_ts_file: { code: 8009, category: DiagnosticCategory.Error, key: "'{0}' can only be used in a .ts file." },
types_can_only_be_used_in_a_ts_file: { code: 8010, category: DiagnosticCategory.Error, key: "'types' can only be used in a .ts file." },
type_arguments_can_only_be_used_in_a_ts_file: { code: 8011, category: DiagnosticCategory.Error, key: "'type arguments' can only be used in a .ts file." },
parameter_modifiers_can_only_be_used_in_a_ts_file: { code: 8012, category: DiagnosticCategory.Error, key: "'parameter modifiers' can only be used in a .ts file." },
can_only_be_used_in_a_ts_file: { code: 8013, category: DiagnosticCategory.Error, key: "'?' can only be used in a .ts file." },
property_declarations_can_only_be_used_in_a_ts_file: { code: 8014, category: DiagnosticCategory.Error, key: "'property declarations' can only be used in a .ts file." },
enum_declarations_can_only_be_used_in_a_ts_file: { code: 8015, category: DiagnosticCategory.Error, key: "'enum declarations' can only be used in a .ts file." },
type_assertion_expressions_can_only_be_used_in_a_ts_file: { code: 8016, category: DiagnosticCategory.Error, key: "'type assertion expressions' can only be used in a .ts file." },
decorators_can_only_be_used_in_a_ts_file: { code: 8017, category: DiagnosticCategory.Error, key: "'decorators' can only be used in a .ts file." },
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." },
Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clauses: { code: 9002, category: DiagnosticCategory.Error, key: "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses." },

View file

@ -659,6 +659,14 @@
"category": "Error",
"code": 1209
},
"Invalid use of '{0}'. Class definitions are automatically in strict mode.": {
"category": "Error",
"code": 1210
},
"A class declaration without the 'default' modifier must have a name": {
"category": "Error",
"code": 1211
},
"Duplicate identifier '{0}'.": {
"category": "Error",
"code": 2300
@ -2013,6 +2021,71 @@
"category": "Error",
"code": 8001
},
"'import ... =' can only be used in a .ts file.": {
"category": "Error",
"code": 8002
},
"'export=' can only be used in a .ts file.": {
"category": "Error",
"code": 8003
},
"'type parameter declarations' can only be used in a .ts file.": {
"category": "Error",
"code": 8004
},
"'implements clauses' can only be used in a .ts file.": {
"category": "Error",
"code": 8005
},
"'interface declarations' can only be used in a .ts file.": {
"category": "Error",
"code": 8006
},
"'module declarations' can only be used in a .ts file.": {
"category": "Error",
"code": 8007
},
"'type aliases' can only be used in a .ts file.": {
"category": "Error",
"code": 8008
},
"'{0}' can only be used in a .ts file.": {
"category": "Error",
"code": 8009
},
"'types' can only be used in a .ts file.": {
"category": "Error",
"code": 8010
},
"'type arguments' can only be used in a .ts file.": {
"category": "Error",
"code": 8011
},
"'parameter modifiers' can only be used in a .ts file.": {
"category": "Error",
"code": 8012
},
"'?' can only be used in a .ts file.": {
"category": "Error",
"code": 8013
},
"'property declarations' can only be used in a .ts file.": {
"category": "Error",
"code": 8014
},
"'enum declarations' can only be used in a .ts file.": {
"category": "Error",
"code": 8015
},
"'type assertion expressions' can only be used in a .ts file.": {
"category": "Error",
"code": 8016
},
"'decorators' can only be used in a .ts file.": {
"category": "Error",
"code": 8017
},
"'yield' expressions are not currently supported.": {
"category": "Error",
"code": 9000

View file

@ -290,6 +290,7 @@ var __param = this.__param || function(index, decorator) { return function (targ
switch (node.kind) {
case SyntaxKind.FunctionDeclaration:
case SyntaxKind.ClassDeclaration:
case SyntaxKind.ClassExpression:
generateNameForFunctionOrClassDeclaration(<Declaration>node);
break;
case SyntaxKind.ModuleDeclaration:
@ -3231,28 +3232,49 @@ var __param = this.__param || function(index, decorator) { return function (targ
}
}
function emitMemberAssignments(node: ClassLikeDeclaration, staticFlag: NodeFlags) {
forEach(node.members, member => {
if (member.kind === SyntaxKind.PropertyDeclaration && (member.flags & NodeFlags.Static) === staticFlag && (<PropertyDeclaration>member).initializer) {
writeLine();
emitLeadingComments(member);
emitStart(member);
emitStart((<PropertyDeclaration>member).name);
if (staticFlag) {
emitDeclarationName(node);
}
else {
write("this");
}
emitMemberAccessForPropertyName((<PropertyDeclaration>member).name);
emitEnd((<PropertyDeclaration>member).name);
write(" = ");
emit((<PropertyDeclaration>member).initializer);
write(";");
emitEnd(member);
emitTrailingComments(member);
function getInitializedProperties(node: ClassLikeDeclaration, static: boolean) {
let properties: PropertyDeclaration[] = [];
for (let member of node.members) {
if (member.kind === SyntaxKind.PropertyDeclaration && static === ((member.flags & NodeFlags.Static) !== 0) && (<PropertyDeclaration>member).initializer) {
properties.push(<PropertyDeclaration>member);
}
});
}
return properties;
}
function emitPropertyDeclarations(node: ClassLikeDeclaration, properties: PropertyDeclaration[]) {
for (let property of properties) {
emitPropertyDeclaration(node, property);
}
}
function emitPropertyDeclaration(node: ClassLikeDeclaration, property: PropertyDeclaration, receiver?: Identifier, isExpression?: boolean) {
writeLine();
emitLeadingComments(property);
emitStart(property);
emitStart(property.name);
if (receiver) {
emit(receiver);
}
else {
if (property.flags & NodeFlags.Static) {
emitDeclarationName(node);
}
else {
write("this");
}
}
emitMemberAccessForPropertyName(property.name);
emitEnd(property.name);
write(" = ");
emit(property.initializer);
if (!isExpression) {
write(";");
}
emitEnd(property);
emitTrailingComments(property);
}
function emitMemberFunctionsForES5AndLower(node: ClassLikeDeclaration) {
@ -3370,6 +3392,14 @@ var __param = this.__param || function(index, decorator) { return function (targ
tempVariables = undefined;
tempParameters = undefined;
emitConstructorWorker(node, baseTypeElement);
tempFlags = saveTempFlags;
tempVariables = saveTempVariables;
tempParameters = saveTempParameters;
}
function emitConstructorWorker(node: ClassLikeDeclaration, baseTypeElement: HeritageClauseElement) {
// Check if we have property assignment inside class declaration.
// If there is property assignment, we need to emit constructor whether users define it or not
// If there is no property assignment, we can omit constructor if users do not define it
@ -3457,7 +3487,7 @@ var __param = this.__param || function(index, decorator) { return function (targ
emitEnd(baseTypeElement);
}
}
emitMemberAssignments(node, /*staticFlag*/0);
emitPropertyDeclarations(node, getInitializedProperties(node, /*static:*/ false));
if (ctor) {
var statements: Node[] = (<Block>ctor.body).statements;
if (superCall) {
@ -3477,10 +3507,6 @@ var __param = this.__param || function(index, decorator) { return function (targ
if (ctor) {
emitTrailingComments(ctor);
}
tempFlags = saveTempFlags;
tempVariables = saveTempVariables;
tempParameters = saveTempParameters;
}
function emitClassExpression(node: ClassExpression) {
@ -3572,6 +3598,29 @@ var __param = this.__param || function(index, decorator) { return function (targ
}
}
// If the class has static properties, and it's a class expression, then we'll need
// to specialize the emit a bit. for a class expression of the form:
//
// class C { static a = 1; static b = 2; ... }
//
// We'll emit:
//
// (_temp = class C { ... }, _temp.a = 1, _temp.b = 2, _temp)
//
// This keeps the expression as an expression, while ensuring that the static parts
// of it have been initialized by the time it is used.
let staticProperties = getInitializedProperties(node, /*static:*/ true);
let isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === SyntaxKind.ClassExpression;
let tempVariable: Identifier;
if (isClassExpressionWithStaticProperties) {
tempVariable = createAndRecordTempVariable(TempFlags.Auto);
write("(");
increaseIndent();
emit(tempVariable);
write(" = ")
}
write("class");
// check if this is an "export default class" as it may not have a name. Do not emit the name if the class is decorated.
@ -3622,9 +3671,24 @@ var __param = this.__param || function(index, decorator) { return function (targ
// From ES6 specification:
// HasLexicalDeclaration (N) : Determines if the argument identifier has a binding in this environment record that was created using
// a lexical declaration such as a LexicalDeclaration or a ClassDeclaration.
writeLine();
emitMemberAssignments(node, NodeFlags.Static);
emitDecoratorsOfClass(node);
if (isClassExpressionWithStaticProperties) {
for (var property of staticProperties) {
write(",");
writeLine();
emitPropertyDeclaration(node, property, /*receiver:*/ tempVariable, /*isExpression:*/ true);
}
write(",");
writeLine();
emit(tempVariable);
decreaseIndent();
write(")");
}
else {
writeLine();
emitPropertyDeclarations(node, staticProperties);
emitDecoratorsOfClass(node);
}
// If this is an exported class, but not on the top level (i.e. on an internal
// module), export it
@ -3680,7 +3744,7 @@ var __param = this.__param || function(index, decorator) { return function (targ
writeLine();
emitConstructor(node, baseTypeNode);
emitMemberFunctionsForES5AndLower(node);
emitMemberAssignments(node, NodeFlags.Static);
emitPropertyDeclarations(node, getInitializedProperties(node, /*static:*/ true));
writeLine();
emitDecoratorsOfClass(node);
writeLine();

View file

@ -828,7 +828,7 @@ module ts {
// to reuse are already at the appropriate position in the new text. That way when we
// reuse them, we don't have to figure out if they need to be adjusted. Second, it makes
// it very easy to determine if we can reuse a node. If the node's position is at where
// we are in the text, then we can reuse it. Otherwise we can't. If hte node's position
// we are in the text, then we can reuse it. Otherwise we can't. If the node's position
// is ahead of us, then we'll need to rescan tokens. If the node's position is behind
// us, then we'll need to skip it or crumble it as appropriate
//
@ -1033,7 +1033,7 @@ module ts {
// that some tokens that would be considered identifiers may be considered keywords.
//
// When adding more parser context flags, consider which is the more common case that the
// flag will be in. This should be hte 'false' state for that flag. The reason for this is
// flag will be in. This should be the 'false' state for that flag. The reason for this is
// that we don't store data in our nodes unless the value is in the *non-default* state. So,
// for example, more often than code 'allows-in' (or doesn't 'disallow-in'). We opt for
// 'disallow-in' set to 'false'. Otherwise, if we had 'allowsIn' set to 'true', then almost
@ -1044,7 +1044,7 @@ module ts {
//
// An important thing about these context concepts. By default they are effectively inherited
// while parsing through every grammar production. i.e. if you don't change them, then when
// you parse a sub-production, it will have the same context values as hte parent production.
// you parse a sub-production, it will have the same context values as the parent production.
// This is great most of the time. After all, consider all the 'expression' grammar productions
// and how nearly all of them pass along the 'in' and 'yield' context values:
//
@ -1836,7 +1836,7 @@ module ts {
// some node, then we cannot get a node from the old source tree. This is because we
// want to mark the next node we encounter as being unusable.
//
// Note: This may be too conservative. Perhaps we could reuse hte node and set the bit
// Note: This may be too conservative. Perhaps we could reuse the node and set the bit
// on it (or its leftmost child) as having the error. For now though, being conservative
// is nice and likely won't ever affect perf.
if (parseErrorBeforeNextFinishedNode) {
@ -4756,15 +4756,13 @@ module ts {
function parseClassDeclarationOrExpression(fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray, kind: SyntaxKind): ClassLikeDeclaration {
// In ES6 specification, All parts of a ClassDeclaration or a ClassExpression are strict mode code
let savedStrictModeContext = inStrictModeContext();
if (languageVersion >= ScriptTarget.ES6) {
setStrictModeContext(true);
}
setStrictModeContext(true);
var node = <ClassLikeDeclaration>createNode(kind, fullStart);
node.decorators = decorators;
setModifiers(node, modifiers);
parseExpected(SyntaxKind.ClassKeyword);
node.name = node.flags & NodeFlags.Default ? parseOptionalIdentifier() : parseIdentifier();
node.name = parseOptionalIdentifier();
node.typeParameters = parseTypeParameters();
node.heritageClauses = parseHeritageClauses(/*isClassHeritageClause:*/ true);

View file

@ -933,7 +933,7 @@ module ts {
// import "mod" => importClause = undefined, moduleSpecifier = "mod"
// In rest of the cases, module specifier is string literal corresponding to module
// ImportClause information is shown at its declaration below.
export interface ImportDeclaration extends Statement, ModuleElement {
export interface ImportDeclaration extends ModuleElement {
importClause?: ImportClause;
moduleSpecifier: Expression;
}
@ -1146,7 +1146,7 @@ module ts {
getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number;
isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean;
getAliasedSymbol(symbol: Symbol): Symbol;
getExportsOfExternalModule(node: ImportDeclaration): Symbol[];
getExportsOfModule(moduleSymbol: Symbol): Symbol[];
// Should not be called directly. Should only be accessed through the Program instance.
/* @internal */ getDiagnostics(sourceFile?: SourceFile): Diagnostic[];

View file

@ -14,6 +14,7 @@
//
/// <reference path='..\services\services.ts' />
/// <reference path='..\services\shims.ts' />
/// <reference path='harnessLanguageService.ts' />
/// <reference path='harness.ts' />
/// <reference path='fourslashRunner.ts' />
@ -115,7 +116,7 @@ module FourSlash {
// Name of testcase metadata including ts.CompilerOptions properties that will be used by globalOptions
// To add additional option, add property into the testOptMetadataNames, refer the property in either globalMetadataNames or fileMetadataNames
// Add cases into convertGlobalOptionsToCompilationsSettings function for the compiler to acknowledge such option from meta data
var testOptMetadataNames = {
var metadataOptionNames = {
baselineFile: 'BaselineFile',
declaration: 'declaration',
emitThisFile: 'emitThisFile', // This flag is used for testing getEmitOutput feature. It allows test-cases to indicate what file to be output in multiple files project
@ -126,14 +127,15 @@ module FourSlash {
outDir: 'outDir',
sourceMap: 'sourceMap',
sourceRoot: 'sourceRoot',
allowNonTsExtensions: 'allowNonTsExtensions',
resolveReference: 'ResolveReference', // This flag is used to specify entry file for resolve file references. The flag is only allow once per test file
};
// List of allowed metadata names
var fileMetadataNames = [testOptMetadataNames.fileName, testOptMetadataNames.emitThisFile, testOptMetadataNames.resolveReference];
var globalMetadataNames = [testOptMetadataNames.baselineFile, testOptMetadataNames.declaration,
testOptMetadataNames.mapRoot, testOptMetadataNames.module, testOptMetadataNames.out,
testOptMetadataNames.outDir, testOptMetadataNames.sourceMap, testOptMetadataNames.sourceRoot]
var fileMetadataNames = [metadataOptionNames.fileName, metadataOptionNames.emitThisFile, metadataOptionNames.resolveReference];
var globalMetadataNames = [metadataOptionNames.allowNonTsExtensions, metadataOptionNames.baselineFile, metadataOptionNames.declaration,
metadataOptionNames.mapRoot, metadataOptionNames.module, metadataOptionNames.out,
metadataOptionNames.outDir, metadataOptionNames.sourceMap, metadataOptionNames.sourceRoot]
function convertGlobalOptionsToCompilerOptions(globalOptions: { [idx: string]: string }): ts.CompilerOptions {
var settings: ts.CompilerOptions = { target: ts.ScriptTarget.ES5 };
@ -141,13 +143,16 @@ module FourSlash {
for (var prop in globalOptions) {
if (globalOptions.hasOwnProperty(prop)) {
switch (prop) {
case testOptMetadataNames.declaration:
case metadataOptionNames.allowNonTsExtensions:
settings.allowNonTsExtensions = true;
break;
case metadataOptionNames.declaration:
settings.declaration = true;
break;
case testOptMetadataNames.mapRoot:
case metadataOptionNames.mapRoot:
settings.mapRoot = globalOptions[prop];
break;
case testOptMetadataNames.module:
case metadataOptionNames.module:
// create appropriate external module target for CompilationSettings
switch (globalOptions[prop]) {
case "AMD":
@ -162,16 +167,16 @@ module FourSlash {
break;
}
break;
case testOptMetadataNames.out:
case metadataOptionNames.out:
settings.out = globalOptions[prop];
break;
case testOptMetadataNames.outDir:
case metadataOptionNames.outDir:
settings.outDir = globalOptions[prop];
break;
case testOptMetadataNames.sourceMap:
case metadataOptionNames.sourceMap:
settings.sourceMap = true;
break;
case testOptMetadataNames.sourceRoot:
case metadataOptionNames.sourceRoot:
settings.sourceRoot = globalOptions[prop];
break;
}
@ -303,7 +308,7 @@ module FourSlash {
ts.forEach(testData.files, file => {
// Create map between fileName and its content for easily looking up when resolveReference flag is specified
this.inputFiles[file.fileName] = file.content;
if (!startResolveFileRef && file.fileOptions[testOptMetadataNames.resolveReference]) {
if (!startResolveFileRef && file.fileOptions[metadataOptionNames.resolveReference]) {
startResolveFileRef = file;
} else if (startResolveFileRef) {
// If entry point for resolving file references is already specified, report duplication error
@ -793,6 +798,13 @@ module FourSlash {
return "\nActual " + name + ":\n\t" + actualValue + "\nExpected value:\n\t" + expectedValue;
}
public getSemanticDiagnostics(expected: string) {
var diagnostics = this.languageService.getSemanticDiagnostics(this.activeFile.fileName);
var realized = ts.realizeDiagnostics(diagnostics, "\r\n");
var actual = JSON.stringify(realized, null, " ");
assert.equal(actual, expected);
}
public verifyQuickInfoString(negative: boolean, expectedText?: string, expectedDocumentation?: string) {
[expectedText, expectedDocumentation].forEach(str => {
if (str) {
@ -1131,7 +1143,7 @@ module FourSlash {
Harness.Baseline.runBaseline(
"Breakpoint Locations for " + this.activeFile.fileName,
this.testData.globalOptions[testOptMetadataNames.baselineFile],
this.testData.globalOptions[metadataOptionNames.baselineFile],
() => {
return this.baselineCurrentFileLocations(pos => this.getBreakpointStatementLocation(pos));
},
@ -1146,7 +1158,7 @@ module FourSlash {
var allFourSlashFiles = this.testData.files;
for (var idx = 0; idx < allFourSlashFiles.length; ++idx) {
var file = allFourSlashFiles[idx];
if (file.fileOptions[testOptMetadataNames.emitThisFile]) {
if (file.fileOptions[metadataOptionNames.emitThisFile]) {
// Find a file with the flag emitThisFile turned on
emitFiles.push(file);
}
@ -1159,7 +1171,7 @@ module FourSlash {
Harness.Baseline.runBaseline(
"Generate getEmitOutput baseline : " + emitFiles.join(" "),
this.testData.globalOptions[testOptMetadataNames.baselineFile],
this.testData.globalOptions[metadataOptionNames.baselineFile],
() => {
var resultString = "";
// Loop through all the emittedFiles and emit them one by one
@ -1704,7 +1716,7 @@ module FourSlash {
Harness.Baseline.runBaseline(
"Name OrDottedNameSpans for " + this.activeFile.fileName,
this.testData.globalOptions[testOptMetadataNames.baselineFile],
this.testData.globalOptions[metadataOptionNames.baselineFile],
() => {
return this.baselineCurrentFileLocations(pos =>
this.getNameOrDottedNameSpan(pos));
@ -2280,7 +2292,7 @@ module FourSlash {
if (globalMetadataNamesIndex === -1) {
if (fileMetadataNamesIndex === -1) {
throw new Error('Unrecognized metadata name "' + match[1] + '". Available global metadata names are: ' + globalMetadataNames.join(', ') + '; file metadata names are: ' + fileMetadataNames.join(', '));
} else if (fileMetadataNamesIndex === fileMetadataNames.indexOf(testOptMetadataNames.fileName)) {
} else if (fileMetadataNamesIndex === fileMetadataNames.indexOf(metadataOptionNames.fileName)) {
// Found an @FileName directive, if this is not the first then create a new subfile
if (currentFileContent) {
var file = parseFileContent(currentFileContent, currentFileName, markerPositions, markers, ranges);

View file

@ -68,12 +68,12 @@ module ts.server {
};
}
private processRequest<T extends protocol.Request>(command: string, arguments?: any): T {
private processRequest<T extends protocol.Request>(command: string, args?: any): T {
var request: protocol.Request = {
seq: this.sequence++,
type: "request",
command: command,
arguments: arguments
arguments: args,
command
};
this.writeMessage(JSON.stringify(request));

View file

@ -1466,6 +1466,10 @@ module ts.server {
return accum;
}
getLength(): number {
return this.root.charCount();
}
every(f: (ll: LineLeaf, s: number, len: number) => boolean, rangeStart: number, rangeEnd?: number) {
if (!rangeEnd) {
rangeEnd = this.root.charCount();

View file

@ -617,12 +617,29 @@ declare module ts.server.protocol {
* Optional modifiers for the kind (such as 'public').
*/
kindModifiers: string;
/**
* A string that is used for comparing completion items so that they can be ordered. This
* is often the same as the name but may be different in certain circumstances.
*/
sortText: string;
}
/**
* Additional completion entry details, available on demand
*/
export interface CompletionEntryDetails extends CompletionEntry {
export interface CompletionEntryDetails {
/**
* The symbol's name.
*/
name: string;
/**
* The symbol's kind (such as 'className' or 'parameterName').
*/
kind: string;
/**
* Optional modifiers for the kind (such as 'public').
*/
kindModifiers: string;
/**
* Display parts of the symbol (similar to quick info).
*/

View file

@ -22,7 +22,7 @@ module ts.NavigateTo {
continue;
}
// It was a match! If the pattern has dots in it, then also see if hte
// It was a match! If the pattern has dots in it, then also see if the
// declaration container matches as well.
if (patternMatcher.patternContainsDots) {
let containers = getContainers(declaration);

View file

@ -418,10 +418,10 @@ module ts.NavigationBar {
}
function createFunctionItem(node: FunctionDeclaration) {
if ((node.name || node.flags & NodeFlags.Default) && node.body && node.body.kind === SyntaxKind.Block) {
if (node.body && node.body.kind === SyntaxKind.Block) {
let childItems = getItemsWorker(sortNodes((<Block>node.body).statements), createChildItem);
return getNavigationBarItem((!node.name && node.flags & NodeFlags.Default) ? "default": node.name.text ,
return getNavigationBarItem(!node.name ? "default": node.name.text ,
ts.ScriptElementKind.functionElement,
getNodeModifiers(node),
[getNodeSpan(node)],
@ -470,7 +470,7 @@ module ts.NavigationBar {
childItems = getItemsWorker(sortNodes(nodes), createChildItem);
}
var nodeName = !node.name && (node.flags & NodeFlags.Default) ? "default" : node.name.text;
var nodeName = !node.name ? "default" : node.name.text;
return getNavigationBarItem(
nodeName,

View file

@ -471,7 +471,7 @@ module ts {
// Helper function to compare two matches to determine which is better. Matches are first
// ordered by kind (so all prefix matches always beat all substring matches). Then, if the
// match is a camel case match, the relative weights of hte match are used to determine
// match is a camel case match, the relative weights of the match are used to determine
// which is better (with a greater weight being better). Then if the match is of the same
// type, then a case sensitive match is considered better than an insensitive one.
function patternMatchCompareTo(match1: PatternMatch, match2: PatternMatch): number {

View file

@ -730,7 +730,7 @@ module ts {
public statements: NodeArray<Statement>;
public endOfFileToken: Node;
public amdDependencies: {name: string; path: string}[];
public amdDependencies: { name: string; path: string }[];
public amdModuleName: string;
public referencedFiles: FileReference[];
@ -769,126 +769,131 @@ module ts {
public getNamedDeclarations() {
if (!this.namedDeclarations) {
let sourceFile = this;
let namedDeclarations: Declaration[] = [];
forEachChild(sourceFile, function visit(node: Node): void {
switch (node.kind) {
case SyntaxKind.FunctionDeclaration:
case SyntaxKind.MethodDeclaration:
case SyntaxKind.MethodSignature:
let functionDeclaration = <FunctionLikeDeclaration>node;
if (functionDeclaration.name && functionDeclaration.name.getFullWidth() > 0) {
let lastDeclaration = namedDeclarations.length > 0 ?
namedDeclarations[namedDeclarations.length - 1] :
undefined;
// Check whether this declaration belongs to an "overload group".
if (lastDeclaration && functionDeclaration.symbol === lastDeclaration.symbol) {
// Overwrite the last declaration if it was an overload
// and this one is an implementation.
if (functionDeclaration.body && !(<FunctionLikeDeclaration>lastDeclaration).body) {
namedDeclarations[namedDeclarations.length - 1] = functionDeclaration;
}
}
else {
namedDeclarations.push(functionDeclaration);
}
forEachChild(node, visit);
}
break;
case SyntaxKind.ClassDeclaration:
case SyntaxKind.InterfaceDeclaration:
case SyntaxKind.TypeAliasDeclaration:
case SyntaxKind.EnumDeclaration:
case SyntaxKind.ModuleDeclaration:
case SyntaxKind.ImportEqualsDeclaration:
case SyntaxKind.ExportSpecifier:
case SyntaxKind.ImportSpecifier:
case SyntaxKind.ImportEqualsDeclaration:
case SyntaxKind.ImportClause:
case SyntaxKind.NamespaceImport:
case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor:
case SyntaxKind.TypeLiteral:
if ((<Declaration>node).name) {
namedDeclarations.push(<Declaration>node);
}
// fall through
case SyntaxKind.Constructor:
case SyntaxKind.VariableStatement:
case SyntaxKind.VariableDeclarationList:
case SyntaxKind.ObjectBindingPattern:
case SyntaxKind.ArrayBindingPattern:
case SyntaxKind.ModuleBlock:
forEachChild(node, visit);
break;
case SyntaxKind.Block:
if (isFunctionBlock(node)) {
forEachChild(node, visit);
}
break;
case SyntaxKind.Parameter:
// Only consider properties defined as constructor parameters
if (!(node.flags & NodeFlags.AccessibilityModifier)) {
break;
}
// fall through
case SyntaxKind.VariableDeclaration:
case SyntaxKind.BindingElement:
if (isBindingPattern((<VariableDeclaration>node).name)) {
forEachChild((<VariableDeclaration>node).name, visit);
break;
}
case SyntaxKind.EnumMember:
case SyntaxKind.PropertyDeclaration:
case SyntaxKind.PropertySignature:
namedDeclarations.push(<Declaration>node);
break;
case SyntaxKind.ExportDeclaration:
// Handle named exports case e.g.:
// export {a, b as B} from "mod";
if ((<ExportDeclaration>node).exportClause) {
forEach((<ExportDeclaration>node).exportClause.elements, visit);
}
break;
case SyntaxKind.ImportDeclaration:
let importClause = (<ImportDeclaration>node).importClause;
if (importClause) {
// Handle default import case e.g.:
// import d from "mod";
if (importClause.name) {
namedDeclarations.push(importClause);
}
// Handle named bindings in imports e.g.:
// import * as NS from "mod";
// import {a, b as B} from "mod";
if (importClause.namedBindings) {
if (importClause.namedBindings.kind === SyntaxKind.NamespaceImport) {
namedDeclarations.push(<NamespaceImport>importClause.namedBindings);
}
else {
forEach((<NamedImports>importClause.namedBindings).elements, visit);
}
}
}
break;
}
});
this.namedDeclarations = namedDeclarations;
this.namedDeclarations = this.computeNamedDeclarations();
}
return this.namedDeclarations;
}
private computeNamedDeclarations() {
let namedDeclarations: Declaration[] = [];
forEachChild(this, visit);
return namedDeclarations;
function visit(node: Node): void {
switch (node.kind) {
case SyntaxKind.FunctionDeclaration:
case SyntaxKind.MethodDeclaration:
case SyntaxKind.MethodSignature:
let functionDeclaration = <FunctionLikeDeclaration>node;
if (functionDeclaration.name && functionDeclaration.name.getFullWidth() > 0) {
let lastDeclaration = namedDeclarations.length > 0 ?
namedDeclarations[namedDeclarations.length - 1] :
undefined;
// Check whether this declaration belongs to an "overload group".
if (lastDeclaration && functionDeclaration.symbol === lastDeclaration.symbol) {
// Overwrite the last declaration if it was an overload
// and this one is an implementation.
if (functionDeclaration.body && !(<FunctionLikeDeclaration>lastDeclaration).body) {
namedDeclarations[namedDeclarations.length - 1] = functionDeclaration;
}
}
else {
namedDeclarations.push(functionDeclaration);
}
forEachChild(node, visit);
}
break;
case SyntaxKind.ClassDeclaration:
case SyntaxKind.InterfaceDeclaration:
case SyntaxKind.TypeAliasDeclaration:
case SyntaxKind.EnumDeclaration:
case SyntaxKind.ModuleDeclaration:
case SyntaxKind.ImportEqualsDeclaration:
case SyntaxKind.ExportSpecifier:
case SyntaxKind.ImportSpecifier:
case SyntaxKind.ImportEqualsDeclaration:
case SyntaxKind.ImportClause:
case SyntaxKind.NamespaceImport:
case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor:
case SyntaxKind.TypeLiteral:
if ((<Declaration>node).name) {
namedDeclarations.push(<Declaration>node);
}
// fall through
case SyntaxKind.Constructor:
case SyntaxKind.VariableStatement:
case SyntaxKind.VariableDeclarationList:
case SyntaxKind.ObjectBindingPattern:
case SyntaxKind.ArrayBindingPattern:
case SyntaxKind.ModuleBlock:
forEachChild(node, visit);
break;
case SyntaxKind.Block:
if (isFunctionBlock(node)) {
forEachChild(node, visit);
}
break;
case SyntaxKind.Parameter:
// Only consider properties defined as constructor parameters
if (!(node.flags & NodeFlags.AccessibilityModifier)) {
break;
}
// fall through
case SyntaxKind.VariableDeclaration:
case SyntaxKind.BindingElement:
if (isBindingPattern((<VariableDeclaration>node).name)) {
forEachChild((<VariableDeclaration>node).name, visit);
break;
}
case SyntaxKind.EnumMember:
case SyntaxKind.PropertyDeclaration:
case SyntaxKind.PropertySignature:
namedDeclarations.push(<Declaration>node);
break;
case SyntaxKind.ExportDeclaration:
// Handle named exports case e.g.:
// export {a, b as B} from "mod";
if ((<ExportDeclaration>node).exportClause) {
forEach((<ExportDeclaration>node).exportClause.elements, visit);
}
break;
case SyntaxKind.ImportDeclaration:
let importClause = (<ImportDeclaration>node).importClause;
if (importClause) {
// Handle default import case e.g.:
// import d from "mod";
if (importClause.name) {
namedDeclarations.push(importClause);
}
// Handle named bindings in imports e.g.:
// import * as NS from "mod";
// import {a, b as B} from "mod";
if (importClause.namedBindings) {
if (importClause.namedBindings.kind === SyntaxKind.NamespaceImport) {
namedDeclarations.push(<NamespaceImport>importClause.namedBindings);
}
else {
forEach((<NamedImports>importClause.namedBindings).elements, visit);
}
}
}
break;
}
}
}
}
//
@ -1143,6 +1148,7 @@ module ts {
name: string;
kind: string; // see ScriptElementKind
kindModifiers: string; // see ScriptElementKindModifier, comma separated
sortText: string;
}
export interface CompletionEntryDetails {
@ -1311,6 +1317,7 @@ module ts {
// TODO: move these to enums
export class ScriptElementKind {
static unknown = "";
static warning = "warning";
// predefined type (void) or keyword (class)
static keyword = "keyword";
@ -2161,7 +2168,8 @@ module ts {
keywordCompletions.push({
name: tokenToString(i),
kind: ScriptElementKind.keyword,
kindModifiers: ScriptElementKindModifier.none
kindModifiers: ScriptElementKindModifier.none,
sortText: "0"
});
}
@ -2425,15 +2433,26 @@ module ts {
return program.getSyntacticDiagnostics(getValidSourceFile(fileName));
}
function isJavaScript(fileName: string) {
return fileExtensionIs(fileName, ".js");
}
/**
* getSemanticDiagnostiscs return array of Diagnostics. If '-d' is not enabled, only report semantic errors
* If '-d' enabled, report both semantic and emitter errors
*/
function getSemanticDiagnostics(fileName: string) {
function getSemanticDiagnostics(fileName: string): Diagnostic[] {
synchronizeHostData();
let targetSourceFile = getValidSourceFile(fileName);
// For JavaScript files, we don't want to report the normal typescript semantic errors.
// Instead, we just report errors for using TypeScript-only constructs from within a
// JavaScript file.
if (isJavaScript(fileName)) {
return getJavaScriptSemanticDiagnostics(targetSourceFile);
}
// Only perform the action per file regardless of '-out' flag as LanguageServiceHost is expected to call this function per file.
// Therefore only get diagnostics for given file.
@ -2447,35 +2466,199 @@ module ts {
return concatenate(semanticDiagnostics, declarationDiagnostics);
}
function getJavaScriptSemanticDiagnostics(sourceFile: SourceFile): Diagnostic[] {
let diagnostics: Diagnostic[] = [];
walk(sourceFile);
return diagnostics;
function walk(node: Node): boolean {
if (!node) {
return false;
}
switch (node.kind) {
case SyntaxKind.ImportEqualsDeclaration:
diagnostics.push(createDiagnosticForNode(node, Diagnostics.import_can_only_be_used_in_a_ts_file));
return true;
case SyntaxKind.ExportAssignment:
diagnostics.push(createDiagnosticForNode(node, Diagnostics.export_can_only_be_used_in_a_ts_file));
return true;
case SyntaxKind.ClassDeclaration:
let classDeclaration = <ClassDeclaration>node;
if (checkModifiers(classDeclaration.modifiers) ||
checkTypeParameters(classDeclaration.typeParameters)) {
return true;
}
break;
case SyntaxKind.HeritageClause:
let heritageClause = <HeritageClause>node;
if (heritageClause.token === SyntaxKind.ImplementsKeyword) {
diagnostics.push(createDiagnosticForNode(node, Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file));
return true;
}
break;
case SyntaxKind.InterfaceDeclaration:
diagnostics.push(createDiagnosticForNode(node, Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file));
return true;
case SyntaxKind.ModuleDeclaration:
diagnostics.push(createDiagnosticForNode(node, Diagnostics.module_declarations_can_only_be_used_in_a_ts_file));
return true;
case SyntaxKind.TypeAliasDeclaration:
diagnostics.push(createDiagnosticForNode(node, Diagnostics.type_aliases_can_only_be_used_in_a_ts_file));
return true;
case SyntaxKind.MethodDeclaration:
case SyntaxKind.MethodSignature:
case SyntaxKind.Constructor:
case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor:
case SyntaxKind.FunctionExpression:
case SyntaxKind.FunctionDeclaration:
case SyntaxKind.ArrowFunction:
case SyntaxKind.FunctionDeclaration:
let functionDeclaration = <FunctionLikeDeclaration>node;
if (checkModifiers(functionDeclaration.modifiers) ||
checkTypeParameters(functionDeclaration.typeParameters) ||
checkTypeAnnotation(functionDeclaration.type)) {
return true;
}
break;
case SyntaxKind.VariableStatement:
let variableStatement = <VariableStatement>node;
if (checkModifiers(variableStatement.modifiers)) {
return true;
}
break;
case SyntaxKind.VariableDeclaration:
let variableDeclaration = <VariableDeclaration>node;
if (checkTypeAnnotation(variableDeclaration.type)) {
return true;
}
break;
case SyntaxKind.CallExpression:
case SyntaxKind.NewExpression:
let expression = <CallExpression>node;
if (expression.typeArguments && expression.typeArguments.length > 0) {
let start = expression.typeArguments.pos;
diagnostics.push(createFileDiagnostic(sourceFile, start, expression.typeArguments.end - start,
Diagnostics.type_arguments_can_only_be_used_in_a_ts_file));
return true;
}
break;
case SyntaxKind.Parameter:
let parameter = <ParameterDeclaration>node;
if (parameter.modifiers) {
let start = parameter.modifiers.pos;
diagnostics.push(createFileDiagnostic(sourceFile, start, parameter.modifiers.end - start,
Diagnostics.parameter_modifiers_can_only_be_used_in_a_ts_file));
return true;
}
if (parameter.questionToken) {
diagnostics.push(createDiagnosticForNode(parameter.questionToken, Diagnostics.can_only_be_used_in_a_ts_file));
return true;
}
if (parameter.type) {
diagnostics.push(createDiagnosticForNode(parameter.type, Diagnostics.types_can_only_be_used_in_a_ts_file));
return true;
}
break;
case SyntaxKind.PropertyDeclaration:
diagnostics.push(createDiagnosticForNode(node, Diagnostics.property_declarations_can_only_be_used_in_a_ts_file));
return true;
case SyntaxKind.EnumDeclaration:
diagnostics.push(createDiagnosticForNode(node, Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file));
return true;
case SyntaxKind.TypeAssertionExpression:
let typeAssertionExpression = <TypeAssertion>node;
diagnostics.push(createDiagnosticForNode(typeAssertionExpression.type, Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file));
return true;
case SyntaxKind.Decorator:
diagnostics.push(createDiagnosticForNode(node, Diagnostics.decorators_can_only_be_used_in_a_ts_file));
return true;
}
return forEachChild(node, walk);
}
function checkTypeParameters(typeParameters: NodeArray<TypeParameterDeclaration>): boolean {
if (typeParameters) {
let start = typeParameters.pos;
diagnostics.push(createFileDiagnostic(sourceFile, start, typeParameters.end - start, Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file));
return true;
}
return false;
}
function checkTypeAnnotation(type: TypeNode): boolean {
if (type) {
diagnostics.push(createDiagnosticForNode(type, Diagnostics.types_can_only_be_used_in_a_ts_file));
return true;
}
return false;
}
function checkModifiers(modifiers: ModifiersArray): boolean {
if (modifiers) {
for (let modifier of modifiers) {
switch (modifier.kind) {
case SyntaxKind.PublicKeyword:
case SyntaxKind.PrivateKeyword:
case SyntaxKind.ProtectedKeyword:
case SyntaxKind.DeclareKeyword:
diagnostics.push(createDiagnosticForNode(modifier, Diagnostics._0_can_only_be_used_in_a_ts_file, tokenToString(modifier.kind)));
return true;
// These are all legal modifiers.
case SyntaxKind.StaticKeyword:
case SyntaxKind.ExportKeyword:
case SyntaxKind.ConstKeyword:
case SyntaxKind.DefaultKeyword:
}
}
}
return false;
}
}
function getCompilerOptionsDiagnostics() {
synchronizeHostData();
return program.getGlobalDiagnostics();
}
/// Completion
function getCompletionEntryDisplayName(symbol: Symbol, target: ScriptTarget, performCharacterChecks: boolean): string {
function getCompletionEntryDisplayNameForSymbol(symbol: Symbol, target: ScriptTarget, performCharacterChecks: boolean): string {
let displayName = symbol.getName();
if (displayName) {
// If this is the default export, get the name of the declaration if it exists
if (displayName === "default") {
let localSymbol = getLocalSymbolForExportDefault(symbol);
if (localSymbol && localSymbol.name) {
displayName = symbol.valueDeclaration.localSymbol.name;
}
}
let firstCharCode = displayName.charCodeAt(0);
// First check of the displayName is not external module; if it is an external module, it is not valid entry
if ((symbol.flags & SymbolFlags.Namespace) && (firstCharCode === CharacterCodes.singleQuote || firstCharCode === CharacterCodes.doubleQuote)) {
// If the symbol is external module, don't show it in the completion list
// (i.e declare module "http" { let x; } | // <= request completion here, "http" should not be there)
return undefined;
}
}
return getCompletionEntryDisplayName(displayName, target, performCharacterChecks);
}
function getCompletionEntryDisplayName(displayName: string, target: ScriptTarget, performCharacterChecks: boolean): string {
if (!displayName) {
return undefined;
}
// If this is the default export, get the name of the declaration if it exists
if (displayName === "default") {
let localSymbol = getLocalSymbolForExportDefault(symbol);
if (localSymbol && localSymbol.name) {
displayName = symbol.valueDeclaration.localSymbol.name;
}
}
let firstCharCode = displayName.charCodeAt(0);
// First check of the displayName is not external module; if it is an external module, it is not valid entry
if ((symbol.flags & SymbolFlags.Namespace) && (firstCharCode === CharacterCodes.singleQuote || firstCharCode === CharacterCodes.doubleQuote)) {
// If the symbol is external module, don't show it in the completion list
// (i.e declare module "http" { let x; } | // <= request completion here, "http" should not be there)
return undefined;
}
if (displayName && displayName.length >= 2 && firstCharCode === displayName.charCodeAt(displayName.length - 1) &&
if (displayName.length >= 2 &&
firstCharCode === displayName.charCodeAt(displayName.length - 1) &&
(firstCharCode === CharacterCodes.singleQuote || firstCharCode === CharacterCodes.doubleQuote)) {
// If the user entered name for the symbol was quoted, removing the quotes is not enough, as the name could be an
// invalid identifier name. We need to check if whatever was inside the quotes is actually a valid identifier name.
@ -2505,19 +2688,24 @@ module ts {
// Try to get a valid display name for this symbol, if we could not find one, then ignore it.
// We would like to only show things that can be added after a dot, so for instance numeric properties can
// not be accessed with a dot (a.1 <- invalid)
let displayName = getCompletionEntryDisplayName(symbol, program.getCompilerOptions().target, /*performCharacterChecks:*/ true);
let displayName = getCompletionEntryDisplayNameForSymbol(symbol, program.getCompilerOptions().target, /*performCharacterChecks:*/ true);
if (!displayName) {
return undefined;
}
// TODO(drosen): Right now we just permit *all* semantic meanings when calling 'getSymbolKind'
// which is permissible given that it is backwards compatible; but really we should consider
// passing the meaning for the node so that we don't report that a suggestion for a value is an interface.
// We COULD also just do what 'getSymbolModifiers' does, which is to use the first declaration.
// TODO(drosen): Right now we just permit *all* semantic meanings when calling
// 'getSymbolKind' which is permissible given that it is backwards compatible; but
// really we should consider passing the meaning for the node so that we don't report
// that a suggestion for a value is an interface. We COULD also just do what
// 'getSymbolModifiers' does, which is to use the first declaration.
// Use a 'sortText' of 0' so that all symbol completion entries come before any other
// entries (like JavaScript identifier entries).
return {
name: displayName,
kind: getSymbolKind(symbol, typeChecker, location),
kindModifiers: getSymbolModifiers(symbol)
kindModifiers: getSymbolModifiers(symbol),
sortText: "0",
};
}
@ -2561,8 +2749,9 @@ module ts {
return undefined;
}
// Find the node where completion is requested on, in the case of a completion after a dot, it is the member access expression
// otherwise, it is a request for all visible symbols in the scope, and the node is the current location
// Find the node where completion is requested on, in the case of a completion after
// a dot, it is the member access expression other wise, it is a request for all
// visible symbols in the scope, and the node is the current location.
let node = currentToken;
let isRightOfDot = false;
if (contextToken && contextToken.kind === SyntaxKind.DotToken && contextToken.parent.kind === SyntaxKind.PropertyAccessExpression) {
@ -2580,11 +2769,26 @@ module ts {
let semanticStart = new Date().getTime();
let isMemberCompletion: boolean;
let isNewIdentifierLocation: boolean;
let symbols: Symbol[];
let symbols: Symbol[] = [];
if (isRightOfDot) {
getTypeScriptMemberSymbols();
}
else {
// For JavaScript or TypeScript, if we're not after a dot, then just try to get the
// global symbols in scope. These results should be valid for either language as
// the set of symbols that can be referenced from this location.
if (!tryGetGlobalSymbols()) {
return undefined;
}
}
log("getCompletionData: Semantic work: " + (new Date().getTime() - semanticStart));
return { symbols, isMemberCompletion, isNewIdentifierLocation, location, isRightOfDot };
function getTypeScriptMemberSymbols(): void {
// Right of dot member completion list
symbols = [];
isMemberCompletion = true;
isNewIdentifierLocation = false;
@ -2598,7 +2802,8 @@ module ts {
if (symbol && symbol.flags & SymbolFlags.HasExports) {
// Extract module or enum members
forEachValue(symbol.exports, symbol => {
let exportedSymbols = typeInfoResolver.getExportsOfModule(symbol);
forEach(exportedSymbols, symbol => {
if (typeInfoResolver.isValidPropertyAccess(<PropertyAccessExpression>(node.parent), symbol.name)) {
symbols.push(symbol);
}
@ -2616,7 +2821,8 @@ module ts {
});
}
}
else {
function tryGetGlobalSymbols(): boolean {
let containingObjectLiteral = getContainingObjectLiteralApplicableForCompletion(contextToken);
if (containingObjectLiteral) {
// Object literal expression, look up possible property names from contextual type
@ -2625,7 +2831,7 @@ module ts {
let contextualType = typeInfoResolver.getContextualType(containingObjectLiteral);
if (!contextualType) {
return undefined;
return false;
}
let contextualTypeMembers = typeInfoResolver.getPropertiesOfType(contextualType);
@ -2642,8 +2848,17 @@ module ts {
if (showCompletionsInImportsClause(contextToken)) {
let importDeclaration = <ImportDeclaration>getAncestor(contextToken, SyntaxKind.ImportDeclaration);
Debug.assert(importDeclaration !== undefined);
let exports = typeInfoResolver.getExportsOfExternalModule(importDeclaration);
symbols = filterModuleExports(exports, importDeclaration);
let exports: Symbol[];
if (importDeclaration.moduleSpecifier) {
let moduleSpecifierSymbol = typeInfoResolver.getSymbolAtLocation(importDeclaration.moduleSpecifier);
if (moduleSpecifierSymbol) {
exports = typeInfoResolver.getExportsOfModule(moduleSpecifierSymbol);
}
}
//let exports = typeInfoResolver.getExportsOfImportDeclaration(importDeclaration);
symbols = exports ? filterModuleExports(exports, importDeclaration) : emptyArray;
}
}
else {
@ -2689,12 +2904,10 @@ module ts {
let symbolMeanings = SymbolFlags.Type | SymbolFlags.Value | SymbolFlags.Namespace | SymbolFlags.Alias;
symbols = typeInfoResolver.getSymbolsInScope(scopeNode, symbolMeanings);
}
return true;
}
log("getCompletionData: Semantic work: " + (new Date().getTime() - semanticStart));
return { symbols, isMemberCompletion, isNewIdentifierLocation, location };
/**
* Finds the first node that "embraces" the position, so that one may
* accurately aggregate locals from the closest containing scope.
@ -3001,12 +3214,20 @@ module ts {
return undefined;
}
let { symbols, isMemberCompletion, isNewIdentifierLocation, location } = completionData;
if (!symbols || symbols.length === 0) {
return undefined;
}
let { symbols, isMemberCompletion, isNewIdentifierLocation, location, isRightOfDot } = completionData;
var entries = getCompletionEntriesFromSymbols(symbols);
let entries: CompletionEntry[];
if (isRightOfDot && isJavaScript(fileName)) {
entries = getCompletionEntriesFromSymbols(symbols);
addRange(entries, getJavaScriptCompletionEntries());
}
else {
if (!symbols || symbols.length === 0) {
return undefined;
}
entries = getCompletionEntriesFromSymbols(symbols);
}
// Add keywords if this is not a member completion list
if (!isMemberCompletion) {
@ -3015,21 +3236,51 @@ module ts {
return { isMemberCompletion, isNewIdentifierLocation, entries };
function getCompletionEntriesFromSymbols(symbols: Symbol[]): CompletionEntry[] {
let start = new Date().getTime();
var entries: CompletionEntry[] = [];
var nameToSymbol: Map<Symbol> = {};
function getJavaScriptCompletionEntries(): CompletionEntry[] {
let entries: CompletionEntry[] = [];
let allNames: Map<string> = {};
let target = program.getCompilerOptions().target;
for (let symbol of symbols) {
let entry = createCompletionEntry(symbol, typeInfoResolver, location);
if (entry) {
let id = escapeIdentifier(entry.name);
if (!lookUp(nameToSymbol, id)) {
entries.push(entry);
nameToSymbol[id] = symbol;
for (let sourceFile of program.getSourceFiles()) {
let nameTable = getNameTable(sourceFile);
for (let name in nameTable) {
if (!allNames[name]) {
allNames[name] = name;
let displayName = getCompletionEntryDisplayName(name, target, /*performCharacterChecks:*/ true);
if (displayName) {
let entry = {
name: displayName,
kind: ScriptElementKind.warning,
kindModifiers: "",
sortText: "1"
};
entries.push(entry);
}
}
}
}
return entries;
}
function getCompletionEntriesFromSymbols(symbols: Symbol[]): CompletionEntry[] {
let start = new Date().getTime();
var entries: CompletionEntry[] = [];
if (symbols) {
var nameToSymbol: Map<Symbol> = {};
for (let symbol of symbols) {
let entry = createCompletionEntry(symbol, typeInfoResolver, location);
if (entry) {
let id = escapeIdentifier(entry.name);
if (!lookUp(nameToSymbol, id)) {
entries.push(entry);
nameToSymbol[id] = symbol;
}
}
}
}
log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (new Date().getTime() - start));
return entries;
}
@ -3048,7 +3299,7 @@ module ts {
// We don't need to perform character checks here because we're only comparing the
// name against 'entryName' (which is known to be good), not building a new
// completion entry.
let symbol = forEach(symbols, s => getCompletionEntryDisplayName(s, target, /*performCharacterChecks:*/ false) === entryName ? s : undefined);
let symbol = forEach(symbols, s => getCompletionEntryDisplayNameForSymbol(s, target, /*performCharacterChecks:*/ false) === entryName ? s : undefined);
if (symbol) {
let displayPartsDocumentationsAndSymbolKind = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, getValidSourceFile(fileName), location, typeInfoResolver, location, SemanticMeaning.All);

View file

@ -331,6 +331,22 @@ module ts {
}
}
/* @internal */
export function realizeDiagnostics(diagnostics: Diagnostic[], newLine: string): { message: string; start: number; length: number; category: string; } []{
return diagnostics.map(d => realizeDiagnostic(d, newLine));
}
function realizeDiagnostic(diagnostic: Diagnostic, newLine: string): { message: string; start: number; length: number; category: string; } {
return {
message: flattenDiagnosticMessageText(diagnostic.messageText, newLine),
start: diagnostic.start,
length: diagnostic.length,
/// TODO: no need for the tolowerCase call
category: DiagnosticCategory[diagnostic.category].toLowerCase(),
code: diagnostic.code
};
}
class LanguageServiceShimObject extends ShimBase implements LanguageServiceShim {
private logger: Logger;
@ -391,18 +407,7 @@ module ts {
private realizeDiagnostics(diagnostics: Diagnostic[]): { message: string; start: number; length: number; category: string; }[]{
var newLine = this.getNewLine();
return diagnostics.map(d => this.realizeDiagnostic(d, newLine));
}
private realizeDiagnostic(diagnostic: Diagnostic, newLine: string): { message: string; start: number; length: number; category: string; } {
return {
message: flattenDiagnosticMessageText(diagnostic.messageText, newLine),
start: diagnostic.start,
length: diagnostic.length,
/// TODO: no need for the tolowerCase call
category: DiagnosticCategory[diagnostic.category].toLowerCase(),
code: diagnostic.code
};
return ts.realizeDiagnostics(diagnostics, newLine);
}
public getSyntacticClassifications(fileName: string, start: number, length: number): string {

View file

@ -760,7 +760,7 @@ declare module "typescript" {
interface ExternalModuleReference extends Node {
expression?: Expression;
}
interface ImportDeclaration extends Statement, ModuleElement {
interface ImportDeclaration extends ModuleElement {
importClause?: ImportClause;
moduleSpecifier: Expression;
}
@ -902,7 +902,7 @@ declare module "typescript" {
getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number;
isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean;
getAliasedSymbol(symbol: Symbol): Symbol;
getExportsOfExternalModule(node: ImportDeclaration): Symbol[];
getExportsOfModule(moduleSymbol: Symbol): Symbol[];
}
interface SymbolDisplayBuilder {
buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
@ -1807,6 +1807,7 @@ declare module "typescript" {
name: string;
kind: string;
kindModifiers: string;
sortText: string;
}
interface CompletionEntryDetails {
name: string;
@ -1949,6 +1950,7 @@ declare module "typescript" {
}
class ScriptElementKind {
static unknown: string;
static warning: string;
static keyword: string;
static scriptElement: string;
static moduleElement: string;

View file

@ -2307,9 +2307,8 @@ declare module "typescript" {
>expression : Expression
>Expression : Expression
}
interface ImportDeclaration extends Statement, ModuleElement {
interface ImportDeclaration extends ModuleElement {
>ImportDeclaration : ImportDeclaration
>Statement : Statement
>ModuleElement : ModuleElement
importClause?: ImportClause;
@ -2818,10 +2817,10 @@ declare module "typescript" {
>Symbol : Symbol
>Symbol : Symbol
getExportsOfExternalModule(node: ImportDeclaration): Symbol[];
>getExportsOfExternalModule : (node: ImportDeclaration) => Symbol[]
>node : ImportDeclaration
>ImportDeclaration : ImportDeclaration
getExportsOfModule(moduleSymbol: Symbol): Symbol[];
>getExportsOfModule : (moduleSymbol: Symbol) => Symbol[]
>moduleSymbol : Symbol
>Symbol : Symbol
>Symbol : Symbol
}
interface SymbolDisplayBuilder {
@ -5788,6 +5787,9 @@ declare module "typescript" {
kindModifiers: string;
>kindModifiers : string
sortText: string;
>sortText : string
}
interface CompletionEntryDetails {
>CompletionEntryDetails : CompletionEntryDetails
@ -6057,6 +6059,9 @@ declare module "typescript" {
static unknown: string;
>unknown : string
static warning: string;
>warning : string
static keyword: string;
>keyword : string

View file

@ -791,7 +791,7 @@ declare module "typescript" {
interface ExternalModuleReference extends Node {
expression?: Expression;
}
interface ImportDeclaration extends Statement, ModuleElement {
interface ImportDeclaration extends ModuleElement {
importClause?: ImportClause;
moduleSpecifier: Expression;
}
@ -933,7 +933,7 @@ declare module "typescript" {
getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number;
isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean;
getAliasedSymbol(symbol: Symbol): Symbol;
getExportsOfExternalModule(node: ImportDeclaration): Symbol[];
getExportsOfModule(moduleSymbol: Symbol): Symbol[];
}
interface SymbolDisplayBuilder {
buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
@ -1838,6 +1838,7 @@ declare module "typescript" {
name: string;
kind: string;
kindModifiers: string;
sortText: string;
}
interface CompletionEntryDetails {
name: string;
@ -1980,6 +1981,7 @@ declare module "typescript" {
}
class ScriptElementKind {
static unknown: string;
static warning: string;
static keyword: string;
static scriptElement: string;
static moduleElement: string;

View file

@ -2453,9 +2453,8 @@ declare module "typescript" {
>expression : Expression
>Expression : Expression
}
interface ImportDeclaration extends Statement, ModuleElement {
interface ImportDeclaration extends ModuleElement {
>ImportDeclaration : ImportDeclaration
>Statement : Statement
>ModuleElement : ModuleElement
importClause?: ImportClause;
@ -2964,10 +2963,10 @@ declare module "typescript" {
>Symbol : Symbol
>Symbol : Symbol
getExportsOfExternalModule(node: ImportDeclaration): Symbol[];
>getExportsOfExternalModule : (node: ImportDeclaration) => Symbol[]
>node : ImportDeclaration
>ImportDeclaration : ImportDeclaration
getExportsOfModule(moduleSymbol: Symbol): Symbol[];
>getExportsOfModule : (moduleSymbol: Symbol) => Symbol[]
>moduleSymbol : Symbol
>Symbol : Symbol
>Symbol : Symbol
}
interface SymbolDisplayBuilder {
@ -5934,6 +5933,9 @@ declare module "typescript" {
kindModifiers: string;
>kindModifiers : string
sortText: string;
>sortText : string
}
interface CompletionEntryDetails {
>CompletionEntryDetails : CompletionEntryDetails
@ -6203,6 +6205,9 @@ declare module "typescript" {
static unknown: string;
>unknown : string
static warning: string;
>warning : string
static keyword: string;
>keyword : string

View file

@ -2453,9 +2453,8 @@ declare module "typescript" {
>expression : Expression
>Expression : Expression
}
interface ImportDeclaration extends Statement, ModuleElement {
interface ImportDeclaration extends ModuleElement {
>ImportDeclaration : ImportDeclaration
>Statement : Statement
>ModuleElement : ModuleElement
importClause?: ImportClause;
@ -2964,10 +2963,10 @@ declare module "typescript" {
>Symbol : Symbol
>Symbol : Symbol
getExportsOfExternalModule(node: ImportDeclaration): Symbol[];
>getExportsOfExternalModule : (node: ImportDeclaration) => Symbol[]
>node : ImportDeclaration
>ImportDeclaration : ImportDeclaration
getExportsOfModule(moduleSymbol: Symbol): Symbol[];
>getExportsOfModule : (moduleSymbol: Symbol) => Symbol[]
>moduleSymbol : Symbol
>Symbol : Symbol
>Symbol : Symbol
}
interface SymbolDisplayBuilder {
@ -5934,6 +5933,9 @@ declare module "typescript" {
kindModifiers: string;
>kindModifiers : string
sortText: string;
>sortText : string
}
interface CompletionEntryDetails {
>CompletionEntryDetails : CompletionEntryDetails
@ -6203,6 +6205,9 @@ declare module "typescript" {
static unknown: string;
>unknown : string
static warning: string;
>warning : string
static keyword: string;
>keyword : string

View file

@ -792,7 +792,7 @@ declare module "typescript" {
interface ExternalModuleReference extends Node {
expression?: Expression;
}
interface ImportDeclaration extends Statement, ModuleElement {
interface ImportDeclaration extends ModuleElement {
importClause?: ImportClause;
moduleSpecifier: Expression;
}
@ -934,7 +934,7 @@ declare module "typescript" {
getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number;
isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean;
getAliasedSymbol(symbol: Symbol): Symbol;
getExportsOfExternalModule(node: ImportDeclaration): Symbol[];
getExportsOfModule(moduleSymbol: Symbol): Symbol[];
}
interface SymbolDisplayBuilder {
buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
@ -1839,6 +1839,7 @@ declare module "typescript" {
name: string;
kind: string;
kindModifiers: string;
sortText: string;
}
interface CompletionEntryDetails {
name: string;
@ -1981,6 +1982,7 @@ declare module "typescript" {
}
class ScriptElementKind {
static unknown: string;
static warning: string;
static keyword: string;
static scriptElement: string;
static moduleElement: string;

View file

@ -2403,9 +2403,8 @@ declare module "typescript" {
>expression : Expression
>Expression : Expression
}
interface ImportDeclaration extends Statement, ModuleElement {
interface ImportDeclaration extends ModuleElement {
>ImportDeclaration : ImportDeclaration
>Statement : Statement
>ModuleElement : ModuleElement
importClause?: ImportClause;
@ -2914,10 +2913,10 @@ declare module "typescript" {
>Symbol : Symbol
>Symbol : Symbol
getExportsOfExternalModule(node: ImportDeclaration): Symbol[];
>getExportsOfExternalModule : (node: ImportDeclaration) => Symbol[]
>node : ImportDeclaration
>ImportDeclaration : ImportDeclaration
getExportsOfModule(moduleSymbol: Symbol): Symbol[];
>getExportsOfModule : (moduleSymbol: Symbol) => Symbol[]
>moduleSymbol : Symbol
>Symbol : Symbol
>Symbol : Symbol
}
interface SymbolDisplayBuilder {
@ -5884,6 +5883,9 @@ declare module "typescript" {
kindModifiers: string;
>kindModifiers : string
sortText: string;
>sortText : string
}
interface CompletionEntryDetails {
>CompletionEntryDetails : CompletionEntryDetails
@ -6153,6 +6155,9 @@ declare module "typescript" {
static unknown: string;
>unknown : string
static warning: string;
>warning : string
static keyword: string;
>keyword : string

View file

@ -829,7 +829,7 @@ declare module "typescript" {
interface ExternalModuleReference extends Node {
expression?: Expression;
}
interface ImportDeclaration extends Statement, ModuleElement {
interface ImportDeclaration extends ModuleElement {
importClause?: ImportClause;
moduleSpecifier: Expression;
}
@ -971,7 +971,7 @@ declare module "typescript" {
getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number;
isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean;
getAliasedSymbol(symbol: Symbol): Symbol;
getExportsOfExternalModule(node: ImportDeclaration): Symbol[];
getExportsOfModule(moduleSymbol: Symbol): Symbol[];
}
interface SymbolDisplayBuilder {
buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
@ -1876,6 +1876,7 @@ declare module "typescript" {
name: string;
kind: string;
kindModifiers: string;
sortText: string;
}
interface CompletionEntryDetails {
name: string;
@ -2018,6 +2019,7 @@ declare module "typescript" {
}
class ScriptElementKind {
static unknown: string;
static warning: string;
static keyword: string;
static scriptElement: string;
static moduleElement: string;

View file

@ -2576,9 +2576,8 @@ declare module "typescript" {
>expression : Expression
>Expression : Expression
}
interface ImportDeclaration extends Statement, ModuleElement {
interface ImportDeclaration extends ModuleElement {
>ImportDeclaration : ImportDeclaration
>Statement : Statement
>ModuleElement : ModuleElement
importClause?: ImportClause;
@ -3087,10 +3086,10 @@ declare module "typescript" {
>Symbol : Symbol
>Symbol : Symbol
getExportsOfExternalModule(node: ImportDeclaration): Symbol[];
>getExportsOfExternalModule : (node: ImportDeclaration) => Symbol[]
>node : ImportDeclaration
>ImportDeclaration : ImportDeclaration
getExportsOfModule(moduleSymbol: Symbol): Symbol[];
>getExportsOfModule : (moduleSymbol: Symbol) => Symbol[]
>moduleSymbol : Symbol
>Symbol : Symbol
>Symbol : Symbol
}
interface SymbolDisplayBuilder {
@ -6057,6 +6056,9 @@ declare module "typescript" {
kindModifiers: string;
>kindModifiers : string
sortText: string;
>sortText : string
}
interface CompletionEntryDetails {
>CompletionEntryDetails : CompletionEntryDetails
@ -6326,6 +6328,9 @@ declare module "typescript" {
static unknown: string;
>unknown : string
static warning: string;
>warning : string
static keyword: string;
>keyword : string

View file

@ -0,0 +1,9 @@
tests/cases/compiler/anonymousClassExpression1.ts(2,19): error TS9003: 'class' expressions are not currently supported.
==== tests/cases/compiler/anonymousClassExpression1.ts (1 errors) ====
function f() {
return typeof class {} === "function";
~~~~~
!!! error TS9003: 'class' expressions are not currently supported.
}

View file

@ -0,0 +1,13 @@
//// [anonymousClassExpression1.ts]
function f() {
return typeof class {} === "function";
}
//// [anonymousClassExpression1.js]
function f() {
return typeof (function () {
function default_1() {
}
return default_1;
})() === "function";
}

View file

@ -0,0 +1,13 @@
tests/cases/compiler/classDeclarationBlockScoping1.ts(5,11): error TS9004: 'class' declarations are only supported directly inside a module or as a top level declaration.
==== tests/cases/compiler/classDeclarationBlockScoping1.ts (1 errors) ====
class C {
}
{
class C {
~
!!! error TS9004: 'class' declarations are only supported directly inside a module or as a top level declaration.
}
}

View file

@ -0,0 +1,22 @@
//// [classDeclarationBlockScoping1.ts]
class C {
}
{
class C {
}
}
//// [classDeclarationBlockScoping1.js]
var C = (function () {
function C() {
}
return C;
})();
{
var C = (function () {
function C() {
}
return C;
})();
}

View file

@ -0,0 +1,18 @@
tests/cases/compiler/classDeclarationBlockScoping2.ts(2,11): error TS9004: 'class' declarations are only supported directly inside a module or as a top level declaration.
tests/cases/compiler/classDeclarationBlockScoping2.ts(5,15): error TS9004: 'class' declarations are only supported directly inside a module or as a top level declaration.
==== tests/cases/compiler/classDeclarationBlockScoping2.ts (2 errors) ====
function f() {
class C {}
~
!!! error TS9004: 'class' declarations are only supported directly inside a module or as a top level declaration.
var c1 = C;
{
class C {}
~
!!! error TS9004: 'class' declarations are only supported directly inside a module or as a top level declaration.
var c2 = C;
}
return C === c1;
}

View file

@ -0,0 +1,29 @@
//// [classDeclarationBlockScoping2.ts]
function f() {
class C {}
var c1 = C;
{
class C {}
var c2 = C;
}
return C === c1;
}
//// [classDeclarationBlockScoping2.js]
function f() {
var C = (function () {
function C() {
}
return C;
})();
var c1 = C;
{
var C = (function () {
function C() {
}
return C;
})();
var c2 = C;
}
return C === c1;
}

View file

@ -0,0 +1,10 @@
tests/cases/compiler/classExpressionWithDecorator1.ts(1,9): error TS1109: Expression expected.
tests/cases/compiler/classExpressionWithDecorator1.ts(1,10): error TS2304: Cannot find name 'decorate'.
==== tests/cases/compiler/classExpressionWithDecorator1.ts (2 errors) ====
var v = @decorate class C { static p = 1 };
~
!!! error TS1109: Expression expected.
~~~~~~~~
!!! error TS2304: Cannot find name 'decorate'.

View file

@ -0,0 +1,26 @@
//// [classExpressionWithDecorator1.ts]
var v = @decorate class C { static p = 1 };
//// [classExpressionWithDecorator1.js]
var __decorate = this.__decorate || function (decorators, target, key, value) {
var kind = typeof (arguments.length == 2 ? value = target : value);
for (var i = decorators.length - 1; i >= 0; --i) {
var decorator = decorators[i];
switch (kind) {
case "function": value = decorator(value) || value; break;
case "number": decorator(target, key, value); break;
case "undefined": decorator(target, key); break;
case "object": value = decorator(target, key, value) || value; break;
}
}
return value;
};
var v = ;
var C = (function () {
function C() {
}
C.p = 1;
C = __decorate([decorate], C);
return C;
})();
;

View file

@ -0,0 +1,7 @@
tests/cases/compiler/classExpressionWithStaticProperties1.ts(1,15): error TS9003: 'class' expressions are not currently supported.
==== tests/cases/compiler/classExpressionWithStaticProperties1.ts (1 errors) ====
var v = class C { static a = 1; static b = 2 };
~
!!! error TS9003: 'class' expressions are not currently supported.

View file

@ -0,0 +1,11 @@
//// [classExpressionWithStaticProperties1.ts]
var v = class C { static a = 1; static b = 2 };
//// [classExpressionWithStaticProperties1.js]
var v = (function () {
function C() {
}
C.a = 1;
C.b = 2;
return C;
})();

View file

@ -0,0 +1,7 @@
tests/cases/compiler/classExpressionWithStaticProperties2.ts(1,15): error TS9003: 'class' expressions are not currently supported.
==== tests/cases/compiler/classExpressionWithStaticProperties2.ts (1 errors) ====
var v = class C { static a = 1; static b };
~
!!! error TS9003: 'class' expressions are not currently supported.

View file

@ -0,0 +1,10 @@
//// [classExpressionWithStaticProperties2.ts]
var v = class C { static a = 1; static b };
//// [classExpressionWithStaticProperties2.js]
var v = (function () {
function C() {
}
C.a = 1;
return C;
})();

View file

@ -0,0 +1,7 @@
tests/cases/compiler/classExpressionWithStaticPropertiesES61.ts(1,15): error TS9003: 'class' expressions are not currently supported.
==== tests/cases/compiler/classExpressionWithStaticPropertiesES61.ts (1 errors) ====
var v = class C { static a = 1; static b = 2 };
~
!!! error TS9003: 'class' expressions are not currently supported.

View file

@ -0,0 +1,10 @@
//// [classExpressionWithStaticPropertiesES61.ts]
var v = class C { static a = 1; static b = 2 };
//// [classExpressionWithStaticPropertiesES61.js]
var v = (_a = class C {
},
_a.a = 1,
_a.b = 2,
_a);
var _a;

View file

@ -0,0 +1,7 @@
tests/cases/compiler/classExpressionWithStaticPropertiesES62.ts(1,15): error TS9003: 'class' expressions are not currently supported.
==== tests/cases/compiler/classExpressionWithStaticPropertiesES62.ts (1 errors) ====
var v = class C { static a = 1; static b };
~
!!! error TS9003: 'class' expressions are not currently supported.

View file

@ -0,0 +1,9 @@
//// [classExpressionWithStaticPropertiesES62.ts]
var v = class C { static a = 1; static b };
//// [classExpressionWithStaticPropertiesES62.js]
var v = (_a = class C {
},
_a.a = 1,
_a);
var _a;

View file

@ -1,4 +1,4 @@
tests/cases/conformance/classes/classDeclarations/classWithPredefinedTypesAsNames2.ts(3,7): error TS1003: Identifier expected.
tests/cases/conformance/classes/classDeclarations/classWithPredefinedTypesAsNames2.ts(3,7): error TS1005: '{' expected.
==== tests/cases/conformance/classes/classDeclarations/classWithPredefinedTypesAsNames2.ts (1 errors) ====
@ -6,4 +6,4 @@ tests/cases/conformance/classes/classDeclarations/classWithPredefinedTypesAsName
class void {}
~~~~
!!! error TS1003: Identifier expected.
!!! error TS1005: '{' expected.

View file

@ -5,9 +5,9 @@ class void {}
//// [classWithPredefinedTypesAsNames2.js]
// classes cannot use predefined types as names
var = (function () {
function () {
var default_1 = (function () {
function default_1() {
}
return ;
return default_1;
})();
void {};

View file

@ -1,40 +1,89 @@
tests/cases/compiler/collisionArgumentsClassConstructor.ts(3,28): error TS2396: Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters.
tests/cases/compiler/collisionArgumentsClassConstructor.ts(3,31): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
tests/cases/compiler/collisionArgumentsClassConstructor.ts(4,13): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
tests/cases/compiler/collisionArgumentsClassConstructor.ts(8,17): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
tests/cases/compiler/collisionArgumentsClassConstructor.ts(8,17): error TS2396: Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters.
tests/cases/compiler/collisionArgumentsClassConstructor.ts(9,13): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
tests/cases/compiler/collisionArgumentsClassConstructor.ts(13,17): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
tests/cases/compiler/collisionArgumentsClassConstructor.ts(14,13): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
tests/cases/compiler/collisionArgumentsClassConstructor.ts(20,13): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
tests/cases/compiler/collisionArgumentsClassConstructor.ts(25,13): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
tests/cases/compiler/collisionArgumentsClassConstructor.ts(30,17): error TS2396: Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters.
tests/cases/compiler/collisionArgumentsClassConstructor.ts(30,24): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
tests/cases/compiler/collisionArgumentsClassConstructor.ts(31,13): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
tests/cases/compiler/collisionArgumentsClassConstructor.ts(35,24): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
tests/cases/compiler/collisionArgumentsClassConstructor.ts(36,13): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
tests/cases/compiler/collisionArgumentsClassConstructor.ts(41,31): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
tests/cases/compiler/collisionArgumentsClassConstructor.ts(44,17): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
tests/cases/compiler/collisionArgumentsClassConstructor.ts(47,17): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
tests/cases/compiler/collisionArgumentsClassConstructor.ts(51,31): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
tests/cases/compiler/collisionArgumentsClassConstructor.ts(52,31): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
tests/cases/compiler/collisionArgumentsClassConstructor.ts(53,25): error TS2396: Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters.
tests/cases/compiler/collisionArgumentsClassConstructor.ts(53,28): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
tests/cases/compiler/collisionArgumentsClassConstructor.ts(54,13): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
tests/cases/compiler/collisionArgumentsClassConstructor.ts(59,17): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
tests/cases/compiler/collisionArgumentsClassConstructor.ts(60,17): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
tests/cases/compiler/collisionArgumentsClassConstructor.ts(61,17): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
tests/cases/compiler/collisionArgumentsClassConstructor.ts(61,17): error TS2396: Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters.
tests/cases/compiler/collisionArgumentsClassConstructor.ts(62,13): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
tests/cases/compiler/collisionArgumentsClassConstructor.ts(67,17): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
tests/cases/compiler/collisionArgumentsClassConstructor.ts(68,17): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
tests/cases/compiler/collisionArgumentsClassConstructor.ts(69,17): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
tests/cases/compiler/collisionArgumentsClassConstructor.ts(70,13): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
tests/cases/compiler/collisionArgumentsClassConstructor.ts(75,31): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
tests/cases/compiler/collisionArgumentsClassConstructor.ts(76,31): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
tests/cases/compiler/collisionArgumentsClassConstructor.ts(79,17): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
tests/cases/compiler/collisionArgumentsClassConstructor.ts(80,17): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
tests/cases/compiler/collisionArgumentsClassConstructor.ts(84,17): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
tests/cases/compiler/collisionArgumentsClassConstructor.ts(85,17): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
==== tests/cases/compiler/collisionArgumentsClassConstructor.ts (5 errors) ====
==== tests/cases/compiler/collisionArgumentsClassConstructor.ts (38 errors) ====
// Constructors
class c1 {
constructor(i: number, ...arguments) { // error
~~~~~~~~~~~~
!!! error TS2396: Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters.
~~~~~~~~~
!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
var arguments: any[]; // no error
~~~~~~~~~
!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
}
}
class c12 {
constructor(arguments: number, ...rest) { // error
~~~~~~~~~
!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
~~~~~~~~~~~~~~~~~
!!! error TS2396: Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters.
var arguments = 10; // no error
~~~~~~~~~
!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
}
}
class c1NoError {
constructor(arguments: number) { // no error
~~~~~~~~~
!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
var arguments = 10; // no error
~~~~~~~~~
!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
}
}
class c2 {
constructor(...restParameters) {
var arguments = 10; // no error
~~~~~~~~~
!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
}
}
class c2NoError {
constructor() {
var arguments = 10; // no error
~~~~~~~~~
!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
}
}
@ -42,63 +91,113 @@ tests/cases/compiler/collisionArgumentsClassConstructor.ts(61,17): error TS2396:
constructor(public arguments: number, ...restParameters) { //arguments is error
~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2396: Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters.
~~~~~~~~~
!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
var arguments = 10; // no error
~~~~~~~~~
!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
}
}
class c3NoError {
constructor(public arguments: number) { // no error
~~~~~~~~~
!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
var arguments = 10; // no error
~~~~~~~~~
!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
}
}
declare class c4 {
constructor(i: number, ...arguments); // No error - no code gen
~~~~~~~~~
!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
}
declare class c42 {
constructor(arguments: number, ...rest); // No error - no code gen
~~~~~~~~~
!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
}
declare class c4NoError {
constructor(arguments: number); // no error
~~~~~~~~~
!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
}
class c5 {
constructor(i: number, ...arguments); // no codegen no error
~~~~~~~~~
!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
constructor(i: string, ...arguments); // no codegen no error
~~~~~~~~~
!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
constructor(i: any, ...arguments) { // error
~~~~~~~~~~~~
!!! error TS2396: Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters.
~~~~~~~~~
!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
var arguments: any[]; // no error
~~~~~~~~~
!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
}
}
class c52 {
constructor(arguments: number, ...rest); // no codegen no error
~~~~~~~~~
!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
constructor(arguments: string, ...rest); // no codegen no error
~~~~~~~~~
!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
constructor(arguments: any, ...rest) { // error
~~~~~~~~~
!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
~~~~~~~~~~~~~~
!!! error TS2396: Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters.
var arguments: any; // no error
~~~~~~~~~
!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
}
}
class c5NoError {
constructor(arguments: number); // no error
~~~~~~~~~
!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
constructor(arguments: string); // no error
~~~~~~~~~
!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
constructor(arguments: any) { // no error
~~~~~~~~~
!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
var arguments: any; // no error
~~~~~~~~~
!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
}
}
declare class c6 {
constructor(i: number, ...arguments); // no codegen no error
~~~~~~~~~
!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
constructor(i: string, ...arguments); // no codegen no error
~~~~~~~~~
!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
}
declare class c62 {
constructor(arguments: number, ...rest); // no codegen no error
~~~~~~~~~
!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
constructor(arguments: string, ...rest); // no codegen no error
~~~~~~~~~
!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
}
declare class c6NoError {
constructor(arguments: number); // no error
~~~~~~~~~
!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
constructor(arguments: string); // no error
~~~~~~~~~
!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
}

View file

@ -1,63 +1,150 @@
tests/cases/compiler/collisionArgumentsClassMethod.ts(2,27): error TS2396: Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters.
tests/cases/compiler/collisionArgumentsClassMethod.ts(2,30): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
tests/cases/compiler/collisionArgumentsClassMethod.ts(3,13): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
tests/cases/compiler/collisionArgumentsClassMethod.ts(5,17): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
tests/cases/compiler/collisionArgumentsClassMethod.ts(5,17): error TS2396: Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters.
tests/cases/compiler/collisionArgumentsClassMethod.ts(6,13): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
tests/cases/compiler/collisionArgumentsClassMethod.ts(8,23): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
tests/cases/compiler/collisionArgumentsClassMethod.ts(9,13): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
tests/cases/compiler/collisionArgumentsClassMethod.ts(11,29): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
tests/cases/compiler/collisionArgumentsClassMethod.ts(12,29): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
tests/cases/compiler/collisionArgumentsClassMethod.ts(13,23): error TS2396: Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters.
tests/cases/compiler/collisionArgumentsClassMethod.ts(13,26): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
tests/cases/compiler/collisionArgumentsClassMethod.ts(14,13): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
tests/cases/compiler/collisionArgumentsClassMethod.ts(16,16): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
tests/cases/compiler/collisionArgumentsClassMethod.ts(17,16): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
tests/cases/compiler/collisionArgumentsClassMethod.ts(18,16): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
tests/cases/compiler/collisionArgumentsClassMethod.ts(18,16): error TS2396: Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters.
tests/cases/compiler/collisionArgumentsClassMethod.ts(19,13): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
tests/cases/compiler/collisionArgumentsClassMethod.ts(21,22): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
tests/cases/compiler/collisionArgumentsClassMethod.ts(22,22): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
tests/cases/compiler/collisionArgumentsClassMethod.ts(23,22): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
tests/cases/compiler/collisionArgumentsClassMethod.ts(24,13): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
tests/cases/compiler/collisionArgumentsClassMethod.ts(29,30): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
tests/cases/compiler/collisionArgumentsClassMethod.ts(30,17): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
tests/cases/compiler/collisionArgumentsClassMethod.ts(31,23): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
tests/cases/compiler/collisionArgumentsClassMethod.ts(33,29): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
tests/cases/compiler/collisionArgumentsClassMethod.ts(34,29): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
tests/cases/compiler/collisionArgumentsClassMethod.ts(35,16): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
tests/cases/compiler/collisionArgumentsClassMethod.ts(36,16): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
tests/cases/compiler/collisionArgumentsClassMethod.ts(37,22): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
tests/cases/compiler/collisionArgumentsClassMethod.ts(38,22): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
tests/cases/compiler/collisionArgumentsClassMethod.ts(43,13): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
tests/cases/compiler/collisionArgumentsClassMethod.ts(46,13): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
==== tests/cases/compiler/collisionArgumentsClassMethod.ts (4 errors) ====
==== tests/cases/compiler/collisionArgumentsClassMethod.ts (33 errors) ====
class c1 {
public foo(i: number, ...arguments) { //arguments is error
~~~~~~~~~~~~
!!! error TS2396: Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters.
~~~~~~~~~
!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
var arguments: any[]; // no error
~~~~~~~~~
!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
}
public foo1(arguments: number, ...rest) { //arguments is error
~~~~~~~~~
!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
~~~~~~~~~~~~~~~~~
!!! error TS2396: Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters.
var arguments = 10; // no error
~~~~~~~~~
!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
}
public fooNoError(arguments: number) { // no error
~~~~~~~~~
!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
var arguments = 10; // no error
~~~~~~~~~
!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
}
public f4(i: number, ...arguments); // no codegen no error
~~~~~~~~~
!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
public f4(i: string, ...arguments); // no codegen no error
~~~~~~~~~
!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
public f4(i: any, ...arguments) { // error
~~~~~~~~~~~~
!!! error TS2396: Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters.
~~~~~~~~~
!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
var arguments: any[]; // no error
~~~~~~~~~
!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
}
public f41(arguments: number, ...rest); // no codegen no error
~~~~~~~~~
!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
public f41(arguments: string, ...rest); // no codegen no error
~~~~~~~~~
!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
public f41(arguments: any, ...rest) { // error
~~~~~~~~~
!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
~~~~~~~~~~~~~~
!!! error TS2396: Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters.
var arguments: any; // no error
~~~~~~~~~
!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
}
public f4NoError(arguments: number); // no error
~~~~~~~~~
!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
public f4NoError(arguments: string); // no error
~~~~~~~~~
!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
public f4NoError(arguments: any) { // no error
~~~~~~~~~
!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
var arguments: any; // no error
~~~~~~~~~
!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
}
}
declare class c2 {
public foo(i: number, ...arguments); // No error - no code gen
~~~~~~~~~
!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
public foo1(arguments: number, ...rest); // No error - no code gen
~~~~~~~~~
!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
public fooNoError(arguments: number); // No error - no code gen
~~~~~~~~~
!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
public f4(i: number, ...arguments); // no codegen no error
~~~~~~~~~
!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
public f4(i: string, ...arguments); // no codegen no error
~~~~~~~~~
!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
public f41(arguments: number, ...rest); // no codegen no error
~~~~~~~~~
!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
public f41(arguments: string, ...rest); // no codegen no error
~~~~~~~~~
!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
public f4NoError(arguments: number); // no error
~~~~~~~~~
!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
public f4NoError(arguments: string); // no error
~~~~~~~~~
!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
}
class c3 {
public foo(...restParameters) {
var arguments = 10; // no error
~~~~~~~~~
!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
}
public fooNoError() {
var arguments = 10; // no error
~~~~~~~~~
!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
}
}

View file

@ -1,12 +1,13 @@
tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES5.ts(4,12): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES5.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_ES5.ts(5,9): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES5.ts(5,17): error TS1102: 'delete' cannot be called on an identifier in strict mode.
tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES5.ts(6,9): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES5.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_ES5.ts(7,16): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES5.ts (6 errors) ====
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES5.ts (7 errors) ====
var id;
class C {
[0 + 1]() { }
@ -18,6 +19,8 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES5.ts(7,1
!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement.
~~~~~~~~~~~
!!! error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
~~
!!! error TS1102: 'delete' cannot be called on an identifier in strict mode.
set [[0, 1]](v) { }
~~~~~~~~
!!! error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.

View file

@ -0,0 +1,12 @@
tests/cases/compiler/constructorStaticParamName.ts(4,18): error TS1003: Identifier expected.
==== tests/cases/compiler/constructorStaticParamName.ts (1 errors) ====
// static as constructor parameter name should only give error if 'use strict'
class test {
constructor (static) { }
~~~~~~
!!! error TS1003: Identifier expected.
}

View file

@ -9,7 +9,7 @@ class test {
//// [constructorStaticParamName.js]
// static as constructor parameter name should only give error if 'use strict'
var test = (function () {
function test(static) {
function test() {
}
return test;
})();

View file

@ -1,10 +0,0 @@
=== tests/cases/compiler/constructorStaticParamName.ts ===
// static as constructor parameter name should only give error if 'use strict'
class test {
>test : test
constructor (static) { }
>static : any
}

View file

@ -21,27 +21,47 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(47,17): error TS
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(49,13): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(53,13): error TS2304: Cannot find name 'console'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(58,5): error TS1128: Declaration or statement expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(65,29): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(69,13): error TS1109: Expression expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(72,37): error TS1127: Invalid character.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(81,13): error TS1109: Expression expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(89,23): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(90,13): error TS1109: Expression expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(94,17): error TS1134: Variable declaration expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(95,13): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(105,29): error TS1109: Expression expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(106,13): error TS1109: Expression expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(108,24): error TS2365: Operator '+' cannot be applied to types 'number' and 'boolean'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(108,24): error TS2304: Cannot find name 'any'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(108,30): error TS2304: Cannot find name 'bool'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(108,37): error TS2304: Cannot find name 'declare'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(108,47): error TS2304: Cannot find name 'constructor'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(108,61): error TS2304: Cannot find name 'get'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(108,67): error TS2304: Cannot find name 'implements'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(111,9): error TS1128: Declaration or statement expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(118,9): error TS2304: Cannot find name 'STATEMENTS'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(118,21): error TS1005: ',' expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(118,30): error TS1005: ';' expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(118,39): error TS1005: ';' expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(138,13): error TS1109: Expression expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(141,32): error TS1005: '{' expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(143,13): error TS1005: 'try' expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(155,9): error TS1128: Declaration or statement expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(155,16): error TS2304: Cannot find name 'TYPES'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(155,23): error TS1005: ';' expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(155,32): error TS1005: ';' expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(159,24): error TS1109: Expression expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(159,30): error TS1005: '(' expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(159,31): error TS2304: Cannot find name 'Property'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(166,13): error TS2365: Operator '+=' cannot be applied to types 'number' and 'void'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(176,9): error TS1128: Declaration or statement expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(176,16): error TS2304: Cannot find name 'OPERATOR'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(176,26): error TS1005: ';' expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(176,35): error TS1005: ';' expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(180,40): error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(205,28): error TS1109: Expression expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(210,5): error TS1128: Declaration or statement expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(213,16): error TS2304: Cannot find name 'bool'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(218,10): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(218,29): error TS2304: Cannot find name 'yield'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(218,36): error TS1005: ';' expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(223,23): error TS2304: Cannot find name 'bool'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(227,13): error TS1109: Expression expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(234,14): error TS1005: '{' expected.
@ -49,7 +69,6 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(235,9): error TS
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(235,16): error TS2304: Cannot find name 'method1'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(235,24): error TS2304: Cannot find name 'val'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(235,27): error TS1005: ',' expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(235,28): error TS2304: Cannot find name 'number'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(235,36): error TS1005: ';' expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(238,9): error TS1128: Declaration or statement expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(238,16): error TS2304: Cannot find name 'method2'.
@ -64,27 +83,23 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(256,9): error TS
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(256,16): error TS2304: Cannot find name 'Overloads'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(256,26): error TS2304: Cannot find name 'value'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(256,31): error TS1005: ',' expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(256,33): error TS2304: Cannot find name 'string'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(257,9): error TS1128: Declaration or statement expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(257,16): error TS2304: Cannot find name 'Overloads'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(257,27): error TS1135: Argument expression expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(257,33): error TS1005: '(' expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(257,35): error TS2304: Cannot find name 'string'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(257,43): error TS1109: Expression expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(257,52): error TS2304: Cannot find name 'string'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(257,60): error TS1005: ';' expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(257,65): error TS1109: Expression expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(259,9): error TS2304: Cannot find name 'public'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(259,16): error TS1005: ';' expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(259,16): error TS2304: Cannot find name 'DefaultValue'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(259,29): error TS2304: Cannot find name 'value'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(259,35): error TS1109: Expression expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(259,37): error TS2304: Cannot find name 'string'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(259,37): error TS2322: Type 'string' is not assignable to type 'boolean'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(259,55): error TS1005: ';' expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(261,1): error TS1128: Declaration or statement expected.
==== tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts (84 errors) ====
==== tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts (99 errors) ====
declare module "fs" {
export class File {
constructor(filename: string);
@ -199,6 +214,8 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(261,1): error TS
/// </summary>
/// <returns></returns>
public VARIABLES(): number {
~~~~~~
!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement.
var local = Number.MAX_VALUE;
var min = Number.MIN_VALUE;
var inf = Number.NEGATIVE_INFINITY -
@ -238,7 +255,11 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(261,1): error TS
var constructor = 0;
var get = 0;
var implements = 0;
~~~~~~~~~~
!!! error TS1134: Variable declaration expected.
var interface = 0;
~~~
!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
var let = 0;
var module = 0;
var number = 0;
@ -256,11 +277,23 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(261,1): error TS
!!! error TS1109: Expression expected.
var sum3 = any + bool + declare + constructor + get + implements + interface + let + module + number + package + private + protected + public + set + static + string + yield;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'number' and 'boolean'.
~~~
!!! error TS2304: Cannot find name 'any'.
~~~~
!!! error TS2304: Cannot find name 'bool'.
~~~~~~~
!!! error TS2304: Cannot find name 'declare'.
~~~~~~~~~~~
!!! error TS2304: Cannot find name 'constructor'.
~~~
!!! error TS2304: Cannot find name 'get'.
~~~~~~~~~~
!!! error TS2304: Cannot find name 'implements'.
return 0;
}
~
!!! error TS1128: Declaration or statement expected.
/// <summary>
/// Test different statements. Including if-else,swith,foreach,(un)checked,lock,using,try-catch-finally
@ -268,6 +301,14 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(261,1): error TS
/// <param name="i"></param>
/// <returns></returns>
STATEMENTS(i: number): number {
~~~~~~~~~~
!!! error TS2304: Cannot find name 'STATEMENTS'.
~
!!! error TS1005: ',' expected.
~
!!! error TS1005: ';' expected.
~
!!! error TS1005: ';' expected.
var retVal = 0;
if (i == 1)
retVal = 1;
@ -311,6 +352,14 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(261,1): error TS
/// </summary>
/// <returns></returns>
public TYPES(): number {
~~~~~~
!!! error TS1128: Declaration or statement expected.
~~~~~
!!! error TS2304: Cannot find name 'TYPES'.
~
!!! error TS1005: ';' expected.
~
!!! error TS1005: ';' expected.
var retVal = 0;
var c = new CLASS();
var xx: IF = c;
@ -340,6 +389,14 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(261,1): error TS
///// </summary>
///// <returns></returns>
public OPERATOR(): number {
~~~~~~
!!! error TS1128: Declaration or statement expected.
~~~~~~~~
!!! error TS2304: Cannot find name 'OPERATOR'.
~
!!! error TS1005: ';' expected.
~
!!! error TS1005: ';' expected.
var a: number[] = [1, 2, 3, 4, 5, ];/*[] bug*/ // YES []
var i = a[1];/*[]*/
i = i + i - i * i / i % i & i | i ^ i;/*+ - * / % & | ^*/
@ -378,6 +435,8 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(261,1): error TS
}
}
~
!!! error TS1128: Declaration or statement expected.
interface IF {
Foo(): bool;
@ -390,10 +449,6 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(261,1): error TS
case d = () => { yield 0; };
~~~~
!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
~~~~~
!!! error TS2304: Cannot find name 'yield'.
~
!!! error TS1005: ';' expected.
public get Property() { return 0; }
public Member() {
return 0;
@ -425,8 +480,6 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(261,1): error TS
!!! error TS2304: Cannot find name 'val'.
~
!!! error TS1005: ',' expected.
~~~~~~
!!! error TS2304: Cannot find name 'number'.
~
!!! error TS1005: ';' expected.
return val;
@ -476,8 +529,6 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(261,1): error TS
!!! error TS2304: Cannot find name 'value'.
~
!!! error TS1005: ',' expected.
~~~~~~
!!! error TS2304: Cannot find name 'string'.
public Overloads( while : string, ...rest: string[]) { &
~~~~~~
!!! error TS1128: Declaration or statement expected.
@ -487,20 +538,14 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(261,1): error TS
!!! error TS1135: Argument expression expected.
~
!!! error TS1005: '(' expected.
~~~~~~
!!! error TS2304: Cannot find name 'string'.
~~~
!!! error TS1109: Expression expected.
~~~~~~
!!! error TS2304: Cannot find name 'string'.
~
!!! error TS1005: ';' expected.
~
!!! error TS1109: Expression expected.
public DefaultValue(value?: string = "Hello") { }
~~~~~~
!!! error TS2304: Cannot find name 'public'.
~~~~~~~~~~~~
!!! error TS1005: ';' expected.
~~~~~~~~~~~~
@ -510,7 +555,7 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(261,1): error TS
~
!!! error TS1109: Expression expected.
~~~~~~
!!! error TS2304: Cannot find name 'string'.
!!! error TS2322: Type 'string' is not assignable to type 'boolean'.
~
!!! error TS1005: ';' expected.
}

View file

@ -342,6 +342,7 @@ var TypeScriptAllInOne;
})(TypeScriptAllInOne || (TypeScriptAllInOne = {}));
var BasicFeatures = (function () {
function BasicFeatures() {
this.implements = 0;
}
/// <summary>
/// Test various of variables. Including nullable,key world as variable,special format
@ -374,120 +375,118 @@ var BasicFeatures = (function () {
var declare = 0;
var constructor = 0;
var get = 0;
var implements = 0;
var interface = 0;
var let = 0;
var module = 0;
var number = 0;
var package = 0;
var private = 0;
var protected = 0;
var public = 0;
var set = 0;
var static = 0;
var string = 0 / >
;
var yield = 0;
var sum3 = any + bool + declare + constructor + get + implements + interface + let + module + number + package + private + protected + public + set + static + string + yield;
return 0;
};
/// <summary>
/// Test different statements. Including if-else,swith,foreach,(un)checked,lock,using,try-catch-finally
/// </summary>
/// <param name="i"></param>
/// <returns></returns>
BasicFeatures.prototype.STATEMENTS = function (i) {
var retVal = 0;
if (i == 1)
retVal = 1;
else
retVal = 0;
switch (i) {
case 2:
retVal = 1;
break;
case 3:
retVal = 1;
break;
default:
break;
}
for (var x in { x: 0, y: 1 }) {
!;
try {
throw null;
}
catch (Exception) { }
}
try {
}
finally {
try { }
catch (Exception) { }
}
return retVal;
};
/// <summary>
/// Test types in ts language. Including class,struct,interface,delegate,anonymous type
/// </summary>
/// <returns></returns>
BasicFeatures.prototype.TYPES = function () {
var retVal = 0;
var c = new CLASS();
var xx = c;
retVal += ;
try { }
catch () { }
Property;
retVal += c.Member();
retVal += xx.Foo() ? 0 : 1;
//anonymous type
var anony = { a: new CLASS() };
retVal += anony.a.d();
return retVal;
};
///// <summary>
///// Test different operators
///// </summary>
///// <returns></returns>
BasicFeatures.prototype.OPERATOR = function () {
var a = [1, 2, 3, 4, 5,]; /*[] bug*/ // YES []
var i = a[1]; /*[]*/
i = i + i - i * i / i % i & i | i ^ i; /*+ - * / % & | ^*/
var b = true && false || true ^ false; /*& | ^*/
b = !b; /*!*/
i = ~i; /*~i*/
b = i < (i - 1) && (i + 1) > i; /*< && >*/
var f = true ? 1 : 0; /*? :*/ // YES :
i++; /*++*/
i--; /*--*/
b = true && false || true; /*&& ||*/
i = i << 5; /*<<*/
i = i >> 5; /*>>*/
var j = i;
b = i == j && i != j && i <= j && i >= j; /*= == && != <= >=*/
i += 5.0; /*+=*/
i -= i; /*-=*/
i *= i; /**=*/
if (i == 0)
i++;
i /= i; /*/=*/
i %= i; /*%=*/
i &= i; /*&=*/
i |= i; /*|=*/
i ^= i; /*^=*/
i <<= i; /*<<=*/
i >>= i; /*>>=*/
if (i == 0 && != b && f == 1)
return 0;
else
return 1;
var ;
};
return BasicFeatures;
})();
var interface = 0;
var let = 0;
var module = 0;
var number = 0;
var package = 0;
var private = 0;
var protected = 0;
var public = 0;
var set = 0;
var static = 0;
var string = 0 / >
;
var yield = 0;
var sum3 = any + bool + declare + constructor + get + implements + interface + let + module + number + package + private + protected + public + set + static + string + yield;
return 0;
/// <summary>
/// Test different statements. Including if-else,swith,foreach,(un)checked,lock,using,try-catch-finally
/// </summary>
/// <param name="i"></param>
/// <returns></returns>
STATEMENTS(i, number);
number;
{
var retVal = 0;
if (i == 1)
retVal = 1;
else
retVal = 0;
switch (i) {
case 2:
retVal = 1;
break;
case 3:
retVal = 1;
break;
default:
break;
}
for (var x in { x: 0, y: 1 }) {
!;
try {
throw null;
}
catch (Exception) { }
}
try {
}
finally {
try { }
catch (Exception) { }
}
return retVal;
}
TYPES();
number;
{
var retVal = 0;
var c = new CLASS();
var xx = c;
retVal += ;
try { }
catch () { }
Property;
retVal += c.Member();
retVal += xx.Foo() ? 0 : 1;
//anonymous type
var anony = { a: new CLASS() };
retVal += anony.a.d();
return retVal;
}
OPERATOR();
number;
{
var a = [1, 2, 3, 4, 5,]; /*[] bug*/ // YES []
var i = a[1]; /*[]*/
i = i + i - i * i / i % i & i | i ^ i; /*+ - * / % & | ^*/
var b = true && false || true ^ false; /*& | ^*/
b = !b; /*!*/
i = ~i; /*~i*/
b = i < (i - 1) && (i + 1) > i; /*< && >*/
var f = true ? 1 : 0; /*? :*/ // YES :
i++; /*++*/
i--; /*--*/
b = true && false || true; /*&& ||*/
i = i << 5; /*<<*/
i = i >> 5; /*>>*/
var j = i;
b = i == j && i != j && i <= j && i >= j; /*= == && != <= >=*/
i += 5.0; /*+=*/
i -= i; /*-=*/
i *= i; /**=*/
if (i == 0)
i++;
i /= i; /*/=*/
i %= i; /*%=*/
i &= i; /*&=*/
i |= i; /*|=*/
i ^= i; /*^=*/
i <<= i; /*<<=*/
i >>= i; /*>>=*/
if (i == 0 && != b && f == 1)
return 0;
else
return 1;
}
var CLASS = (function () {
function CLASS() {
this.d = function () { yield; 0; };
this.d = function () { ; };
}
Object.defineProperty(CLASS.prototype, "Property", {
get: function () { return 0; },

View file

@ -0,0 +1,353 @@
tests/cases/compiler/convertKeywordsYes.ts(293,11): error TS1005: '{' expected.
tests/cases/compiler/convertKeywordsYes.ts(293,21): error TS1005: ';' expected.
tests/cases/compiler/convertKeywordsYes.ts(294,11): error TS1005: '{' expected.
tests/cases/compiler/convertKeywordsYes.ts(296,11): error TS1005: '{' expected.
tests/cases/compiler/convertKeywordsYes.ts(296,19): error TS1005: ';' expected.
tests/cases/compiler/convertKeywordsYes.ts(297,11): error TS1005: '{' expected.
tests/cases/compiler/convertKeywordsYes.ts(297,19): error TS1005: ';' expected.
tests/cases/compiler/convertKeywordsYes.ts(298,11): error TS1005: '{' expected.
tests/cases/compiler/convertKeywordsYes.ts(298,21): error TS1005: ';' expected.
tests/cases/compiler/convertKeywordsYes.ts(299,11): error TS1005: '{' expected.
tests/cases/compiler/convertKeywordsYes.ts(299,18): error TS1005: ';' expected.
tests/cases/compiler/convertKeywordsYes.ts(301,11): error TS1005: '{' expected.
tests/cases/compiler/convertKeywordsYes.ts(301,18): error TS1005: ';' expected.
tests/cases/compiler/convertKeywordsYes.ts(303,11): error TS1005: '{' expected.
tests/cases/compiler/convertKeywordsYes.ts(303,17): error TS1005: ';' expected.
==== tests/cases/compiler/convertKeywordsYes.ts (15 errors) ====
// reserved ES5 future in strict mode
var constructor = 0;
var any = 0;
var boolean = 0;
var implements = 0;
var interface = 0;
var let = 0;
var module = 0;
var number = 0;
var package = 0;
var private = 0;
var protected = 0;
var public = 0;
var set = 0;
var static = 0;
var string = 0;
var get = 0;
var yield = 0;
var declare = 0;
function bigGeneric<
constructor,
implements ,
interface ,
let,
module ,
package,
private ,
protected,
public ,
set ,
static ,
get ,
yield,
declare
>(c: constructor,
a: any,
b2: boolean,
i: implements ,
i2: interface ,
l: let,
m: module ,
n: number,
p: package,
p2: private ,
p3: protected,
p4: public ,
s: set ,
s2: static ,
s3: string,
g: get ,
y: yield,
d: declare ) { }
var bigObject = {
constructor: 0,
any: 0,
boolean: 0,
implements: 0,
interface: 0,
let: 0,
module: 0,
number: 0,
package: 0,
private: 0,
protected: 0,
public: 0,
set: 0,
static: 0,
string: 0,
get: 0,
yield: 0,
break: 0,
case: 0,
catch: 0,
class: 0,
continue: 0,
const: 0,
debugger: 0,
declare: 0,
default: 0,
delete: 0,
do: 0,
else: 0,
enum: 0,
export: 0,
extends: 0,
false: 0,
finally: 0,
for: 0,
function: 0,
if: 0,
import: 0,
in: 0,
instanceof: 0,
new: 0,
null: 0,
return: 0,
super: 0,
switch: 0,
this: 0,
throw: 0,
true: 0,
try: 0,
typeof: 0,
var: 0,
void: 0,
while: 0,
with: 0,
};
interface bigInterface {
constructor;
any;
boolean;
implements;
interface;
let;
module;
number;
package;
private;
protected;
public;
set;
static;
string;
get;
yield;
break;
case;
catch;
class;
continue;
const;
debugger;
declare;
default;
delete;
do;
else;
enum;
export;
extends;
false;
finally;
for;
function;
if;
import;
in;
instanceof;
new;
null;
return;
super;
switch;
this;
throw;
true;
try;
typeof;
var;
void;
while;
with;
}
class bigClass {
public "constructor" = 0;
public any = 0;
public boolean = 0;
public implements = 0;
public interface = 0;
public let = 0;
public module = 0;
public number = 0;
public package = 0;
public private = 0;
public protected = 0;
public public = 0;
public set = 0;
public static = 0;
public string = 0;
public get = 0;
public yield = 0;
public break = 0;
public case = 0;
public catch = 0;
public class = 0;
public continue = 0;
public const = 0;
public debugger = 0;
public declare = 0;
public default = 0;
public delete = 0;
public do = 0;
public else = 0;
public enum = 0;
public export = 0;
public extends = 0;
public false = 0;
public finally = 0;
public for = 0;
public function = 0;
public if = 0;
public import = 0;
public in = 0;
public instanceof = 0;
public new = 0;
public null = 0;
public return = 0;
public super = 0;
public switch = 0;
public this = 0;
public throw = 0;
public true = 0;
public try = 0;
public typeof = 0;
public var = 0;
public void = 0;
public while = 0;
public with = 0;
}
enum bigEnum {
constructor,
any,
boolean,
implements,
interface,
let,
module,
number,
package,
private,
protected,
public,
set,
static,
string,
get,
yield,
break,
case,
catch,
class,
continue,
const,
debugger,
declare,
default,
delete,
do,
else,
enum,
export,
extends,
false,
finally,
for,
function,
if,
import,
in,
instanceof,
new,
null,
return,
super,
switch,
this,
throw,
true,
try,
typeof,
var,
void,
while,
with,
}
module bigModule {
class constructor { }
class implements { }
class interface { }
~~~~~~~~~
!!! error TS1005: '{' expected.
~
!!! error TS1005: ';' expected.
class let { }
~~~
!!! error TS1005: '{' expected.
class module { }
class package { }
~~~~~~~
!!! error TS1005: '{' expected.
~
!!! error TS1005: ';' expected.
class private { }
~~~~~~~
!!! error TS1005: '{' expected.
~
!!! error TS1005: ';' expected.
class protected { }
~~~~~~~~~
!!! error TS1005: '{' expected.
~
!!! error TS1005: ';' expected.
class public { }
~~~~~~
!!! error TS1005: '{' expected.
~
!!! error TS1005: ';' expected.
class set { }
class static { }
~~~~~~
!!! error TS1005: '{' expected.
~
!!! error TS1005: ';' expected.
class get { }
class yield { }
~~~~~
!!! error TS1005: '{' expected.
~
!!! error TS1005: ';' expected.
class declare { }
}

View file

@ -505,66 +505,81 @@ var bigModule;
}
return constructor;
})();
var implements = (function () {
function implements() {
var default_1 = (function () {
function default_1() {
}
return implements;
return default_1;
})();
var interface = (function () {
function interface() {
var default_2 = (function () {
function default_2() {
}
return interface;
return default_2;
})();
var let = (function () {
function let() {
interface;
{ }
var default_3 = (function () {
function default_3() {
}
return let;
return default_3;
})();
var _a = void 0;
var module = (function () {
function module() {
}
return module;
})();
var package = (function () {
function package() {
var default_4 = (function () {
function default_4() {
}
return package;
return default_4;
})();
var private = (function () {
function private() {
package;
{ }
var default_5 = (function () {
function default_5() {
}
return private;
return default_5;
})();
var protected = (function () {
function protected() {
private;
{ }
var default_6 = (function () {
function default_6() {
}
return protected;
return default_6;
})();
var public = (function () {
function public() {
protected;
{ }
var default_7 = (function () {
function default_7() {
}
return public;
return default_7;
})();
public;
{ }
var set = (function () {
function set() {
}
return set;
})();
var static = (function () {
function static() {
var default_8 = (function () {
function default_8() {
}
return static;
return default_8;
})();
static;
{ }
var get = (function () {
function get() {
}
return get;
})();
var yield = (function () {
function yield() {
var default_9 = (function () {
function default_9() {
}
return yield;
return default_9;
})();
yield;
{ }
var declare = (function () {
function declare() {
}

View file

@ -1,879 +0,0 @@
=== tests/cases/compiler/convertKeywordsYes.ts ===
// reserved ES5 future in strict mode
var constructor = 0;
>constructor : number
var any = 0;
>any : number
var boolean = 0;
>boolean : number
var implements = 0;
>implements : number
var interface = 0;
>interface : number
var let = 0;
>let : number
var module = 0;
>module : number
var number = 0;
>number : number
var package = 0;
>package : number
var private = 0;
>private : number
var protected = 0;
>protected : number
var public = 0;
>public : number
var set = 0;
>set : number
var static = 0;
>static : number
var string = 0;
>string : number
var get = 0;
>get : number
var yield = 0;
>yield : number
var declare = 0;
>declare : number
function bigGeneric<
>bigGeneric : <constructor, implements, interface, let, module, package, private, protected, public, set, static, get, yield, declare>(c: constructor, a: any, b2: boolean, i: implements, i2: interface, l: let, m: module, n: number, p: package, p2: private, p3: protected, p4: public, s: set, s2: static, s3: string, g: get, y: yield, d: declare) => void
constructor,
>constructor : constructor
implements ,
>implements : implements
interface ,
>interface : interface
let,
>let : let
module ,
>module : module
package,
>package : package
private ,
>private : private
protected,
>protected : protected
public ,
>public : public
set ,
>set : set
static ,
>static : static
get ,
>get : get
yield,
>yield : yield
declare
>declare : declare
>(c: constructor,
>c : constructor
>constructor : constructor
a: any,
>a : any
b2: boolean,
>b2 : boolean
i: implements ,
>i : implements
>implements : implements
i2: interface ,
>i2 : interface
>interface : interface
l: let,
>l : let
>let : let
m: module ,
>m : module
>module : module
n: number,
>n : number
p: package,
>p : package
>package : package
p2: private ,
>p2 : private
>private : private
p3: protected,
>p3 : protected
>protected : protected
p4: public ,
>p4 : public
>public : public
s: set ,
>s : set
>set : set
s2: static ,
>s2 : static
>static : static
s3: string,
>s3 : string
g: get ,
>g : get
>get : get
y: yield,
>y : yield
>yield : yield
d: declare ) { }
>d : declare
>declare : declare
var bigObject = {
>bigObject : { constructor: number; any: number; boolean: number; implements: number; interface: number; let: number; module: number; number: number; package: number; private: number; protected: number; public: number; set: number; static: number; string: number; get: number; yield: number; break: number; case: number; catch: number; class: number; continue: number; const: number; debugger: number; declare: number; default: number; delete: number; do: number; else: number; enum: number; export: number; extends: number; false: number; finally: number; for: number; function: number; if: number; import: number; in: number; instanceof: number; new: number; null: number; return: number; super: number; switch: number; this: number; throw: number; true: number; try: number; typeof: number; var: number; void: number; while: number; with: number; }
>{ constructor: 0, any: 0, boolean: 0, implements: 0, interface: 0, let: 0, module: 0, number: 0, package: 0, private: 0, protected: 0, public: 0, set: 0, static: 0, string: 0, get: 0, yield: 0, break: 0, case: 0, catch: 0, class: 0, continue: 0, const: 0, debugger: 0, declare: 0, default: 0, delete: 0, do: 0, else: 0, enum: 0, export: 0, extends: 0, false: 0, finally: 0, for: 0, function: 0, if: 0, import: 0, in: 0, instanceof: 0, new: 0, null: 0, return: 0, super: 0, switch: 0, this: 0, throw: 0, true: 0, try: 0, typeof: 0, var: 0, void: 0, while: 0, with: 0,} : { constructor: number; any: number; boolean: number; implements: number; interface: number; let: number; module: number; number: number; package: number; private: number; protected: number; public: number; set: number; static: number; string: number; get: number; yield: number; break: number; case: number; catch: number; class: number; continue: number; const: number; debugger: number; declare: number; default: number; delete: number; do: number; else: number; enum: number; export: number; extends: number; false: number; finally: number; for: number; function: number; if: number; import: number; in: number; instanceof: number; new: number; null: number; return: number; super: number; switch: number; this: number; throw: number; true: number; try: number; typeof: number; var: number; void: number; while: number; with: number; }
constructor: 0,
>constructor : number
any: 0,
>any : number
boolean: 0,
>boolean : number
implements: 0,
>implements : number
interface: 0,
>interface : number
let: 0,
>let : number
module: 0,
>module : number
number: 0,
>number : number
package: 0,
>package : number
private: 0,
>private : number
protected: 0,
>protected : number
public: 0,
>public : number
set: 0,
>set : number
static: 0,
>static : number
string: 0,
>string : number
get: 0,
>get : number
yield: 0,
>yield : number
break: 0,
>break : number
case: 0,
>case : number
catch: 0,
>catch : number
class: 0,
>class : number
continue: 0,
>continue : number
const: 0,
>const : number
debugger: 0,
>debugger : number
declare: 0,
>declare : number
default: 0,
>default : number
delete: 0,
>delete : number
do: 0,
>do : number
else: 0,
>else : number
enum: 0,
>enum : number
export: 0,
>export : number
extends: 0,
>extends : number
false: 0,
>false : number
finally: 0,
>finally : number
for: 0,
>for : number
function: 0,
>function : number
if: 0,
>if : number
import: 0,
>import : number
in: 0,
>in : number
instanceof: 0,
>instanceof : number
new: 0,
>new : number
null: 0,
>null : number
return: 0,
>return : number
super: 0,
>super : number
switch: 0,
>switch : number
this: 0,
>this : number
throw: 0,
>throw : number
true: 0,
>true : number
try: 0,
>try : number
typeof: 0,
>typeof : number
var: 0,
>var : number
void: 0,
>void : number
while: 0,
>while : number
with: 0,
>with : number
};
interface bigInterface {
>bigInterface : bigInterface
constructor;
>constructor : any
any;
>any : any
boolean;
>boolean : any
implements;
>implements : any
interface;
>interface : any
let;
>let : any
module;
>module : any
number;
>number : any
package;
>package : any
private;
>private : any
protected;
>protected : any
public;
>public : any
set;
>set : any
static;
>static : any
string;
>string : any
get;
>get : any
yield;
>yield : any
break;
>break : any
case;
>case : any
catch;
>catch : any
class;
>class : any
continue;
>continue : any
const;
>const : any
debugger;
>debugger : any
declare;
>declare : any
default;
>default : any
delete;
>delete : any
do;
>do : any
else;
>else : any
enum;
>enum : any
export;
>export : any
extends;
>extends : any
false;
>false : any
finally;
>finally : any
for;
>for : any
function;
>function : any
if;
>if : any
import;
>import : any
in;
>in : any
instanceof;
>instanceof : any
new;
>new : any
null;
>null : any
return;
>return : any
super;
>super : any
switch;
>switch : any
this;
>this : any
throw;
>throw : any
true;
>true : any
try;
>try : any
typeof;
>typeof : any
var;
>var : any
void;
>void : any
while;
>while : any
with;
>with : any
}
class bigClass {
>bigClass : bigClass
public "constructor" = 0;
public any = 0;
>any : number
public boolean = 0;
>boolean : number
public implements = 0;
>implements : number
public interface = 0;
>interface : number
public let = 0;
>let : number
public module = 0;
>module : number
public number = 0;
>number : number
public package = 0;
>package : number
public private = 0;
>private : number
public protected = 0;
>protected : number
public public = 0;
>public : number
public set = 0;
>set : number
public static = 0;
>static : number
public string = 0;
>string : number
public get = 0;
>get : number
public yield = 0;
>yield : number
public break = 0;
>break : number
public case = 0;
>case : number
public catch = 0;
>catch : number
public class = 0;
>class : number
public continue = 0;
>continue : number
public const = 0;
>const : number
public debugger = 0;
>debugger : number
public declare = 0;
>declare : number
public default = 0;
>default : number
public delete = 0;
>delete : number
public do = 0;
>do : number
public else = 0;
>else : number
public enum = 0;
>enum : number
public export = 0;
>export : number
public extends = 0;
>extends : number
public false = 0;
>false : number
public finally = 0;
>finally : number
public for = 0;
>for : number
public function = 0;
>function : number
public if = 0;
>if : number
public import = 0;
>import : number
public in = 0;
>in : number
public instanceof = 0;
>instanceof : number
public new = 0;
>new : number
public null = 0;
>null : number
public return = 0;
>return : number
public super = 0;
>super : number
public switch = 0;
>switch : number
public this = 0;
>this : number
public throw = 0;
>throw : number
public true = 0;
>true : number
public try = 0;
>try : number
public typeof = 0;
>typeof : number
public var = 0;
>var : number
public void = 0;
>void : number
public while = 0;
>while : number
public with = 0;
>with : number
}
enum bigEnum {
>bigEnum : bigEnum
constructor,
>constructor : bigEnum
any,
>any : bigEnum
boolean,
>boolean : bigEnum
implements,
>implements : bigEnum
interface,
>interface : bigEnum
let,
>let : bigEnum
module,
>module : bigEnum
number,
>number : bigEnum
package,
>package : bigEnum
private,
>private : bigEnum
protected,
>protected : bigEnum
public,
>public : bigEnum
set,
>set : bigEnum
static,
>static : bigEnum
string,
>string : bigEnum
get,
>get : bigEnum
yield,
>yield : bigEnum
break,
>break : bigEnum
case,
>case : bigEnum
catch,
>catch : bigEnum
class,
>class : bigEnum
continue,
>continue : bigEnum
const,
>const : bigEnum
debugger,
>debugger : bigEnum
declare,
>declare : bigEnum
default,
>default : bigEnum
delete,
>delete : bigEnum
do,
>do : bigEnum
else,
>else : bigEnum
enum,
>enum : bigEnum
export,
>export : bigEnum
extends,
>extends : bigEnum
false,
>false : bigEnum
finally,
>finally : bigEnum
for,
>for : bigEnum
function,
>function : bigEnum
if,
>if : bigEnum
import,
>import : bigEnum
in,
>in : bigEnum
instanceof,
>instanceof : bigEnum
new,
>new : bigEnum
null,
>null : bigEnum
return,
>return : bigEnum
super,
>super : bigEnum
switch,
>switch : bigEnum
this,
>this : bigEnum
throw,
>throw : bigEnum
true,
>true : bigEnum
try,
>try : bigEnum
typeof,
>typeof : bigEnum
var,
>var : bigEnum
void,
>void : bigEnum
while,
>while : bigEnum
with,
>with : bigEnum
}
module bigModule {
>bigModule : typeof bigModule
class constructor { }
>constructor : constructor
class implements { }
>implements : implements
class interface { }
>interface : interface
class let { }
>let : let
class module { }
>module : module
class package { }
>package : package
class private { }
>private : private
class protected { }
>protected : protected
class public { }
>public : public
class set { }
>set : set
class static { }
>static : static
class get { }
>get : get
class yield { }
>yield : yield
class declare { }
>declare : declare
}

View file

@ -1,35 +1,11 @@
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor3.ts(4,5): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor3.ts(4,5): error TS2304: Cannot find name 'public'.
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor3.ts(4,12): error TS1005: ';' expected.
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor3.ts(4,16): error TS1146: Declaration expected.
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor3.ts(4,17): error TS2304: Cannot find name 'get'.
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor3.ts(4,21): error TS1005: ';' expected.
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor3.ts(4,21): error TS2304: Cannot find name 'accessor'.
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor3.ts(4,32): error TS1005: ';' expected.
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor3.ts(5,1): error TS1128: Declaration or statement expected.
==== tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor3.ts (9 errors) ====
==== tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor3.ts (1 errors) ====
declare function dec<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
class C {
public @dec get accessor() { return 1; }
~~~~~~
!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
~~~~~~
!!! error TS2304: Cannot find name 'public'.
~
!!! error TS1005: ';' expected.
!!! error TS1146: Declaration expected.
~~~
!!! error TS2304: Cannot find name 'get'.
~~~~~~~~
!!! error TS1005: ';' expected.
~~~~~~~~
!!! error TS2304: Cannot find name 'accessor'.
~
!!! error TS1005: ';' expected.
}
~
!!! error TS1128: Declaration or statement expected.
}

View file

@ -6,14 +6,27 @@ class C {
}
//// [decoratorOnClassAccessor3.js]
var __decorate = this.__decorate || function (decorators, target, key, value) {
var kind = typeof (arguments.length == 2 ? value = target : value);
for (var i = decorators.length - 1; i >= 0; --i) {
var decorator = decorators[i];
switch (kind) {
case "function": value = decorator(value) || value; break;
case "number": decorator(target, key, value); break;
case "undefined": decorator(target, key); break;
case "object": value = decorator(target, key, value) || value; break;
}
}
return value;
};
var C = (function () {
function C() {
}
Object.defineProperty(C.prototype, "accessor", {
get: function () { return 1; },
enumerable: true,
configurable: true
});
Object.defineProperty(C.prototype, "accessor", __decorate([dec], C.prototype, "accessor", Object.getOwnPropertyDescriptor(C.prototype, "accessor")));
return C;
})();
public;
get;
accessor();
{
return 1;
}

View file

@ -1,44 +1,11 @@
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts(4,5): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts(4,5): error TS2304: Cannot find name 'public'.
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts(4,12): error TS1005: ';' expected.
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts(4,16): error TS1146: Declaration expected.
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts(4,17): error TS2304: Cannot find name 'set'.
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts(4,21): error TS1005: ';' expected.
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts(4,21): error TS2304: Cannot find name 'accessor'.
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts(4,30): error TS2304: Cannot find name 'value'.
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts(4,35): error TS1005: ',' expected.
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts(4,37): error TS2304: Cannot find name 'number'.
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts(4,45): error TS1005: ';' expected.
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts(5,1): error TS1128: Declaration or statement expected.
==== tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts (12 errors) ====
==== tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts (1 errors) ====
declare function dec<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
class C {
public @dec set accessor(value: number) { }
~~~~~~
!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
~~~~~~
!!! error TS2304: Cannot find name 'public'.
~
!!! error TS1005: ';' expected.
!!! error TS1146: Declaration expected.
~~~
!!! error TS2304: Cannot find name 'set'.
~~~~~~~~
!!! error TS1005: ';' expected.
~~~~~~~~
!!! error TS2304: Cannot find name 'accessor'.
~~~~~
!!! error TS2304: Cannot find name 'value'.
~
!!! error TS1005: ',' expected.
~~~~~~
!!! error TS2304: Cannot find name 'number'.
~
!!! error TS1005: ';' expected.
}
~
!!! error TS1128: Declaration or statement expected.
}

View file

@ -6,12 +6,27 @@ class C {
}
//// [decoratorOnClassAccessor6.js]
var __decorate = this.__decorate || function (decorators, target, key, value) {
var kind = typeof (arguments.length == 2 ? value = target : value);
for (var i = decorators.length - 1; i >= 0; --i) {
var decorator = decorators[i];
switch (kind) {
case "function": value = decorator(value) || value; break;
case "number": decorator(target, key, value); break;
case "undefined": decorator(target, key); break;
case "object": value = decorator(target, key, value) || value; break;
}
}
return value;
};
var C = (function () {
function C() {
}
Object.defineProperty(C.prototype, "accessor", {
set: function (value) { },
enumerable: true,
configurable: true
});
Object.defineProperty(C.prototype, "accessor", __decorate([dec], C.prototype, "accessor", Object.getOwnPropertyDescriptor(C.prototype, "accessor")));
return C;
})();
public;
set;
accessor(value, number);
{ }

View file

@ -1,11 +1,14 @@
tests/cases/conformance/decorators/class/constructor/parameter/decoratorOnClassConstructorParameter4.ts(4,17): error TS1003: Identifier expected.
tests/cases/conformance/decorators/class/constructor/parameter/decoratorOnClassConstructorParameter4.ts(4,24): error TS1005: ',' expected.
==== tests/cases/conformance/decorators/class/constructor/parameter/decoratorOnClassConstructorParameter4.ts (1 errors) ====
==== tests/cases/conformance/decorators/class/constructor/parameter/decoratorOnClassConstructorParameter4.ts (2 errors) ====
declare function dec(target: Function, propertyKey: string | symbol, parameterIndex: number): void;
class C {
constructor(public @dec p: number) {}
~~~~~~
!!! error TS1003: Identifier expected.
~
!!! error TS1005: ',' expected.
}

View file

@ -15,7 +15,7 @@ var __decorate = this.__decorate || (typeof Reflect === "object" && Reflect.deco
};
var __param = this.__param || function(index, decorator) { return function (target, key) { decorator(target, key, index); } };
var C = (function () {
function C(public, p) {
function C(, p) {
}
C = __decorate([
__param(1, dec)

View file

@ -1,29 +1,11 @@
tests/cases/conformance/decorators/class/method/decoratorOnClassMethod3.ts(4,5): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
tests/cases/conformance/decorators/class/method/decoratorOnClassMethod3.ts(4,5): error TS2304: Cannot find name 'public'.
tests/cases/conformance/decorators/class/method/decoratorOnClassMethod3.ts(4,12): error TS1005: ';' expected.
tests/cases/conformance/decorators/class/method/decoratorOnClassMethod3.ts(4,16): error TS1146: Declaration expected.
tests/cases/conformance/decorators/class/method/decoratorOnClassMethod3.ts(4,17): error TS2304: Cannot find name 'method'.
tests/cases/conformance/decorators/class/method/decoratorOnClassMethod3.ts(4,26): error TS1005: ';' expected.
tests/cases/conformance/decorators/class/method/decoratorOnClassMethod3.ts(5,1): error TS1128: Declaration or statement expected.
==== tests/cases/conformance/decorators/class/method/decoratorOnClassMethod3.ts (7 errors) ====
==== tests/cases/conformance/decorators/class/method/decoratorOnClassMethod3.ts (1 errors) ====
declare function dec<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
class C {
public @dec method() {}
~~~~~~
!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
~~~~~~
!!! error TS2304: Cannot find name 'public'.
~
!!! error TS1005: ';' expected.
!!! error TS1146: Declaration expected.
~~~~~~
!!! error TS2304: Cannot find name 'method'.
~
!!! error TS1005: ';' expected.
}
~
!!! error TS1128: Declaration or statement expected.
}

View file

@ -6,11 +6,23 @@ class C {
}
//// [decoratorOnClassMethod3.js]
var __decorate = this.__decorate || function (decorators, target, key, value) {
var kind = typeof (arguments.length == 2 ? value = target : value);
for (var i = decorators.length - 1; i >= 0; --i) {
var decorator = decorators[i];
switch (kind) {
case "function": value = decorator(value) || value; break;
case "number": decorator(target, key, value); break;
case "undefined": decorator(target, key); break;
case "object": value = decorator(target, key, value) || value; break;
}
}
return value;
};
var C = (function () {
function C() {
}
C.prototype.method = function () { };
Object.defineProperty(C.prototype, "method", __decorate([dec], C.prototype, "method", Object.getOwnPropertyDescriptor(C.prototype, "method")));
return C;
})();
public;
method();
{ }

View file

@ -1,26 +1,11 @@
tests/cases/conformance/decorators/class/property/decoratorOnClassProperty3.ts(4,5): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
tests/cases/conformance/decorators/class/property/decoratorOnClassProperty3.ts(4,5): error TS2304: Cannot find name 'public'.
tests/cases/conformance/decorators/class/property/decoratorOnClassProperty3.ts(4,12): error TS1005: ';' expected.
tests/cases/conformance/decorators/class/property/decoratorOnClassProperty3.ts(4,16): error TS1146: Declaration expected.
tests/cases/conformance/decorators/class/property/decoratorOnClassProperty3.ts(4,17): error TS2304: Cannot find name 'prop'.
tests/cases/conformance/decorators/class/property/decoratorOnClassProperty3.ts(5,1): error TS1128: Declaration or statement expected.
==== tests/cases/conformance/decorators/class/property/decoratorOnClassProperty3.ts (6 errors) ====
==== tests/cases/conformance/decorators/class/property/decoratorOnClassProperty3.ts (1 errors) ====
declare function dec(target: any, propertyKey: string): void;
class C {
public @dec prop;
~~~~~~
!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
~~~~~~
!!! error TS2304: Cannot find name 'public'.
~
!!! error TS1005: ';' expected.
!!! error TS1146: Declaration expected.
~~~~
!!! error TS2304: Cannot find name 'prop'.
}
~
!!! error TS1128: Declaration or statement expected.
}

View file

@ -6,10 +6,22 @@ class C {
}
//// [decoratorOnClassProperty3.js]
var __decorate = this.__decorate || function (decorators, target, key, value) {
var kind = typeof (arguments.length == 2 ? value = target : value);
for (var i = decorators.length - 1; i >= 0; --i) {
var decorator = decorators[i];
switch (kind) {
case "function": value = decorator(value) || value; break;
case "number": decorator(target, key, value); break;
case "undefined": decorator(target, key); break;
case "object": value = decorator(target, key, value) || value; break;
}
}
return value;
};
var C = (function () {
function C() {
}
__decorate([dec], C.prototype, "prop");
return C;
})();
public;
prop;

View file

@ -8,9 +8,13 @@ tests/cases/compiler/externModule.ts(18,6): error TS2390: Constructor implementa
tests/cases/compiler/externModule.ts(20,13): error TS2391: Function implementation is missing or not immediately following the declaration.
tests/cases/compiler/externModule.ts(26,13): error TS2391: Function implementation is missing or not immediately following the declaration.
tests/cases/compiler/externModule.ts(28,13): error TS2391: Function implementation is missing or not immediately following the declaration.
tests/cases/compiler/externModule.ts(32,11): error TS2304: Cannot find name 'XDate'.
tests/cases/compiler/externModule.ts(34,7): error TS2304: Cannot find name 'XDate'.
tests/cases/compiler/externModule.ts(36,7): error TS2304: Cannot find name 'XDate'.
tests/cases/compiler/externModule.ts(37,3): error TS2304: Cannot find name 'XDate'.
==== tests/cases/compiler/externModule.ts (10 errors) ====
==== tests/cases/compiler/externModule.ts (14 errors) ====
declare module {
~~~~~~~
!!! error TS2304: Cannot find name 'declare'.
@ -63,10 +67,18 @@ tests/cases/compiler/externModule.ts(28,13): error TS2391: Function implementati
}
var d=new XDate();
~~~~~
!!! error TS2304: Cannot find name 'XDate'.
d.getDay();
d=new XDate(1978,2);
~~~~~
!!! error TS2304: Cannot find name 'XDate'.
d.getXDate();
var n=XDate.parse("3/2/2004");
~~~~~
!!! error TS2304: Cannot find name 'XDate'.
n=XDate.UTC(1964,2,1);
~~~~~
!!! error TS2304: Cannot find name 'XDate'.

View file

@ -1,4 +1,4 @@
tests/cases/conformance/types/specifyingTypes/predefinedTypes/objectTypesWithPredefinedTypesAsName2.ts(3,7): error TS1003: Identifier expected.
tests/cases/conformance/types/specifyingTypes/predefinedTypes/objectTypesWithPredefinedTypesAsName2.ts(3,7): error TS1005: '{' expected.
==== tests/cases/conformance/types/specifyingTypes/predefinedTypes/objectTypesWithPredefinedTypesAsName2.ts (1 errors) ====
@ -6,4 +6,4 @@ tests/cases/conformance/types/specifyingTypes/predefinedTypes/objectTypesWithPre
class void {} // parse error unlike the others
~~~~
!!! error TS1003: Identifier expected.
!!! error TS1005: '{' expected.

View file

@ -5,9 +5,9 @@ class void {} // parse error unlike the others
//// [objectTypesWithPredefinedTypesAsName2.js]
// it is an error to use a predefined type as a type name
var = (function () {
function () {
var default_1 = (function () {
function default_1() {
}
return ;
return default_1;
})();
void {}; // parse error unlike the others

View file

@ -1,6 +1,6 @@
tests/cases/conformance/es6/classDeclaration/parseClassDeclarationInStrictModeByDefaultInES6.ts(4,16): error TS1100: Invalid use of 'arguments' in strict mode.
tests/cases/conformance/es6/classDeclaration/parseClassDeclarationInStrictModeByDefaultInES6.ts(5,17): error TS1100: Invalid use of 'eval' in strict mode.
tests/cases/conformance/es6/classDeclaration/parseClassDeclarationInStrictModeByDefaultInES6.ts(6,9): error TS1100: Invalid use of 'arguments' in strict mode.
tests/cases/conformance/es6/classDeclaration/parseClassDeclarationInStrictModeByDefaultInES6.ts(4,16): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
tests/cases/conformance/es6/classDeclaration/parseClassDeclarationInStrictModeByDefaultInES6.ts(5,17): error TS1210: Invalid use of 'eval'. Class definitions are automatically in strict mode.
tests/cases/conformance/es6/classDeclaration/parseClassDeclarationInStrictModeByDefaultInES6.ts(6,9): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
tests/cases/conformance/es6/classDeclaration/parseClassDeclarationInStrictModeByDefaultInES6.ts(6,9): error TS2322: Type 'string' is not assignable to type 'IArguments'.
Property 'callee' is missing in type 'String'.
@ -11,13 +11,13 @@ tests/cases/conformance/es6/classDeclaration/parseClassDeclarationInStrictModeBy
public implements() { }
public foo(arguments: any) { }
~~~~~~~~~
!!! error TS1100: Invalid use of 'arguments' in strict mode.
!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
private bar(eval:any) {
~~~~
!!! error TS1100: Invalid use of 'eval' in strict mode.
!!! error TS1210: Invalid use of 'eval'. Class definitions are automatically in strict mode.
arguments = "hello";
~~~~~~~~~
!!! error TS1100: Invalid use of 'arguments' in strict mode.
!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
~~~~~~~~~
!!! error TS2322: Type 'string' is not assignable to type 'IArguments'.
!!! error TS2322: Property 'callee' is missing in type 'String'.

View file

@ -1,10 +1,13 @@
tests/cases/conformance/parser/ecmascript5/RegressionTests/parser509668.ts(3,16): error TS1003: Identifier expected.
tests/cases/conformance/parser/ecmascript5/RegressionTests/parser509668.ts(3,23): error TS1005: ',' expected.
==== tests/cases/conformance/parser/ecmascript5/RegressionTests/parser509668.ts (1 errors) ====
==== tests/cases/conformance/parser/ecmascript5/RegressionTests/parser509668.ts (2 errors) ====
class Foo3 {
// Doesn't work, but should
constructor (public ...args: string[]) { }
~~~~~~
!!! error TS1003: Identifier expected.
~~~
!!! error TS1005: ',' expected.
}

View file

@ -7,7 +7,7 @@ class Foo3 {
//// [parser509668.js]
var Foo3 = (function () {
// Doesn't work, but should
function Foo3(public) {
function Foo3() {
var args = [];
for (var _i = 1; _i < arguments.length; _i++) {
args[_i - 1] = arguments[_i];

View file

@ -1,4 +1,4 @@
tests/cases/conformance/parser/ecmascript5/RegressionTests/parser553699.ts(3,21): error TS2304: Cannot find name 'public'.
tests/cases/conformance/parser/ecmascript5/RegressionTests/parser553699.ts(3,21): error TS1110: Type expected.
==== tests/cases/conformance/parser/ecmascript5/RegressionTests/parser553699.ts (1 errors) ====
@ -6,7 +6,7 @@ tests/cases/conformance/parser/ecmascript5/RegressionTests/parser553699.ts(3,21)
constructor() { }
public banana (x: public) { }
~~~~~~
!!! error TS2304: Cannot find name 'public'.
!!! error TS1110: Type expected.
}
class Bar {

View file

@ -12,7 +12,7 @@ class Bar {
var Foo = (function () {
function Foo() {
}
Foo.prototype.banana = function (x) { };
Foo.prototype.banana = function (x, ) { };
return Foo;
})();
var Bar = (function () {

View file

@ -0,0 +1,10 @@
tests/cases/conformance/parser/ecmascript5/RegressionTests/parser642331.ts(2,18): error TS1003: Identifier expected.
==== tests/cases/conformance/parser/ecmascript5/RegressionTests/parser642331.ts (1 errors) ====
class test {
constructor (static) { }
~~~~~~
!!! error TS1003: Identifier expected.
}

View file

@ -6,7 +6,7 @@ class test {
//// [parser642331.js]
var test = (function () {
function test(static) {
function test() {
}
return test;
})();

View file

@ -1,8 +0,0 @@
=== tests/cases/conformance/parser/ecmascript5/RegressionTests/parser642331.ts ===
class test {
>test : test
constructor (static) { }
>static : any
}

View file

@ -1,6 +1,6 @@
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/VariableLists/parserInvalidIdentifiersInVariableStatements1.ts(1,5): error TS1134: Variable declaration expected.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/VariableLists/parserInvalidIdentifiersInVariableStatements1.ts(3,5): error TS1134: Variable declaration expected.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/VariableLists/parserInvalidIdentifiersInVariableStatements1.ts(3,10): error TS1003: Identifier expected.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/VariableLists/parserInvalidIdentifiersInVariableStatements1.ts(3,10): error TS1005: '{' expected.
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/VariableLists/parserInvalidIdentifiersInVariableStatements1.ts (3 errors) ====
@ -12,6 +12,6 @@ tests/cases/conformance/parser/ecmascript5/ErrorRecovery/VariableLists/parserInv
~~~~~
!!! error TS1134: Variable declaration expected.
~
!!! error TS1003: Identifier expected.
!!! error TS1005: '{' expected.
var bar;

View file

@ -9,10 +9,10 @@ var bar;
var ;
var foo;
var ;
var = (function () {
function () {
var default_1 = (function () {
function default_1() {
}
return ;
return default_1;
})();
;
var bar;

View file

@ -115,6 +115,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(504,58): error
tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(506,22): error TS2304: Cannot find name 'NodeType'.
tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(507,58): error TS2304: Cannot find name 'TokenID'.
tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(518,32): error TS2304: Cannot find name 'NodeType'.
tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(520,29): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(525,27): error TS2304: Cannot find name 'Signature'.
tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(527,36): error TS2304: Cannot find name 'TypeFlow'.
tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(528,34): error TS2304: Cannot find name 'NodeType'.
@ -246,6 +247,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(963,27): error
tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(969,31): error TS2304: Cannot find name 'Symbol'.
tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(977,32): error TS2304: Cannot find name 'Symbol'.
tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(981,27): error TS2304: Cannot find name 'Type'.
tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(985,29): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(1004,44): error TS2304: Cannot find name 'hasFlag'.
tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(1004,67): error TS2304: Cannot find name 'FncFlags'.
tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(1005,57): error TS2304: Cannot find name 'FncFlags'.
@ -515,7 +517,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(2356,30): error
tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(2356,48): error TS2304: Cannot find name 'TokenID'.
==== tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts (515 errors) ====
==== tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts (517 errors) ====
// Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0.
// See LICENSE.txt in the project root for complete license information.
@ -1270,6 +1272,8 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(2356,48): error
!!! error TS2304: Cannot find name 'NodeType'.
public target: AST,
public arguments: ASTList) {
~~~~~~~~~
!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
super(nodeType);
this.minChar = this.target.minChar;
}
@ -1997,6 +2001,8 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(2356,48): error
constructor (public name: Identifier, public bod: ASTList, public isConstructor: boolean,
public arguments: ASTList, public vars: ASTList, public scopes: ASTList, public statics: ASTList,
~~~~~~~~~
!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
nodeType: number) {
super(nodeType);

View file

@ -1,7 +1,8 @@
tests/cases/compiler/superCallsInConstructor.ts(12,9): error TS1101: 'with' statements are not allowed in strict mode.
tests/cases/compiler/superCallsInConstructor.ts(12,14): error TS2410: All symbols within a 'with' block will be resolved to 'any'.
==== tests/cases/compiler/superCallsInConstructor.ts (1 errors) ====
==== tests/cases/compiler/superCallsInConstructor.ts (2 errors) ====
class C {
foo() {}
bar() {}
@ -14,6 +15,8 @@ tests/cases/compiler/superCallsInConstructor.ts(12,14): error TS2410: All symbol
class Derived extends Base {
constructor() {
with(new C()) {
~~~~
!!! error TS1101: 'with' statements are not allowed in strict mode.
~~~~~~~
!!! error TS2410: All symbols within a 'with' block will be resolved to 'any'.
foo();

View file

@ -1,7 +1,8 @@
tests/cases/compiler/varArgConstructorMemberParameter.ts(10,18): error TS1003: Identifier expected.
tests/cases/compiler/varArgConstructorMemberParameter.ts(10,25): error TS1005: ',' expected.
==== tests/cases/compiler/varArgConstructorMemberParameter.ts (1 errors) ====
==== tests/cases/compiler/varArgConstructorMemberParameter.ts (2 errors) ====
class Foo1 {
constructor (...args: string[]) { }
}
@ -12,6 +13,8 @@ tests/cases/compiler/varArgConstructorMemberParameter.ts(10,25): error TS1005: '
class Foo3 {
constructor (public ...args: string[]) { }
~~~~~~
!!! error TS1003: Identifier expected.
~~~
!!! error TS1005: ',' expected.
}

View file

@ -29,7 +29,7 @@ var Foo2 = (function () {
return Foo2;
})();
var Foo3 = (function () {
function Foo3(public) {
function Foo3() {
var args = [];
for (var _i = 1; _i < arguments.length; _i++) {
args[_i - 1] = arguments[_i];

View file

@ -0,0 +1,3 @@
function f() {
return typeof class {} === "function";
}

View file

@ -0,0 +1,7 @@
class C {
}
{
class C {
}
}

View file

@ -0,0 +1,9 @@
function f() {
class C {}
var c1 = C;
{
class C {}
var c2 = C;
}
return C === c1;
}

View file

@ -0,0 +1 @@
var v = @decorate class C { static p = 1 };

View file

@ -0,0 +1 @@
var v = class C { static a = 1; static b = 2 };

View file

@ -0,0 +1 @@
var v = class C { static a = 1; static b };

View file

@ -0,0 +1,2 @@
//@target: es6
var v = class C { static a = 1; static b = 2 };

View file

@ -0,0 +1,2 @@
//@target: es6
var v = class C { static a = 1; static b };

View file

@ -28,7 +28,7 @@
// this line triggers a semantic/syntactic error check, remove line when 788570 is fixed
edit.insert('');
debugger;
goTo.marker('1');
verify.completionListContains("multiM", "module multiM", "this is multi declare module\nthi is multi module 2\nthis is multi module 3 comment");

View file

@ -0,0 +1,39 @@
///<reference path="fourslash.ts" />
// @Filename: A.ts
////export interface I1 { one: number }
////export interface I2 { two: string }
////export type I1_OR_I2 = I1 | I2;
////
////export class C1 {
//// one: string;
////}
////
////export module Inner {
//// export interface I3 {
//// three: boolean
//// }
////
//// export var varVar = 100;
//// export let letVar = 200;
//// export const constVar = 300;
////}
// @Filename: B.ts
////export var bVar = "bee!";
// @Filename: C.ts
////export var cVar = "see!";
////export * from "A";
////export * from "B"
// @Filename: D.ts
////import * as c from "C";
////var x = c./**/
goTo.marker();
verify.completionListContains("C1");
verify.completionListContains("Inner");
verify.completionListContains("bVar");
verify.completionListContains("cVar");
verify.not.completionListContains("__export");

View file

@ -0,0 +1,39 @@
///<reference path="fourslash.ts" />
// @Filename: A.ts
////export interface I1 { one: number }
////export interface I2 { two: string }
////export type I1_OR_I2 = I1 | I2;
////
////export class C1 {
//// one: string;
////}
////
////export module Inner {
//// export interface I3 {
//// three: boolean
//// }
////
//// export var varVar = 100;
//// export let letVar = 200;
//// export const constVar = 300;
////}
// @Filename: B.ts
////export var bVar = "bee!";
// @Filename: C.ts
////export var cVar = "see!";
////export * from "A";
////export * from "B"
// @Filename: D.ts
////import * as c from "C";
////var x = c.Inner./**/
goTo.marker();
verify.completionListContains("varVar");
verify.completionListContains("letVar");
verify.completionListContains("constVar");
verify.not.completionListContains("__export");

View file

@ -0,0 +1,40 @@
///<reference path="fourslash.ts" />
// @Filename: A.ts
////export interface I1 { one: number }
////export interface I2 { two: string }
////export type I1_OR_I2 = I1 | I2;
////
////export class C1 {
//// one: string;
////}
////
////export module Inner {
//// export interface I3 {
//// three: boolean
//// }
////
//// export var varVar = 100;
//// export let letVar = 200;
//// export const constVar = 300;
////}
// @Filename: B.ts
////export var bVar = "bee!";
// @Filename: C.ts
////export var cVar = "see!";
////export * from "A";
////export * from "B"
// @Filename: D.ts
////import * as c from "C";
////var x: c./**/
goTo.marker();
verify.completionListContains("I1");
verify.completionListContains("I2");
verify.completionListContains("I1_OR_I2");
verify.completionListContains("C1");
verify.not.completionListContains("__export");

View file

@ -0,0 +1,37 @@
///<reference path="fourslash.ts" />
// @Filename: A.ts
////export interface I1 { one: number }
////export interface I2 { two: string }
////export type I1_OR_I2 = I1 | I2;
////
////export class C1 {
//// one: string;
////}
////
////export module Inner {
//// export interface I3 {
//// three: boolean
//// }
////
//// export var varVar = 100;
//// export let letVar = 200;
//// export const constVar = 300;
////}
// @Filename: B.ts
////export var bVar = "bee!";
// @Filename: C.ts
////export var cVar = "see!";
////export * from "A";
////export * from "B"
// @Filename: D.ts
////import * as c from "C";
////var x: c.Inner./**/
goTo.marker();
verify.completionListContains("I3");
verify.not.completionListContains("__export");

View file

@ -7,7 +7,7 @@
//// declare module 'https' {
//// }
//// /*2*/
debugger;
goTo.marker("1");
verify.not.completionListContains("http");
goTo.marker("2");

View file

@ -439,6 +439,10 @@ module FourSlashInterface {
displayParts: ts.SymbolDisplayPart[], documentation: ts.SymbolDisplayPart[]) {
FourSlash.currentTestState.verifyQuickInfoDisplayParts(kind, kindModifiers, textSpan, displayParts, documentation);
}
public getSemanticDiagnostics(expected: string) {
FourSlash.currentTestState.getSemanticDiagnostics(expected);
}
}
export class edit {

View file

@ -0,0 +1,15 @@
/// <reference path="fourslash.ts" />
// @allowNonTsExtensions: true
// @Filename: a.js
//// import a = b;
verify.getSemanticDiagnostics(`[
{
"message": "'import ... =' can only be used in a .ts file.",
"start": 0,
"length": 13,
"category": "error",
"code": 8002
}
]`);

View file

@ -0,0 +1,15 @@
/// <reference path="fourslash.ts" />
// @allowNonTsExtensions: true
// @Filename: a.js
//// function F<T>() { }
verify.getSemanticDiagnostics(`[
{
"message": "'type parameter declarations' can only be used in a .ts file.",
"start": 11,
"length": 1,
"category": "error",
"code": 8004
}
]`);

View file

@ -0,0 +1,15 @@
/// <reference path="fourslash.ts" />
// @allowNonTsExtensions: true
// @Filename: a.js
//// function F(): number { }
verify.getSemanticDiagnostics(`[
{
"message": "'types' can only be used in a .ts file.",
"start": 14,
"length": 6,
"category": "error",
"code": 8010
}
]`);

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