mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge branch 'master' into LSAPICleanup
Conflicts: src/services/services.ts
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
/// <reference path="..\src\harness\external\node.d.ts" />
|
||||
|
||||
import cp = require('child_process');
|
||||
import fs = require('fs');
|
||||
|
||||
// Slice off 'node bisect-test.js' from the commandline args
|
||||
var args = process.argv.slice(2);
|
||||
|
||||
function tsc(tscArgs: string, onExit: (exitCode: number) => void) {
|
||||
var tsc = cp.exec('node built/local/tsc.js ' + tscArgs,() => void 0);
|
||||
tsc.on('close', tscExitCode => {
|
||||
onExit(tscExitCode);
|
||||
});
|
||||
}
|
||||
|
||||
var jake = cp.exec('jake clean local', () => void 0);
|
||||
jake.on('close', jakeExitCode => {
|
||||
if (jakeExitCode === 0) {
|
||||
// See what we're being asked to do
|
||||
if (args[1] === 'compiles' || args[1] === '!compiles') {
|
||||
tsc(args[0], tscExitCode => {
|
||||
if ((tscExitCode === 0) === (args[1] === 'compiles')) {
|
||||
console.log('Good');
|
||||
process.exit(0); // Good
|
||||
} else {
|
||||
console.log('Bad');
|
||||
process.exit(1); // Bad
|
||||
}
|
||||
});
|
||||
} else if (args[1] === 'emits' || args[1] === '!emits') {
|
||||
tsc(args[0], tscExitCode => {
|
||||
fs.readFile(args[2], 'utf-8', (err, data) => {
|
||||
var doesContains = data.indexOf(args[3]) >= 0;
|
||||
if (doesContains === (args[1] === 'emits')) {
|
||||
console.log('Good');
|
||||
process.exit(0); // Good
|
||||
} else {
|
||||
console.log('Bad');
|
||||
process.exit(1); // Bad
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
console.log('Unknown command line arguments.');
|
||||
console.log('Usage (compile errors): git bisect run scripts\bisect.js "foo.ts --module amd" compiles');
|
||||
console.log('Usage (emit check): git bisect run scripts\bisect.js bar.ts emits bar.js "_this = this"');
|
||||
// Aborts the 'git bisect run' process
|
||||
process.exit(-1);
|
||||
}
|
||||
} else {
|
||||
// Compiler build failed; skip this commit
|
||||
console.log('Skip');
|
||||
process.exit(125); // bisect skip
|
||||
}
|
||||
});
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
echo off
|
||||
IF NOT EXIST scripts\bisect.cmd GOTO :wrongdir
|
||||
IF "%1" == "" GOTO :usage
|
||||
IF "%1" == "GO" GOTO :run
|
||||
GOTO :copy
|
||||
|
||||
:usage
|
||||
echo Usage: bisect GoodCommit BadCommit test.ts compiles
|
||||
echo Usage: bisect GoodCommit BadCommit test.ts emits test.js "var x = 3"
|
||||
GOTO :eof
|
||||
|
||||
:copy
|
||||
copy scripts\bisect.cmd scripts\bisect-fresh.cmd
|
||||
scripts\bisect-fresh GO %*
|
||||
GOTO :eof
|
||||
|
||||
:run
|
||||
call jake local
|
||||
node built/local/tsc.js scripts/bisect-test.ts --module commonjs
|
||||
git bisect start %2 %3
|
||||
git bisect run node scripts/bisect-test.js %4 %5 %6 %7
|
||||
del scripts\bisect-test.js
|
||||
del scripts\bisect-fresh.cmd
|
||||
GOTO :eof
|
||||
|
||||
:wrongdir
|
||||
@echo Run this file from the repo folder, not the scripts folder
|
||||
GOTO :eof
|
||||
|
||||
:eof
|
||||
+25
-19
@@ -9,8 +9,8 @@ module ts {
|
||||
|
||||
export function getModuleInstanceState(node: Node): ModuleInstanceState {
|
||||
// A module is uninstantiated if it contains only
|
||||
// 1. interface declarations
|
||||
if (node.kind === SyntaxKind.InterfaceDeclaration) {
|
||||
// 1. interface declarations, type alias declarations
|
||||
if (node.kind === SyntaxKind.InterfaceDeclaration || node.kind === SyntaxKind.TypeAliasDeclaration) {
|
||||
return ModuleInstanceState.NonInstantiated;
|
||||
}
|
||||
// 2. const enum declarations don't make module instantiated
|
||||
@@ -50,12 +50,13 @@ module ts {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns false if any of the following are true:
|
||||
* 1. declaration has no name
|
||||
* 2. declaration has a literal name (not computed)
|
||||
* 3. declaration has a computed property name that is a known symbol
|
||||
* A declaration has a dynamic name if both of the following are true:
|
||||
* 1. The declaration has a computed property name
|
||||
* 2. The computed name is *not* expressed as Symbol.<name>, where name
|
||||
* is a property of the Symbol constructor that denotes a built in
|
||||
* Symbol.
|
||||
*/
|
||||
export function hasComputedNameButNotSymbol(declaration: Declaration): boolean {
|
||||
export function hasDynamicName(declaration: Declaration): boolean {
|
||||
return declaration.name && declaration.name.kind === SyntaxKind.ComputedPropertyName;
|
||||
}
|
||||
|
||||
@@ -96,7 +97,7 @@ module ts {
|
||||
if (node.kind === SyntaxKind.ModuleDeclaration && node.name.kind === SyntaxKind.StringLiteral) {
|
||||
return '"' + (<LiteralExpression>node.name).text + '"';
|
||||
}
|
||||
Debug.assert(!hasComputedNameButNotSymbol(node));
|
||||
Debug.assert(!hasDynamicName(node));
|
||||
return (<Identifier | LiteralExpression>node.name).text;
|
||||
}
|
||||
switch (node.kind) {
|
||||
@@ -118,11 +119,7 @@ module ts {
|
||||
}
|
||||
|
||||
function declareSymbol(symbols: SymbolTable, parent: Symbol, node: Declaration, includes: SymbolFlags, excludes: SymbolFlags): Symbol {
|
||||
// Nodes with computed property names will not get symbols, because the type checker
|
||||
// does not make properties for them.
|
||||
if (hasComputedNameButNotSymbol(node)) {
|
||||
return undefined;
|
||||
}
|
||||
Debug.assert(!hasDynamicName(node));
|
||||
|
||||
var name = getDeclarationName(node);
|
||||
if (name !== undefined) {
|
||||
@@ -395,14 +392,14 @@ module ts {
|
||||
break;
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
case SyntaxKind.PropertySignature:
|
||||
bindDeclaration(<Declaration>node, SymbolFlags.Property | ((<PropertyDeclaration>node).questionToken ? SymbolFlags.Optional : 0), SymbolFlags.PropertyExcludes, /*isBlockScopeContainer*/ false);
|
||||
bindPropertyOrMethodOrAccessor(<Declaration>node, SymbolFlags.Property | ((<PropertyDeclaration>node).questionToken ? SymbolFlags.Optional : 0), SymbolFlags.PropertyExcludes, /*isBlockScopeContainer*/ false);
|
||||
break;
|
||||
case SyntaxKind.PropertyAssignment:
|
||||
case SyntaxKind.ShorthandPropertyAssignment:
|
||||
bindDeclaration(<Declaration>node, SymbolFlags.Property, SymbolFlags.PropertyExcludes, /*isBlockScopeContainer*/ false);
|
||||
bindPropertyOrMethodOrAccessor(<Declaration>node, SymbolFlags.Property, SymbolFlags.PropertyExcludes, /*isBlockScopeContainer*/ false);
|
||||
break;
|
||||
case SyntaxKind.EnumMember:
|
||||
bindDeclaration(<Declaration>node, SymbolFlags.EnumMember, SymbolFlags.EnumMemberExcludes, /*isBlockScopeContainer*/ false);
|
||||
bindPropertyOrMethodOrAccessor(<Declaration>node, SymbolFlags.EnumMember, SymbolFlags.EnumMemberExcludes, /*isBlockScopeContainer*/ false);
|
||||
break;
|
||||
case SyntaxKind.CallSignature:
|
||||
case SyntaxKind.ConstructSignature:
|
||||
@@ -415,7 +412,7 @@ module ts {
|
||||
// as other properties in the object literal. So we use SymbolFlags.PropertyExcludes
|
||||
// so that it will conflict with any other object literal members with the same
|
||||
// name.
|
||||
bindDeclaration(<Declaration>node, SymbolFlags.Method | ((<MethodDeclaration>node).questionToken ? SymbolFlags.Optional : 0),
|
||||
bindPropertyOrMethodOrAccessor(<Declaration>node, SymbolFlags.Method | ((<MethodDeclaration>node).questionToken ? SymbolFlags.Optional : 0),
|
||||
isObjectLiteralMethod(node) ? SymbolFlags.PropertyExcludes : SymbolFlags.MethodExcludes, /*isBlockScopeContainer*/ true);
|
||||
break;
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
@@ -425,10 +422,10 @@ module ts {
|
||||
bindDeclaration(<Declaration>node, SymbolFlags.Constructor, /*symbolExcludes:*/ 0, /*isBlockScopeContainer:*/ true);
|
||||
break;
|
||||
case SyntaxKind.GetAccessor:
|
||||
bindDeclaration(<Declaration>node, SymbolFlags.GetAccessor, SymbolFlags.GetAccessorExcludes, /*isBlockScopeContainer*/ true);
|
||||
bindPropertyOrMethodOrAccessor(<Declaration>node, SymbolFlags.GetAccessor, SymbolFlags.GetAccessorExcludes, /*isBlockScopeContainer*/ true);
|
||||
break;
|
||||
case SyntaxKind.SetAccessor:
|
||||
bindDeclaration(<Declaration>node, SymbolFlags.SetAccessor, SymbolFlags.SetAccessorExcludes, /*isBlockScopeContainer*/ true);
|
||||
bindPropertyOrMethodOrAccessor(<Declaration>node, SymbolFlags.SetAccessor, SymbolFlags.SetAccessorExcludes, /*isBlockScopeContainer*/ true);
|
||||
break;
|
||||
|
||||
case SyntaxKind.FunctionType:
|
||||
@@ -510,5 +507,14 @@ module ts {
|
||||
declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, SymbolFlags.Property, SymbolFlags.PropertyExcludes);
|
||||
}
|
||||
}
|
||||
|
||||
function bindPropertyOrMethodOrAccessor(node: Declaration, symbolKind: SymbolFlags, symbolExcludes: SymbolFlags, isBlockScopeContainer: boolean) {
|
||||
if (hasDynamicName(node)) {
|
||||
bindAnonymousDeclaration(node, symbolKind, "__computed", isBlockScopeContainer);
|
||||
}
|
||||
else {
|
||||
bindDeclaration(node, symbolKind, symbolExcludes, isBlockScopeContainer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+254
-166
@@ -16,6 +16,8 @@ module ts {
|
||||
var emptySymbols: SymbolTable = {};
|
||||
|
||||
var compilerOptions = host.getCompilerOptions();
|
||||
var languageVersion = compilerOptions.target || ScriptTarget.ES3;
|
||||
|
||||
var emitResolver = createResolver();
|
||||
|
||||
var checker: TypeChecker = {
|
||||
@@ -335,6 +337,25 @@ module ts {
|
||||
break loop;
|
||||
}
|
||||
break;
|
||||
|
||||
// It is not legal to reference a class's own type parameters from a computed property name that
|
||||
// belongs to the class. For example:
|
||||
//
|
||||
// function foo<T>() { return '' }
|
||||
// class C<T> { // <-- Class's own type parameter T
|
||||
// [foo<T>()]() { } // <-- Reference to T from class's own computed property
|
||||
// }
|
||||
//
|
||||
case SyntaxKind.ComputedPropertyName:
|
||||
var grandparent = location.parent.parent;
|
||||
if (grandparent.kind === SyntaxKind.ClassDeclaration || grandparent.kind === SyntaxKind.InterfaceDeclaration) {
|
||||
// A reference to this grandparent's type parameters would be an error
|
||||
if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & SymbolFlags.Type)) {
|
||||
error(errorLocation, Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type);
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.MethodSignature:
|
||||
case SyntaxKind.Constructor:
|
||||
@@ -1658,7 +1679,7 @@ module ts {
|
||||
// Use type of the specified property, or otherwise, for a numeric name, the type of the numeric index signature,
|
||||
// or otherwise the type of the string index signature.
|
||||
var type = getTypeOfPropertyOfType(parentType, name.text) ||
|
||||
isNumericName(name.text) && getIndexTypeOfType(parentType, IndexKind.Number) ||
|
||||
isNumericLiteralName(name.text) && getIndexTypeOfType(parentType, IndexKind.Number) ||
|
||||
getIndexTypeOfType(parentType, IndexKind.String);
|
||||
if (!type) {
|
||||
error(name, Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), declarationNameToString(name));
|
||||
@@ -1704,7 +1725,7 @@ module ts {
|
||||
if (declaration.kind === SyntaxKind.Parameter) {
|
||||
var func = <FunctionLikeDeclaration>declaration.parent;
|
||||
// For a parameter of a set accessor, use the type of the get accessor if one is present
|
||||
if (func.kind === SyntaxKind.SetAccessor && !hasComputedNameButNotSymbol(func)) {
|
||||
if (func.kind === SyntaxKind.SetAccessor && !hasDynamicName(func)) {
|
||||
var getter = <AccessorDeclaration>getDeclarationOfKind(declaration.parent.symbol, SyntaxKind.GetAccessor);
|
||||
if (getter) {
|
||||
return getReturnTypeOfSignature(getSignatureFromDeclaration(getter));
|
||||
@@ -2620,7 +2641,7 @@ module ts {
|
||||
else {
|
||||
// TypeScript 1.0 spec (April 2014):
|
||||
// If only one accessor includes a type annotation, the other behaves as if it had the same type annotation.
|
||||
if (declaration.kind === SyntaxKind.GetAccessor && !hasComputedNameButNotSymbol(declaration)) {
|
||||
if (declaration.kind === SyntaxKind.GetAccessor && !hasDynamicName(declaration)) {
|
||||
var setter = <AccessorDeclaration>getDeclarationOfKind(declaration.symbol, SyntaxKind.SetAccessor);
|
||||
returnType = getAnnotatedAccessorType(setter);
|
||||
}
|
||||
@@ -4757,6 +4778,7 @@ module ts {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
/*Transitively mark all linked imports as referenced*/
|
||||
function markLinkedImportsAsReferenced(node: ImportDeclaration): void {
|
||||
var nodeLinks = getNodeLinks(node);
|
||||
@@ -4853,6 +4875,9 @@ module ts {
|
||||
// do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.ComputedPropertyName:
|
||||
error(node, Diagnostics.this_cannot_be_referenced_in_a_computed_property_name);
|
||||
break;
|
||||
}
|
||||
|
||||
if (needToCaptureLexicalThis) {
|
||||
@@ -4867,26 +4892,6 @@ module ts {
|
||||
return anyType;
|
||||
}
|
||||
|
||||
function getSuperContainer(node: Node): Node {
|
||||
while (true) {
|
||||
node = node.parent;
|
||||
if (!node) return node;
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.ArrowFunction:
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
case SyntaxKind.PropertySignature:
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.MethodSignature:
|
||||
case SyntaxKind.Constructor:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
return node;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function isInConstructorArgumentInitializer(node: Node, constructorDecl: Node): boolean {
|
||||
for (var n = node; n && n !== constructorDecl; n = n.parent) {
|
||||
if (n.kind === SyntaxKind.Parameter) {
|
||||
@@ -4910,7 +4915,7 @@ module ts {
|
||||
return unknownType;
|
||||
}
|
||||
|
||||
var container = getSuperContainer(node);
|
||||
var container = getSuperContainer(node, /*includeFunctions*/ true);
|
||||
|
||||
if (container) {
|
||||
var canUseSuperExpression = false;
|
||||
@@ -4928,7 +4933,7 @@ module ts {
|
||||
// super property access might appear in arrow functions with arbitrary deep nesting
|
||||
var needToCaptureLexicalThis = false;
|
||||
while (container && container.kind === SyntaxKind.ArrowFunction) {
|
||||
container = getSuperContainer(container);
|
||||
container = getSuperContainer(container, /*includeFunctions*/ true);
|
||||
needToCaptureLexicalThis = true;
|
||||
}
|
||||
|
||||
@@ -4983,7 +4988,10 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
if (isCallExpression) {
|
||||
if (container.kind === SyntaxKind.ComputedPropertyName) {
|
||||
error(node, Diagnostics.super_cannot_be_referenced_in_a_computed_property_name);
|
||||
}
|
||||
else if (isCallExpression) {
|
||||
error(node, Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors);
|
||||
}
|
||||
else {
|
||||
@@ -5165,13 +5173,22 @@ module ts {
|
||||
function getContextualTypeForObjectLiteralElement(element: ObjectLiteralElement) {
|
||||
var objectLiteral = <ObjectLiteralExpression>element.parent;
|
||||
var type = getContextualType(objectLiteral);
|
||||
// TODO(jfreeman): Handle this case for computed names and symbols
|
||||
var name = (<Identifier>element.name).text;
|
||||
if (type && name) {
|
||||
return getTypeOfPropertyOfContextualType(type, name) ||
|
||||
isNumericName(name) && getIndexTypeOfContextualType(type, IndexKind.Number) ||
|
||||
if (type) {
|
||||
if (!hasDynamicName(element)) {
|
||||
// For a (non-symbol) computed property, there is no reason to look up the name
|
||||
// in the type. It will just be "__computed", which does not appear in any
|
||||
// SymbolTable.
|
||||
var symbolName = getSymbolOfNode(element).name;
|
||||
var propertyType = getTypeOfPropertyOfContextualType(type, symbolName);
|
||||
if (propertyType) {
|
||||
return propertyType;
|
||||
}
|
||||
}
|
||||
|
||||
return isNumericName(element.name) && getIndexTypeOfContextualType(type, IndexKind.Number) ||
|
||||
getIndexTypeOfContextualType(type, IndexKind.String);
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@@ -5370,7 +5387,17 @@ module ts {
|
||||
return createArrayType(getUnionType(elementTypes));
|
||||
}
|
||||
|
||||
function isNumericName(name: string) {
|
||||
function isNumericName(name: DeclarationName): boolean {
|
||||
return name.kind === SyntaxKind.ComputedPropertyName ? isNumericComputedName(<ComputedPropertyName>name) : isNumericLiteralName((<Identifier>name).text);
|
||||
}
|
||||
|
||||
function isNumericComputedName(name: ComputedPropertyName): boolean {
|
||||
// It seems odd to consider an expression of type Any to result in a numeric name,
|
||||
// but this behavior is consistent with checkIndexedAccess
|
||||
return isTypeOfKind(checkComputedPropertyName(name), TypeFlags.Any | TypeFlags.NumberLike);
|
||||
}
|
||||
|
||||
function isNumericLiteralName(name: string) {
|
||||
// The intent of numeric names is that
|
||||
// - they are names with text in a numeric form, and that
|
||||
// - setting properties/indexing with them is always equivalent to doing so with the numeric literal 'numLit',
|
||||
@@ -5395,64 +5422,85 @@ module ts {
|
||||
return (+name).toString() === name;
|
||||
}
|
||||
|
||||
function checkComputedPropertyName(node: ComputedPropertyName): Type {
|
||||
var links = getNodeLinks(node.expression);
|
||||
if (!links.resolvedType) {
|
||||
links.resolvedType = checkExpression(node.expression);
|
||||
|
||||
// This will allow types number, string, or any. It will also allow enums, the unknown
|
||||
// type, and any union of these types (like string | number).
|
||||
if (!isTypeOfKind(links.resolvedType, TypeFlags.Any | TypeFlags.NumberLike | TypeFlags.StringLike)) {
|
||||
error(node, Diagnostics.A_computed_property_name_must_be_of_type_string_number_or_any);
|
||||
}
|
||||
}
|
||||
|
||||
return links.resolvedType;
|
||||
}
|
||||
|
||||
function checkObjectLiteral(node: ObjectLiteralExpression, contextualMapper?: TypeMapper): Type {
|
||||
// Grammar checking
|
||||
checkGrammarObjectLiteralExpression(node);
|
||||
|
||||
var members = node.symbol.members;
|
||||
var properties: SymbolTable = {};
|
||||
var contextualType = getContextualType(node);
|
||||
var typeFlags: TypeFlags;
|
||||
|
||||
for (var id in members) {
|
||||
if (hasProperty(members, id)) {
|
||||
var member = members[id];
|
||||
if (member.flags & SymbolFlags.Property || isObjectLiteralMethod(member.declarations[0])) {
|
||||
var memberDecl = <ObjectLiteralElement>member.declarations[0];
|
||||
if (memberDecl.kind === SyntaxKind.PropertyAssignment) {
|
||||
var type = checkExpression((<PropertyAssignment>memberDecl).initializer, contextualMapper);
|
||||
}
|
||||
else if (memberDecl.kind === SyntaxKind.MethodDeclaration) {
|
||||
var type = checkObjectLiteralMethod(<MethodDeclaration>memberDecl, contextualMapper);
|
||||
}
|
||||
else {
|
||||
Debug.assert(memberDecl.kind === SyntaxKind.ShorthandPropertyAssignment);
|
||||
var type = memberDecl.name.kind === SyntaxKind.ComputedPropertyName
|
||||
? unknownType
|
||||
: checkExpression(<Identifier>memberDecl.name, contextualMapper);
|
||||
}
|
||||
typeFlags |= type.flags;
|
||||
var prop = <TransientSymbol>createSymbol(SymbolFlags.Property | SymbolFlags.Transient | member.flags, member.name);
|
||||
prop.declarations = member.declarations;
|
||||
prop.parent = member.parent;
|
||||
if (member.valueDeclaration) {
|
||||
prop.valueDeclaration = member.valueDeclaration;
|
||||
}
|
||||
|
||||
prop.type = type;
|
||||
prop.target = member;
|
||||
member = prop;
|
||||
for (var i = 0; i < node.properties.length; i++) {
|
||||
var memberDecl = node.properties[i];
|
||||
var member = memberDecl.symbol;
|
||||
if (memberDecl.kind === SyntaxKind.PropertyAssignment ||
|
||||
memberDecl.kind === SyntaxKind.ShorthandPropertyAssignment ||
|
||||
isObjectLiteralMethod(memberDecl)) {
|
||||
if (memberDecl.kind === SyntaxKind.PropertyAssignment) {
|
||||
var type = checkPropertyAssignment(<PropertyAssignment>memberDecl, contextualMapper);
|
||||
}
|
||||
else if (memberDecl.kind === SyntaxKind.MethodDeclaration) {
|
||||
var type = checkObjectLiteralMethod(<MethodDeclaration>memberDecl, contextualMapper);
|
||||
}
|
||||
else {
|
||||
// TypeScript 1.0 spec (April 2014)
|
||||
// A get accessor declaration is processed in the same manner as
|
||||
// an ordinary function declaration(section 6.1) with no parameters.
|
||||
// A set accessor declaration is processed in the same manner
|
||||
// as an ordinary function declaration with a single parameter and a Void return type.
|
||||
var getAccessor = <AccessorDeclaration>getDeclarationOfKind(member, SyntaxKind.GetAccessor);
|
||||
if (getAccessor) {
|
||||
checkAccessorDeclaration(getAccessor);
|
||||
}
|
||||
|
||||
var setAccessor = <AccessorDeclaration>getDeclarationOfKind(member, SyntaxKind.SetAccessor);
|
||||
if (setAccessor) {
|
||||
checkAccessorDeclaration(setAccessor);
|
||||
}
|
||||
Debug.assert(memberDecl.kind === SyntaxKind.ShorthandPropertyAssignment);
|
||||
var type = memberDecl.name.kind === SyntaxKind.ComputedPropertyName
|
||||
? unknownType
|
||||
: checkExpression(<Identifier>memberDecl.name, contextualMapper);
|
||||
}
|
||||
typeFlags |= type.flags;
|
||||
var prop = <TransientSymbol>createSymbol(SymbolFlags.Property | SymbolFlags.Transient | member.flags, member.name);
|
||||
prop.declarations = member.declarations;
|
||||
prop.parent = member.parent;
|
||||
if (member.valueDeclaration) {
|
||||
prop.valueDeclaration = member.valueDeclaration;
|
||||
}
|
||||
|
||||
prop.type = type;
|
||||
prop.target = member;
|
||||
member = prop;
|
||||
}
|
||||
else {
|
||||
// TypeScript 1.0 spec (April 2014)
|
||||
// A get accessor declaration is processed in the same manner as
|
||||
// an ordinary function declaration(section 6.1) with no parameters.
|
||||
// A set accessor declaration is processed in the same manner
|
||||
// as an ordinary function declaration with a single parameter and a Void return type.
|
||||
Debug.assert(memberDecl.kind === SyntaxKind.GetAccessor || memberDecl.kind === SyntaxKind.SetAccessor);
|
||||
checkAccessorDeclaration(<AccessorDeclaration>memberDecl);
|
||||
}
|
||||
|
||||
if (!hasDynamicName(memberDecl)) {
|
||||
properties[member.name] = member;
|
||||
}
|
||||
}
|
||||
|
||||
// If object literal is contextually (but not inferentially) typed, copy missing optional properties from
|
||||
// the contextual type such that the resulting type becomes a subtype in cases where only optional properties
|
||||
// were omitted. There is no need to create new property objects as nothing in them needs to change.
|
||||
if (contextualType && !isInferentialContext(contextualMapper)) {
|
||||
forEach(getPropertiesOfObjectType(contextualType), p => {
|
||||
if (p.flags & SymbolFlags.Optional && !hasProperty(properties, p.name)) {
|
||||
properties[p.name] = p;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var stringIndexType = getIndexType(IndexKind.String);
|
||||
var numberIndexType = getIndexType(IndexKind.Number);
|
||||
var result = createAnonymousType(node.symbol, properties, emptyArray, emptyArray, stringIndexType, numberIndexType);
|
||||
@@ -5462,13 +5510,12 @@ module ts {
|
||||
function getIndexType(kind: IndexKind) {
|
||||
if (contextualType && contextualTypeHasIndexSignature(contextualType, kind)) {
|
||||
var propTypes: Type[] = [];
|
||||
for (var id in properties) {
|
||||
if (hasProperty(properties, id)) {
|
||||
if (kind === IndexKind.String || isNumericName(id)) {
|
||||
var type = getTypeOfSymbol(properties[id]);
|
||||
if (!contains(propTypes, type)) {
|
||||
propTypes.push(type);
|
||||
}
|
||||
for (var i = 0; i < node.properties.length; i++) {
|
||||
var propertyDecl = node.properties[i];
|
||||
if (kind === IndexKind.String || isNumericName(propertyDecl.name)) {
|
||||
var type = getTypeOfSymbol(getSymbolOfNode(propertyDecl));
|
||||
if (!contains(propTypes, type)) {
|
||||
propTypes.push(type);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5618,7 +5665,7 @@ module ts {
|
||||
}
|
||||
|
||||
var isConstEnum = isConstEnumObjectType(objectType);
|
||||
if (isConstEnum &&
|
||||
if (isConstEnum &&
|
||||
(!node.argumentExpression || node.argumentExpression.kind !== SyntaxKind.StringLiteral)) {
|
||||
error(node.argumentExpression, Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal);
|
||||
return unknownType;
|
||||
@@ -5650,10 +5697,10 @@ module ts {
|
||||
}
|
||||
|
||||
// Check for compatible indexer types.
|
||||
if (indexType.flags & (TypeFlags.Any | TypeFlags.StringLike | TypeFlags.NumberLike)) {
|
||||
if (isTypeOfKind(indexType, TypeFlags.Any | TypeFlags.StringLike | TypeFlags.NumberLike)) {
|
||||
|
||||
// Try to use a number indexer.
|
||||
if (indexType.flags & (TypeFlags.Any | TypeFlags.NumberLike)) {
|
||||
if (isTypeOfKind(indexType, TypeFlags.Any | TypeFlags.NumberLike)) {
|
||||
var numberIndexType = getIndexTypeOfType(objectType, IndexKind.Number);
|
||||
if (numberIndexType) {
|
||||
return numberIndexType;
|
||||
@@ -6357,7 +6404,7 @@ module ts {
|
||||
|
||||
function checkTaggedTemplateExpression(node: TaggedTemplateExpression): Type {
|
||||
// Grammar checking
|
||||
if (compilerOptions.target < ScriptTarget.ES6) {
|
||||
if (languageVersion < ScriptTarget.ES6) {
|
||||
grammarErrorOnFirstToken(node.template, Diagnostics.Tagged_templates_are_only_available_when_targeting_ECMAScript_6_and_higher);
|
||||
}
|
||||
|
||||
@@ -6554,7 +6601,7 @@ module ts {
|
||||
}
|
||||
|
||||
function checkArithmeticOperandType(operand: Node, type: Type, diagnostic: DiagnosticMessage): boolean {
|
||||
if (!(type.flags & (TypeFlags.Any | TypeFlags.NumberLike))) {
|
||||
if (!isTypeOfKind(type, TypeFlags.Any | TypeFlags.NumberLike)) {
|
||||
error(operand, diagnostic);
|
||||
return false;
|
||||
}
|
||||
@@ -6705,12 +6752,21 @@ module ts {
|
||||
return numberType;
|
||||
}
|
||||
|
||||
// Return true if type an object type, a type parameter, or a union type composed of only those kinds of types
|
||||
function isStructuredType(type: Type): boolean {
|
||||
if (type.flags & TypeFlags.Union) {
|
||||
return !forEach((<UnionType>type).types, t => !isStructuredType(t));
|
||||
// Return true if type has the given flags, or is a union type composed of types that all have those flags
|
||||
function isTypeOfKind(type: Type, kind: TypeFlags): boolean {
|
||||
if (type.flags & kind) {
|
||||
return true;
|
||||
}
|
||||
return (type.flags & (TypeFlags.ObjectType | TypeFlags.TypeParameter)) !== 0;
|
||||
if (type.flags & TypeFlags.Union) {
|
||||
var types = (<UnionType>type).types;
|
||||
for (var i = 0; i < types.length; i++) {
|
||||
if (!(types[i].flags & kind)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function isConstEnumObjectType(type: Type): boolean {
|
||||
@@ -6727,7 +6783,7 @@ module ts {
|
||||
// and the right operand to be of type Any or a subtype of the 'Function' interface type.
|
||||
// The result is always of the Boolean primitive type.
|
||||
// NOTE: do not raise error if leftType is unknown as related error was already reported
|
||||
if (!(leftType.flags & TypeFlags.Any || isStructuredType(leftType))) {
|
||||
if (!isTypeOfKind(leftType, TypeFlags.Any | TypeFlags.ObjectType | TypeFlags.TypeParameter)) {
|
||||
error(node.left, Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter);
|
||||
}
|
||||
// NOTE: do not raise error if right is unknown as related error was already reported
|
||||
@@ -6742,10 +6798,10 @@ module ts {
|
||||
// The in operator requires the left operand to be of type Any, the String primitive type, or the Number primitive type,
|
||||
// and the right operand to be of type Any, an object type, or a type parameter type.
|
||||
// The result is always of the Boolean primitive type.
|
||||
if (leftType !== anyType && leftType !== stringType && leftType !== numberType) {
|
||||
if (!isTypeOfKind(leftType, TypeFlags.Any | TypeFlags.StringLike | TypeFlags.NumberLike)) {
|
||||
error(node.left, Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_types_any_string_or_number);
|
||||
}
|
||||
if (!(rightType.flags & TypeFlags.Any || isStructuredType(rightType))) {
|
||||
if (!isTypeOfKind(rightType, TypeFlags.Any | TypeFlags.ObjectType | TypeFlags.TypeParameter)) {
|
||||
error(node.right, Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter);
|
||||
}
|
||||
return booleanType;
|
||||
@@ -6760,7 +6816,7 @@ module ts {
|
||||
var name = <Identifier>(<PropertyAssignment>p).name;
|
||||
var type = sourceType.flags & TypeFlags.Any ? sourceType :
|
||||
getTypeOfPropertyOfType(sourceType, name.text) ||
|
||||
isNumericName(name.text) && getIndexTypeOfType(sourceType, IndexKind.Number) ||
|
||||
isNumericLiteralName(name.text) && getIndexTypeOfType(sourceType, IndexKind.Number) ||
|
||||
getIndexTypeOfType(sourceType, IndexKind.String);
|
||||
if (type) {
|
||||
checkDestructuringAssignment((<PropertyAssignment>p).initializer || name, type);
|
||||
@@ -6906,16 +6962,16 @@ module ts {
|
||||
if (rightType.flags & (TypeFlags.Undefined | TypeFlags.Null)) rightType = leftType;
|
||||
|
||||
var resultType: Type;
|
||||
if (leftType.flags & TypeFlags.NumberLike && rightType.flags & TypeFlags.NumberLike) {
|
||||
if (isTypeOfKind(leftType, TypeFlags.NumberLike) && isTypeOfKind(rightType, TypeFlags.NumberLike)) {
|
||||
// Operands of an enum type are treated as having the primitive type Number.
|
||||
// If both operands are of the Number primitive type, the result is of the Number primitive type.
|
||||
resultType = numberType;
|
||||
}
|
||||
else if (leftType.flags & TypeFlags.StringLike || rightType.flags & TypeFlags.StringLike) {
|
||||
else if (isTypeOfKind(leftType, TypeFlags.StringLike) || isTypeOfKind(rightType, TypeFlags.StringLike)) {
|
||||
// If one or both operands are of the String primitive type, the result is of the String primitive type.
|
||||
resultType = stringType;
|
||||
}
|
||||
else if (leftType.flags & TypeFlags.Any || leftType === unknownType || rightType.flags & TypeFlags.Any || rightType === unknownType) {
|
||||
else if (leftType.flags & TypeFlags.Any || rightType.flags & TypeFlags.Any) {
|
||||
// Otherwise, the result is of type Any.
|
||||
// NOTE: unknown type here denotes error type. Old compiler treated this case as any type so do we.
|
||||
resultType = anyType;
|
||||
@@ -7041,10 +7097,22 @@ module ts {
|
||||
return links.resolvedType;
|
||||
}
|
||||
|
||||
function checkPropertyAssignment(node: PropertyAssignment, contextualMapper?: TypeMapper): Type {
|
||||
if (hasDynamicName(node)) {
|
||||
checkComputedPropertyName(<ComputedPropertyName>node.name);
|
||||
}
|
||||
|
||||
return checkExpression((<PropertyAssignment>node).initializer, contextualMapper);
|
||||
}
|
||||
|
||||
function checkObjectLiteralMethod(node: MethodDeclaration, contextualMapper?: TypeMapper): Type {
|
||||
// Grammar checking
|
||||
checkGrammarMethod(node);
|
||||
|
||||
if (hasDynamicName(node)) {
|
||||
checkComputedPropertyName(<ComputedPropertyName>node.name);
|
||||
}
|
||||
|
||||
var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper);
|
||||
return instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper);
|
||||
}
|
||||
@@ -7415,7 +7483,7 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasComputedNameButNotSymbol(node)) {
|
||||
if (!hasDynamicName(node)) {
|
||||
// TypeScript 1.0 spec (April 2014): 8.4.3
|
||||
// Accessors for the same member name must specify the same accessibility.
|
||||
var otherKind = node.kind === SyntaxKind.GetAccessor ? SyntaxKind.SetAccessor : SyntaxKind.GetAccessor;
|
||||
@@ -7435,9 +7503,9 @@ module ts {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
checkAndStoreTypeOfAccessors(getSymbolOfNode(node));
|
||||
}
|
||||
|
||||
checkAndStoreTypeOfAccessors(getSymbolOfNode(node));
|
||||
}
|
||||
|
||||
checkFunctionLikeDeclaration(node);
|
||||
@@ -7853,7 +7921,12 @@ module ts {
|
||||
function checkFunctionLikeDeclaration(node: FunctionLikeDeclaration): void {
|
||||
checkSignatureDeclaration(node);
|
||||
|
||||
if (!hasComputedNameButNotSymbol(node)) {
|
||||
if (hasDynamicName(node)) {
|
||||
// This check will account for methods in class/interface declarations,
|
||||
// as well as accessors in classes/object literals
|
||||
checkComputedPropertyName(<ComputedPropertyName>node.name);
|
||||
}
|
||||
else {
|
||||
// first we want to check the local symbol that contain this declaration
|
||||
// - if node.localSymbol !== undefined - this is current declaration is exported and localSymbol points to the local symbol
|
||||
// - if node.localSymbol === undefined - this node is non-exported so we can just pick the result of getSymbolOfNode
|
||||
@@ -8082,7 +8155,8 @@ module ts {
|
||||
function checkVariableLikeDeclaration(node: VariableLikeDeclaration) {
|
||||
checkSourceElement(node.type);
|
||||
// For a computed property, just check the initializer and exit
|
||||
if (hasComputedNameButNotSymbol(node)) {
|
||||
if (hasDynamicName(node)) {
|
||||
checkComputedPropertyName(<ComputedPropertyName>node.name);
|
||||
if (node.initializer) {
|
||||
checkExpressionCached(node.initializer);
|
||||
}
|
||||
@@ -8271,7 +8345,7 @@ module ts {
|
||||
var exprType = checkExpression(node.expression);
|
||||
// unknownType is returned i.e. if node.expression is identifier whose name cannot be resolved
|
||||
// in this case error about missing name is already reported - do not report extra one
|
||||
if (!(exprType.flags & TypeFlags.Any || isStructuredType(exprType))) {
|
||||
if (!isTypeOfKind(exprType, TypeFlags.Any | TypeFlags.ObjectType | TypeFlags.TypeParameter)) {
|
||||
error(node.expression, Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter);
|
||||
}
|
||||
|
||||
@@ -8425,45 +8499,7 @@ module ts {
|
||||
if (node.finallyBlock) checkBlock(node.finallyBlock);
|
||||
}
|
||||
|
||||
function checkIndexConstraints(type: Type) {
|
||||
|
||||
function checkIndexConstraintForProperty(prop: Symbol, propertyType: Type, indexDeclaration: Declaration, indexType: Type, indexKind: IndexKind): void {
|
||||
if (!indexType) {
|
||||
return;
|
||||
}
|
||||
|
||||
// index is numeric and property name is not valid numeric literal
|
||||
if (indexKind === IndexKind.Number && !isNumericName(prop.name)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// perform property check if property or indexer is declared in 'type'
|
||||
// this allows to rule out cases when both property and indexer are inherited from the base class
|
||||
var errorNode: Node;
|
||||
if (prop.parent === type.symbol) {
|
||||
errorNode = prop.valueDeclaration;
|
||||
}
|
||||
else if (indexDeclaration) {
|
||||
errorNode = indexDeclaration;
|
||||
}
|
||||
|
||||
else if (type.flags & TypeFlags.Interface) {
|
||||
// for interfaces property and indexer might be inherited from different bases
|
||||
// check if any base class already has both property and indexer.
|
||||
// check should be performed only if 'type' is the first type that brings property\indexer together
|
||||
var someBaseClassHasBothPropertyAndIndexer = forEach((<InterfaceType>type).baseTypes, base => getPropertyOfObjectType(base, prop.name) && getIndexTypeOfType(base, indexKind));
|
||||
errorNode = someBaseClassHasBothPropertyAndIndexer ? undefined : type.symbol.declarations[0];
|
||||
}
|
||||
|
||||
if (errorNode && !isTypeAssignableTo(propertyType, indexType)) {
|
||||
var errorMessage =
|
||||
indexKind === IndexKind.String
|
||||
? Diagnostics.Property_0_of_type_1_is_not_assignable_to_string_index_type_2
|
||||
: Diagnostics.Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2;
|
||||
error(errorNode, errorMessage, symbolToString(prop), typeToString(propertyType), typeToString(indexType));
|
||||
}
|
||||
}
|
||||
|
||||
function checkIndexConstraints(type: Type) {
|
||||
var declaredNumberIndexer = getIndexDeclarationOfSymbol(type.symbol, IndexKind.Number);
|
||||
var declaredStringIndexer = getIndexDeclarationOfSymbol(type.symbol, IndexKind.String);
|
||||
|
||||
@@ -8473,9 +8509,24 @@ module ts {
|
||||
if (stringIndexType || numberIndexType) {
|
||||
forEach(getPropertiesOfObjectType(type), prop => {
|
||||
var propType = getTypeOfSymbol(prop);
|
||||
checkIndexConstraintForProperty(prop, propType, declaredStringIndexer, stringIndexType, IndexKind.String);
|
||||
checkIndexConstraintForProperty(prop, propType, declaredNumberIndexer, numberIndexType, IndexKind.Number);
|
||||
checkIndexConstraintForProperty(prop, propType, type, declaredStringIndexer, stringIndexType, IndexKind.String);
|
||||
checkIndexConstraintForProperty(prop, propType, type, declaredNumberIndexer, numberIndexType, IndexKind.Number);
|
||||
});
|
||||
|
||||
if (type.flags & TypeFlags.Class && type.symbol.valueDeclaration.kind === SyntaxKind.ClassDeclaration) {
|
||||
var classDeclaration = <ClassDeclaration>type.symbol.valueDeclaration;
|
||||
for (var i = 0; i < classDeclaration.members.length; i++) {
|
||||
var member = classDeclaration.members[i];
|
||||
// Only process instance properties with computed names here.
|
||||
// Static properties cannot be in conflict with indexers,
|
||||
// and properties with literal names were already checked.
|
||||
if (!(member.flags & NodeFlags.Static) && hasDynamicName(member)) {
|
||||
var propType = getTypeOfSymbol(member.symbol);
|
||||
checkIndexConstraintForProperty(member.symbol, propType, type, declaredStringIndexer, stringIndexType, IndexKind.String);
|
||||
checkIndexConstraintForProperty(member.symbol, propType, type, declaredNumberIndexer, numberIndexType, IndexKind.Number);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var errorNode: Node;
|
||||
@@ -8492,9 +8543,51 @@ module ts {
|
||||
error(errorNode, Diagnostics.Numeric_index_type_0_is_not_assignable_to_string_index_type_1,
|
||||
typeToString(numberIndexType), typeToString(stringIndexType));
|
||||
}
|
||||
|
||||
function checkIndexConstraintForProperty(
|
||||
prop: Symbol,
|
||||
propertyType: Type,
|
||||
containingType: Type,
|
||||
indexDeclaration: Declaration,
|
||||
indexType: Type,
|
||||
indexKind: IndexKind): void {
|
||||
|
||||
if (!indexType) {
|
||||
return;
|
||||
}
|
||||
|
||||
// index is numeric and property name is not valid numeric literal
|
||||
if (indexKind === IndexKind.Number && !isNumericName(prop.valueDeclaration.name)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// perform property check if property or indexer is declared in 'type'
|
||||
// this allows to rule out cases when both property and indexer are inherited from the base class
|
||||
var errorNode: Node;
|
||||
if (prop.valueDeclaration.name.kind === SyntaxKind.ComputedPropertyName || prop.parent === containingType.symbol) {
|
||||
errorNode = prop.valueDeclaration;
|
||||
}
|
||||
else if (indexDeclaration) {
|
||||
errorNode = indexDeclaration;
|
||||
}
|
||||
else if (containingType.flags & TypeFlags.Interface) {
|
||||
// for interfaces property and indexer might be inherited from different bases
|
||||
// check if any base class already has both property and indexer.
|
||||
// check should be performed only if 'type' is the first type that brings property\indexer together
|
||||
var someBaseClassHasBothPropertyAndIndexer = forEach((<InterfaceType>containingType).baseTypes, base => getPropertyOfObjectType(base, prop.name) && getIndexTypeOfType(base, indexKind));
|
||||
errorNode = someBaseClassHasBothPropertyAndIndexer ? undefined : containingType.symbol.declarations[0];
|
||||
}
|
||||
|
||||
if (errorNode && !isTypeAssignableTo(propertyType, indexType)) {
|
||||
var errorMessage =
|
||||
indexKind === IndexKind.String
|
||||
? Diagnostics.Property_0_of_type_1_is_not_assignable_to_string_index_type_2
|
||||
: Diagnostics.Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2;
|
||||
error(errorNode, errorMessage, symbolToString(prop), typeToString(propertyType), typeToString(indexType));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO(jfreeman): Decide what to do for computed properties
|
||||
function checkTypeNameIsReserved(name: DeclarationName, message: DiagnosticMessage): void {
|
||||
// TS 1.0 spec (April 2014): 3.6.1
|
||||
// The predefined type keywords are reserved and cannot be used as names of user defined types.
|
||||
@@ -8788,8 +8881,7 @@ module ts {
|
||||
var enumIsConst = isConst(node);
|
||||
|
||||
forEach(node.members, member => {
|
||||
// TODO(jfreeman): Check that it is not a computed name
|
||||
if(isNumericName((<Identifier>member.name).text)) {
|
||||
if (member.name.kind !== SyntaxKind.ComputedPropertyName && isNumericLiteralName((<Identifier>member.name).text)) {
|
||||
error(member.name, Diagnostics.An_enum_member_cannot_have_a_numeric_name);
|
||||
}
|
||||
var initializer = member.initializer;
|
||||
@@ -9979,8 +10071,8 @@ module ts {
|
||||
if (symbol && (symbol.flags & SymbolFlags.EnumMember)) {
|
||||
var declaration = symbol.valueDeclaration;
|
||||
var constantValue: number;
|
||||
if (declaration.kind === SyntaxKind.EnumMember && (constantValue = getNodeLinks(declaration).enumMemberValue) !== undefined) {
|
||||
return constantValue;
|
||||
if (declaration.kind === SyntaxKind.EnumMember) {
|
||||
return getEnumMemberValue(<EnumMember>declaration);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10055,7 +10147,7 @@ module ts {
|
||||
globalRegExpType = getGlobalType("RegExp");
|
||||
// If we're in ES6 mode, load the TemplateStringsArray.
|
||||
// Otherwise, default to 'unknown' for the purposes of type checking in LS scenarios.
|
||||
globalTemplateStringsArrayType = compilerOptions.target >= ScriptTarget.ES6
|
||||
globalTemplateStringsArrayType = languageVersion >= ScriptTarget.ES6
|
||||
? getGlobalType("TemplateStringsArray")
|
||||
: unknownType;
|
||||
anyArrayType = createArrayType(anyType);
|
||||
@@ -10416,22 +10508,18 @@ module ts {
|
||||
return false;
|
||||
}
|
||||
|
||||
function checkGrammarComputedPropertyName(node: Node): void {
|
||||
function checkGrammarComputedPropertyName(node: Node): boolean {
|
||||
// If node is not a computedPropertyName, just skip the grammar checking
|
||||
if (node.kind !== SyntaxKind.ComputedPropertyName) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
// Since computed properties are not supported in the type checker, disallow them in TypeScript 1.4
|
||||
// Once full support is added, remove this error.
|
||||
grammarErrorOnNode(node, Diagnostics.Computed_property_names_are_not_currently_supported);
|
||||
return;
|
||||
|
||||
var computedPropertyName = <ComputedPropertyName>node;
|
||||
if (compilerOptions.target < ScriptTarget.ES6) {
|
||||
grammarErrorOnNode(node, Diagnostics.Computed_property_names_are_only_available_when_targeting_ECMAScript_6_and_higher);
|
||||
if (languageVersion < ScriptTarget.ES6) {
|
||||
return grammarErrorOnNode(node, Diagnostics.Computed_property_names_are_only_available_when_targeting_ECMAScript_6_and_higher);
|
||||
}
|
||||
else if (computedPropertyName.expression.kind === SyntaxKind.BinaryExpression && (<BinaryExpression>computedPropertyName.expression).operator === SyntaxKind.CommaToken) {
|
||||
grammarErrorOnNode(computedPropertyName.expression, Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name);
|
||||
return grammarErrorOnNode(computedPropertyName.expression, Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10527,7 +10615,7 @@ module ts {
|
||||
|
||||
function checkGrammarAccessor(accessor: MethodDeclaration): boolean {
|
||||
var kind = accessor.kind;
|
||||
if (compilerOptions.target < ScriptTarget.ES5) {
|
||||
if (languageVersion < ScriptTarget.ES5) {
|
||||
return grammarErrorOnNode(accessor.name, Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher);
|
||||
}
|
||||
else if (isInAmbientContext(accessor)) {
|
||||
@@ -10732,7 +10820,7 @@ module ts {
|
||||
return grammarErrorAtPos(getSourceFileOfNode(declarationList), declarations.pos, declarations.end - declarations.pos, Diagnostics.Variable_declaration_list_cannot_be_empty);
|
||||
}
|
||||
|
||||
if (compilerOptions.target < ScriptTarget.ES6) {
|
||||
if (languageVersion < ScriptTarget.ES6) {
|
||||
if (isLet(declarationList)) {
|
||||
return grammarErrorOnFirstToken(declarationList, Diagnostics.let_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher);
|
||||
}
|
||||
@@ -10834,7 +10922,7 @@ module ts {
|
||||
function grammarErrorOnFirstToken(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): boolean {
|
||||
var sourceFile = getSourceFileOfNode(node);
|
||||
if (!hasParseDiagnostics(sourceFile)) {
|
||||
var scanner = createScanner(compilerOptions.target, /*skipTrivia*/ true, sourceFile.text);
|
||||
var scanner = createScanner(languageVersion, /*skipTrivia*/ true, sourceFile.text);
|
||||
var start = scanToken(scanner, node.pos);
|
||||
diagnostics.push(createFileDiagnostic(sourceFile, start, scanner.getTextPos() - start, message, arg0, arg1, arg2));
|
||||
return true;
|
||||
@@ -10976,7 +11064,7 @@ module ts {
|
||||
if (node.parserContextFlags & ParserContextFlags.StrictMode) {
|
||||
return grammarErrorOnNode(node, Diagnostics.Octal_literals_are_not_allowed_in_strict_mode);
|
||||
}
|
||||
else if (compilerOptions.target >= ScriptTarget.ES5) {
|
||||
else if (languageVersion >= ScriptTarget.ES5) {
|
||||
return grammarErrorOnNode(node, Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher);
|
||||
}
|
||||
}
|
||||
@@ -10985,7 +11073,7 @@ module ts {
|
||||
function grammarErrorAfterFirstToken(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): boolean {
|
||||
var sourceFile = getSourceFileOfNode(node);
|
||||
if (!hasParseDiagnostics(sourceFile)) {
|
||||
var scanner = createScanner(compilerOptions.target, /*skipTrivia*/ true, sourceFile.text);
|
||||
var scanner = createScanner(languageVersion, /*skipTrivia*/ true, sourceFile.text);
|
||||
scanToken(scanner, node.pos);
|
||||
diagnostics.push(createFileDiagnostic(sourceFile, scanner.getTextPos(), 0, message, arg0, arg1, arg2));
|
||||
return true;
|
||||
|
||||
@@ -33,6 +33,10 @@ module ts {
|
||||
type: "boolean",
|
||||
description: Diagnostics.Print_this_message,
|
||||
},
|
||||
{
|
||||
name: "listFiles",
|
||||
type: "boolean",
|
||||
},
|
||||
{
|
||||
name: "locale",
|
||||
type: "string",
|
||||
@@ -40,6 +44,7 @@ module ts {
|
||||
{
|
||||
name: "mapRoot",
|
||||
type: "string",
|
||||
isFilePath: true,
|
||||
description: Diagnostics.Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations,
|
||||
paramType: Diagnostics.LOCATION,
|
||||
},
|
||||
@@ -90,6 +95,7 @@ module ts {
|
||||
{
|
||||
name: "outDir",
|
||||
type: "string",
|
||||
isFilePath: true,
|
||||
description: Diagnostics.Redirect_output_structure_to_the_directory,
|
||||
paramType: Diagnostics.DIRECTORY,
|
||||
},
|
||||
@@ -98,6 +104,14 @@ module ts {
|
||||
type: "boolean",
|
||||
description: Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code
|
||||
},
|
||||
{
|
||||
name: "project",
|
||||
shortName: "p",
|
||||
type: "string",
|
||||
isFilePath: true,
|
||||
description: Diagnostics.Compile_the_project_in_the_given_directory,
|
||||
paramType: Diagnostics.DIRECTORY
|
||||
},
|
||||
{
|
||||
name: "removeComments",
|
||||
type: "boolean",
|
||||
@@ -111,6 +125,7 @@ module ts {
|
||||
{
|
||||
name: "sourceRoot",
|
||||
type: "string",
|
||||
isFilePath: true,
|
||||
description: Diagnostics.Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations,
|
||||
paramType: Diagnostics.LOCATION,
|
||||
},
|
||||
@@ -141,26 +156,19 @@ module ts {
|
||||
}
|
||||
];
|
||||
|
||||
var shortOptionNames: Map<string> = {};
|
||||
var optionNameMap: Map<CommandLineOption> = {};
|
||||
|
||||
forEach(optionDeclarations, option => {
|
||||
optionNameMap[option.name.toLowerCase()] = option;
|
||||
|
||||
if (option.shortName) {
|
||||
shortOptionNames[option.shortName] = option.name;
|
||||
}
|
||||
});
|
||||
|
||||
export function parseCommandLine(commandLine: string[]): ParsedCommandLine {
|
||||
// Set default compiler option values
|
||||
var options: CompilerOptions = {
|
||||
target: ScriptTarget.ES3,
|
||||
module: ModuleKind.None
|
||||
};
|
||||
var options: CompilerOptions = {};
|
||||
var filenames: string[] = [];
|
||||
var errors: Diagnostic[] = [];
|
||||
var shortOptionNames: Map<string> = {};
|
||||
var optionNameMap: Map<CommandLineOption> = {};
|
||||
|
||||
forEach(optionDeclarations, option => {
|
||||
optionNameMap[option.name.toLowerCase()] = option;
|
||||
if (option.shortName) {
|
||||
shortOptionNames[option.shortName] = option.name;
|
||||
}
|
||||
});
|
||||
parseStrings(commandLine);
|
||||
return {
|
||||
options,
|
||||
@@ -256,4 +264,84 @@ module ts {
|
||||
parseStrings(args);
|
||||
}
|
||||
}
|
||||
|
||||
export function readConfigFile(filename: string): any {
|
||||
try {
|
||||
var text = sys.readFile(filename);
|
||||
return /\S/.test(text) ? JSON.parse(text) : {};
|
||||
}
|
||||
catch (e) {
|
||||
}
|
||||
}
|
||||
|
||||
export function parseConfigFile(json: any, basePath?: string): ParsedCommandLine {
|
||||
var errors: Diagnostic[] = [];
|
||||
|
||||
return {
|
||||
options: getCompilerOptions(),
|
||||
filenames: getFiles(),
|
||||
errors
|
||||
};
|
||||
|
||||
function getCompilerOptions(): CompilerOptions {
|
||||
var options: CompilerOptions = {};
|
||||
var optionNameMap: Map<CommandLineOption> = {};
|
||||
forEach(optionDeclarations, option => {
|
||||
optionNameMap[option.name] = option;
|
||||
});
|
||||
var jsonOptions = json["compilerOptions"];
|
||||
if (jsonOptions) {
|
||||
for (var id in jsonOptions) {
|
||||
if (hasProperty(optionNameMap, id)) {
|
||||
var opt = optionNameMap[id];
|
||||
var optType = opt.type;
|
||||
var value = jsonOptions[id];
|
||||
var expectedType = typeof optType === "string" ? optType : "string";
|
||||
if (typeof value === expectedType) {
|
||||
if (typeof optType !== "string") {
|
||||
var key = value.toLowerCase();
|
||||
if (hasProperty(optType, key)) {
|
||||
value = optType[key];
|
||||
}
|
||||
else {
|
||||
errors.push(createCompilerDiagnostic(opt.error));
|
||||
value = 0;
|
||||
}
|
||||
}
|
||||
if (opt.isFilePath) {
|
||||
value = normalizePath(combinePaths(basePath, value));
|
||||
}
|
||||
options[opt.name] = value;
|
||||
}
|
||||
else {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.Compiler_option_0_requires_a_value_of_type_1, id, expectedType));
|
||||
}
|
||||
}
|
||||
else {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.Unknown_compiler_option_0, id));
|
||||
}
|
||||
}
|
||||
}
|
||||
return options;
|
||||
}
|
||||
|
||||
function getFiles(): string[] {
|
||||
var files: string[] = [];
|
||||
if (hasProperty(json, "files")) {
|
||||
if (json["files"] instanceof Array) {
|
||||
var files = map(<string[]>json["files"], s => combinePaths(basePath, s));
|
||||
}
|
||||
}
|
||||
else {
|
||||
var sysFiles = sys.readDirectory(basePath, ".ts");
|
||||
for (var i = 0; i < sysFiles.length; i++) {
|
||||
var name = sysFiles[i];
|
||||
if (!fileExtensionIs(name, ".d.ts") || !contains(sysFiles, name.substr(0, name.length - 5) + ".ts")) {
|
||||
files.push(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
return files;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+14
-1
@@ -178,6 +178,19 @@ module ts {
|
||||
return <T>result;
|
||||
}
|
||||
|
||||
export function extend<T>(first: Map<T>, second: Map<T>): Map<T> {
|
||||
var result: Map<T> = {};
|
||||
for (var id in first) {
|
||||
result[id] = first[id];
|
||||
}
|
||||
for (var id in second) {
|
||||
if (!hasProperty(result, id)) {
|
||||
result[id] = second[id];
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export function forEachValue<T, U>(map: Map<T>, callback: (value: T) => U): U {
|
||||
var result: U;
|
||||
for (var id in map) {
|
||||
@@ -568,7 +581,7 @@ module ts {
|
||||
export function combinePaths(path1: string, path2: string) {
|
||||
if (!(path1 && path1.length)) return path2;
|
||||
if (!(path2 && path2.length)) return path1;
|
||||
if (path2.charAt(0) === directorySeparator) return path2;
|
||||
if (getRootLength(path2) !== 0) return path2;
|
||||
if (path1.charAt(path1.length - 1) === directorySeparator) return path1 + path2;
|
||||
return path1 + directorySeparator + path2;
|
||||
}
|
||||
|
||||
@@ -299,6 +299,10 @@ module ts {
|
||||
Type_0_is_not_an_array_type: { code: 2461, category: DiagnosticCategory.Error, key: "Type '{0}' is not an array type." },
|
||||
A_rest_element_must_be_last_in_an_array_destructuring_pattern: { code: 2462, category: DiagnosticCategory.Error, key: "A rest element must be last in an array destructuring pattern" },
|
||||
A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature: { code: 2463, category: DiagnosticCategory.Error, key: "A binding pattern parameter cannot be optional in an implementation signature." },
|
||||
A_computed_property_name_must_be_of_type_string_number_or_any: { code: 2464, category: DiagnosticCategory.Error, key: "A computed property name must be of type 'string', 'number', or 'any'." },
|
||||
this_cannot_be_referenced_in_a_computed_property_name: { code: 2465, category: DiagnosticCategory.Error, key: "'this' cannot be referenced in a computed property name." },
|
||||
super_cannot_be_referenced_in_a_computed_property_name: { code: 2466, category: DiagnosticCategory.Error, key: "'super' cannot be referenced in a computed property name." },
|
||||
A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type: { code: 2466, category: DiagnosticCategory.Error, key: "A computed property name cannot reference a type parameter from its containing type." },
|
||||
Import_declaration_0_is_using_private_name_1: { code: 4000, category: DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." },
|
||||
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." },
|
||||
Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." },
|
||||
@@ -380,11 +384,13 @@ module ts {
|
||||
Cannot_read_file_0_Colon_1: { code: 5012, category: DiagnosticCategory.Error, key: "Cannot read file '{0}': {1}" },
|
||||
Unsupported_file_encoding: { code: 5013, category: DiagnosticCategory.Error, key: "Unsupported file encoding." },
|
||||
Unknown_compiler_option_0: { code: 5023, category: DiagnosticCategory.Error, key: "Unknown compiler option '{0}'." },
|
||||
Compiler_option_0_requires_a_value_of_type_1: { code: 5024, category: DiagnosticCategory.Error, key: "Compiler option '{0}' requires a value of type {1}." },
|
||||
Could_not_write_file_0_Colon_1: { code: 5033, category: DiagnosticCategory.Error, key: "Could not write file '{0}': {1}" },
|
||||
Option_mapRoot_cannot_be_specified_without_specifying_sourcemap_option: { code: 5038, category: DiagnosticCategory.Error, key: "Option mapRoot cannot be specified without specifying sourcemap option." },
|
||||
Option_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option: { code: 5039, category: DiagnosticCategory.Error, key: "Option sourceRoot cannot be specified without specifying sourcemap option." },
|
||||
Option_noEmit_cannot_be_specified_with_option_out_or_outDir: { code: 5040, category: DiagnosticCategory.Error, key: "Option noEmit cannot be specified with option out or outDir." },
|
||||
Option_noEmit_cannot_be_specified_with_option_declaration: { code: 5041, category: DiagnosticCategory.Error, key: "Option noEmit cannot be specified with option declaration." },
|
||||
Option_mapRoot_cannot_be_specified_without_specifying_sourcemap_option: { code: 5038, category: DiagnosticCategory.Error, key: "Option 'mapRoot' cannot be specified without specifying 'sourcemap' option." },
|
||||
Option_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option: { code: 5039, category: DiagnosticCategory.Error, key: "Option 'sourceRoot' cannot be specified without specifying 'sourcemap' option." },
|
||||
Option_noEmit_cannot_be_specified_with_option_out_or_outDir: { code: 5040, category: DiagnosticCategory.Error, key: "Option 'noEmit' cannot be specified with option 'out' or 'outDir'." },
|
||||
Option_noEmit_cannot_be_specified_with_option_declaration: { code: 5041, category: DiagnosticCategory.Error, key: "Option 'noEmit' cannot be specified with option 'declaration'." },
|
||||
Option_project_cannot_be_mixed_with_source_files_on_a_command_line: { code: 5042, category: DiagnosticCategory.Error, key: "Option 'project' cannot be mixed with source files on a command line." },
|
||||
Concatenate_and_emit_output_to_single_file: { code: 6001, category: DiagnosticCategory.Message, key: "Concatenate and emit output to single file." },
|
||||
Generates_corresponding_d_ts_file: { code: 6002, category: DiagnosticCategory.Message, key: "Generates corresponding '.d.ts' file." },
|
||||
Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: { code: 6003, category: DiagnosticCategory.Message, key: "Specifies the location where debugger should locate map files instead of generated locations." },
|
||||
@@ -399,6 +405,7 @@ module ts {
|
||||
Specify_module_code_generation_Colon_commonjs_or_amd: { code: 6016, category: DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs' or 'amd'" },
|
||||
Print_this_message: { code: 6017, category: DiagnosticCategory.Message, key: "Print this message." },
|
||||
Print_the_compiler_s_version: { code: 6019, category: DiagnosticCategory.Message, key: "Print the compiler's version." },
|
||||
Compile_the_project_in_the_given_directory: { code: 6020, category: DiagnosticCategory.Message, key: "Compile the project in the given directory." },
|
||||
Syntax_Colon_0: { code: 6023, category: DiagnosticCategory.Message, key: "Syntax: {0}" },
|
||||
options: { code: 6024, category: DiagnosticCategory.Message, key: "options" },
|
||||
file: { code: 6025, category: DiagnosticCategory.Message, key: "file" },
|
||||
@@ -406,7 +413,7 @@ module ts {
|
||||
Options_Colon: { code: 6027, category: DiagnosticCategory.Message, key: "Options:" },
|
||||
Version_0: { code: 6029, category: DiagnosticCategory.Message, key: "Version {0}" },
|
||||
Insert_command_line_options_and_files_from_a_file: { code: 6030, category: DiagnosticCategory.Message, key: "Insert command line options and files from a file." },
|
||||
File_change_detected_Compiling: { code: 6032, category: DiagnosticCategory.Message, key: "File change detected. Compiling..." },
|
||||
File_change_detected_Starting_incremental_compilation: { code: 6032, category: DiagnosticCategory.Message, key: "File change detected. Starting incremental compilation..." },
|
||||
KIND: { code: 6034, category: DiagnosticCategory.Message, key: "KIND" },
|
||||
FILE: { code: 6035, category: DiagnosticCategory.Message, key: "FILE" },
|
||||
VERSION: { code: 6036, category: DiagnosticCategory.Message, key: "VERSION" },
|
||||
@@ -445,6 +452,5 @@ module ts {
|
||||
You_cannot_rename_this_element: { code: 8000, category: DiagnosticCategory.Error, key: "You cannot rename this element." },
|
||||
yield_expressions_are_not_currently_supported: { code: 9000, category: DiagnosticCategory.Error, key: "'yield' expressions are not currently supported.", isEarly: true },
|
||||
Generators_are_not_currently_supported: { code: 9001, category: DiagnosticCategory.Error, key: "Generators are not currently supported.", isEarly: true },
|
||||
Computed_property_names_are_not_currently_supported: { code: 9002, category: DiagnosticCategory.Error, key: "Computed property names are not currently supported.", isEarly: true },
|
||||
};
|
||||
}
|
||||
@@ -675,7 +675,7 @@
|
||||
},
|
||||
"A parameter property may not be a binding pattern.": {
|
||||
"category": "Error",
|
||||
"code": 1187
|
||||
"code": 1187
|
||||
},
|
||||
|
||||
"Duplicate identifier '{0}'.": {
|
||||
@@ -1288,7 +1288,23 @@
|
||||
},
|
||||
"A binding pattern parameter cannot be optional in an implementation signature.": {
|
||||
"category": "Error",
|
||||
"code": 2463
|
||||
"code": 2463
|
||||
},
|
||||
"A computed property name must be of type 'string', 'number', or 'any'.": {
|
||||
"category": "Error",
|
||||
"code": 2464
|
||||
},
|
||||
"'this' cannot be referenced in a computed property name.": {
|
||||
"category": "Error",
|
||||
"code": 2465
|
||||
},
|
||||
"'super' cannot be referenced in a computed property name.": {
|
||||
"category": "Error",
|
||||
"code": 2466
|
||||
},
|
||||
"A computed property name cannot reference a type parameter from its containing type.": {
|
||||
"category": "Error",
|
||||
"code": 2466
|
||||
},
|
||||
|
||||
"Import declaration '{0}' is using private name '{1}'.": {
|
||||
@@ -1618,26 +1634,34 @@
|
||||
"category": "Error",
|
||||
"code": 5023
|
||||
},
|
||||
"Compiler option '{0}' requires a value of type {1}.": {
|
||||
"category": "Error",
|
||||
"code": 5024
|
||||
},
|
||||
"Could not write file '{0}': {1}": {
|
||||
"category": "Error",
|
||||
"code": 5033
|
||||
},
|
||||
"Option mapRoot cannot be specified without specifying sourcemap option.": {
|
||||
"Option 'mapRoot' cannot be specified without specifying 'sourcemap' option.": {
|
||||
"category": "Error",
|
||||
"code": 5038
|
||||
},
|
||||
"Option sourceRoot cannot be specified without specifying sourcemap option.": {
|
||||
"Option 'sourceRoot' cannot be specified without specifying 'sourcemap' option.": {
|
||||
"category": "Error",
|
||||
"code": 5039
|
||||
},
|
||||
"Option noEmit cannot be specified with option out or outDir.": {
|
||||
"Option 'noEmit' cannot be specified with option 'out' or 'outDir'.": {
|
||||
"category": "Error",
|
||||
"code": 5040
|
||||
},
|
||||
"Option noEmit cannot be specified with option declaration.": {
|
||||
"Option 'noEmit' cannot be specified with option 'declaration'.": {
|
||||
"category": "Error",
|
||||
"code": 5041
|
||||
},
|
||||
"Option 'project' cannot be mixed with source files on a command line.": {
|
||||
"category": "Error",
|
||||
"code": 5042
|
||||
},
|
||||
"Concatenate and emit output to single file.": {
|
||||
"category": "Message",
|
||||
"code": 6001
|
||||
@@ -1694,6 +1718,10 @@
|
||||
"category": "Message",
|
||||
"code": 6019
|
||||
},
|
||||
"Compile the project in the given directory.": {
|
||||
"category": "Message",
|
||||
"code": 6020
|
||||
},
|
||||
"Syntax: {0}": {
|
||||
"category": "Message",
|
||||
"code": 6023
|
||||
@@ -1722,7 +1750,7 @@
|
||||
"category": "Message",
|
||||
"code": 6030
|
||||
},
|
||||
"File change detected. Compiling...": {
|
||||
"File change detected. Starting incremental compilation...": {
|
||||
"category": "Message",
|
||||
"code": 6032
|
||||
},
|
||||
@@ -1880,10 +1908,5 @@
|
||||
"category": "Error",
|
||||
"code": 9001,
|
||||
"isEarly": true
|
||||
},
|
||||
"Computed property names are not currently supported.": {
|
||||
"category": "Error",
|
||||
"code": 9002,
|
||||
"isEarly": true
|
||||
}
|
||||
}
|
||||
|
||||
+47
-20
@@ -170,9 +170,10 @@ module ts {
|
||||
function writeCommentRange(currentSourceFile: SourceFile, writer: EmitTextWriter, comment: CommentRange, newLine: string){
|
||||
if (currentSourceFile.text.charCodeAt(comment.pos + 1) === CharacterCodes.asterisk) {
|
||||
var firstCommentLineAndCharacter = currentSourceFile.getLineAndCharacterFromPosition(comment.pos);
|
||||
var lastLine = currentSourceFile.getLineStarts().length;
|
||||
var firstCommentLineIndent: number;
|
||||
for (var pos = comment.pos, currentLine = firstCommentLineAndCharacter.line; pos < comment.end; currentLine++) {
|
||||
var nextLineStart = currentSourceFile.getPositionFromLineAndCharacter(currentLine + 1, /*character*/1);
|
||||
var nextLineStart = currentLine === lastLine ? (comment.end + 1) : currentSourceFile.getPositionFromLineAndCharacter(currentLine + 1, /*character*/1);
|
||||
|
||||
if (pos !== comment.pos) {
|
||||
// If we are not emitting first line, we need to write the spaces to adjust the alignment
|
||||
@@ -339,6 +340,7 @@ module ts {
|
||||
function emitDeclarations(host: EmitHost, resolver: EmitResolver, diagnostics: Diagnostic[], jsFilePath: string, root?: SourceFile): DeclarationEmit {
|
||||
var newLine = host.getNewLine();
|
||||
var compilerOptions = host.getCompilerOptions();
|
||||
var languageVersion = compilerOptions.target || ScriptTarget.ES3;
|
||||
|
||||
var write: (s: string) => void;
|
||||
var writeLine: () => void;
|
||||
@@ -930,6 +932,10 @@ module ts {
|
||||
}
|
||||
|
||||
function emitPropertyDeclaration(node: Declaration) {
|
||||
if (hasDynamicName(node)) {
|
||||
return;
|
||||
}
|
||||
|
||||
emitJsDocComments(node);
|
||||
emitClassMemberDeclarationFlags(node);
|
||||
emitVariableDeclaration(<VariableDeclaration>node);
|
||||
@@ -937,11 +943,13 @@ module ts {
|
||||
writeLine();
|
||||
}
|
||||
|
||||
// TODO(jfreeman): Factor out common part of property definition, but treat name differently
|
||||
function emitVariableDeclaration(node: VariableDeclaration) {
|
||||
// If we are emitting property it isn't moduleElement and hence we already know it needs to be emitted
|
||||
// so there is no check needed to see if declaration is visible
|
||||
if (node.kind !== SyntaxKind.VariableDeclaration || resolver.isDeclarationVisible(node)) {
|
||||
// If this node is a computed name, it can only be a symbol, because we've already skipped
|
||||
// it if it's not a well known symbol. In that case, the text of the name will be exactly
|
||||
// what we want, namely the name expression enclosed in brackets.
|
||||
writeTextOfNode(currentSourceFile, node.name);
|
||||
// If optional property emit ?
|
||||
if ((node.kind === SyntaxKind.PropertyDeclaration || node.kind === SyntaxKind.PropertySignature) && hasQuestionToken(node)) {
|
||||
@@ -1028,6 +1036,10 @@ module ts {
|
||||
}
|
||||
|
||||
function emitAccessorDeclaration(node: AccessorDeclaration) {
|
||||
if (hasDynamicName(node)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var accessors = getAllAccessorDeclarations(<ClassDeclaration>node.parent, node);
|
||||
if (node === accessors.firstAccessor) {
|
||||
emitJsDocComments(accessors.getAccessor);
|
||||
@@ -1105,6 +1117,10 @@ module ts {
|
||||
}
|
||||
|
||||
function emitFunctionDeclaration(node: FunctionLikeDeclaration) {
|
||||
if (hasDynamicName(node)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If we are emitting Method/Constructor it isn't moduleElement and hence already determined to be emitting
|
||||
// so no need to verify if the declaration is visible
|
||||
if ((node.kind !== SyntaxKind.FunctionDeclaration || resolver.isDeclarationVisible(node)) &&
|
||||
@@ -1473,6 +1489,7 @@ module ts {
|
||||
export function emitFiles(resolver: EmitResolver, host: EmitHost, targetSourceFile?: SourceFile): EmitResult {
|
||||
// var program = resolver.getProgram();
|
||||
var compilerOptions = host.getCompilerOptions();
|
||||
var languageVersion = compilerOptions.target || ScriptTarget.ES3;
|
||||
var sourceMapDataList: SourceMapData[] = compilerOptions.sourceMap ? [] : undefined;
|
||||
var diagnostics: Diagnostic[] = [];
|
||||
var newLine = host.getNewLine();
|
||||
@@ -1720,7 +1737,14 @@ module ts {
|
||||
if (scopeName) {
|
||||
var parentIndex = getSourceMapNameIndex();
|
||||
if (parentIndex !== -1) {
|
||||
scopeName = sourceMapData.sourceMapNames[parentIndex] + "." + scopeName;
|
||||
// Child scopes are always shown with a dot (even if they have no name),
|
||||
// unless it is a computed property. Then it is shown with brackets,
|
||||
// but the brackets are included in the name.
|
||||
var name = (<Declaration>node).name;
|
||||
if (!name || name.kind !== SyntaxKind.ComputedPropertyName) {
|
||||
scopeName = "." + scopeName;
|
||||
}
|
||||
scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName;
|
||||
}
|
||||
|
||||
scopeNameIndex = getProperty(sourceMapNameIndexMap, scopeName);
|
||||
@@ -1748,8 +1772,11 @@ module ts {
|
||||
node.kind === SyntaxKind.EnumDeclaration) {
|
||||
// Declaration and has associated name use it
|
||||
if ((<Declaration>node).name) {
|
||||
// TODO(jfreeman): Ask shkamat about what this name should be for source maps
|
||||
scopeName = (<Identifier>(<Declaration>node).name).text;
|
||||
var name = (<Declaration>node).name;
|
||||
// For computed property names, the text will include the brackets
|
||||
scopeName = name.kind === SyntaxKind.ComputedPropertyName
|
||||
? getTextOfNode(name)
|
||||
: (<Identifier>(<Declaration>node).name).text;
|
||||
}
|
||||
recordScopeNameStart(scopeName);
|
||||
}
|
||||
@@ -2021,14 +2048,14 @@ module ts {
|
||||
}
|
||||
|
||||
function emitLiteral(node: LiteralExpression) {
|
||||
var text = compilerOptions.target < ScriptTarget.ES6 && isTemplateLiteralKind(node.kind) ? getTemplateLiteralAsStringLiteral(node) :
|
||||
var text = languageVersion < ScriptTarget.ES6 && isTemplateLiteralKind(node.kind) ? getTemplateLiteralAsStringLiteral(node) :
|
||||
node.parent ? getSourceTextOfNodeFromSourceFile(currentSourceFile, node) :
|
||||
node.text;
|
||||
if (compilerOptions.sourceMap && (node.kind === SyntaxKind.StringLiteral || isTemplateLiteralKind(node.kind))) {
|
||||
writer.writeLiteral(text);
|
||||
}
|
||||
// For version below ES6, emit binary integer literal and octal integer literal in canonical form
|
||||
else if (compilerOptions.target < ScriptTarget.ES6 && node.kind === SyntaxKind.NumericLiteral && isBinaryOrOctalIntegerLiteral(text)) {
|
||||
else if (languageVersion < ScriptTarget.ES6 && node.kind === SyntaxKind.NumericLiteral && isBinaryOrOctalIntegerLiteral(text)) {
|
||||
write(node.text);
|
||||
}
|
||||
else {
|
||||
@@ -2043,7 +2070,7 @@ module ts {
|
||||
function emitTemplateExpression(node: TemplateExpression): void {
|
||||
// In ES6 mode and above, we can simply emit each portion of a template in order, but in
|
||||
// ES3 & ES5 we must convert the template expression into a series of string concatenations.
|
||||
if (compilerOptions.target >= ScriptTarget.ES6) {
|
||||
if (languageVersion >= ScriptTarget.ES6) {
|
||||
forEachChild(node, emit);
|
||||
return;
|
||||
}
|
||||
@@ -2150,7 +2177,7 @@ module ts {
|
||||
//
|
||||
// TODO (drosen): Note that we need to account for the upcoming 'yield' and
|
||||
// spread ('...') unary operators that are anticipated for ES6.
|
||||
Debug.assert(compilerOptions.target <= ScriptTarget.ES5);
|
||||
Debug.assert(languageVersion < ScriptTarget.ES6);
|
||||
switch (expression.kind) {
|
||||
case SyntaxKind.BinaryExpression:
|
||||
switch ((<BinaryExpression>expression).operator) {
|
||||
@@ -2335,7 +2362,7 @@ module ts {
|
||||
write("[]");
|
||||
return;
|
||||
}
|
||||
if (compilerOptions.target >= ScriptTarget.ES6) {
|
||||
if (languageVersion >= ScriptTarget.ES6) {
|
||||
write("[");
|
||||
emitList(elements, 0, elements.length, /*multiLine*/(node.flags & NodeFlags.MultiLine) !== 0,
|
||||
/*trailingComma*/ elements.hasTrailingComma);
|
||||
@@ -2385,7 +2412,7 @@ module ts {
|
||||
write(" ");
|
||||
}
|
||||
emitList(properties, 0, properties.length, /*multiLine*/ multiLine,
|
||||
/*trailingComma*/ properties.hasTrailingComma && compilerOptions.target >= ScriptTarget.ES5);
|
||||
/*trailingComma*/ properties.hasTrailingComma && languageVersion >= ScriptTarget.ES5);
|
||||
if (!multiLine) {
|
||||
write(" ");
|
||||
}
|
||||
@@ -2405,7 +2432,7 @@ module ts {
|
||||
}
|
||||
emitLeadingComments(node);
|
||||
emit(node.name);
|
||||
if (compilerOptions.target < ScriptTarget.ES6) {
|
||||
if (languageVersion < ScriptTarget.ES6) {
|
||||
write(": function ");
|
||||
}
|
||||
emitSignatureAndBody(node);
|
||||
@@ -2431,7 +2458,7 @@ module ts {
|
||||
// export var obj = { y };
|
||||
// }
|
||||
// The short-hand property in obj need to emit as such ... = { y : m.y } regardless of the TargetScript version
|
||||
if (compilerOptions.target < ScriptTarget.ES6 || resolver.getExpressionNamePrefix(node.name)) {
|
||||
if (languageVersion < ScriptTarget.ES6 || resolver.getExpressionNamePrefix(node.name)) {
|
||||
// Emit identifier as an identifier
|
||||
write(": ");
|
||||
// Even though this is stored as identifier treat it as an expression
|
||||
@@ -2513,7 +2540,7 @@ module ts {
|
||||
}
|
||||
|
||||
function emitTaggedTemplateExpression(node: TaggedTemplateExpression): void {
|
||||
Debug.assert(compilerOptions.target >= ScriptTarget.ES6, "Trying to emit a tagged template in pre-ES6 mode.");
|
||||
Debug.assert(languageVersion >= ScriptTarget.ES6, "Trying to emit a tagged template in pre-ES6 mode.");
|
||||
emit(node.tag);
|
||||
write(" ");
|
||||
emit(node.template);
|
||||
@@ -2605,7 +2632,7 @@ module ts {
|
||||
|
||||
|
||||
function emitBinaryExpression(node: BinaryExpression) {
|
||||
if (compilerOptions.target < ScriptTarget.ES6 && node.operator === SyntaxKind.EqualsToken &&
|
||||
if (languageVersion < ScriptTarget.ES6 && node.operator === SyntaxKind.EqualsToken &&
|
||||
(node.left.kind === SyntaxKind.ObjectLiteralExpression || node.left.kind === SyntaxKind.ArrayLiteralExpression)) {
|
||||
emitDestructuring(node);
|
||||
}
|
||||
@@ -3101,7 +3128,7 @@ module ts {
|
||||
function emitVariableDeclaration(node: VariableDeclaration) {
|
||||
emitLeadingComments(node);
|
||||
if (isBindingPattern(node.name)) {
|
||||
if (compilerOptions.target < ScriptTarget.ES6) {
|
||||
if (languageVersion < ScriptTarget.ES6) {
|
||||
emitDestructuring(node);
|
||||
}
|
||||
else {
|
||||
@@ -3136,7 +3163,7 @@ module ts {
|
||||
|
||||
function emitParameter(node: ParameterDeclaration) {
|
||||
emitLeadingComments(node);
|
||||
if (compilerOptions.target < ScriptTarget.ES6) {
|
||||
if (languageVersion < ScriptTarget.ES6) {
|
||||
if (isBindingPattern(node.name)) {
|
||||
var name = createTempVariable(node);
|
||||
if (!tempParameters) {
|
||||
@@ -3160,7 +3187,7 @@ module ts {
|
||||
}
|
||||
|
||||
function emitDefaultValueAssignments(node: FunctionLikeDeclaration) {
|
||||
if (compilerOptions.target < ScriptTarget.ES6) {
|
||||
if (languageVersion < ScriptTarget.ES6) {
|
||||
var tempIndex = 0;
|
||||
forEach(node.parameters, p => {
|
||||
if (isBindingPattern(p.name)) {
|
||||
@@ -3190,7 +3217,7 @@ module ts {
|
||||
}
|
||||
|
||||
function emitRestParameter(node: FunctionLikeDeclaration) {
|
||||
if (compilerOptions.target < ScriptTarget.ES6 && hasRestParameters(node)) {
|
||||
if (languageVersion < ScriptTarget.ES6 && hasRestParameters(node)) {
|
||||
var restIndex = node.parameters.length - 1;
|
||||
var restParam = node.parameters[restIndex];
|
||||
var tempName = createTempVariable(node, /*forLoopVariable*/ true).text;
|
||||
@@ -3269,7 +3296,7 @@ module ts {
|
||||
write("(");
|
||||
if (node) {
|
||||
var parameters = node.parameters;
|
||||
var omitCount = compilerOptions.target < ScriptTarget.ES6 && hasRestParameters(node) ? 1 : 0;
|
||||
var omitCount = languageVersion < ScriptTarget.ES6 && hasRestParameters(node) ? 1 : 0;
|
||||
emitList(parameters, 0, parameters.length - omitCount, /*multiLine*/ false, /*trailingComma*/ false);
|
||||
}
|
||||
write(")");
|
||||
|
||||
@@ -146,7 +146,9 @@ module ts {
|
||||
function invokeEmitter(targetSourceFile?: SourceFile) {
|
||||
var resolver = getDiagnosticsProducingTypeChecker().getEmitResolver();
|
||||
return emitFiles(resolver, getEmitHost(), targetSourceFile);
|
||||
} function getSourceFile(filename: string) {
|
||||
}
|
||||
|
||||
function getSourceFile(filename: string) {
|
||||
filename = host.getCanonicalFileName(filename);
|
||||
return hasProperty(filesByName, filename) ? filesByName[filename] : undefined;
|
||||
}
|
||||
@@ -340,7 +342,7 @@ module ts {
|
||||
}
|
||||
|
||||
var firstExternalModule = forEach(files, f => isExternalModule(f) ? f : undefined);
|
||||
if (firstExternalModule && options.module === ModuleKind.None) {
|
||||
if (firstExternalModule && !options.module) {
|
||||
// We cannot use createDiagnosticFromNode because nodes do not have parents yet
|
||||
var externalModuleErrorSpan = getErrorSpanForNode(firstExternalModule.externalModuleIndicator);
|
||||
var errorStart = skipTrivia(firstExternalModule.text, externalModuleErrorSpan.pos);
|
||||
|
||||
@@ -224,15 +224,15 @@ module ts {
|
||||
}
|
||||
|
||||
function isUnicodeIdentifierStart(code: number, languageVersion: ScriptTarget) {
|
||||
return languageVersion === ScriptTarget.ES3 ?
|
||||
lookupInUnicodeMap(code, unicodeES3IdentifierStart) :
|
||||
lookupInUnicodeMap(code, unicodeES5IdentifierStart);
|
||||
return languageVersion >= ScriptTarget.ES5 ?
|
||||
lookupInUnicodeMap(code, unicodeES5IdentifierStart) :
|
||||
lookupInUnicodeMap(code, unicodeES3IdentifierStart);
|
||||
}
|
||||
|
||||
function isUnicodeIdentifierPart(code: number, languageVersion: ScriptTarget) {
|
||||
return languageVersion === ScriptTarget.ES3 ?
|
||||
lookupInUnicodeMap(code, unicodeES3IdentifierPart) :
|
||||
lookupInUnicodeMap(code, unicodeES5IdentifierPart);
|
||||
return languageVersion >= ScriptTarget.ES5 ?
|
||||
lookupInUnicodeMap(code, unicodeES5IdentifierPart) :
|
||||
lookupInUnicodeMap(code, unicodeES3IdentifierPart);
|
||||
}
|
||||
|
||||
function makeReverseMap(source: Map<number>): string[] {
|
||||
@@ -279,7 +279,7 @@ module ts {
|
||||
}
|
||||
|
||||
export function getPositionFromLineAndCharacter(lineStarts: number[], line: number, character: number): number {
|
||||
Debug.assert(line > 0);
|
||||
Debug.assert(line > 0 && line <= lineStarts.length );
|
||||
return lineStarts[line - 1] + character - 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/// <reference path="core.ts"/>
|
||||
|
||||
module ts {
|
||||
export interface System {
|
||||
@@ -14,6 +15,7 @@ module ts {
|
||||
createDirectory(directoryName: string): void;
|
||||
getExecutingFilePath(): string;
|
||||
getCurrentDirectory(): string;
|
||||
readDirectory(path: string, extension?: string): string[];
|
||||
getMemoryUsage? (): number;
|
||||
exit(exitCode?: number): void;
|
||||
}
|
||||
@@ -28,6 +30,13 @@ module ts {
|
||||
declare var global: any;
|
||||
declare var __filename: string;
|
||||
|
||||
declare class Enumerator {
|
||||
public atEnd(): boolean;
|
||||
public moveNext(): boolean;
|
||||
public item(): any;
|
||||
constructor(o: any);
|
||||
}
|
||||
|
||||
export var sys: System = (function () {
|
||||
|
||||
function getWScriptSystem(): System {
|
||||
@@ -100,6 +109,34 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
function getNames(collection: any): string[] {
|
||||
var result: string[] = [];
|
||||
for (var e = new Enumerator(collection); !e.atEnd(); e.moveNext()) {
|
||||
result.push(e.item().Name);
|
||||
}
|
||||
return result.sort();
|
||||
}
|
||||
|
||||
function readDirectory(path: string, extension?: string): string[] {
|
||||
var result: string[] = [];
|
||||
visitDirectory(path);
|
||||
return result;
|
||||
function visitDirectory(path: string) {
|
||||
var folder = fso.GetFolder(path || ".");
|
||||
var files = getNames(folder.files);
|
||||
for (var i = 0; i < files.length; i++) {
|
||||
var name = files[i];
|
||||
if (!extension || fileExtensionIs(name, extension)) {
|
||||
result.push(combinePaths(path, name));
|
||||
}
|
||||
}
|
||||
var subfolders = getNames(folder.subfolders);
|
||||
for (var i = 0; i < subfolders.length; i++) {
|
||||
visitDirectory(combinePaths(path, subfolders[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
args,
|
||||
newLine: "\r\n",
|
||||
@@ -129,6 +166,7 @@ module ts {
|
||||
getCurrentDirectory() {
|
||||
return new ActiveXObject("WScript.Shell").CurrentDirectory;
|
||||
},
|
||||
readDirectory,
|
||||
exit(exitCode?: number): void {
|
||||
try {
|
||||
WScript.Quit(exitCode);
|
||||
@@ -185,6 +223,31 @@ module ts {
|
||||
_fs.writeFileSync(fileName, data, "utf8");
|
||||
}
|
||||
|
||||
function readDirectory(path: string, extension?: string): string[] {
|
||||
var result: string[] = [];
|
||||
visitDirectory(path);
|
||||
return result;
|
||||
function visitDirectory(path: string) {
|
||||
var files = _fs.readdirSync(path || ".").sort();
|
||||
var directories: string[] = [];
|
||||
for (var i = 0; i < files.length; i++) {
|
||||
var name = combinePaths(path, files[i]);
|
||||
var stat = _fs.lstatSync(name);
|
||||
if (stat.isFile()) {
|
||||
if (!extension || fileExtensionIs(name, extension)) {
|
||||
result.push(name);
|
||||
}
|
||||
}
|
||||
else if (stat.isDirectory()) {
|
||||
directories.push(name);
|
||||
}
|
||||
}
|
||||
for (var i = 0; i < directories.length; i++) {
|
||||
visitDirectory(directories[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
args: process.argv.slice(2),
|
||||
newLine: _os.EOL,
|
||||
@@ -231,6 +294,7 @@ module ts {
|
||||
getCurrentDirectory() {
|
||||
return process.cwd();
|
||||
},
|
||||
readDirectory,
|
||||
getMemoryUsage() {
|
||||
if (global.gc) {
|
||||
global.gc();
|
||||
|
||||
+158
-98
@@ -4,6 +4,10 @@
|
||||
module ts {
|
||||
var version = "1.4.0.0";
|
||||
|
||||
export interface SourceFile {
|
||||
fileWatcher: FileWatcher;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if the locale is in the appropriate format,
|
||||
* and if it is, attempts to set the appropriate language.
|
||||
@@ -126,16 +130,43 @@ module ts {
|
||||
reportStatisticalValue(name, (time / 1000).toFixed(2) + "s");
|
||||
}
|
||||
|
||||
function isJSONSupported() {
|
||||
return typeof JSON === "object" && typeof JSON.parse === "function";
|
||||
}
|
||||
|
||||
function findConfigFile(): string {
|
||||
var searchPath = normalizePath(sys.getCurrentDirectory());
|
||||
var filename = "tsconfig.json";
|
||||
while (true) {
|
||||
if (sys.fileExists(filename)) {
|
||||
return filename;
|
||||
}
|
||||
var parentPath = getDirectoryPath(searchPath);
|
||||
if (parentPath === searchPath) {
|
||||
break;
|
||||
}
|
||||
searchPath = parentPath;
|
||||
filename = "../" + filename;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function executeCommandLine(args: string[]): void {
|
||||
var commandLine = parseCommandLine(args);
|
||||
var compilerOptions = commandLine.options;
|
||||
var configFilename: string; // Configuration file name (if any)
|
||||
var configFileWatcher: FileWatcher; // Configuration file watcher
|
||||
var cachedProgram: Program; // Program cached from last compilation
|
||||
var rootFilenames: string[]; // Root filenames for compilation
|
||||
var compilerOptions: CompilerOptions; // Compiler options for compilation
|
||||
var compilerHost: CompilerHost; // Compiler host
|
||||
var hostGetSourceFile: typeof compilerHost.getSourceFile; // getSourceFile method from default host
|
||||
var timerHandle: number; // Handle for 0.25s wait timer
|
||||
|
||||
if (compilerOptions.locale) {
|
||||
if (typeof JSON === "undefined") {
|
||||
if (commandLine.options.locale) {
|
||||
if (!isJSONSupported()) {
|
||||
reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--locale"));
|
||||
return sys.exit(1);
|
||||
return sys.exit(EmitReturnStatus.CompilerOptionsErrors);
|
||||
}
|
||||
|
||||
validateLocaleAndSetLanguage(commandLine.options.locale, commandLine.errors);
|
||||
}
|
||||
|
||||
@@ -146,131 +177,153 @@ module ts {
|
||||
return sys.exit(EmitReturnStatus.CompilerOptionsErrors);
|
||||
}
|
||||
|
||||
if (compilerOptions.version) {
|
||||
if (commandLine.options.version) {
|
||||
reportDiagnostic(createCompilerDiagnostic(Diagnostics.Version_0, version));
|
||||
return sys.exit(EmitReturnStatus.Succeeded);
|
||||
}
|
||||
|
||||
if (compilerOptions.help) {
|
||||
if (commandLine.options.help) {
|
||||
printVersion();
|
||||
printHelp();
|
||||
return sys.exit(EmitReturnStatus.Succeeded);
|
||||
}
|
||||
|
||||
if (commandLine.filenames.length === 0) {
|
||||
if (commandLine.options.project) {
|
||||
if (!isJSONSupported()) {
|
||||
reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--project"));
|
||||
return sys.exit(EmitReturnStatus.CompilerOptionsErrors);
|
||||
}
|
||||
configFilename = normalizePath(combinePaths(commandLine.options.project, "tsconfig.json"));
|
||||
if (commandLine.filenames.length !== 0) {
|
||||
reportDiagnostic(createCompilerDiagnostic(Diagnostics.Option_project_cannot_be_mixed_with_source_files_on_a_command_line));
|
||||
return sys.exit(EmitReturnStatus.CompilerOptionsErrors);
|
||||
}
|
||||
}
|
||||
else if (commandLine.filenames.length === 0 && isJSONSupported()) {
|
||||
configFilename = findConfigFile();
|
||||
}
|
||||
|
||||
if (commandLine.filenames.length === 0 && !configFilename) {
|
||||
printVersion();
|
||||
printHelp();
|
||||
return sys.exit(EmitReturnStatus.CompilerOptionsErrors);
|
||||
}
|
||||
|
||||
var defaultCompilerHost = createCompilerHost(compilerOptions);
|
||||
|
||||
if (compilerOptions.watch) {
|
||||
if (commandLine.options.watch) {
|
||||
if (!sys.watchFile) {
|
||||
reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--watch"));
|
||||
return sys.exit(EmitReturnStatus.CompilerOptionsErrors);
|
||||
}
|
||||
|
||||
watchProgram(commandLine, defaultCompilerHost);
|
||||
}
|
||||
else {
|
||||
var result = compile(commandLine, defaultCompilerHost).exitStatus
|
||||
return sys.exit(result);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Compiles the program once, and then watches all given and referenced files for changes.
|
||||
* Upon detecting a file change, watchProgram will queue up file modification events for the next
|
||||
* 250ms and then perform a recompilation. The reasoning is that in some cases, an editor can
|
||||
* save all files at once, and we'd like to just perform a single recompilation.
|
||||
*/
|
||||
function watchProgram(commandLine: ParsedCommandLine, compilerHost: CompilerHost): void {
|
||||
var watchers: Map<FileWatcher> = {};
|
||||
var updatedFiles: Map<boolean> = {};
|
||||
|
||||
// Compile the program the first time and watch all given/referenced files.
|
||||
var program = compile(commandLine, compilerHost).program;
|
||||
reportDiagnostic(createCompilerDiagnostic(Diagnostics.Compilation_complete_Watching_for_file_changes));
|
||||
addWatchers(program);
|
||||
return;
|
||||
|
||||
function addWatchers(program: Program) {
|
||||
forEach(program.getSourceFiles(), f => {
|
||||
var filename = getCanonicalName(f.filename);
|
||||
watchers[filename] = sys.watchFile(filename, fileUpdated);
|
||||
});
|
||||
}
|
||||
|
||||
function removeWatchers(program: Program) {
|
||||
forEach(program.getSourceFiles(), f => {
|
||||
var filename = getCanonicalName(f.filename);
|
||||
if (hasProperty(watchers, filename)) {
|
||||
watchers[filename].close();
|
||||
}
|
||||
});
|
||||
|
||||
watchers = {};
|
||||
}
|
||||
|
||||
// Fired off whenever a file is changed.
|
||||
function fileUpdated(filename: string) {
|
||||
var firstNotification = isEmpty(updatedFiles);
|
||||
updatedFiles[getCanonicalName(filename)] = true;
|
||||
|
||||
// Only start this off when the first file change comes in,
|
||||
// so that we can batch up all further changes.
|
||||
if (firstNotification) {
|
||||
setTimeout(() => {
|
||||
var changedFiles = updatedFiles;
|
||||
updatedFiles = {};
|
||||
|
||||
recompile(changedFiles);
|
||||
}, 250);
|
||||
if (configFilename) {
|
||||
configFileWatcher = sys.watchFile(configFilename, configFileChanged);
|
||||
}
|
||||
}
|
||||
|
||||
function recompile(changedFiles: Map<boolean>) {
|
||||
reportDiagnostic(createCompilerDiagnostic(Diagnostics.File_change_detected_Compiling));
|
||||
// Remove all the watchers, as we may not be watching every file
|
||||
// specified since the last compilation cycle.
|
||||
removeWatchers(program);
|
||||
performCompilation();
|
||||
|
||||
// Reuse source files from the last compilation so long as they weren't changed.
|
||||
var oldSourceFiles = arrayToMap(
|
||||
filter(program.getSourceFiles(), file => !hasProperty(changedFiles, getCanonicalName(file.filename))),
|
||||
file => getCanonicalName(file.filename));
|
||||
// Invoked to perform initial compilation or re-compilation in watch mode
|
||||
function performCompilation() {
|
||||
|
||||
// We create a new compiler host for this compilation cycle.
|
||||
// This new host is effectively the same except that 'getSourceFile'
|
||||
// will try to reuse the SourceFiles from the last compilation cycle
|
||||
// so long as they were not modified.
|
||||
var newCompilerHost = clone(compilerHost);
|
||||
newCompilerHost.getSourceFile = (fileName, languageVersion, onError) => {
|
||||
fileName = getCanonicalName(fileName);
|
||||
|
||||
var sourceFile = lookUp(oldSourceFiles, fileName);
|
||||
if (sourceFile) {
|
||||
return sourceFile;
|
||||
if (!cachedProgram) {
|
||||
if (configFilename) {
|
||||
var configObject = readConfigFile(configFilename);
|
||||
if (!configObject) {
|
||||
reportDiagnostic(createCompilerDiagnostic(Diagnostics.Unable_to_open_file_0, configFilename));
|
||||
return sys.exit(EmitReturnStatus.CompilerOptionsErrors);
|
||||
}
|
||||
var configParseResult = parseConfigFile(configObject, getDirectoryPath(configFilename));
|
||||
if (configParseResult.errors.length > 0) {
|
||||
reportDiagnostics(configParseResult.errors);
|
||||
return sys.exit(EmitReturnStatus.CompilerOptionsErrors);
|
||||
}
|
||||
rootFilenames = configParseResult.filenames;
|
||||
compilerOptions = extend(commandLine.options, configParseResult.options);
|
||||
}
|
||||
else {
|
||||
rootFilenames = commandLine.filenames;
|
||||
compilerOptions = commandLine.options;
|
||||
}
|
||||
compilerHost = createCompilerHost(compilerOptions);
|
||||
hostGetSourceFile = compilerHost.getSourceFile;
|
||||
compilerHost.getSourceFile = getSourceFile;
|
||||
}
|
||||
|
||||
return compilerHost.getSourceFile(fileName, languageVersion, onError);
|
||||
};
|
||||
var compileResult = compile(rootFilenames, compilerOptions, compilerHost);
|
||||
|
||||
program = compile(commandLine, newCompilerHost).program;
|
||||
if (!commandLine.options.watch) {
|
||||
return sys.exit(compileResult.exitStatus);
|
||||
}
|
||||
|
||||
setCachedProgram(compileResult.program);
|
||||
reportDiagnostic(createCompilerDiagnostic(Diagnostics.Compilation_complete_Watching_for_file_changes));
|
||||
addWatchers(program);
|
||||
}
|
||||
|
||||
function getCanonicalName(fileName: string) {
|
||||
return compilerHost.getCanonicalFileName(fileName);
|
||||
function getSourceFile(filename: string, languageVersion: ScriptTarget, onError ?: (message: string) => void) {
|
||||
// Return existing SourceFile object if one is available
|
||||
if (cachedProgram) {
|
||||
var sourceFile = cachedProgram.getSourceFile(filename);
|
||||
// A modified source file has no watcher and should not be reused
|
||||
if (sourceFile && sourceFile.fileWatcher) {
|
||||
return sourceFile;
|
||||
}
|
||||
}
|
||||
// Use default host function
|
||||
var sourceFile = hostGetSourceFile(filename, languageVersion, onError);
|
||||
if (sourceFile && commandLine.options.watch) {
|
||||
// Attach a file watcher
|
||||
sourceFile.fileWatcher = sys.watchFile(sourceFile.filename, () => sourceFileChanged(sourceFile));
|
||||
}
|
||||
return sourceFile;
|
||||
}
|
||||
|
||||
// Change cached program to the given program
|
||||
function setCachedProgram(program: Program) {
|
||||
if (cachedProgram) {
|
||||
var newSourceFiles = program ? program.getSourceFiles() : undefined;
|
||||
forEach(cachedProgram.getSourceFiles(), sourceFile => {
|
||||
if (!(newSourceFiles && contains(newSourceFiles, sourceFile))) {
|
||||
if (sourceFile.fileWatcher) {
|
||||
sourceFile.fileWatcher.close();
|
||||
sourceFile.fileWatcher = undefined;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
cachedProgram = program;
|
||||
}
|
||||
|
||||
// If a source file changes, mark it as unwatched and start the recompilation timer
|
||||
function sourceFileChanged(sourceFile: SourceFile) {
|
||||
sourceFile.fileWatcher = undefined;
|
||||
startTimer();
|
||||
}
|
||||
|
||||
// If the configuration file changes, forget cached program and start the recompilation timer
|
||||
function configFileChanged() {
|
||||
setCachedProgram(undefined);
|
||||
startTimer();
|
||||
}
|
||||
|
||||
// Upon detecting a file change, wait for 250ms and then perform a recompilation. This gives batch
|
||||
// operations (such as saving all modified files in an editor) a chance to complete before we kick
|
||||
// off a new compilation.
|
||||
function startTimer() {
|
||||
if (timerHandle) {
|
||||
clearTimeout(timerHandle);
|
||||
}
|
||||
timerHandle = setTimeout(recompile, 250);
|
||||
}
|
||||
|
||||
function recompile() {
|
||||
timerHandle = undefined;
|
||||
reportDiagnostic(createCompilerDiagnostic(Diagnostics.File_change_detected_Starting_incremental_compilation));
|
||||
performCompilation();
|
||||
}
|
||||
}
|
||||
|
||||
function compile(commandLine: ParsedCommandLine, compilerHost: CompilerHost) {
|
||||
function compile(filenames: string[], compilerOptions: CompilerOptions, compilerHost: CompilerHost) {
|
||||
var parseStart = new Date().getTime();
|
||||
var compilerOptions = commandLine.options;
|
||||
var program = createProgram(commandLine.filenames, compilerOptions, compilerHost);
|
||||
var program = createProgram(filenames, compilerOptions, compilerHost);
|
||||
|
||||
var bindStart = new Date().getTime();
|
||||
var errors: Diagnostic[] = program.getDiagnostics();
|
||||
@@ -303,7 +356,14 @@ module ts {
|
||||
}
|
||||
|
||||
reportDiagnostics(errors);
|
||||
if (commandLine.options.diagnostics) {
|
||||
|
||||
if (compilerOptions.listFiles) {
|
||||
forEach(program.getSourceFiles(), file => {
|
||||
sys.write(file.filename + sys.newLine);
|
||||
});
|
||||
}
|
||||
|
||||
if (compilerOptions.diagnostics) {
|
||||
var memoryUsed = sys.getMemoryUsage ? sys.getMemoryUsage() : -1;
|
||||
reportCountStatistic("Files", program.getSourceFiles().length);
|
||||
reportCountStatistic("Lines", countLines(program));
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"noImplicitAny": true,
|
||||
"removeComments": true,
|
||||
"preserveConstEnums": true,
|
||||
"out": "../../built/local/tsc.js",
|
||||
"sourceMap": true
|
||||
},
|
||||
"files": [
|
||||
"core.ts",
|
||||
"sys.ts",
|
||||
"types.ts",
|
||||
"scanner.ts",
|
||||
"parser.ts",
|
||||
"utilities.ts",
|
||||
"binder.ts",
|
||||
"checker.ts",
|
||||
"emitter.ts",
|
||||
"program.ts",
|
||||
"commandLineParser.ts",
|
||||
"tsc.ts",
|
||||
"diagnosticInformationMap.generated.ts"
|
||||
]
|
||||
}
|
||||
@@ -1448,6 +1448,7 @@ module ts {
|
||||
diagnostics?: boolean;
|
||||
emitBOM?: boolean;
|
||||
help?: boolean;
|
||||
listFiles?: boolean;
|
||||
locale?: string;
|
||||
mapRoot?: string;
|
||||
module?: ModuleKind;
|
||||
@@ -1461,6 +1462,7 @@ module ts {
|
||||
out?: string;
|
||||
outDir?: string;
|
||||
preserveConstEnums?: boolean;
|
||||
project?: string;
|
||||
removeComments?: boolean;
|
||||
sourceMap?: boolean;
|
||||
sourceRoot?: string;
|
||||
@@ -1501,10 +1503,11 @@ module ts {
|
||||
export interface CommandLineOption {
|
||||
name: string;
|
||||
type: string | Map<number>; // "string", "number", "boolean", or an object literal mapping named values to actual values
|
||||
shortName?: string; // A short mnemonic for convenience - for instance, 'h' can be used in place of 'help'.
|
||||
isFilePath?: boolean; // True if option value is a path or filename
|
||||
shortName?: string; // A short mnemonic for convenience - for instance, 'h' can be used in place of 'help'
|
||||
description?: DiagnosticMessage; // The message describing what the command line switch does
|
||||
paramType?: DiagnosticMessage; // The name to be used for a non-boolean option's parameter.
|
||||
error?: DiagnosticMessage; // The error given when the argument does not fit a customized 'type'.
|
||||
paramType?: DiagnosticMessage; // The name to be used for a non-boolean option's parameter
|
||||
error?: DiagnosticMessage; // The error given when the argument does not fit a customized 'type'
|
||||
}
|
||||
|
||||
export const enum CharacterCodes {
|
||||
|
||||
@@ -399,6 +399,21 @@ module ts {
|
||||
return undefined;
|
||||
}
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.ComputedPropertyName:
|
||||
// If the grandparent node is an object literal (as opposed to a class),
|
||||
// then the computed property is not a 'this' container.
|
||||
// A computed property name in a class needs to be a this container
|
||||
// so that we can error on it.
|
||||
if (node.parent.parent.kind === SyntaxKind.ClassDeclaration) {
|
||||
return node;
|
||||
}
|
||||
// If this is a computed property, then the parent should not
|
||||
// make it a this container. The parent might be a property
|
||||
// in an object literal, like a method or accessor. But in order for
|
||||
// such a parent to be a this container, the reference must be in
|
||||
// the *body* of the container.
|
||||
node = node.parent;
|
||||
break;
|
||||
case SyntaxKind.ArrowFunction:
|
||||
if (!includeArrowFunctions) {
|
||||
continue;
|
||||
@@ -421,13 +436,32 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
export function getSuperContainer(node: Node): Node {
|
||||
export function getSuperContainer(node: Node, includeFunctions: boolean): Node {
|
||||
while (true) {
|
||||
node = node.parent;
|
||||
if (!node) {
|
||||
return undefined;
|
||||
}
|
||||
if (!node) return node;
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.ComputedPropertyName:
|
||||
// If the grandparent node is an object literal (as opposed to a class),
|
||||
// then the computed property is not a 'super' container.
|
||||
// A computed property name in a class needs to be a super container
|
||||
// so that we can error on it.
|
||||
if (node.parent.parent.kind === SyntaxKind.ClassDeclaration) {
|
||||
return node;
|
||||
}
|
||||
// If this is a computed property, then the parent should not
|
||||
// make it a super container. The parent might be a property
|
||||
// in an object literal, like a method or accessor. But in order for
|
||||
// such a parent to be a super container, the reference must be in
|
||||
// the *body* of the container.
|
||||
node = node.parent;
|
||||
break;
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.ArrowFunction:
|
||||
if (!includeFunctions) {
|
||||
continue;
|
||||
}
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
case SyntaxKind.PropertySignature:
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
@@ -527,6 +561,8 @@ module ts {
|
||||
return node === (<TypeAssertion>parent).expression;
|
||||
case SyntaxKind.TemplateSpan:
|
||||
return node === (<TemplateSpan>parent).expression;
|
||||
case SyntaxKind.ComputedPropertyName:
|
||||
return node === (<ComputedPropertyName>parent).expression;
|
||||
default:
|
||||
if (isExpression(parent)) {
|
||||
return true;
|
||||
|
||||
@@ -548,6 +548,18 @@ module FourSlash {
|
||||
}
|
||||
}
|
||||
|
||||
public verifyGetEmitOutputForCurrentFile(expected: string): void {
|
||||
var emit = this.languageService.getEmitOutput(this.activeFile.fileName);
|
||||
if (emit.outputFiles.length !== 1) {
|
||||
throw new Error("Expected exactly one output from emit of " + this.activeFile.fileName);
|
||||
}
|
||||
this.taoInvalidReason = 'verifyGetEmitOutputForCurrentFile impossible';
|
||||
var actual = emit.outputFiles[0].text;
|
||||
if (actual !== expected) {
|
||||
this.raiseError("Expected emit output to be '" + expected + "', but got '" + actual + "'");
|
||||
}
|
||||
}
|
||||
|
||||
public verifyMemberListContains(symbol: string, text?: string, documentation?: string, kind?: string) {
|
||||
this.scenarioActions.push('<ShowCompletionList />');
|
||||
this.scenarioActions.push('<VerifyCompletionContainsItem ItemName="' + symbol + '"/>');
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
declare var require: any;
|
||||
declare var process: any;
|
||||
var Buffer = require('buffer').Buffer;
|
||||
|
||||
// this will work in the browser via browserify
|
||||
var _chai: typeof chai = require('chai');
|
||||
@@ -1207,7 +1208,6 @@ module Harness {
|
||||
|
||||
export function getErrorBaseline(inputFiles: { unitName: string; content: string }[], diagnostics: HarnessDiagnostic[]) {
|
||||
diagnostics.sort(compareDiagnostics);
|
||||
|
||||
var outputLines: string[] = [];
|
||||
// Count up all the errors we find so we don't miss any
|
||||
var totalErrorsReported = 0;
|
||||
@@ -1298,8 +1298,13 @@ module Harness {
|
||||
return diagnostic.filename && isLibraryFile(diagnostic.filename);
|
||||
});
|
||||
|
||||
var numTest262HarnessDiagnostics = ts.countWhere(diagnostics, diagnostic => {
|
||||
// Count an error generated from tests262-harness folder.This should only apply for test262
|
||||
return diagnostic.filename && diagnostic.filename.indexOf("test262-harness") >= 0;
|
||||
});
|
||||
|
||||
// Verify we didn't miss any errors in total
|
||||
assert.equal(totalErrorsReported + numLibraryDiagnostics, diagnostics.length, 'total number of errors');
|
||||
assert.equal(totalErrorsReported + numLibraryDiagnostics + numTest262HarnessDiagnostics, diagnostics.length, 'total number of errors');
|
||||
|
||||
return minimalDiagnosticsToString(diagnostics) +
|
||||
ts.sys.newLine + ts.sys.newLine + outputLines.join('\r\n');
|
||||
@@ -1642,7 +1647,8 @@ module Harness {
|
||||
}
|
||||
|
||||
function writeComparison(expected: string, actual: string, relativeFilename: string, actualFilename: string, descriptionForDescribe: string) {
|
||||
if (expected != actual) {
|
||||
var encoded_actual = (new Buffer(actual)).toString('utf8')
|
||||
if (expected != encoded_actual) {
|
||||
// Overwrite & issue error
|
||||
var errMsg = 'The baseline file ' + relativeFilename + ' has changed';
|
||||
throw new Error(errMsg);
|
||||
|
||||
@@ -243,8 +243,18 @@ module ts.formatting {
|
||||
}
|
||||
|
||||
var precedingToken = findPrecedingToken(originalRange.pos, sourceFile);
|
||||
// no preceding token found - start from the beginning of enclosing node
|
||||
return precedingToken ? precedingToken.end : enclosingNode.pos;
|
||||
if (!precedingToken) {
|
||||
// no preceding token found - start from the beginning of enclosing node
|
||||
return enclosingNode.pos;
|
||||
}
|
||||
|
||||
// preceding token ends after the start of original range (i.e when originaRange.pos falls in the middle of literal)
|
||||
// start from the beginning of enclosingNode to handle the entire 'originalRange'
|
||||
if (precedingToken.end >= originalRange.pos) {
|
||||
return enclosingNode.pos;
|
||||
}
|
||||
|
||||
return precedingToken.end;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -187,6 +187,9 @@ module ts.formatting {
|
||||
}
|
||||
|
||||
// consume trailing trivia
|
||||
if (trailingTrivia) {
|
||||
trailingTrivia = undefined;
|
||||
}
|
||||
while(scanner.getStartPos() < endPos) {
|
||||
currentToken = scanner.scan();
|
||||
if (!isTrivia(currentToken)) {
|
||||
|
||||
@@ -12,10 +12,15 @@ module ts.formatting {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// no indentation in string \regex literals
|
||||
if ((precedingToken.kind === SyntaxKind.StringLiteral || precedingToken.kind === SyntaxKind.RegularExpressionLiteral) &&
|
||||
precedingToken.getStart(sourceFile) <= position &&
|
||||
precedingToken.end > position) {
|
||||
// no indentation in string \regex\template literals
|
||||
var precedingTokenIsLiteral =
|
||||
precedingToken.kind === SyntaxKind.StringLiteral ||
|
||||
precedingToken.kind === SyntaxKind.RegularExpressionLiteral ||
|
||||
precedingToken.kind === SyntaxKind.NoSubstitutionTemplateLiteral ||
|
||||
precedingToken.kind === SyntaxKind.TemplateHead ||
|
||||
precedingToken.kind === SyntaxKind.TemplateMiddle ||
|
||||
precedingToken.kind === SyntaxKind.TemplateTail;
|
||||
if (precedingTokenIsLiteral && precedingToken.getStart(sourceFile) <= position && precedingToken.end > position) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
+56
-14
@@ -58,7 +58,7 @@ module ts {
|
||||
export interface SourceFile {
|
||||
version: string;
|
||||
scriptSnapshot: IScriptSnapshot;
|
||||
|
||||
nameTable: Map<string>;
|
||||
getNamedDeclarations(): Declaration[];
|
||||
}
|
||||
|
||||
@@ -750,6 +750,7 @@ module ts {
|
||||
public version: string;
|
||||
public languageVersion: ScriptTarget;
|
||||
public identifiers: Map<string>;
|
||||
public nameTable: Map<string>;
|
||||
|
||||
private namedDeclarations: Declaration[];
|
||||
|
||||
@@ -1537,6 +1538,8 @@ module ts {
|
||||
export function createLanguageServiceSourceFile(filename: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile {
|
||||
var sourceFile = createSourceFile(filename, scriptSnapshot.getText(0, scriptSnapshot.getLength()), scriptTarget, setNodeParents);
|
||||
setSourceFileFields(sourceFile, scriptSnapshot, version);
|
||||
// after full parsing we can use table with interned strings as name table
|
||||
sourceFile.nameTable = sourceFile.identifiers;
|
||||
return sourceFile;
|
||||
}
|
||||
|
||||
@@ -1568,6 +1571,9 @@ module ts {
|
||||
if (!disableIncrementalParsing) {
|
||||
var newSourceFile = sourceFile.update(scriptSnapshot.getText(0, scriptSnapshot.getLength()), textChangeRange);
|
||||
setSourceFileFields(newSourceFile, scriptSnapshot, version);
|
||||
// after incremental parsing nameTable might not be up-to-date
|
||||
// drop it so it can be lazily recreated later
|
||||
newSourceFile.nameTable = undefined;
|
||||
return newSourceFile;
|
||||
}
|
||||
}
|
||||
@@ -3207,7 +3213,7 @@ module ts {
|
||||
|
||||
if (node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.ThisKeyword || node.kind === SyntaxKind.SuperKeyword ||
|
||||
isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) {
|
||||
return getReferencesForNode(node, [sourceFile], /*findInStrings:*/ false, /*findInComments:*/ false);
|
||||
return getReferencesForNode(node, [sourceFile], /*searchOnlyInCurrentFile*/ true, /*findInStrings:*/ false, /*findInComments:*/ false);
|
||||
}
|
||||
|
||||
switch (node.kind) {
|
||||
@@ -3760,10 +3766,31 @@ module ts {
|
||||
}
|
||||
|
||||
Debug.assert(node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.NumericLiteral || node.kind === SyntaxKind.StringLiteral);
|
||||
return getReferencesForNode(node, program.getSourceFiles(), findInStrings, findInComments);
|
||||
return getReferencesForNode(node, program.getSourceFiles(), /*searchOnlyInCurrentFile*/ false, findInStrings, findInComments);
|
||||
}
|
||||
|
||||
function getReferencesForNode(node: Node, sourceFiles: SourceFile[], findInStrings: boolean, findInComments: boolean): ReferenceEntry[] {
|
||||
function initializeNameTable(sourceFile: SourceFile): void {
|
||||
var nameTable: Map<string> = {};
|
||||
|
||||
walk(sourceFile);
|
||||
sourceFile.nameTable = nameTable;
|
||||
|
||||
function walk(node: Node) {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.Identifier:
|
||||
nameTable[(<Identifier>node).text] = (<Identifier>node).text;
|
||||
break;
|
||||
case SyntaxKind.StringLiteral:
|
||||
case SyntaxKind.NumericLiteral:
|
||||
nameTable[(<LiteralExpression>node).text] = (<LiteralExpression>node).text;
|
||||
break;
|
||||
default:
|
||||
forEachChild(node, walk);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getReferencesForNode(node: Node, sourceFiles: SourceFile[], searchOnlyInCurrentFile: boolean, findInStrings: boolean, findInComments: boolean): ReferenceEntry[] {
|
||||
// Labels
|
||||
if (isLabelName(node)) {
|
||||
if (isJumpStatementTarget(node)) {
|
||||
@@ -3819,15 +3846,28 @@ module ts {
|
||||
getReferencesInNode(scope, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result);
|
||||
}
|
||||
else {
|
||||
var internedName = getInternedName(symbol, declarations)
|
||||
forEach(sourceFiles, sourceFile => {
|
||||
cancellationToken.throwIfCancellationRequested();
|
||||
if (searchOnlyInCurrentFile) {
|
||||
Debug.assert(sourceFiles.length === 1);
|
||||
result = [];
|
||||
getReferencesInNode(sourceFiles[0], symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result);
|
||||
}
|
||||
else {
|
||||
var internedName = getInternedName(symbol, declarations)
|
||||
forEach(sourceFiles, sourceFile => {
|
||||
cancellationToken.throwIfCancellationRequested();
|
||||
|
||||
if (lookUp(sourceFile.identifiers, internedName)) {
|
||||
result = result || [];
|
||||
getReferencesInNode(sourceFile, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result);
|
||||
}
|
||||
});
|
||||
if (!sourceFile.nameTable) {
|
||||
initializeNameTable(sourceFile)
|
||||
}
|
||||
|
||||
Debug.assert(sourceFile.nameTable !== undefined);
|
||||
|
||||
if (lookUp(sourceFile.nameTable, internedName)) {
|
||||
result = result || [];
|
||||
getReferencesInNode(sourceFile, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -4086,7 +4126,7 @@ module ts {
|
||||
}
|
||||
|
||||
function getReferencesForSuperKeyword(superKeyword: Node): ReferenceEntry[] {
|
||||
var searchSpaceNode = getSuperContainer(superKeyword);
|
||||
var searchSpaceNode = getSuperContainer(superKeyword, /*includeFunctions*/ false);
|
||||
if (!searchSpaceNode) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -4121,7 +4161,7 @@ module ts {
|
||||
return;
|
||||
}
|
||||
|
||||
var container = getSuperContainer(node);
|
||||
var container = getSuperContainer(node, /*includeFunctions*/ false);
|
||||
|
||||
// If we have a 'super' container, we must have an enclosing class.
|
||||
// Now make sure the owning class is the same as the search-space
|
||||
@@ -4163,6 +4203,8 @@ module ts {
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.FunctionExpression:
|
||||
break;
|
||||
// Computed properties in classes are not handled here because references to this are illegal,
|
||||
// so there is no point finding references to them.
|
||||
default:
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"noImplicitAny": true,
|
||||
"removeComments": true,
|
||||
"preserveConstEnums": true,
|
||||
"out": "../../built/local/typescriptServices.js",
|
||||
"sourceMap": true
|
||||
},
|
||||
"files": [
|
||||
"../compiler/core.ts",
|
||||
"../compiler/sys.ts",
|
||||
"../compiler/types.ts",
|
||||
"../compiler/scanner.ts",
|
||||
"../compiler/parser.ts",
|
||||
"../compiler/utilities.ts",
|
||||
"../compiler/binder.ts",
|
||||
"../compiler/checker.ts",
|
||||
"../compiler/emitter.ts",
|
||||
"../compiler/program.ts",
|
||||
"../compiler/commandLineParser.ts",
|
||||
"../compiler/diagnosticInformationMap.generated.ts",
|
||||
"breakpoints.ts",
|
||||
"navigationBar.ts",
|
||||
"outliningElementsCollector.ts",
|
||||
"services.ts",
|
||||
"shims.ts",
|
||||
"signatureHelp.ts",
|
||||
"utilities.ts",
|
||||
"formatting/formatting.ts",
|
||||
"formatting/formattingContext.ts",
|
||||
"formatting/formattingRequestKind.ts",
|
||||
"formatting/formattingScanner.ts",
|
||||
"formatting/references.ts",
|
||||
"formatting/rule.ts",
|
||||
"formatting/ruleAction.ts",
|
||||
"formatting/ruleDescriptor.ts",
|
||||
"formatting/ruleFlag.ts",
|
||||
"formatting/ruleOperation.ts",
|
||||
"formatting/ruleOperationContext.ts",
|
||||
"formatting/rules.ts",
|
||||
"formatting/rulesMap.ts",
|
||||
"formatting/rulesProvider.ts",
|
||||
"formatting/smartIndenter.ts",
|
||||
"formatting/tokenRange.ts"
|
||||
]
|
||||
}
|
||||
@@ -1,7 +1,13 @@
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration8_es6.ts(1,11): error TS9002: Computed property names are not currently supported.
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration8_es6.ts(1,11): error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration8_es6.ts(1,12): error TS2304: Cannot find name 'yield'.
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration8_es6.ts(1,20): error TS2304: Cannot find name 'foo'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration8_es6.ts (1 errors) ====
|
||||
==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration8_es6.ts (3 errors) ====
|
||||
var v = { [yield]: foo }
|
||||
~~~~~~~
|
||||
!!! error TS9002: Computed property names are not currently supported.
|
||||
!!! error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher.
|
||||
~~~~~
|
||||
!!! error TS2304: Cannot find name 'yield'.
|
||||
~~~
|
||||
!!! error TS2304: Cannot find name 'foo'.
|
||||
@@ -1,12 +1,15 @@
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts(1,10): error TS9001: Generators are not currently supported.
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts(2,13): error TS9002: Computed property names are not currently supported.
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts(2,13): error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts(2,14): error TS9000: 'yield' expressions are not currently supported.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts (2 errors) ====
|
||||
==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts (3 errors) ====
|
||||
function * foo() {
|
||||
~
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
var v = { [yield]: foo }
|
||||
~~~~~~~
|
||||
!!! error TS9002: Computed property names are not currently supported.
|
||||
!!! error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher.
|
||||
~~~~~
|
||||
!!! error TS9000: 'yield' expressions are not currently supported.
|
||||
}
|
||||
@@ -1,7 +1,13 @@
|
||||
tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts(1,12): error TS9002: Computed property names are not currently supported.
|
||||
tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts(1,11): error TS9001: Generators are not currently supported.
|
||||
tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts(1,12): error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts(1,13): error TS2304: Cannot find name 'foo'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts (1 errors) ====
|
||||
==== tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts (3 errors) ====
|
||||
var v = { *[foo()]() { } }
|
||||
~
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
~~~~~~~
|
||||
!!! error TS9002: Computed property names are not currently supported.
|
||||
!!! error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher.
|
||||
~~~
|
||||
!!! error TS2304: Cannot find name 'foo'.
|
||||
@@ -1,9 +1,12 @@
|
||||
tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration3_es6.ts(2,4): error TS9001: Generators are not currently supported.
|
||||
tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration3_es6.ts(2,6): error TS2304: Cannot find name 'foo'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration3_es6.ts (1 errors) ====
|
||||
==== tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration3_es6.ts (2 errors) ====
|
||||
class C {
|
||||
*[foo]() { }
|
||||
~
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
~~~
|
||||
!!! error TS2304: Cannot find name 'foo'.
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
//// [additionOperatorWithNumberAndEnum.ts]
|
||||
enum E { a, b }
|
||||
enum F { c, d }
|
||||
|
||||
var a: number;
|
||||
var b: E;
|
||||
var c: E | F;
|
||||
|
||||
var r1 = a + a;
|
||||
var r2 = a + b;
|
||||
@@ -12,7 +14,15 @@ var r4 = b + b;
|
||||
var r5 = 0 + a;
|
||||
var r6 = E.a + 0;
|
||||
var r7 = E.a + E.b;
|
||||
var r8 = E['a'] + E['b'];
|
||||
var r8 = E['a'] + E['b'];
|
||||
var r9 = E['a'] + F['c'];
|
||||
|
||||
var r10 = a + c;
|
||||
var r11 = c + a;
|
||||
var r12 = b + c;
|
||||
var r13 = c + b;
|
||||
var r14 = c + c;
|
||||
|
||||
|
||||
//// [additionOperatorWithNumberAndEnum.js]
|
||||
var E;
|
||||
@@ -20,8 +30,14 @@ var E;
|
||||
E[E["a"] = 0] = "a";
|
||||
E[E["b"] = 1] = "b";
|
||||
})(E || (E = {}));
|
||||
var F;
|
||||
(function (F) {
|
||||
F[F["c"] = 0] = "c";
|
||||
F[F["d"] = 1] = "d";
|
||||
})(F || (F = {}));
|
||||
var a;
|
||||
var b;
|
||||
var c;
|
||||
var r1 = a + a;
|
||||
var r2 = a + b;
|
||||
var r3 = b + a;
|
||||
@@ -30,3 +46,9 @@ var r5 = 0 + a;
|
||||
var r6 = 0 /* a */ + 0;
|
||||
var r7 = 0 /* a */ + 1 /* b */;
|
||||
var r8 = 0 /* 'a' */ + 1 /* 'b' */;
|
||||
var r9 = 0 /* 'a' */ + 0 /* 'c' */;
|
||||
var r10 = a + c;
|
||||
var r11 = c + a;
|
||||
var r12 = b + c;
|
||||
var r13 = c + b;
|
||||
var r14 = c + c;
|
||||
|
||||
@@ -4,6 +4,11 @@ enum E { a, b }
|
||||
>a : E
|
||||
>b : E
|
||||
|
||||
enum F { c, d }
|
||||
>F : F
|
||||
>c : F
|
||||
>d : F
|
||||
|
||||
var a: number;
|
||||
>a : number
|
||||
|
||||
@@ -11,6 +16,11 @@ var b: E;
|
||||
>b : E
|
||||
>E : E
|
||||
|
||||
var c: E | F;
|
||||
>c : E | F
|
||||
>E : E
|
||||
>F : F
|
||||
|
||||
var r1 = a + a;
|
||||
>r1 : number
|
||||
>a + a : number
|
||||
@@ -65,3 +75,41 @@ var r8 = E['a'] + E['b'];
|
||||
>E['b'] : E
|
||||
>E : typeof E
|
||||
|
||||
var r9 = E['a'] + F['c'];
|
||||
>r9 : number
|
||||
>E['a'] + F['c'] : number
|
||||
>E['a'] : E
|
||||
>E : typeof E
|
||||
>F['c'] : F
|
||||
>F : typeof F
|
||||
|
||||
var r10 = a + c;
|
||||
>r10 : number
|
||||
>a + c : number
|
||||
>a : number
|
||||
>c : E | F
|
||||
|
||||
var r11 = c + a;
|
||||
>r11 : number
|
||||
>c + a : number
|
||||
>c : E | F
|
||||
>a : number
|
||||
|
||||
var r12 = b + c;
|
||||
>r12 : number
|
||||
>b + c : number
|
||||
>b : E
|
||||
>c : E | F
|
||||
|
||||
var r13 = c + b;
|
||||
>r13 : number
|
||||
>c + b : number
|
||||
>c : E | F
|
||||
>b : E
|
||||
|
||||
var r14 = c + c;
|
||||
>r14 : number
|
||||
>c + c : number
|
||||
>c : E | F
|
||||
>c : E | F
|
||||
|
||||
|
||||
@@ -0,0 +1,301 @@
|
||||
//// [arithmeticOperatorWithEnumUnion.ts]
|
||||
// operands of an enum type are treated as having the primitive type Number.
|
||||
|
||||
enum E {
|
||||
a,
|
||||
b
|
||||
}
|
||||
enum F {
|
||||
c,
|
||||
d
|
||||
}
|
||||
|
||||
var a: any;
|
||||
var b: number;
|
||||
var c: E | F;
|
||||
|
||||
// operator *
|
||||
var ra1 = c * a;
|
||||
var ra2 = c * b;
|
||||
var ra3 = c * c;
|
||||
var ra4 = a * c;
|
||||
var ra5 = b * c;
|
||||
var ra6 = E.a * a;
|
||||
var ra7 = E.a * b;
|
||||
var ra8 = E.a * E.b;
|
||||
var ra9 = E.a * 1;
|
||||
var ra10 = a * E.b;
|
||||
var ra11 = b * E.b;
|
||||
var ra12 = 1 * E.b;
|
||||
|
||||
// operator /
|
||||
var rb1 = c / a;
|
||||
var rb2 = c / b;
|
||||
var rb3 = c / c;
|
||||
var rb4 = a / c;
|
||||
var rb5 = b / c;
|
||||
var rb6 = E.a / a;
|
||||
var rb7 = E.a / b;
|
||||
var rb8 = E.a / E.b;
|
||||
var rb9 = E.a / 1;
|
||||
var rb10 = a / E.b;
|
||||
var rb11 = b / E.b;
|
||||
var rb12 = 1 / E.b;
|
||||
|
||||
// operator %
|
||||
var rc1 = c % a;
|
||||
var rc2 = c % b;
|
||||
var rc3 = c % c;
|
||||
var rc4 = a % c;
|
||||
var rc5 = b % c;
|
||||
var rc6 = E.a % a;
|
||||
var rc7 = E.a % b;
|
||||
var rc8 = E.a % E.b;
|
||||
var rc9 = E.a % 1;
|
||||
var rc10 = a % E.b;
|
||||
var rc11 = b % E.b;
|
||||
var rc12 = 1 % E.b;
|
||||
|
||||
// operator -
|
||||
var rd1 = c - a;
|
||||
var rd2 = c - b;
|
||||
var rd3 = c - c;
|
||||
var rd4 = a - c;
|
||||
var rd5 = b - c;
|
||||
var rd6 = E.a - a;
|
||||
var rd7 = E.a - b;
|
||||
var rd8 = E.a - E.b;
|
||||
var rd9 = E.a - 1;
|
||||
var rd10 = a - E.b;
|
||||
var rd11 = b - E.b;
|
||||
var rd12 = 1 - E.b;
|
||||
|
||||
// operator <<
|
||||
var re1 = c << a;
|
||||
var re2 = c << b;
|
||||
var re3 = c << c;
|
||||
var re4 = a << c;
|
||||
var re5 = b << c;
|
||||
var re6 = E.a << a;
|
||||
var re7 = E.a << b;
|
||||
var re8 = E.a << E.b;
|
||||
var re9 = E.a << 1;
|
||||
var re10 = a << E.b;
|
||||
var re11 = b << E.b;
|
||||
var re12 = 1 << E.b;
|
||||
|
||||
// operator >>
|
||||
var rf1 = c >> a;
|
||||
var rf2 = c >> b;
|
||||
var rf3 = c >> c;
|
||||
var rf4 = a >> c;
|
||||
var rf5 = b >> c;
|
||||
var rf6 = E.a >> a;
|
||||
var rf7 = E.a >> b;
|
||||
var rf8 = E.a >> E.b;
|
||||
var rf9 = E.a >> 1;
|
||||
var rf10 = a >> E.b;
|
||||
var rf11 = b >> E.b;
|
||||
var rf12 = 1 >> E.b;
|
||||
|
||||
// operator >>>
|
||||
var rg1 = c >>> a;
|
||||
var rg2 = c >>> b;
|
||||
var rg3 = c >>> c;
|
||||
var rg4 = a >>> c;
|
||||
var rg5 = b >>> c;
|
||||
var rg6 = E.a >>> a;
|
||||
var rg7 = E.a >>> b;
|
||||
var rg8 = E.a >>> E.b;
|
||||
var rg9 = E.a >>> 1;
|
||||
var rg10 = a >>> E.b;
|
||||
var rg11 = b >>> E.b;
|
||||
var rg12 = 1 >>> E.b;
|
||||
|
||||
// operator &
|
||||
var rh1 = c & a;
|
||||
var rh2 = c & b;
|
||||
var rh3 = c & c;
|
||||
var rh4 = a & c;
|
||||
var rh5 = b & c;
|
||||
var rh6 = E.a & a;
|
||||
var rh7 = E.a & b;
|
||||
var rh8 = E.a & E.b;
|
||||
var rh9 = E.a & 1;
|
||||
var rh10 = a & E.b;
|
||||
var rh11 = b & E.b;
|
||||
var rh12 = 1 & E.b;
|
||||
|
||||
// operator ^
|
||||
var ri1 = c ^ a;
|
||||
var ri2 = c ^ b;
|
||||
var ri3 = c ^ c;
|
||||
var ri4 = a ^ c;
|
||||
var ri5 = b ^ c;
|
||||
var ri6 = E.a ^ a;
|
||||
var ri7 = E.a ^ b;
|
||||
var ri8 = E.a ^ E.b;
|
||||
var ri9 = E.a ^ 1;
|
||||
var ri10 = a ^ E.b;
|
||||
var ri11 = b ^ E.b;
|
||||
var ri12 = 1 ^ E.b;
|
||||
|
||||
// operator |
|
||||
var rj1 = c | a;
|
||||
var rj2 = c | b;
|
||||
var rj3 = c | c;
|
||||
var rj4 = a | c;
|
||||
var rj5 = b | c;
|
||||
var rj6 = E.a | a;
|
||||
var rj7 = E.a | b;
|
||||
var rj8 = E.a | E.b;
|
||||
var rj9 = E.a | 1;
|
||||
var rj10 = a | E.b;
|
||||
var rj11 = b | E.b;
|
||||
var rj12 = 1 | E.b;
|
||||
|
||||
//// [arithmeticOperatorWithEnumUnion.js]
|
||||
// operands of an enum type are treated as having the primitive type Number.
|
||||
var E;
|
||||
(function (E) {
|
||||
E[E["a"] = 0] = "a";
|
||||
E[E["b"] = 1] = "b";
|
||||
})(E || (E = {}));
|
||||
var F;
|
||||
(function (F) {
|
||||
F[F["c"] = 0] = "c";
|
||||
F[F["d"] = 1] = "d";
|
||||
})(F || (F = {}));
|
||||
var a;
|
||||
var b;
|
||||
var c;
|
||||
// operator *
|
||||
var ra1 = c * a;
|
||||
var ra2 = c * b;
|
||||
var ra3 = c * c;
|
||||
var ra4 = a * c;
|
||||
var ra5 = b * c;
|
||||
var ra6 = 0 /* a */ * a;
|
||||
var ra7 = 0 /* a */ * b;
|
||||
var ra8 = 0 /* a */ * 1 /* b */;
|
||||
var ra9 = 0 /* a */ * 1;
|
||||
var ra10 = a * 1 /* b */;
|
||||
var ra11 = b * 1 /* b */;
|
||||
var ra12 = 1 * 1 /* b */;
|
||||
// operator /
|
||||
var rb1 = c / a;
|
||||
var rb2 = c / b;
|
||||
var rb3 = c / c;
|
||||
var rb4 = a / c;
|
||||
var rb5 = b / c;
|
||||
var rb6 = 0 /* a */ / a;
|
||||
var rb7 = 0 /* a */ / b;
|
||||
var rb8 = 0 /* a */ / 1 /* b */;
|
||||
var rb9 = 0 /* a */ / 1;
|
||||
var rb10 = a / 1 /* b */;
|
||||
var rb11 = b / 1 /* b */;
|
||||
var rb12 = 1 / 1 /* b */;
|
||||
// operator %
|
||||
var rc1 = c % a;
|
||||
var rc2 = c % b;
|
||||
var rc3 = c % c;
|
||||
var rc4 = a % c;
|
||||
var rc5 = b % c;
|
||||
var rc6 = 0 /* a */ % a;
|
||||
var rc7 = 0 /* a */ % b;
|
||||
var rc8 = 0 /* a */ % 1 /* b */;
|
||||
var rc9 = 0 /* a */ % 1;
|
||||
var rc10 = a % 1 /* b */;
|
||||
var rc11 = b % 1 /* b */;
|
||||
var rc12 = 1 % 1 /* b */;
|
||||
// operator -
|
||||
var rd1 = c - a;
|
||||
var rd2 = c - b;
|
||||
var rd3 = c - c;
|
||||
var rd4 = a - c;
|
||||
var rd5 = b - c;
|
||||
var rd6 = 0 /* a */ - a;
|
||||
var rd7 = 0 /* a */ - b;
|
||||
var rd8 = 0 /* a */ - 1 /* b */;
|
||||
var rd9 = 0 /* a */ - 1;
|
||||
var rd10 = a - 1 /* b */;
|
||||
var rd11 = b - 1 /* b */;
|
||||
var rd12 = 1 - 1 /* b */;
|
||||
// operator <<
|
||||
var re1 = c << a;
|
||||
var re2 = c << b;
|
||||
var re3 = c << c;
|
||||
var re4 = a << c;
|
||||
var re5 = b << c;
|
||||
var re6 = 0 /* a */ << a;
|
||||
var re7 = 0 /* a */ << b;
|
||||
var re8 = 0 /* a */ << 1 /* b */;
|
||||
var re9 = 0 /* a */ << 1;
|
||||
var re10 = a << 1 /* b */;
|
||||
var re11 = b << 1 /* b */;
|
||||
var re12 = 1 << 1 /* b */;
|
||||
// operator >>
|
||||
var rf1 = c >> a;
|
||||
var rf2 = c >> b;
|
||||
var rf3 = c >> c;
|
||||
var rf4 = a >> c;
|
||||
var rf5 = b >> c;
|
||||
var rf6 = 0 /* a */ >> a;
|
||||
var rf7 = 0 /* a */ >> b;
|
||||
var rf8 = 0 /* a */ >> 1 /* b */;
|
||||
var rf9 = 0 /* a */ >> 1;
|
||||
var rf10 = a >> 1 /* b */;
|
||||
var rf11 = b >> 1 /* b */;
|
||||
var rf12 = 1 >> 1 /* b */;
|
||||
// operator >>>
|
||||
var rg1 = c >>> a;
|
||||
var rg2 = c >>> b;
|
||||
var rg3 = c >>> c;
|
||||
var rg4 = a >>> c;
|
||||
var rg5 = b >>> c;
|
||||
var rg6 = 0 /* a */ >>> a;
|
||||
var rg7 = 0 /* a */ >>> b;
|
||||
var rg8 = 0 /* a */ >>> 1 /* b */;
|
||||
var rg9 = 0 /* a */ >>> 1;
|
||||
var rg10 = a >>> 1 /* b */;
|
||||
var rg11 = b >>> 1 /* b */;
|
||||
var rg12 = 1 >>> 1 /* b */;
|
||||
// operator &
|
||||
var rh1 = c & a;
|
||||
var rh2 = c & b;
|
||||
var rh3 = c & c;
|
||||
var rh4 = a & c;
|
||||
var rh5 = b & c;
|
||||
var rh6 = 0 /* a */ & a;
|
||||
var rh7 = 0 /* a */ & b;
|
||||
var rh8 = 0 /* a */ & 1 /* b */;
|
||||
var rh9 = 0 /* a */ & 1;
|
||||
var rh10 = a & 1 /* b */;
|
||||
var rh11 = b & 1 /* b */;
|
||||
var rh12 = 1 & 1 /* b */;
|
||||
// operator ^
|
||||
var ri1 = c ^ a;
|
||||
var ri2 = c ^ b;
|
||||
var ri3 = c ^ c;
|
||||
var ri4 = a ^ c;
|
||||
var ri5 = b ^ c;
|
||||
var ri6 = 0 /* a */ ^ a;
|
||||
var ri7 = 0 /* a */ ^ b;
|
||||
var ri8 = 0 /* a */ ^ 1 /* b */;
|
||||
var ri9 = 0 /* a */ ^ 1;
|
||||
var ri10 = a ^ 1 /* b */;
|
||||
var ri11 = b ^ 1 /* b */;
|
||||
var ri12 = 1 ^ 1 /* b */;
|
||||
// operator |
|
||||
var rj1 = c | a;
|
||||
var rj2 = c | b;
|
||||
var rj3 = c | c;
|
||||
var rj4 = a | c;
|
||||
var rj5 = b | c;
|
||||
var rj6 = 0 /* a */ | a;
|
||||
var rj7 = 0 /* a */ | b;
|
||||
var rj8 = 0 /* a */ | 1 /* b */;
|
||||
var rj9 = 0 /* a */ | 1;
|
||||
var rj10 = a | 1 /* b */;
|
||||
var rj11 = b | 1 /* b */;
|
||||
var rj12 = 1 | 1 /* b */;
|
||||
@@ -0,0 +1,903 @@
|
||||
=== tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithEnumUnion.ts ===
|
||||
// operands of an enum type are treated as having the primitive type Number.
|
||||
|
||||
enum E {
|
||||
>E : E
|
||||
|
||||
a,
|
||||
>a : E
|
||||
|
||||
b
|
||||
>b : E
|
||||
}
|
||||
enum F {
|
||||
>F : F
|
||||
|
||||
c,
|
||||
>c : F
|
||||
|
||||
d
|
||||
>d : F
|
||||
}
|
||||
|
||||
var a: any;
|
||||
>a : any
|
||||
|
||||
var b: number;
|
||||
>b : number
|
||||
|
||||
var c: E | F;
|
||||
>c : E | F
|
||||
>E : E
|
||||
>F : F
|
||||
|
||||
// operator *
|
||||
var ra1 = c * a;
|
||||
>ra1 : number
|
||||
>c * a : number
|
||||
>c : E | F
|
||||
>a : any
|
||||
|
||||
var ra2 = c * b;
|
||||
>ra2 : number
|
||||
>c * b : number
|
||||
>c : E | F
|
||||
>b : number
|
||||
|
||||
var ra3 = c * c;
|
||||
>ra3 : number
|
||||
>c * c : number
|
||||
>c : E | F
|
||||
>c : E | F
|
||||
|
||||
var ra4 = a * c;
|
||||
>ra4 : number
|
||||
>a * c : number
|
||||
>a : any
|
||||
>c : E | F
|
||||
|
||||
var ra5 = b * c;
|
||||
>ra5 : number
|
||||
>b * c : number
|
||||
>b : number
|
||||
>c : E | F
|
||||
|
||||
var ra6 = E.a * a;
|
||||
>ra6 : number
|
||||
>E.a * a : number
|
||||
>E.a : E
|
||||
>E : typeof E
|
||||
>a : E
|
||||
>a : any
|
||||
|
||||
var ra7 = E.a * b;
|
||||
>ra7 : number
|
||||
>E.a * b : number
|
||||
>E.a : E
|
||||
>E : typeof E
|
||||
>a : E
|
||||
>b : number
|
||||
|
||||
var ra8 = E.a * E.b;
|
||||
>ra8 : number
|
||||
>E.a * E.b : number
|
||||
>E.a : E
|
||||
>E : typeof E
|
||||
>a : E
|
||||
>E.b : E
|
||||
>E : typeof E
|
||||
>b : E
|
||||
|
||||
var ra9 = E.a * 1;
|
||||
>ra9 : number
|
||||
>E.a * 1 : number
|
||||
>E.a : E
|
||||
>E : typeof E
|
||||
>a : E
|
||||
|
||||
var ra10 = a * E.b;
|
||||
>ra10 : number
|
||||
>a * E.b : number
|
||||
>a : any
|
||||
>E.b : E
|
||||
>E : typeof E
|
||||
>b : E
|
||||
|
||||
var ra11 = b * E.b;
|
||||
>ra11 : number
|
||||
>b * E.b : number
|
||||
>b : number
|
||||
>E.b : E
|
||||
>E : typeof E
|
||||
>b : E
|
||||
|
||||
var ra12 = 1 * E.b;
|
||||
>ra12 : number
|
||||
>1 * E.b : number
|
||||
>E.b : E
|
||||
>E : typeof E
|
||||
>b : E
|
||||
|
||||
// operator /
|
||||
var rb1 = c / a;
|
||||
>rb1 : number
|
||||
>c / a : number
|
||||
>c : E | F
|
||||
>a : any
|
||||
|
||||
var rb2 = c / b;
|
||||
>rb2 : number
|
||||
>c / b : number
|
||||
>c : E | F
|
||||
>b : number
|
||||
|
||||
var rb3 = c / c;
|
||||
>rb3 : number
|
||||
>c / c : number
|
||||
>c : E | F
|
||||
>c : E | F
|
||||
|
||||
var rb4 = a / c;
|
||||
>rb4 : number
|
||||
>a / c : number
|
||||
>a : any
|
||||
>c : E | F
|
||||
|
||||
var rb5 = b / c;
|
||||
>rb5 : number
|
||||
>b / c : number
|
||||
>b : number
|
||||
>c : E | F
|
||||
|
||||
var rb6 = E.a / a;
|
||||
>rb6 : number
|
||||
>E.a / a : number
|
||||
>E.a : E
|
||||
>E : typeof E
|
||||
>a : E
|
||||
>a : any
|
||||
|
||||
var rb7 = E.a / b;
|
||||
>rb7 : number
|
||||
>E.a / b : number
|
||||
>E.a : E
|
||||
>E : typeof E
|
||||
>a : E
|
||||
>b : number
|
||||
|
||||
var rb8 = E.a / E.b;
|
||||
>rb8 : number
|
||||
>E.a / E.b : number
|
||||
>E.a : E
|
||||
>E : typeof E
|
||||
>a : E
|
||||
>E.b : E
|
||||
>E : typeof E
|
||||
>b : E
|
||||
|
||||
var rb9 = E.a / 1;
|
||||
>rb9 : number
|
||||
>E.a / 1 : number
|
||||
>E.a : E
|
||||
>E : typeof E
|
||||
>a : E
|
||||
|
||||
var rb10 = a / E.b;
|
||||
>rb10 : number
|
||||
>a / E.b : number
|
||||
>a : any
|
||||
>E.b : E
|
||||
>E : typeof E
|
||||
>b : E
|
||||
|
||||
var rb11 = b / E.b;
|
||||
>rb11 : number
|
||||
>b / E.b : number
|
||||
>b : number
|
||||
>E.b : E
|
||||
>E : typeof E
|
||||
>b : E
|
||||
|
||||
var rb12 = 1 / E.b;
|
||||
>rb12 : number
|
||||
>1 / E.b : number
|
||||
>E.b : E
|
||||
>E : typeof E
|
||||
>b : E
|
||||
|
||||
// operator %
|
||||
var rc1 = c % a;
|
||||
>rc1 : number
|
||||
>c % a : number
|
||||
>c : E | F
|
||||
>a : any
|
||||
|
||||
var rc2 = c % b;
|
||||
>rc2 : number
|
||||
>c % b : number
|
||||
>c : E | F
|
||||
>b : number
|
||||
|
||||
var rc3 = c % c;
|
||||
>rc3 : number
|
||||
>c % c : number
|
||||
>c : E | F
|
||||
>c : E | F
|
||||
|
||||
var rc4 = a % c;
|
||||
>rc4 : number
|
||||
>a % c : number
|
||||
>a : any
|
||||
>c : E | F
|
||||
|
||||
var rc5 = b % c;
|
||||
>rc5 : number
|
||||
>b % c : number
|
||||
>b : number
|
||||
>c : E | F
|
||||
|
||||
var rc6 = E.a % a;
|
||||
>rc6 : number
|
||||
>E.a % a : number
|
||||
>E.a : E
|
||||
>E : typeof E
|
||||
>a : E
|
||||
>a : any
|
||||
|
||||
var rc7 = E.a % b;
|
||||
>rc7 : number
|
||||
>E.a % b : number
|
||||
>E.a : E
|
||||
>E : typeof E
|
||||
>a : E
|
||||
>b : number
|
||||
|
||||
var rc8 = E.a % E.b;
|
||||
>rc8 : number
|
||||
>E.a % E.b : number
|
||||
>E.a : E
|
||||
>E : typeof E
|
||||
>a : E
|
||||
>E.b : E
|
||||
>E : typeof E
|
||||
>b : E
|
||||
|
||||
var rc9 = E.a % 1;
|
||||
>rc9 : number
|
||||
>E.a % 1 : number
|
||||
>E.a : E
|
||||
>E : typeof E
|
||||
>a : E
|
||||
|
||||
var rc10 = a % E.b;
|
||||
>rc10 : number
|
||||
>a % E.b : number
|
||||
>a : any
|
||||
>E.b : E
|
||||
>E : typeof E
|
||||
>b : E
|
||||
|
||||
var rc11 = b % E.b;
|
||||
>rc11 : number
|
||||
>b % E.b : number
|
||||
>b : number
|
||||
>E.b : E
|
||||
>E : typeof E
|
||||
>b : E
|
||||
|
||||
var rc12 = 1 % E.b;
|
||||
>rc12 : number
|
||||
>1 % E.b : number
|
||||
>E.b : E
|
||||
>E : typeof E
|
||||
>b : E
|
||||
|
||||
// operator -
|
||||
var rd1 = c - a;
|
||||
>rd1 : number
|
||||
>c - a : number
|
||||
>c : E | F
|
||||
>a : any
|
||||
|
||||
var rd2 = c - b;
|
||||
>rd2 : number
|
||||
>c - b : number
|
||||
>c : E | F
|
||||
>b : number
|
||||
|
||||
var rd3 = c - c;
|
||||
>rd3 : number
|
||||
>c - c : number
|
||||
>c : E | F
|
||||
>c : E | F
|
||||
|
||||
var rd4 = a - c;
|
||||
>rd4 : number
|
||||
>a - c : number
|
||||
>a : any
|
||||
>c : E | F
|
||||
|
||||
var rd5 = b - c;
|
||||
>rd5 : number
|
||||
>b - c : number
|
||||
>b : number
|
||||
>c : E | F
|
||||
|
||||
var rd6 = E.a - a;
|
||||
>rd6 : number
|
||||
>E.a - a : number
|
||||
>E.a : E
|
||||
>E : typeof E
|
||||
>a : E
|
||||
>a : any
|
||||
|
||||
var rd7 = E.a - b;
|
||||
>rd7 : number
|
||||
>E.a - b : number
|
||||
>E.a : E
|
||||
>E : typeof E
|
||||
>a : E
|
||||
>b : number
|
||||
|
||||
var rd8 = E.a - E.b;
|
||||
>rd8 : number
|
||||
>E.a - E.b : number
|
||||
>E.a : E
|
||||
>E : typeof E
|
||||
>a : E
|
||||
>E.b : E
|
||||
>E : typeof E
|
||||
>b : E
|
||||
|
||||
var rd9 = E.a - 1;
|
||||
>rd9 : number
|
||||
>E.a - 1 : number
|
||||
>E.a : E
|
||||
>E : typeof E
|
||||
>a : E
|
||||
|
||||
var rd10 = a - E.b;
|
||||
>rd10 : number
|
||||
>a - E.b : number
|
||||
>a : any
|
||||
>E.b : E
|
||||
>E : typeof E
|
||||
>b : E
|
||||
|
||||
var rd11 = b - E.b;
|
||||
>rd11 : number
|
||||
>b - E.b : number
|
||||
>b : number
|
||||
>E.b : E
|
||||
>E : typeof E
|
||||
>b : E
|
||||
|
||||
var rd12 = 1 - E.b;
|
||||
>rd12 : number
|
||||
>1 - E.b : number
|
||||
>E.b : E
|
||||
>E : typeof E
|
||||
>b : E
|
||||
|
||||
// operator <<
|
||||
var re1 = c << a;
|
||||
>re1 : number
|
||||
>c << a : number
|
||||
>c : E | F
|
||||
>a : any
|
||||
|
||||
var re2 = c << b;
|
||||
>re2 : number
|
||||
>c << b : number
|
||||
>c : E | F
|
||||
>b : number
|
||||
|
||||
var re3 = c << c;
|
||||
>re3 : number
|
||||
>c << c : number
|
||||
>c : E | F
|
||||
>c : E | F
|
||||
|
||||
var re4 = a << c;
|
||||
>re4 : number
|
||||
>a << c : number
|
||||
>a : any
|
||||
>c : E | F
|
||||
|
||||
var re5 = b << c;
|
||||
>re5 : number
|
||||
>b << c : number
|
||||
>b : number
|
||||
>c : E | F
|
||||
|
||||
var re6 = E.a << a;
|
||||
>re6 : number
|
||||
>E.a << a : number
|
||||
>E.a : E
|
||||
>E : typeof E
|
||||
>a : E
|
||||
>a : any
|
||||
|
||||
var re7 = E.a << b;
|
||||
>re7 : number
|
||||
>E.a << b : number
|
||||
>E.a : E
|
||||
>E : typeof E
|
||||
>a : E
|
||||
>b : number
|
||||
|
||||
var re8 = E.a << E.b;
|
||||
>re8 : number
|
||||
>E.a << E.b : number
|
||||
>E.a : E
|
||||
>E : typeof E
|
||||
>a : E
|
||||
>E.b : E
|
||||
>E : typeof E
|
||||
>b : E
|
||||
|
||||
var re9 = E.a << 1;
|
||||
>re9 : number
|
||||
>E.a << 1 : number
|
||||
>E.a : E
|
||||
>E : typeof E
|
||||
>a : E
|
||||
|
||||
var re10 = a << E.b;
|
||||
>re10 : number
|
||||
>a << E.b : number
|
||||
>a : any
|
||||
>E.b : E
|
||||
>E : typeof E
|
||||
>b : E
|
||||
|
||||
var re11 = b << E.b;
|
||||
>re11 : number
|
||||
>b << E.b : number
|
||||
>b : number
|
||||
>E.b : E
|
||||
>E : typeof E
|
||||
>b : E
|
||||
|
||||
var re12 = 1 << E.b;
|
||||
>re12 : number
|
||||
>1 << E.b : number
|
||||
>E.b : E
|
||||
>E : typeof E
|
||||
>b : E
|
||||
|
||||
// operator >>
|
||||
var rf1 = c >> a;
|
||||
>rf1 : number
|
||||
>c >> a : number
|
||||
>c : E | F
|
||||
>a : any
|
||||
|
||||
var rf2 = c >> b;
|
||||
>rf2 : number
|
||||
>c >> b : number
|
||||
>c : E | F
|
||||
>b : number
|
||||
|
||||
var rf3 = c >> c;
|
||||
>rf3 : number
|
||||
>c >> c : number
|
||||
>c : E | F
|
||||
>c : E | F
|
||||
|
||||
var rf4 = a >> c;
|
||||
>rf4 : number
|
||||
>a >> c : number
|
||||
>a : any
|
||||
>c : E | F
|
||||
|
||||
var rf5 = b >> c;
|
||||
>rf5 : number
|
||||
>b >> c : number
|
||||
>b : number
|
||||
>c : E | F
|
||||
|
||||
var rf6 = E.a >> a;
|
||||
>rf6 : number
|
||||
>E.a >> a : number
|
||||
>E.a : E
|
||||
>E : typeof E
|
||||
>a : E
|
||||
>a : any
|
||||
|
||||
var rf7 = E.a >> b;
|
||||
>rf7 : number
|
||||
>E.a >> b : number
|
||||
>E.a : E
|
||||
>E : typeof E
|
||||
>a : E
|
||||
>b : number
|
||||
|
||||
var rf8 = E.a >> E.b;
|
||||
>rf8 : number
|
||||
>E.a >> E.b : number
|
||||
>E.a : E
|
||||
>E : typeof E
|
||||
>a : E
|
||||
>E.b : E
|
||||
>E : typeof E
|
||||
>b : E
|
||||
|
||||
var rf9 = E.a >> 1;
|
||||
>rf9 : number
|
||||
>E.a >> 1 : number
|
||||
>E.a : E
|
||||
>E : typeof E
|
||||
>a : E
|
||||
|
||||
var rf10 = a >> E.b;
|
||||
>rf10 : number
|
||||
>a >> E.b : number
|
||||
>a : any
|
||||
>E.b : E
|
||||
>E : typeof E
|
||||
>b : E
|
||||
|
||||
var rf11 = b >> E.b;
|
||||
>rf11 : number
|
||||
>b >> E.b : number
|
||||
>b : number
|
||||
>E.b : E
|
||||
>E : typeof E
|
||||
>b : E
|
||||
|
||||
var rf12 = 1 >> E.b;
|
||||
>rf12 : number
|
||||
>1 >> E.b : number
|
||||
>E.b : E
|
||||
>E : typeof E
|
||||
>b : E
|
||||
|
||||
// operator >>>
|
||||
var rg1 = c >>> a;
|
||||
>rg1 : number
|
||||
>c >>> a : number
|
||||
>c : E | F
|
||||
>a : any
|
||||
|
||||
var rg2 = c >>> b;
|
||||
>rg2 : number
|
||||
>c >>> b : number
|
||||
>c : E | F
|
||||
>b : number
|
||||
|
||||
var rg3 = c >>> c;
|
||||
>rg3 : number
|
||||
>c >>> c : number
|
||||
>c : E | F
|
||||
>c : E | F
|
||||
|
||||
var rg4 = a >>> c;
|
||||
>rg4 : number
|
||||
>a >>> c : number
|
||||
>a : any
|
||||
>c : E | F
|
||||
|
||||
var rg5 = b >>> c;
|
||||
>rg5 : number
|
||||
>b >>> c : number
|
||||
>b : number
|
||||
>c : E | F
|
||||
|
||||
var rg6 = E.a >>> a;
|
||||
>rg6 : number
|
||||
>E.a >>> a : number
|
||||
>E.a : E
|
||||
>E : typeof E
|
||||
>a : E
|
||||
>a : any
|
||||
|
||||
var rg7 = E.a >>> b;
|
||||
>rg7 : number
|
||||
>E.a >>> b : number
|
||||
>E.a : E
|
||||
>E : typeof E
|
||||
>a : E
|
||||
>b : number
|
||||
|
||||
var rg8 = E.a >>> E.b;
|
||||
>rg8 : number
|
||||
>E.a >>> E.b : number
|
||||
>E.a : E
|
||||
>E : typeof E
|
||||
>a : E
|
||||
>E.b : E
|
||||
>E : typeof E
|
||||
>b : E
|
||||
|
||||
var rg9 = E.a >>> 1;
|
||||
>rg9 : number
|
||||
>E.a >>> 1 : number
|
||||
>E.a : E
|
||||
>E : typeof E
|
||||
>a : E
|
||||
|
||||
var rg10 = a >>> E.b;
|
||||
>rg10 : number
|
||||
>a >>> E.b : number
|
||||
>a : any
|
||||
>E.b : E
|
||||
>E : typeof E
|
||||
>b : E
|
||||
|
||||
var rg11 = b >>> E.b;
|
||||
>rg11 : number
|
||||
>b >>> E.b : number
|
||||
>b : number
|
||||
>E.b : E
|
||||
>E : typeof E
|
||||
>b : E
|
||||
|
||||
var rg12 = 1 >>> E.b;
|
||||
>rg12 : number
|
||||
>1 >>> E.b : number
|
||||
>E.b : E
|
||||
>E : typeof E
|
||||
>b : E
|
||||
|
||||
// operator &
|
||||
var rh1 = c & a;
|
||||
>rh1 : number
|
||||
>c & a : number
|
||||
>c : E | F
|
||||
>a : any
|
||||
|
||||
var rh2 = c & b;
|
||||
>rh2 : number
|
||||
>c & b : number
|
||||
>c : E | F
|
||||
>b : number
|
||||
|
||||
var rh3 = c & c;
|
||||
>rh3 : number
|
||||
>c & c : number
|
||||
>c : E | F
|
||||
>c : E | F
|
||||
|
||||
var rh4 = a & c;
|
||||
>rh4 : number
|
||||
>a & c : number
|
||||
>a : any
|
||||
>c : E | F
|
||||
|
||||
var rh5 = b & c;
|
||||
>rh5 : number
|
||||
>b & c : number
|
||||
>b : number
|
||||
>c : E | F
|
||||
|
||||
var rh6 = E.a & a;
|
||||
>rh6 : number
|
||||
>E.a & a : number
|
||||
>E.a : E
|
||||
>E : typeof E
|
||||
>a : E
|
||||
>a : any
|
||||
|
||||
var rh7 = E.a & b;
|
||||
>rh7 : number
|
||||
>E.a & b : number
|
||||
>E.a : E
|
||||
>E : typeof E
|
||||
>a : E
|
||||
>b : number
|
||||
|
||||
var rh8 = E.a & E.b;
|
||||
>rh8 : number
|
||||
>E.a & E.b : number
|
||||
>E.a : E
|
||||
>E : typeof E
|
||||
>a : E
|
||||
>E.b : E
|
||||
>E : typeof E
|
||||
>b : E
|
||||
|
||||
var rh9 = E.a & 1;
|
||||
>rh9 : number
|
||||
>E.a & 1 : number
|
||||
>E.a : E
|
||||
>E : typeof E
|
||||
>a : E
|
||||
|
||||
var rh10 = a & E.b;
|
||||
>rh10 : number
|
||||
>a & E.b : number
|
||||
>a : any
|
||||
>E.b : E
|
||||
>E : typeof E
|
||||
>b : E
|
||||
|
||||
var rh11 = b & E.b;
|
||||
>rh11 : number
|
||||
>b & E.b : number
|
||||
>b : number
|
||||
>E.b : E
|
||||
>E : typeof E
|
||||
>b : E
|
||||
|
||||
var rh12 = 1 & E.b;
|
||||
>rh12 : number
|
||||
>1 & E.b : number
|
||||
>E.b : E
|
||||
>E : typeof E
|
||||
>b : E
|
||||
|
||||
// operator ^
|
||||
var ri1 = c ^ a;
|
||||
>ri1 : number
|
||||
>c ^ a : number
|
||||
>c : E | F
|
||||
>a : any
|
||||
|
||||
var ri2 = c ^ b;
|
||||
>ri2 : number
|
||||
>c ^ b : number
|
||||
>c : E | F
|
||||
>b : number
|
||||
|
||||
var ri3 = c ^ c;
|
||||
>ri3 : number
|
||||
>c ^ c : number
|
||||
>c : E | F
|
||||
>c : E | F
|
||||
|
||||
var ri4 = a ^ c;
|
||||
>ri4 : number
|
||||
>a ^ c : number
|
||||
>a : any
|
||||
>c : E | F
|
||||
|
||||
var ri5 = b ^ c;
|
||||
>ri5 : number
|
||||
>b ^ c : number
|
||||
>b : number
|
||||
>c : E | F
|
||||
|
||||
var ri6 = E.a ^ a;
|
||||
>ri6 : number
|
||||
>E.a ^ a : number
|
||||
>E.a : E
|
||||
>E : typeof E
|
||||
>a : E
|
||||
>a : any
|
||||
|
||||
var ri7 = E.a ^ b;
|
||||
>ri7 : number
|
||||
>E.a ^ b : number
|
||||
>E.a : E
|
||||
>E : typeof E
|
||||
>a : E
|
||||
>b : number
|
||||
|
||||
var ri8 = E.a ^ E.b;
|
||||
>ri8 : number
|
||||
>E.a ^ E.b : number
|
||||
>E.a : E
|
||||
>E : typeof E
|
||||
>a : E
|
||||
>E.b : E
|
||||
>E : typeof E
|
||||
>b : E
|
||||
|
||||
var ri9 = E.a ^ 1;
|
||||
>ri9 : number
|
||||
>E.a ^ 1 : number
|
||||
>E.a : E
|
||||
>E : typeof E
|
||||
>a : E
|
||||
|
||||
var ri10 = a ^ E.b;
|
||||
>ri10 : number
|
||||
>a ^ E.b : number
|
||||
>a : any
|
||||
>E.b : E
|
||||
>E : typeof E
|
||||
>b : E
|
||||
|
||||
var ri11 = b ^ E.b;
|
||||
>ri11 : number
|
||||
>b ^ E.b : number
|
||||
>b : number
|
||||
>E.b : E
|
||||
>E : typeof E
|
||||
>b : E
|
||||
|
||||
var ri12 = 1 ^ E.b;
|
||||
>ri12 : number
|
||||
>1 ^ E.b : number
|
||||
>E.b : E
|
||||
>E : typeof E
|
||||
>b : E
|
||||
|
||||
// operator |
|
||||
var rj1 = c | a;
|
||||
>rj1 : number
|
||||
>c | a : number
|
||||
>c : E | F
|
||||
>a : any
|
||||
|
||||
var rj2 = c | b;
|
||||
>rj2 : number
|
||||
>c | b : number
|
||||
>c : E | F
|
||||
>b : number
|
||||
|
||||
var rj3 = c | c;
|
||||
>rj3 : number
|
||||
>c | c : number
|
||||
>c : E | F
|
||||
>c : E | F
|
||||
|
||||
var rj4 = a | c;
|
||||
>rj4 : number
|
||||
>a | c : number
|
||||
>a : any
|
||||
>c : E | F
|
||||
|
||||
var rj5 = b | c;
|
||||
>rj5 : number
|
||||
>b | c : number
|
||||
>b : number
|
||||
>c : E | F
|
||||
|
||||
var rj6 = E.a | a;
|
||||
>rj6 : number
|
||||
>E.a | a : number
|
||||
>E.a : E
|
||||
>E : typeof E
|
||||
>a : E
|
||||
>a : any
|
||||
|
||||
var rj7 = E.a | b;
|
||||
>rj7 : number
|
||||
>E.a | b : number
|
||||
>E.a : E
|
||||
>E : typeof E
|
||||
>a : E
|
||||
>b : number
|
||||
|
||||
var rj8 = E.a | E.b;
|
||||
>rj8 : number
|
||||
>E.a | E.b : number
|
||||
>E.a : E
|
||||
>E : typeof E
|
||||
>a : E
|
||||
>E.b : E
|
||||
>E : typeof E
|
||||
>b : E
|
||||
|
||||
var rj9 = E.a | 1;
|
||||
>rj9 : number
|
||||
>E.a | 1 : number
|
||||
>E.a : E
|
||||
>E : typeof E
|
||||
>a : E
|
||||
|
||||
var rj10 = a | E.b;
|
||||
>rj10 : number
|
||||
>a | E.b : number
|
||||
>a : any
|
||||
>E.b : E
|
||||
>E : typeof E
|
||||
>b : E
|
||||
|
||||
var rj11 = b | E.b;
|
||||
>rj11 : number
|
||||
>b | E.b : number
|
||||
>b : number
|
||||
>E.b : E
|
||||
>E : typeof E
|
||||
>b : E
|
||||
|
||||
var rj12 = 1 | E.b;
|
||||
>rj12 : number
|
||||
>1 | E.b : number
|
||||
>E.b : E
|
||||
>E : typeof E
|
||||
>b : E
|
||||
|
||||
@@ -2,10 +2,10 @@ tests/cases/compiler/assignmentCompatBug2.ts(1,5): error TS2322: Type '{ a: numb
|
||||
Property 'b' is missing in type '{ a: number; }'.
|
||||
tests/cases/compiler/assignmentCompatBug2.ts(3,1): error TS2322: Type '{ a: number; }' is not assignable to type '{ b: number; }'.
|
||||
Property 'b' is missing in type '{ a: number; }'.
|
||||
tests/cases/compiler/assignmentCompatBug2.ts(15,1): error TS2322: Type '{ f: (n: number) => number; g: (s: string) => number; }' is not assignable to type '{ f(n: number): number; g(s: string): number; m: number; n?: number; k?(a: any): any; }'.
|
||||
Property 'm' is missing in type '{ f: (n: number) => number; g: (s: string) => number; }'.
|
||||
tests/cases/compiler/assignmentCompatBug2.ts(20,1): error TS2322: Type '{ f: (n: number) => number; m: number; }' is not assignable to type '{ f(n: number): number; g(s: string): number; m: number; n?: number; k?(a: any): any; }'.
|
||||
Property 'g' is missing in type '{ f: (n: number) => number; m: number; }'.
|
||||
tests/cases/compiler/assignmentCompatBug2.ts(15,1): error TS2322: Type '{ f: (n: number) => number; g: (s: string) => number; n?: number; k?(a: any): any; }' is not assignable to type '{ f(n: number): number; g(s: string): number; m: number; n?: number; k?(a: any): any; }'.
|
||||
Property 'm' is missing in type '{ f: (n: number) => number; g: (s: string) => number; n?: number; k?(a: any): any; }'.
|
||||
tests/cases/compiler/assignmentCompatBug2.ts(20,1): error TS2322: Type '{ f: (n: number) => number; m: number; n?: number; k?(a: any): any; }' is not assignable to type '{ f(n: number): number; g(s: string): number; m: number; n?: number; k?(a: any): any; }'.
|
||||
Property 'g' is missing in type '{ f: (n: number) => number; m: number; n?: number; k?(a: any): any; }'.
|
||||
tests/cases/compiler/assignmentCompatBug2.ts(33,1): error TS2322: Type '{ f: (n: number) => number; g: (s: string) => number; n: number; k: (a: any) => any; }' is not assignable to type '{ f(n: number): number; g(s: string): number; m: number; n?: number; k?(a: any): any; }'.
|
||||
Property 'm' is missing in type '{ f: (n: number) => number; g: (s: string) => number; n: number; k: (a: any) => any; }'.
|
||||
|
||||
@@ -33,16 +33,16 @@ tests/cases/compiler/assignmentCompatBug2.ts(33,1): error TS2322: Type '{ f: (n:
|
||||
|
||||
b3 = {
|
||||
~~
|
||||
!!! error TS2322: Type '{ f: (n: number) => number; g: (s: string) => number; }' is not assignable to type '{ f(n: number): number; g(s: string): number; m: number; n?: number; k?(a: any): any; }'.
|
||||
!!! error TS2322: Property 'm' is missing in type '{ f: (n: number) => number; g: (s: string) => number; }'.
|
||||
!!! error TS2322: Type '{ f: (n: number) => number; g: (s: string) => number; n?: number; k?(a: any): any; }' is not assignable to type '{ f(n: number): number; g(s: string): number; m: number; n?: number; k?(a: any): any; }'.
|
||||
!!! error TS2322: Property 'm' is missing in type '{ f: (n: number) => number; g: (s: string) => number; n?: number; k?(a: any): any; }'.
|
||||
f: (n) => { return 0; },
|
||||
g: (s) => { return 0; },
|
||||
}; // error
|
||||
|
||||
b3 = {
|
||||
~~
|
||||
!!! error TS2322: Type '{ f: (n: number) => number; m: number; }' is not assignable to type '{ f(n: number): number; g(s: string): number; m: number; n?: number; k?(a: any): any; }'.
|
||||
!!! error TS2322: Property 'g' is missing in type '{ f: (n: number) => number; m: number; }'.
|
||||
!!! error TS2322: Type '{ f: (n: number) => number; m: number; n?: number; k?(a: any): any; }' is not assignable to type '{ f(n: number): number; g(s: string): number; m: number; n?: number; k?(a: any): any; }'.
|
||||
!!! error TS2322: Property 'g' is missing in type '{ f: (n: number) => number; m: number; n?: number; k?(a: any): any; }'.
|
||||
f: (n) => { return 0; },
|
||||
m: 0,
|
||||
}; // error
|
||||
|
||||
@@ -51,13 +51,13 @@ var b: { foo: string; baz?: string }
|
||||
var a2: S2 = { foo: '' };
|
||||
>a2 : S2
|
||||
>S2 : S2
|
||||
>{ foo: '' } : { foo: string; }
|
||||
>{ foo: '' } : { foo: string; bar?: string; }
|
||||
>foo : string
|
||||
|
||||
var b2: T2 = { foo: '' };
|
||||
>b2 : T2
|
||||
>T2 : T2
|
||||
>{ foo: '' } : { foo: string; }
|
||||
>{ foo: '' } : { foo: string; baz?: string; }
|
||||
>foo : string
|
||||
|
||||
s = t;
|
||||
|
||||
@@ -12,7 +12,7 @@ module __test1__ {
|
||||
>U : U
|
||||
>obj4 : interfaceWithPublicAndOptional<number, string>
|
||||
>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional<T, U>
|
||||
>{ one: 1 } : { one: number; }
|
||||
>{ one: 1 } : { one: number; two?: string; }
|
||||
>one : number
|
||||
|
||||
export var __val__obj4 = obj4;
|
||||
|
||||
@@ -12,7 +12,7 @@ module __test1__ {
|
||||
>U : U
|
||||
>obj4 : interfaceWithPublicAndOptional<number, string>
|
||||
>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional<T, U>
|
||||
>{ one: 1 } : { one: number; }
|
||||
>{ one: 1 } : { one: number; two?: string; }
|
||||
>one : number
|
||||
|
||||
export var __val__obj4 = obj4;
|
||||
|
||||
@@ -12,7 +12,7 @@ module __test1__ {
|
||||
>U : U
|
||||
>obj4 : interfaceWithPublicAndOptional<number, string>
|
||||
>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional<T, U>
|
||||
>{ one: 1 } : { one: number; }
|
||||
>{ one: 1 } : { one: number; two?: string; }
|
||||
>one : number
|
||||
|
||||
export var __val__obj4 = obj4;
|
||||
|
||||
@@ -12,7 +12,7 @@ module __test1__ {
|
||||
>U : U
|
||||
>obj4 : interfaceWithPublicAndOptional<number, string>
|
||||
>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional<T, U>
|
||||
>{ one: 1 } : { one: number; }
|
||||
>{ one: 1 } : { one: number; two?: string; }
|
||||
>one : number
|
||||
|
||||
export var __val__obj4 = obj4;
|
||||
|
||||
@@ -12,7 +12,7 @@ module __test1__ {
|
||||
>U : U
|
||||
>obj4 : interfaceWithPublicAndOptional<number, string>
|
||||
>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional<T, U>
|
||||
>{ one: 1 } : { one: number; }
|
||||
>{ one: 1 } : { one: number; two?: string; }
|
||||
>one : number
|
||||
|
||||
export var __val__obj4 = obj4;
|
||||
|
||||
@@ -12,7 +12,7 @@ module __test1__ {
|
||||
>U : U
|
||||
>obj4 : interfaceWithPublicAndOptional<number, string>
|
||||
>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional<T, U>
|
||||
>{ one: 1 } : { one: number; }
|
||||
>{ one: 1 } : { one: number; two?: string; }
|
||||
>one : number
|
||||
|
||||
export var __val__obj4 = obj4;
|
||||
@@ -29,7 +29,7 @@ module __test2__ {
|
||||
>T : T
|
||||
>obj3 : interfaceWithOptional<number>
|
||||
>interfaceWithOptional : interfaceWithOptional<T>
|
||||
>{ } : {}
|
||||
>{ } : { one?: number; }
|
||||
|
||||
export var __val__obj3 = obj3;
|
||||
>__val__obj3 : interfaceWithOptional<number>
|
||||
|
||||
@@ -12,7 +12,7 @@ module __test1__ {
|
||||
>U : U
|
||||
>obj4 : interfaceWithPublicAndOptional<number, string>
|
||||
>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional<T, U>
|
||||
>{ one: 1 } : { one: number; }
|
||||
>{ one: 1 } : { one: number; two?: string; }
|
||||
>one : number
|
||||
|
||||
export var __val__obj4 = obj4;
|
||||
@@ -32,7 +32,7 @@ module __test2__ {
|
||||
>U : U
|
||||
>obj4 : interfaceWithPublicAndOptional<number, string>
|
||||
>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional<T, U>
|
||||
>{ one: 1 } : { one: number; }
|
||||
>{ one: 1 } : { one: number; two?: string; }
|
||||
>one : number
|
||||
|
||||
export var __val__obj4 = obj4;
|
||||
|
||||
@@ -12,7 +12,7 @@ module __test1__ {
|
||||
>U : U
|
||||
>obj4 : interfaceWithPublicAndOptional<number, string>
|
||||
>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional<T, U>
|
||||
>{ one: 1 } : { one: number; }
|
||||
>{ one: 1 } : { one: number; two?: string; }
|
||||
>one : number
|
||||
|
||||
export var __val__obj4 = obj4;
|
||||
|
||||
@@ -12,7 +12,7 @@ module __test1__ {
|
||||
>U : U
|
||||
>obj4 : interfaceWithPublicAndOptional<number, string>
|
||||
>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional<T, U>
|
||||
>{ one: 1 } : { one: number; }
|
||||
>{ one: 1 } : { one: number; two?: string; }
|
||||
>one : number
|
||||
|
||||
export var __val__obj4 = obj4;
|
||||
|
||||
@@ -55,27 +55,4 @@ interface B<TBase extends Base> extends A {
|
||||
}
|
||||
var b: B<Derived> = null;
|
||||
var z: Derived = b.foo();
|
||||
class Base { private a: string; }
|
||||
class Derived extends Base { private b: string; }
|
||||
|
||||
// Note - commmenting "extends Foo" prevents the error
|
||||
interface Foo {
|
||||
[i: number]: Base;
|
||||
}
|
||||
interface FooOf<TBase extends Base> extends Foo {
|
||||
[i: number]: TBase;
|
||||
}
|
||||
var x: FooOf<Derived> = null;
|
||||
var y: Derived = x[0];
|
||||
|
||||
/*
|
||||
// Note - the equivalent for normal interface methods works fine:
|
||||
interface A {
|
||||
foo(): Base;
|
||||
}
|
||||
interface B<TBase extends Base> extends A {
|
||||
foo(): TBase;
|
||||
}
|
||||
var b: B<Derived> = null;
|
||||
var z: Derived = b.foo();
|
||||
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
//// [commentEmitWithCommentOnLastLine.ts]
|
||||
var x: any;
|
||||
/*
|
||||
var bar;
|
||||
*/
|
||||
|
||||
//// [commentEmitWithCommentOnLastLine.js]
|
||||
var x;
|
||||
/*
|
||||
var bar;
|
||||
*/
|
||||
@@ -0,0 +1,7 @@
|
||||
=== tests/cases/compiler/commentEmitWithCommentOnLastLine.ts ===
|
||||
var x: any;
|
||||
>x : any
|
||||
|
||||
/*
|
||||
var bar;
|
||||
*/
|
||||
@@ -1,8 +1,9 @@
|
||||
tests/cases/compiler/complicatedPrivacy.ts(24,38): error TS1005: ';' expected.
|
||||
tests/cases/compiler/complicatedPrivacy.ts(35,6): error TS2304: Cannot find name 'number'.
|
||||
tests/cases/compiler/complicatedPrivacy.ts(73,49): error TS2305: Module 'mglo5' has no exported member 'i6'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/complicatedPrivacy.ts (2 errors) ====
|
||||
==== tests/cases/compiler/complicatedPrivacy.ts (3 errors) ====
|
||||
module m1 {
|
||||
export module m2 {
|
||||
|
||||
@@ -39,7 +40,9 @@ tests/cases/compiler/complicatedPrivacy.ts(73,49): error TS2305: Module 'mglo5'
|
||||
|
||||
export function f4(arg1:
|
||||
{
|
||||
[number]: C1;
|
||||
[number]: C1; // Used to be indexer, now it is a computed property
|
||||
~~~~~~
|
||||
!!! error TS2304: Cannot find name 'number'.
|
||||
}) {
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames1.ts(2,9): error TS9002: Computed property names are not currently supported.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames1.ts(3,9): error TS9002: Computed property names are not currently supported.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames1.ts (2 errors) ====
|
||||
var v = {
|
||||
get [0 + 1]() { return 0 },
|
||||
~~~~~~~
|
||||
!!! error TS9002: Computed property names are not currently supported.
|
||||
set [0 + 1](v: string) { } //No error
|
||||
~~~~~~~
|
||||
!!! error TS9002: Computed property names are not currently supported.
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
//// [computedPropertyNames1.ts]
|
||||
var v = {
|
||||
get [0 + 1]() { return 0 },
|
||||
set [0 + 1](v: string) { } //No error
|
||||
}
|
||||
|
||||
//// [computedPropertyNames1.js]
|
||||
var v = {
|
||||
get [0 + 1]() {
|
||||
return 0;
|
||||
},
|
||||
set [0 + 1](v) {
|
||||
} //No error
|
||||
};
|
||||
@@ -0,0 +1,12 @@
|
||||
=== tests/cases/conformance/es6/computedProperties/computedPropertyNames1.ts ===
|
||||
var v = {
|
||||
>v : {}
|
||||
>{ get [0 + 1]() { return 0 }, set [0 + 1](v: string) { } //No error} : {}
|
||||
|
||||
get [0 + 1]() { return 0 },
|
||||
>0 + 1 : number
|
||||
|
||||
set [0 + 1](v: string) { } //No error
|
||||
>0 + 1 : number
|
||||
>v : string
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
//// [computedPropertyNames10.ts]
|
||||
var s: string;
|
||||
var n: number;
|
||||
var a: any;
|
||||
var v = {
|
||||
[s]() { },
|
||||
[n]() { },
|
||||
[s + s]() { },
|
||||
[s + n]() { },
|
||||
[+s]() { },
|
||||
[""]() { },
|
||||
[0]() { },
|
||||
[a]() { },
|
||||
[<any>true]() { },
|
||||
[`hello bye`]() { },
|
||||
[`hello ${a} bye`]() { }
|
||||
}
|
||||
|
||||
//// [computedPropertyNames10.js]
|
||||
var s;
|
||||
var n;
|
||||
var a;
|
||||
var v = {
|
||||
[s]() {
|
||||
},
|
||||
[n]() {
|
||||
},
|
||||
[s + s]() {
|
||||
},
|
||||
[s + n]() {
|
||||
},
|
||||
[+s]() {
|
||||
},
|
||||
[""]() {
|
||||
},
|
||||
[0]() {
|
||||
},
|
||||
[a]() {
|
||||
},
|
||||
[true]() {
|
||||
},
|
||||
[`hello bye`]() {
|
||||
},
|
||||
[`hello ${a} bye`]() {
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,46 @@
|
||||
=== tests/cases/conformance/es6/computedProperties/computedPropertyNames10.ts ===
|
||||
var s: string;
|
||||
>s : string
|
||||
|
||||
var n: number;
|
||||
>n : number
|
||||
|
||||
var a: any;
|
||||
>a : any
|
||||
|
||||
var v = {
|
||||
>v : {}
|
||||
>{ [s]() { }, [n]() { }, [s + s]() { }, [s + n]() { }, [+s]() { }, [""]() { }, [0]() { }, [a]() { }, [<any>true]() { }, [`hello bye`]() { }, [`hello ${a} bye`]() { }} : {}
|
||||
|
||||
[s]() { },
|
||||
>s : string
|
||||
|
||||
[n]() { },
|
||||
>n : number
|
||||
|
||||
[s + s]() { },
|
||||
>s + s : string
|
||||
>s : string
|
||||
>s : string
|
||||
|
||||
[s + n]() { },
|
||||
>s + n : string
|
||||
>s : string
|
||||
>n : number
|
||||
|
||||
[+s]() { },
|
||||
>+s : number
|
||||
>s : string
|
||||
|
||||
[""]() { },
|
||||
[0]() { },
|
||||
[a]() { },
|
||||
>a : any
|
||||
|
||||
[<any>true]() { },
|
||||
><any>true : any
|
||||
|
||||
[`hello bye`]() { },
|
||||
[`hello ${a} bye`]() { }
|
||||
>a : any
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
//// [computedPropertyNames11.ts]
|
||||
var s: string;
|
||||
var n: number;
|
||||
var a: any;
|
||||
var v = {
|
||||
get [s]() { return 0; },
|
||||
set [n](v) { },
|
||||
get [s + s]() { return 0; },
|
||||
set [s + n](v) { },
|
||||
get [+s]() { return 0; },
|
||||
set [""](v) { },
|
||||
get [0]() { return 0; },
|
||||
set [a](v) { },
|
||||
get [<any>true]() { return 0; },
|
||||
set [`hello bye`](v) { },
|
||||
get [`hello ${a} bye`]() { return 0; }
|
||||
}
|
||||
|
||||
//// [computedPropertyNames11.js]
|
||||
var s;
|
||||
var n;
|
||||
var a;
|
||||
var v = {
|
||||
get [s]() {
|
||||
return 0;
|
||||
},
|
||||
set [n](v) {
|
||||
},
|
||||
get [s + s]() {
|
||||
return 0;
|
||||
},
|
||||
set [s + n](v) {
|
||||
},
|
||||
get [+s]() {
|
||||
return 0;
|
||||
},
|
||||
set [""](v) {
|
||||
},
|
||||
get [0]() {
|
||||
return 0;
|
||||
},
|
||||
set [a](v) {
|
||||
},
|
||||
get [true]() {
|
||||
return 0;
|
||||
},
|
||||
set [`hello bye`](v) {
|
||||
},
|
||||
get [`hello ${a} bye`]() {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,53 @@
|
||||
=== tests/cases/conformance/es6/computedProperties/computedPropertyNames11.ts ===
|
||||
var s: string;
|
||||
>s : string
|
||||
|
||||
var n: number;
|
||||
>n : number
|
||||
|
||||
var a: any;
|
||||
>a : any
|
||||
|
||||
var v = {
|
||||
>v : {}
|
||||
>{ get [s]() { return 0; }, set [n](v) { }, get [s + s]() { return 0; }, set [s + n](v) { }, get [+s]() { return 0; }, set [""](v) { }, get [0]() { return 0; }, set [a](v) { }, get [<any>true]() { return 0; }, set [`hello bye`](v) { }, get [`hello ${a} bye`]() { return 0; }} : {}
|
||||
|
||||
get [s]() { return 0; },
|
||||
>s : string
|
||||
|
||||
set [n](v) { },
|
||||
>n : number
|
||||
>v : any
|
||||
|
||||
get [s + s]() { return 0; },
|
||||
>s + s : string
|
||||
>s : string
|
||||
>s : string
|
||||
|
||||
set [s + n](v) { },
|
||||
>s + n : string
|
||||
>s : string
|
||||
>n : number
|
||||
>v : any
|
||||
|
||||
get [+s]() { return 0; },
|
||||
>+s : number
|
||||
>s : string
|
||||
|
||||
set [""](v) { },
|
||||
>v : any
|
||||
|
||||
get [0]() { return 0; },
|
||||
set [a](v) { },
|
||||
>a : any
|
||||
>v : any
|
||||
|
||||
get [<any>true]() { return 0; },
|
||||
><any>true : any
|
||||
|
||||
set [`hello bye`](v) { },
|
||||
>v : any
|
||||
|
||||
get [`hello ${a} bye`]() { return 0; }
|
||||
>a : any
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames12.ts(5,5): error TS1166: Computed property names are not allowed in class property declarations.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames12.ts(6,5): error TS1166: Computed property names are not allowed in class property declarations.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames12.ts(7,12): error TS1166: Computed property names are not allowed in class property declarations.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames12.ts(8,5): error TS1166: Computed property names are not allowed in class property declarations.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames12.ts(9,5): error TS1166: Computed property names are not allowed in class property declarations.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames12.ts(10,12): error TS1166: Computed property names are not allowed in class property declarations.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames12.ts(11,5): error TS1166: Computed property names are not allowed in class property declarations.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames12.ts(12,5): error TS1166: Computed property names are not allowed in class property declarations.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames12.ts(13,12): error TS1166: Computed property names are not allowed in class property declarations.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames12.ts(14,5): error TS1166: Computed property names are not allowed in class property declarations.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames12.ts(15,12): error TS1166: Computed property names are not allowed in class property declarations.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames12.ts (11 errors) ====
|
||||
var s: string;
|
||||
var n: number;
|
||||
var a: any;
|
||||
class C {
|
||||
[s]: number;
|
||||
~~~
|
||||
!!! error TS1166: Computed property names are not allowed in class property declarations.
|
||||
[n] = n;
|
||||
~~~
|
||||
!!! error TS1166: Computed property names are not allowed in class property declarations.
|
||||
static [s + s]: string;
|
||||
~~~~~~~
|
||||
!!! error TS1166: Computed property names are not allowed in class property declarations.
|
||||
[s + n] = 2;
|
||||
~~~~~~~
|
||||
!!! error TS1166: Computed property names are not allowed in class property declarations.
|
||||
[+s]: typeof s;
|
||||
~~~~
|
||||
!!! error TS1166: Computed property names are not allowed in class property declarations.
|
||||
static [""]: number;
|
||||
~~~~
|
||||
!!! error TS1166: Computed property names are not allowed in class property declarations.
|
||||
[0]: number;
|
||||
~~~
|
||||
!!! error TS1166: Computed property names are not allowed in class property declarations.
|
||||
[a]: number;
|
||||
~~~
|
||||
!!! error TS1166: Computed property names are not allowed in class property declarations.
|
||||
static [<any>true]: number;
|
||||
~~~~~~~~~~~
|
||||
!!! error TS1166: Computed property names are not allowed in class property declarations.
|
||||
[`hello bye`] = 0;
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS1166: Computed property names are not allowed in class property declarations.
|
||||
static [`hello ${a} bye`] = 0
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1166: Computed property names are not allowed in class property declarations.
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
//// [computedPropertyNames13.ts]
|
||||
var s: string;
|
||||
var n: number;
|
||||
var a: any;
|
||||
class C {
|
||||
[s]() {}
|
||||
[n]() { }
|
||||
static [s + s]() { }
|
||||
[s + n]() { }
|
||||
[+s]() { }
|
||||
static [""]() { }
|
||||
[0]() { }
|
||||
[a]() { }
|
||||
static [<any>true]() { }
|
||||
[`hello bye`]() { }
|
||||
static [`hello ${a} bye`]() { }
|
||||
}
|
||||
|
||||
//// [computedPropertyNames13.js]
|
||||
var s;
|
||||
var n;
|
||||
var a;
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype[s] = function () {
|
||||
};
|
||||
C.prototype[n] = function () {
|
||||
};
|
||||
C[s + s] = function () {
|
||||
};
|
||||
C.prototype[s + n] = function () {
|
||||
};
|
||||
C.prototype[+s] = function () {
|
||||
};
|
||||
C[""] = function () {
|
||||
};
|
||||
C.prototype[0] = function () {
|
||||
};
|
||||
C.prototype[a] = function () {
|
||||
};
|
||||
C[true] = function () {
|
||||
};
|
||||
C.prototype[`hello bye`] = function () {
|
||||
};
|
||||
C[`hello ${a} bye`] = function () {
|
||||
};
|
||||
return C;
|
||||
})();
|
||||
@@ -0,0 +1,45 @@
|
||||
=== tests/cases/conformance/es6/computedProperties/computedPropertyNames13.ts ===
|
||||
var s: string;
|
||||
>s : string
|
||||
|
||||
var n: number;
|
||||
>n : number
|
||||
|
||||
var a: any;
|
||||
>a : any
|
||||
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
[s]() {}
|
||||
>s : string
|
||||
|
||||
[n]() { }
|
||||
>n : number
|
||||
|
||||
static [s + s]() { }
|
||||
>s + s : string
|
||||
>s : string
|
||||
>s : string
|
||||
|
||||
[s + n]() { }
|
||||
>s + n : string
|
||||
>s : string
|
||||
>n : number
|
||||
|
||||
[+s]() { }
|
||||
>+s : number
|
||||
>s : string
|
||||
|
||||
static [""]() { }
|
||||
[0]() { }
|
||||
[a]() { }
|
||||
>a : any
|
||||
|
||||
static [<any>true]() { }
|
||||
><any>true : any
|
||||
|
||||
[`hello bye`]() { }
|
||||
static [`hello ${a} bye`]() { }
|
||||
>a : any
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames14.ts(3,5): error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames14.ts(4,12): error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames14.ts(5,5): error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames14.ts(6,12): error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames14.ts(7,5): error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames14.ts(8,12): error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames14.ts (6 errors) ====
|
||||
var b: boolean;
|
||||
class C {
|
||||
[b]() {}
|
||||
~~~
|
||||
!!! error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
|
||||
static [true]() { }
|
||||
~~~~~~
|
||||
!!! error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
|
||||
[[]]() { }
|
||||
~~~~
|
||||
!!! error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
|
||||
static [{}]() { }
|
||||
~~~~
|
||||
!!! error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
|
||||
[undefined]() { }
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
|
||||
static [null]() { }
|
||||
~~~~~~
|
||||
!!! error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
//// [computedPropertyNames14.ts]
|
||||
var b: boolean;
|
||||
class C {
|
||||
[b]() {}
|
||||
static [true]() { }
|
||||
[[]]() { }
|
||||
static [{}]() { }
|
||||
[undefined]() { }
|
||||
static [null]() { }
|
||||
}
|
||||
|
||||
//// [computedPropertyNames14.js]
|
||||
var b;
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype[b] = function () {
|
||||
};
|
||||
C[true] = function () {
|
||||
};
|
||||
C.prototype[[]] = function () {
|
||||
};
|
||||
C[{}] = function () {
|
||||
};
|
||||
C.prototype[undefined] = function () {
|
||||
};
|
||||
C[null] = function () {
|
||||
};
|
||||
return C;
|
||||
})();
|
||||
@@ -0,0 +1,17 @@
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames15.ts(6,5): error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames15.ts(7,5): error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames15.ts (2 errors) ====
|
||||
var p1: number | string;
|
||||
var p2: number | number[];
|
||||
var p3: string | boolean;
|
||||
class C {
|
||||
[p1]() { }
|
||||
[p2]() { }
|
||||
~~~~
|
||||
!!! error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
|
||||
[p3]() { }
|
||||
~~~~
|
||||
!!! error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
//// [computedPropertyNames15.ts]
|
||||
var p1: number | string;
|
||||
var p2: number | number[];
|
||||
var p3: string | boolean;
|
||||
class C {
|
||||
[p1]() { }
|
||||
[p2]() { }
|
||||
[p3]() { }
|
||||
}
|
||||
|
||||
//// [computedPropertyNames15.js]
|
||||
var p1;
|
||||
var p2;
|
||||
var p3;
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype[p1] = function () {
|
||||
};
|
||||
C.prototype[p2] = function () {
|
||||
};
|
||||
C.prototype[p3] = function () {
|
||||
};
|
||||
return C;
|
||||
})();
|
||||
@@ -0,0 +1,99 @@
|
||||
//// [computedPropertyNames16.ts]
|
||||
var s: string;
|
||||
var n: number;
|
||||
var a: any;
|
||||
class C {
|
||||
get [s]() { return 0;}
|
||||
set [n](v) { }
|
||||
static get [s + s]() { return 0; }
|
||||
set [s + n](v) { }
|
||||
get [+s]() { return 0; }
|
||||
static set [""](v) { }
|
||||
get [0]() { return 0; }
|
||||
set [a](v) { }
|
||||
static get [<any>true]() { return 0; }
|
||||
set [`hello bye`](v) { }
|
||||
get [`hello ${a} bye`]() { return 0; }
|
||||
}
|
||||
|
||||
//// [computedPropertyNames16.js]
|
||||
var s;
|
||||
var n;
|
||||
var a;
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
Object.defineProperty(C.prototype, s, {
|
||||
get: function () {
|
||||
return 0;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(C.prototype, n, {
|
||||
set: function (v) {
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(C, s + s, {
|
||||
get: function () {
|
||||
return 0;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(C.prototype, s + n, {
|
||||
set: function (v) {
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(C.prototype, +s, {
|
||||
get: function () {
|
||||
return 0;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(C, "", {
|
||||
set: function (v) {
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(C.prototype, 0, {
|
||||
get: function () {
|
||||
return 0;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(C.prototype, a, {
|
||||
set: function (v) {
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(C, true, {
|
||||
get: function () {
|
||||
return 0;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(C.prototype, `hello bye`, {
|
||||
set: function (v) {
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(C.prototype, `hello ${a} bye`, {
|
||||
get: function () {
|
||||
return 0;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
return C;
|
||||
})();
|
||||
@@ -0,0 +1,52 @@
|
||||
=== tests/cases/conformance/es6/computedProperties/computedPropertyNames16.ts ===
|
||||
var s: string;
|
||||
>s : string
|
||||
|
||||
var n: number;
|
||||
>n : number
|
||||
|
||||
var a: any;
|
||||
>a : any
|
||||
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
get [s]() { return 0;}
|
||||
>s : string
|
||||
|
||||
set [n](v) { }
|
||||
>n : number
|
||||
>v : any
|
||||
|
||||
static get [s + s]() { return 0; }
|
||||
>s + s : string
|
||||
>s : string
|
||||
>s : string
|
||||
|
||||
set [s + n](v) { }
|
||||
>s + n : string
|
||||
>s : string
|
||||
>n : number
|
||||
>v : any
|
||||
|
||||
get [+s]() { return 0; }
|
||||
>+s : number
|
||||
>s : string
|
||||
|
||||
static set [""](v) { }
|
||||
>v : any
|
||||
|
||||
get [0]() { return 0; }
|
||||
set [a](v) { }
|
||||
>a : any
|
||||
>v : any
|
||||
|
||||
static get [<any>true]() { return 0; }
|
||||
><any>true : any
|
||||
|
||||
set [`hello bye`](v) { }
|
||||
>v : any
|
||||
|
||||
get [`hello ${a} bye`]() { return 0; }
|
||||
>a : any
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames17.ts(3,9): error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames17.ts(4,16): error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames17.ts(5,9): error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames17.ts(6,9): error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames17.ts(7,16): error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames17.ts(8,9): error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames17.ts (6 errors) ====
|
||||
var b: boolean;
|
||||
class C {
|
||||
get [b]() { return 0;}
|
||||
~~~
|
||||
!!! error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
|
||||
static set [true](v) { }
|
||||
~~~~~~
|
||||
!!! error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
|
||||
get [[]]() { return 0; }
|
||||
~~~~
|
||||
!!! error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
|
||||
set [{}](v) { }
|
||||
~~~~
|
||||
!!! error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
|
||||
static get [undefined]() { return 0; }
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
|
||||
set [null](v) { }
|
||||
~~~~~~
|
||||
!!! error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
//// [computedPropertyNames17.ts]
|
||||
var b: boolean;
|
||||
class C {
|
||||
get [b]() { return 0;}
|
||||
static set [true](v) { }
|
||||
get [[]]() { return 0; }
|
||||
set [{}](v) { }
|
||||
static get [undefined]() { return 0; }
|
||||
set [null](v) { }
|
||||
}
|
||||
|
||||
//// [computedPropertyNames17.js]
|
||||
var b;
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
Object.defineProperty(C.prototype, b, {
|
||||
get: function () {
|
||||
return 0;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(C, true, {
|
||||
set: function (v) {
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(C.prototype, [], {
|
||||
get: function () {
|
||||
return 0;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(C.prototype, {}, {
|
||||
set: function (v) {
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(C, undefined, {
|
||||
get: function () {
|
||||
return 0;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(C.prototype, null, {
|
||||
set: function (v) {
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
return C;
|
||||
})();
|
||||
@@ -0,0 +1,13 @@
|
||||
//// [computedPropertyNames18.ts]
|
||||
function foo() {
|
||||
var obj = {
|
||||
[this.bar]: 0
|
||||
}
|
||||
}
|
||||
|
||||
//// [computedPropertyNames18.js]
|
||||
function foo() {
|
||||
var obj = {
|
||||
[this.bar]: 0
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
=== tests/cases/conformance/es6/computedProperties/computedPropertyNames18.ts ===
|
||||
function foo() {
|
||||
>foo : () => void
|
||||
|
||||
var obj = {
|
||||
>obj : {}
|
||||
>{ [this.bar]: 0 } : {}
|
||||
|
||||
[this.bar]: 0
|
||||
>this.bar : any
|
||||
>this : any
|
||||
>bar : any
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames19.ts(3,10): error TS2331: 'this' cannot be referenced in a module body.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames19.ts (1 errors) ====
|
||||
module M {
|
||||
var obj = {
|
||||
[this.bar]: 0
|
||||
~~~~
|
||||
!!! error TS2331: 'this' cannot be referenced in a module body.
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
//// [computedPropertyNames19.ts]
|
||||
module M {
|
||||
var obj = {
|
||||
[this.bar]: 0
|
||||
}
|
||||
}
|
||||
|
||||
//// [computedPropertyNames19.js]
|
||||
var M;
|
||||
(function (M) {
|
||||
var obj = {
|
||||
[this.bar]: 0
|
||||
};
|
||||
})(M || (M = {}));
|
||||
@@ -1,37 +1,19 @@
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames2.ts(4,5): error TS9002: Computed property names are not currently supported.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames2.ts(5,12): error TS9002: Computed property names are not currently supported.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames2.ts(6,9): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames2.ts(6,9): error TS9002: Computed property names are not currently supported.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames2.ts(7,9): error TS9002: Computed property names are not currently supported.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames2.ts(8,16): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames2.ts(8,16): error TS9002: Computed property names are not currently supported.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames2.ts(9,16): error TS9002: Computed property names are not currently supported.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames2.ts (8 errors) ====
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames2.ts (2 errors) ====
|
||||
var methodName = "method";
|
||||
var accessorName = "accessor";
|
||||
class C {
|
||||
[methodName]() { }
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS9002: Computed property names are not currently supported.
|
||||
static [methodName]() { }
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS9002: Computed property names are not currently supported.
|
||||
get [accessorName]() { }
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement.
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS9002: Computed property names are not currently supported.
|
||||
set [accessorName](v) { }
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS9002: Computed property names are not currently supported.
|
||||
static get [accessorName]() { }
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement.
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS9002: Computed property names are not currently supported.
|
||||
static set [accessorName](v) { }
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS9002: Computed property names are not currently supported.
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
//// [computedPropertyNames2.ts]
|
||||
var methodName = "method";
|
||||
var accessorName = "accessor";
|
||||
class C {
|
||||
[methodName]() { }
|
||||
static [methodName]() { }
|
||||
get [accessorName]() { }
|
||||
set [accessorName](v) { }
|
||||
static get [accessorName]() { }
|
||||
static set [accessorName](v) { }
|
||||
}
|
||||
|
||||
//// [computedPropertyNames2.js]
|
||||
var methodName = "method";
|
||||
var accessorName = "accessor";
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype[methodName] = function () {
|
||||
};
|
||||
C[methodName] = function () {
|
||||
};
|
||||
Object.defineProperty(C.prototype, accessorName, {
|
||||
get: function () {
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(C.prototype, accessorName, {
|
||||
set: function (v) {
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(C, accessorName, {
|
||||
get: function () {
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(C, accessorName, {
|
||||
set: function (v) {
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
return C;
|
||||
})();
|
||||
@@ -0,0 +1,9 @@
|
||||
//// [computedPropertyNames20.ts]
|
||||
var obj = {
|
||||
[this.bar]: 0
|
||||
}
|
||||
|
||||
//// [computedPropertyNames20.js]
|
||||
var obj = {
|
||||
[this.bar]: 0
|
||||
};
|
||||
@@ -0,0 +1,10 @@
|
||||
=== tests/cases/conformance/es6/computedProperties/computedPropertyNames20.ts ===
|
||||
var obj = {
|
||||
>obj : {}
|
||||
>{ [this.bar]: 0} : {}
|
||||
|
||||
[this.bar]: 0
|
||||
>this.bar : any
|
||||
>this : any
|
||||
>bar : any
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames21.ts(5,6): error TS2465: 'this' cannot be referenced in a computed property name.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames21.ts (1 errors) ====
|
||||
class C {
|
||||
bar() {
|
||||
return 0;
|
||||
}
|
||||
[this.bar()]() { }
|
||||
~~~~
|
||||
!!! error TS2465: 'this' cannot be referenced in a computed property name.
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
//// [computedPropertyNames21.ts]
|
||||
class C {
|
||||
bar() {
|
||||
return 0;
|
||||
}
|
||||
[this.bar()]() { }
|
||||
}
|
||||
|
||||
//// [computedPropertyNames21.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.bar = function () {
|
||||
return 0;
|
||||
};
|
||||
C.prototype[this.bar()] = function () {
|
||||
};
|
||||
return C;
|
||||
})();
|
||||
@@ -0,0 +1,23 @@
|
||||
//// [computedPropertyNames22.ts]
|
||||
class C {
|
||||
bar() {
|
||||
var obj = {
|
||||
[this.bar()]() { }
|
||||
};
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
//// [computedPropertyNames22.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.bar = function () {
|
||||
var obj = {
|
||||
[this.bar()]() {
|
||||
}
|
||||
};
|
||||
return 0;
|
||||
};
|
||||
return C;
|
||||
})();
|
||||
@@ -0,0 +1,21 @@
|
||||
=== tests/cases/conformance/es6/computedProperties/computedPropertyNames22.ts ===
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
bar() {
|
||||
>bar : () => number
|
||||
|
||||
var obj = {
|
||||
>obj : {}
|
||||
>{ [this.bar()]() { } } : {}
|
||||
|
||||
[this.bar()]() { }
|
||||
>this.bar() : number
|
||||
>this.bar : () => number
|
||||
>this : C
|
||||
>bar : () => number
|
||||
|
||||
};
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames23.ts(6,12): error TS2465: 'this' cannot be referenced in a computed property name.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames23.ts (1 errors) ====
|
||||
class C {
|
||||
bar() {
|
||||
return 0;
|
||||
}
|
||||
[
|
||||
{ [this.bar()]: 1 }[0]
|
||||
~~~~
|
||||
!!! error TS2465: 'this' cannot be referenced in a computed property name.
|
||||
]() { }
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
//// [computedPropertyNames23.ts]
|
||||
class C {
|
||||
bar() {
|
||||
return 0;
|
||||
}
|
||||
[
|
||||
{ [this.bar()]: 1 }[0]
|
||||
]() { }
|
||||
}
|
||||
|
||||
//// [computedPropertyNames23.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.bar = function () {
|
||||
return 0;
|
||||
};
|
||||
C.prototype[{ [this.bar()]: 1 }[0]] = function () {
|
||||
};
|
||||
return C;
|
||||
})();
|
||||
@@ -0,0 +1,16 @@
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames24.ts(9,6): error TS2466: 'super' cannot be referenced in a computed property name.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames24.ts (1 errors) ====
|
||||
class Base {
|
||||
bar() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
class C extends Base {
|
||||
// Gets emitted as super, not _super, which is consistent with
|
||||
// use of super in static properties initializers.
|
||||
[super.bar()]() { }
|
||||
~~~~~
|
||||
!!! error TS2466: 'super' cannot be referenced in a computed property name.
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
//// [computedPropertyNames24.ts]
|
||||
class Base {
|
||||
bar() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
class C extends Base {
|
||||
// Gets emitted as super, not _super, which is consistent with
|
||||
// use of super in static properties initializers.
|
||||
[super.bar()]() { }
|
||||
}
|
||||
|
||||
//// [computedPropertyNames24.js]
|
||||
var __extends = this.__extends || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
__.prototype = b.prototype;
|
||||
d.prototype = new __();
|
||||
};
|
||||
var Base = (function () {
|
||||
function Base() {
|
||||
}
|
||||
Base.prototype.bar = function () {
|
||||
return 0;
|
||||
};
|
||||
return Base;
|
||||
})();
|
||||
var C = (function (_super) {
|
||||
__extends(C, _super);
|
||||
function C() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
// Gets emitted as super, not _super, which is consistent with
|
||||
// use of super in static properties initializers.
|
||||
C.prototype[super.bar.call(this)] = function () {
|
||||
};
|
||||
return C;
|
||||
})(Base);
|
||||
@@ -0,0 +1,44 @@
|
||||
//// [computedPropertyNames25.ts]
|
||||
class Base {
|
||||
bar() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
class C extends Base {
|
||||
foo() {
|
||||
var obj = {
|
||||
[super.bar()]() { }
|
||||
};
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
//// [computedPropertyNames25.js]
|
||||
var __extends = this.__extends || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
__.prototype = b.prototype;
|
||||
d.prototype = new __();
|
||||
};
|
||||
var Base = (function () {
|
||||
function Base() {
|
||||
}
|
||||
Base.prototype.bar = function () {
|
||||
return 0;
|
||||
};
|
||||
return Base;
|
||||
})();
|
||||
var C = (function (_super) {
|
||||
__extends(C, _super);
|
||||
function C() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
C.prototype.foo = function () {
|
||||
var obj = {
|
||||
[_super.prototype.bar.call(this)]() {
|
||||
}
|
||||
};
|
||||
return 0;
|
||||
};
|
||||
return C;
|
||||
})(Base);
|
||||
@@ -0,0 +1,31 @@
|
||||
=== tests/cases/conformance/es6/computedProperties/computedPropertyNames25.ts ===
|
||||
class Base {
|
||||
>Base : Base
|
||||
|
||||
bar() {
|
||||
>bar : () => number
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
class C extends Base {
|
||||
>C : C
|
||||
>Base : Base
|
||||
|
||||
foo() {
|
||||
>foo : () => number
|
||||
|
||||
var obj = {
|
||||
>obj : {}
|
||||
>{ [super.bar()]() { } } : {}
|
||||
|
||||
[super.bar()]() { }
|
||||
>super.bar() : number
|
||||
>super.bar : () => number
|
||||
>super : Base
|
||||
>bar : () => number
|
||||
|
||||
};
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames26.ts(10,12): error TS2466: 'super' cannot be referenced in a computed property name.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames26.ts (1 errors) ====
|
||||
class Base {
|
||||
bar() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
class C extends Base {
|
||||
// Gets emitted as super, not _super, which is consistent with
|
||||
// use of super in static properties initializers.
|
||||
[
|
||||
{ [super.bar()]: 1 }[0]
|
||||
~~~~~
|
||||
!!! error TS2466: 'super' cannot be referenced in a computed property name.
|
||||
]() { }
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
//// [computedPropertyNames26.ts]
|
||||
class Base {
|
||||
bar() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
class C extends Base {
|
||||
// Gets emitted as super, not _super, which is consistent with
|
||||
// use of super in static properties initializers.
|
||||
[
|
||||
{ [super.bar()]: 1 }[0]
|
||||
]() { }
|
||||
}
|
||||
|
||||
//// [computedPropertyNames26.js]
|
||||
var __extends = this.__extends || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
__.prototype = b.prototype;
|
||||
d.prototype = new __();
|
||||
};
|
||||
var Base = (function () {
|
||||
function Base() {
|
||||
}
|
||||
Base.prototype.bar = function () {
|
||||
return 0;
|
||||
};
|
||||
return Base;
|
||||
})();
|
||||
var C = (function (_super) {
|
||||
__extends(C, _super);
|
||||
function C() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
// Gets emitted as super, not _super, which is consistent with
|
||||
// use of super in static properties initializers.
|
||||
C.prototype[{ [super.bar.call(this)]: 1 }[0]] = function () {
|
||||
};
|
||||
return C;
|
||||
})(Base);
|
||||
@@ -0,0 +1,11 @@
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames27.ts(4,7): error TS2466: 'super' cannot be referenced in a computed property name.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames27.ts (1 errors) ====
|
||||
class Base {
|
||||
}
|
||||
class C extends Base {
|
||||
[(super(), "prop")]() { }
|
||||
~~~~~
|
||||
!!! error TS2466: 'super' cannot be referenced in a computed property name.
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
//// [computedPropertyNames27.ts]
|
||||
class Base {
|
||||
}
|
||||
class C extends Base {
|
||||
[(super(), "prop")]() { }
|
||||
}
|
||||
|
||||
//// [computedPropertyNames27.js]
|
||||
var __extends = this.__extends || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
__.prototype = b.prototype;
|
||||
d.prototype = new __();
|
||||
};
|
||||
var Base = (function () {
|
||||
function Base() {
|
||||
}
|
||||
return Base;
|
||||
})();
|
||||
var C = (function (_super) {
|
||||
__extends(C, _super);
|
||||
function C() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
C.prototype[(_super.call(this), "prop")] = function () {
|
||||
};
|
||||
return C;
|
||||
})(Base);
|
||||
@@ -0,0 +1,35 @@
|
||||
//// [computedPropertyNames28.ts]
|
||||
class Base {
|
||||
}
|
||||
class C extends Base {
|
||||
constructor() {
|
||||
super();
|
||||
var obj = {
|
||||
[(super(), "prop")]() { }
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
//// [computedPropertyNames28.js]
|
||||
var __extends = this.__extends || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
__.prototype = b.prototype;
|
||||
d.prototype = new __();
|
||||
};
|
||||
var Base = (function () {
|
||||
function Base() {
|
||||
}
|
||||
return Base;
|
||||
})();
|
||||
var C = (function (_super) {
|
||||
__extends(C, _super);
|
||||
function C() {
|
||||
_super.call(this);
|
||||
var obj = {
|
||||
[(_super.call(this), "prop")]() {
|
||||
}
|
||||
};
|
||||
}
|
||||
return C;
|
||||
})(Base);
|
||||
@@ -0,0 +1,26 @@
|
||||
=== tests/cases/conformance/es6/computedProperties/computedPropertyNames28.ts ===
|
||||
class Base {
|
||||
>Base : Base
|
||||
}
|
||||
class C extends Base {
|
||||
>C : C
|
||||
>Base : Base
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
>super() : void
|
||||
>super : typeof Base
|
||||
|
||||
var obj = {
|
||||
>obj : {}
|
||||
>{ [(super(), "prop")]() { } } : {}
|
||||
|
||||
[(super(), "prop")]() { }
|
||||
>(super(), "prop") : string
|
||||
>super(), "prop" : string
|
||||
>super() : void
|
||||
>super : typeof Base
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
//// [computedPropertyNames29.ts]
|
||||
class C {
|
||||
bar() {
|
||||
() => {
|
||||
var obj = {
|
||||
[this.bar()]() { } // needs capture
|
||||
};
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
//// [computedPropertyNames29.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.bar = function () {
|
||||
var _this = this;
|
||||
(function () {
|
||||
var obj = {
|
||||
[_this.bar()]() {
|
||||
} // needs capture
|
||||
};
|
||||
});
|
||||
return 0;
|
||||
};
|
||||
return C;
|
||||
})();
|
||||
@@ -0,0 +1,25 @@
|
||||
=== tests/cases/conformance/es6/computedProperties/computedPropertyNames29.ts ===
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
bar() {
|
||||
>bar : () => number
|
||||
|
||||
() => {
|
||||
>() => { var obj = { [this.bar()]() { } // needs capture }; } : () => void
|
||||
|
||||
var obj = {
|
||||
>obj : {}
|
||||
>{ [this.bar()]() { } // needs capture } : {}
|
||||
|
||||
[this.bar()]() { } // needs capture
|
||||
>this.bar() : number
|
||||
>this.bar : () => number
|
||||
>this : C
|
||||
>bar : () => number
|
||||
|
||||
};
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -1,36 +1,30 @@
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts(3,5): error TS9002: Computed property names are not currently supported.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts(4,12): error TS9002: Computed property names are not currently supported.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts(4,12): error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts(5,9): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts(5,9): error TS9002: Computed property names are not currently supported.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts(6,9): error TS9002: Computed property names are not currently supported.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts(5,9): error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts(6,9): error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts(7,16): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts(7,16): error TS9002: Computed property names are not currently supported.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts(8,16): error TS9002: Computed property names are not currently supported.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts(7,16): error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts (8 errors) ====
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts (6 errors) ====
|
||||
var id;
|
||||
class C {
|
||||
[0 + 1]() { }
|
||||
~~~~~~~
|
||||
!!! error TS9002: Computed property names are not currently supported.
|
||||
static [() => { }]() { }
|
||||
~~~~~~~~~~~
|
||||
!!! error TS9002: Computed property names are not currently supported.
|
||||
!!! error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
|
||||
get [delete id]() { }
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement.
|
||||
~~~~~~~~~~~
|
||||
!!! error TS9002: Computed property names are not currently supported.
|
||||
!!! error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
|
||||
set [[0, 1]](v) { }
|
||||
~~~~~~~~
|
||||
!!! error TS9002: Computed property names are not currently supported.
|
||||
!!! error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
|
||||
static get [<String>""]() { }
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement.
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS9002: Computed property names are not currently supported.
|
||||
!!! error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
|
||||
static set [id.toString()](v) { }
|
||||
~~~~~~~~~~~~~~~
|
||||
!!! error TS9002: Computed property names are not currently supported.
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
//// [computedPropertyNames3.ts]
|
||||
var id;
|
||||
class C {
|
||||
[0 + 1]() { }
|
||||
static [() => { }]() { }
|
||||
get [delete id]() { }
|
||||
set [[0, 1]](v) { }
|
||||
static get [<String>""]() { }
|
||||
static set [id.toString()](v) { }
|
||||
}
|
||||
|
||||
//// [computedPropertyNames3.js]
|
||||
var id;
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype[0 + 1] = function () {
|
||||
};
|
||||
C[function () {
|
||||
}] = function () {
|
||||
};
|
||||
Object.defineProperty(C.prototype, delete id, {
|
||||
get: function () {
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(C.prototype, [0, 1], {
|
||||
set: function (v) {
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(C, "", {
|
||||
get: function () {
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(C, id.toString(), {
|
||||
set: function (v) {
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
return C;
|
||||
})();
|
||||
@@ -0,0 +1,21 @@
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames30.ts(11,19): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames30.ts (1 errors) ====
|
||||
class Base {
|
||||
}
|
||||
class C extends Base {
|
||||
constructor() {
|
||||
super();
|
||||
() => {
|
||||
var obj = {
|
||||
// Ideally, we would capture this. But the reference is
|
||||
// illegal, and not capturing this is consistent with
|
||||
//treatment of other similar violations.
|
||||
[(super(), "prop")]() { }
|
||||
~~~~~
|
||||
!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
//// [computedPropertyNames30.ts]
|
||||
class Base {
|
||||
}
|
||||
class C extends Base {
|
||||
constructor() {
|
||||
super();
|
||||
() => {
|
||||
var obj = {
|
||||
// Ideally, we would capture this. But the reference is
|
||||
// illegal, and not capturing this is consistent with
|
||||
//treatment of other similar violations.
|
||||
[(super(), "prop")]() { }
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//// [computedPropertyNames30.js]
|
||||
var __extends = this.__extends || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
__.prototype = b.prototype;
|
||||
d.prototype = new __();
|
||||
};
|
||||
var Base = (function () {
|
||||
function Base() {
|
||||
}
|
||||
return Base;
|
||||
})();
|
||||
var C = (function (_super) {
|
||||
__extends(C, _super);
|
||||
function C() {
|
||||
_super.call(this);
|
||||
(function () {
|
||||
var obj = {
|
||||
// Ideally, we would capture this. But the reference is
|
||||
// illegal, and not capturing this is consistent with
|
||||
//treatment of other similar violations.
|
||||
[(_super.call(this), "prop")]() {
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
return C;
|
||||
})(Base);
|
||||
@@ -0,0 +1,49 @@
|
||||
//// [computedPropertyNames31.ts]
|
||||
class Base {
|
||||
bar() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
class C extends Base {
|
||||
foo() {
|
||||
() => {
|
||||
var obj = {
|
||||
[super.bar()]() { } // needs capture
|
||||
};
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
//// [computedPropertyNames31.js]
|
||||
var __extends = this.__extends || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
__.prototype = b.prototype;
|
||||
d.prototype = new __();
|
||||
};
|
||||
var Base = (function () {
|
||||
function Base() {
|
||||
}
|
||||
Base.prototype.bar = function () {
|
||||
return 0;
|
||||
};
|
||||
return Base;
|
||||
})();
|
||||
var C = (function (_super) {
|
||||
__extends(C, _super);
|
||||
function C() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
C.prototype.foo = function () {
|
||||
var _this = this;
|
||||
(function () {
|
||||
var obj = {
|
||||
[_super.prototype.bar.call(_this)]() {
|
||||
} // needs capture
|
||||
};
|
||||
});
|
||||
return 0;
|
||||
};
|
||||
return C;
|
||||
})(Base);
|
||||
@@ -0,0 +1,35 @@
|
||||
=== tests/cases/conformance/es6/computedProperties/computedPropertyNames31.ts ===
|
||||
class Base {
|
||||
>Base : Base
|
||||
|
||||
bar() {
|
||||
>bar : () => number
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
class C extends Base {
|
||||
>C : C
|
||||
>Base : Base
|
||||
|
||||
foo() {
|
||||
>foo : () => number
|
||||
|
||||
() => {
|
||||
>() => { var obj = { [super.bar()]() { } // needs capture }; } : () => void
|
||||
|
||||
var obj = {
|
||||
>obj : {}
|
||||
>{ [super.bar()]() { } // needs capture } : {}
|
||||
|
||||
[super.bar()]() { } // needs capture
|
||||
>super.bar() : number
|
||||
>super.bar : () => number
|
||||
>super : Base
|
||||
>bar : () => number
|
||||
|
||||
};
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames32.ts(6,10): error TS2466: A computed property name cannot reference a type parameter from its containing type.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames32.ts (1 errors) ====
|
||||
function foo<T>() { return '' }
|
||||
class C<T> {
|
||||
bar() {
|
||||
return 0;
|
||||
}
|
||||
[foo<T>()]() { }
|
||||
~
|
||||
!!! error TS2466: A computed property name cannot reference a type parameter from its containing type.
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
//// [computedPropertyNames32.ts]
|
||||
function foo<T>() { return '' }
|
||||
class C<T> {
|
||||
bar() {
|
||||
return 0;
|
||||
}
|
||||
[foo<T>()]() { }
|
||||
}
|
||||
|
||||
//// [computedPropertyNames32.js]
|
||||
function foo() {
|
||||
return '';
|
||||
}
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.bar = function () {
|
||||
return 0;
|
||||
};
|
||||
C.prototype[foo()] = function () {
|
||||
};
|
||||
return C;
|
||||
})();
|
||||
@@ -0,0 +1,27 @@
|
||||
//// [computedPropertyNames33.ts]
|
||||
function foo<T>() { return '' }
|
||||
class C<T> {
|
||||
bar() {
|
||||
var obj = {
|
||||
[foo<T>()]() { }
|
||||
};
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
//// [computedPropertyNames33.js]
|
||||
function foo() {
|
||||
return '';
|
||||
}
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.bar = function () {
|
||||
var obj = {
|
||||
[foo()]() {
|
||||
}
|
||||
};
|
||||
return 0;
|
||||
};
|
||||
return C;
|
||||
})();
|
||||
@@ -0,0 +1,25 @@
|
||||
=== tests/cases/conformance/es6/computedProperties/computedPropertyNames33.ts ===
|
||||
function foo<T>() { return '' }
|
||||
>foo : <T>() => string
|
||||
>T : T
|
||||
|
||||
class C<T> {
|
||||
>C : C<T>
|
||||
>T : T
|
||||
|
||||
bar() {
|
||||
>bar : () => number
|
||||
|
||||
var obj = {
|
||||
>obj : {}
|
||||
>{ [foo<T>()]() { } } : {}
|
||||
|
||||
[foo<T>()]() { }
|
||||
>foo<T>() : string
|
||||
>foo : <T>() => string
|
||||
>T : T
|
||||
|
||||
};
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user