Merge branch 'master' of https://github.com/Microsoft/TypeScript into generators

Conflicts:
	src/compiler/diagnosticInformationMap.generated.ts
	src/compiler/diagnosticMessages.json
	tests/baselines/reference/emitArrowFunctionWhenUsingArguments14_ES6.symbols
	tests/baselines/reference/emitArrowFunctionWhenUsingArguments15_ES6.symbols
	tests/baselines/reference/emitArrowFunctionWhenUsingArguments16_ES6.symbols
	tests/baselines/reference/emitArrowFunctionWhenUsingArguments17_ES6.symbols
	tests/baselines/reference/emitArrowFunctionWhenUsingArguments18_ES6.symbols
	tests/baselines/reference/for-of37.symbols
	tests/baselines/reference/for-of38.symbols
	tests/baselines/reference/for-of40.symbols
	tests/baselines/reference/for-of45.symbols
	tests/baselines/reference/for-of50.symbols
	tests/baselines/reference/iterableArrayPattern30.symbols
	tests/baselines/reference/promiseVoidErrorCallback.symbols
	tests/baselines/reference/typedArrays.symbols
This commit is contained in:
Jason Freeman
2015-05-29 17:14:29 -07:00
47 changed files with 3780 additions and 92 deletions
+1
View File
@@ -123,6 +123,7 @@ var harnessSources = [
return path.join(harnessDirectory, f);
}).concat([
"incrementalParser.ts",
"jsDocParsing.ts",
"services/colorization.ts",
"services/documentRegistry.ts",
"services/preProcessFile.ts",
+5 -2
View File
@@ -312,8 +312,11 @@ module ts {
Debug.assert(start >= 0, "start must be non-negative, is " + start);
Debug.assert(length >= 0, "length must be non-negative, is " + length);
Debug.assert(start <= file.text.length, `start must be within the bounds of the file. ${ start } > ${ file.text.length }`);
Debug.assert(end <= file.text.length, `end must be the bounds of the file. ${ end } > ${ file.text.length }`);
if (file) {
Debug.assert(start <= file.text.length, `start must be within the bounds of the file. ${ start } > ${ file.text.length }`);
Debug.assert(end <= file.text.length, `end must be the bounds of the file. ${ end } > ${ file.text.length }`);
}
let text = getLocaleSpecificMessage(message.key);
@@ -177,6 +177,7 @@ module ts {
Generators_are_only_available_when_targeting_ECMAScript_6_or_higher: { code: 1219, category: DiagnosticCategory.Error, key: "Generators are only available when targeting ECMAScript 6 or higher." },
Generators_are_not_allowed_in_an_ambient_context: { code: 1220, category: DiagnosticCategory.Error, key: "Generators are not allowed in an ambient context." },
An_overload_signature_cannot_be_declared_as_a_generator: { code: 1221, category: DiagnosticCategory.Error, key: "An overload signature cannot be declared as a generator." },
_0_tag_already_specified: { code: 1219, category: DiagnosticCategory.Error, key: "'{0}' tag already specified." },
Duplicate_identifier_0: { code: 2300, category: DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." },
Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." },
Static_members_cannot_reference_class_type_parameters: { code: 2302, category: DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." },
@@ -541,7 +542,6 @@ module ts {
types_can_only_be_used_in_a_ts_file: { code: 8010, category: DiagnosticCategory.Error, key: "'types' can only be used in a .ts file." },
type_arguments_can_only_be_used_in_a_ts_file: { code: 8011, category: DiagnosticCategory.Error, key: "'type arguments' can only be used in a .ts file." },
parameter_modifiers_can_only_be_used_in_a_ts_file: { code: 8012, category: DiagnosticCategory.Error, key: "'parameter modifiers' can only be used in a .ts file." },
can_only_be_used_in_a_ts_file: { code: 8013, category: DiagnosticCategory.Error, key: "'?' can only be used in a .ts file." },
property_declarations_can_only_be_used_in_a_ts_file: { code: 8014, category: DiagnosticCategory.Error, key: "'property declarations' can only be used in a .ts file." },
enum_declarations_can_only_be_used_in_a_ts_file: { code: 8015, category: DiagnosticCategory.Error, key: "'enum declarations' can only be used in a .ts file." },
type_assertion_expressions_can_only_be_used_in_a_ts_file: { code: 8016, category: DiagnosticCategory.Error, key: "'type assertion expressions' can only be used in a .ts file." },
+4 -4
View File
@@ -697,6 +697,10 @@
},
"'{0}' tag already specified.": {
"category": "Error",
"code": 1219
},
"Duplicate identifier '{0}'.": {
"category": "Error",
"code": 2300
@@ -2157,10 +2161,6 @@
"category": "Error",
"code": 8012
},
"'?' can only be used in a .ts file.": {
"category": "Error",
"code": 8013
},
"'property declarations' can only be used in a .ts file.": {
"category": "Error",
"code": 8014
+840 -38
View File
File diff suppressed because it is too large Load Diff
+20 -6
View File
@@ -598,12 +598,26 @@ module ts {
ch > CharacterCodes.maxAsciiCharacter && isUnicodeIdentifierPart(ch, languageVersion);
}
/** Creates a scanner over a (possibly unspecified) range of a piece of text. */
export function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean, text?: string, onError?: ErrorCallback, start?: number, length?: number): Scanner {
let pos: number; // Current position (end position of text of current token)
let end: number; // end of text
let startPos: number; // Start position of whitespace before current token
let tokenPos: number; // Start position of text of current token
/* @internal */
// Creates a scanner over a (possibly unspecified) range of a piece of text.
export function createScanner(languageVersion: ScriptTarget,
skipTrivia: boolean,
text?: string,
onError?: ErrorCallback,
start?: number,
length?: number): Scanner {
// Current position (end position of text of current token)
let pos: number;
// end of text
let end: number;
// Start position of whitespace before current token
let startPos: number;
// Start position of text of current token
let tokenPos: number;
let token: SyntaxKind;
let tokenValue: string;
let precedingLineBreak: boolean;
+143 -10
View File
@@ -270,6 +270,32 @@ module ts {
// Top-level nodes
SourceFile,
// JSDoc nodes.
JSDocTypeExpression,
// The * type.
JSDocAllType,
// The ? type.
JSDocUnknownType,
JSDocArrayType,
JSDocUnionType,
JSDocTupleType,
JSDocNullableType,
JSDocNonNullableType,
JSDocRecordType,
JSDocRecordMember,
JSDocTypeReference,
JSDocOptionalType,
JSDocFunctionType,
JSDocVariadicType,
JSDocConstructorType,
JSDocThisType,
JSDocComment,
JSDocTag,
JSDocParameterTag,
JSDocReturnTag,
JSDocTypeTag,
JSDocTemplateTag,
// Synthesized list
SyntaxList,
// Enum value count
@@ -324,6 +350,8 @@ module ts {
/* @internal */
export const enum ParserContextFlags {
None = 0,
// Set if this node was parsed in strict mode. Used for grammar error checks, as well as
// checking if the node can be reused in incremental settings.
StrictMode = 1 << 0,
@@ -345,6 +373,10 @@ module ts {
// error.
ThisNodeHasError = 1 << 5,
// This node was parsed in a JavaScript file and can be processed differently. For example
// its type can be specified usign a JSDoc comment.
JavaScriptFile = 1 << 6,
// Context flags set directly by the parser.
ParserGeneratedFlags = StrictMode | DisallowIn | Yield | GeneratorParameter | Decorator | ThisNodeHasError,
@@ -352,10 +384,10 @@ module ts {
// Used during incremental parsing to determine if this node or any of its children had an
// error. Computed only once and then cached.
ThisNodeOrAnySubNodesHasError = 1 << 6,
ThisNodeOrAnySubNodesHasError = 1 << 7,
// Used to know if we've computed data from children and cached it in this node.
HasAggregatedChildData = 1 << 7
HasAggregatedChildData = 1 << 8
}
/* @internal */
@@ -371,14 +403,15 @@ module ts {
// Specific context the parser was in when this node was created. Normally undefined.
// Only set when the parser was in some interesting context (like async/yield).
/* @internal */ parserContextFlags?: ParserContextFlags;
decorators?: NodeArray<Decorator>; // Array of decorators (in document order)
modifiers?: ModifiersArray; // Array of modifiers
/* @internal */ id?: number; // Unique id (used to look up NodeLinks)
parent?: Node; // Parent node (initialized by binding)
/* @internal */ symbol?: Symbol; // Symbol declared by node (initialized by binding)
/* @internal */ locals?: SymbolTable; // Locals associated with node (initialized by binding)
/* @internal */ nextContainer?: Node; // Next container in declaration order (initialized by binding)
/* @internal */ localSymbol?: Symbol; // Local symbol declared by node (initialized by binding only for exported nodes)
decorators?: NodeArray<Decorator>; // Array of decorators (in document order)
modifiers?: ModifiersArray; // Array of modifiers
/* @internal */ id?: number; // Unique id (used to look up NodeLinks)
parent?: Node; // Parent node (initialized by binding
/* @internal */ jsDocComment?: JSDocComment; // JSDoc for the node, if it has any. Only for .js files.
/* @internal */ symbol?: Symbol; // Symbol declared by node (initialized by binding)
/* @internal */ locals?: SymbolTable; // Locals associated with node (initialized by binding)
/* @internal */ nextContainer?: Node; // Next container in declaration order (initialized by binding)
/* @internal */ localSymbol?: Symbol; // Local symbol declared by node (initialized by binding only for exported nodes)
}
export interface NodeArray<T> extends Array<T>, TextRange {
@@ -992,6 +1025,106 @@ module ts {
kind: SyntaxKind;
}
// represents a top level: { type } expression in a JSDoc comment.
export interface JSDocTypeExpression extends Node {
type: JSDocType;
}
export interface JSDocType extends TypeNode {
_jsDocTypeBrand: any;
}
export interface JSDocAllType extends JSDocType {
_JSDocAllTypeBrand: any;
}
export interface JSDocUnknownType extends JSDocType {
_JSDocUnknownTypeBrand: any;
}
export interface JSDocArrayType extends JSDocType {
elementType: JSDocType;
}
export interface JSDocUnionType extends JSDocType {
types: NodeArray<JSDocType>;
}
export interface JSDocTupleType extends JSDocType {
types: NodeArray<JSDocType>;
}
export interface JSDocNonNullableType extends JSDocType {
type: JSDocType;
}
export interface JSDocNullableType extends JSDocType {
type: JSDocType;
}
export interface JSDocRecordType extends JSDocType, TypeLiteralNode {
members: NodeArray<JSDocRecordMember>;
}
export interface JSDocTypeReference extends JSDocType {
name: EntityName;
typeArguments: NodeArray<JSDocType>
}
export interface JSDocOptionalType extends JSDocType {
type: JSDocType;
}
export interface JSDocFunctionType extends JSDocType, SignatureDeclaration {
parameters: NodeArray<ParameterDeclaration>;
type: JSDocType;
}
export interface JSDocVariadicType extends JSDocType {
type: JSDocType;
}
export interface JSDocConstructorType extends JSDocType {
type: JSDocType;
}
export interface JSDocThisType extends JSDocType {
type: JSDocType;
}
export interface JSDocRecordMember extends PropertyDeclaration {
name: Identifier | LiteralExpression,
type?: JSDocType
}
export interface JSDocComment extends Node {
tags: NodeArray<JSDocTag>;
}
export interface JSDocTag extends Node {
atToken: Node;
tagName: Identifier;
}
export interface JSDocTemplateTag extends JSDocTag {
typeParameters: NodeArray<TypeParameterDeclaration>;
}
export interface JSDocReturnTag extends JSDocTag {
typeExpression: JSDocTypeExpression;
}
export interface JSDocTypeTag extends JSDocTag {
typeExpression: JSDocTypeExpression;
}
export interface JSDocParameterTag extends JSDocTag {
preParameterName?: Identifier;
typeExpression?: JSDocTypeExpression;
postParameterName?: Identifier;
isBracketed: boolean;
}
// Source files are declarations when they are external modules.
export interface SourceFile extends Declaration {
statements: NodeArray<ModuleElement>;
+93 -1
View File
@@ -595,6 +595,12 @@ module ts {
return false;
}
export function isClassLike(node: Node): boolean {
if (node) {
return node.kind === SyntaxKind.ClassDeclaration || node.kind === SyntaxKind.ClassExpression;
}
}
export function isFunctionLike(node: Node): boolean {
if (node) {
switch (node.kind) {
@@ -958,7 +964,7 @@ module ts {
}
export function hasDotDotDotToken(node: Node) {
return node && node.kind === SyntaxKind.Parameter && (<ParameterDeclaration>node).dotDotDotToken !== undefined;
return node && node.kind === SyntaxKind.Parameter && (<ParameterDeclaration>node).dotDotDotToken !== undefined;
}
export function hasQuestionToken(node: Node) {
@@ -984,6 +990,78 @@ module ts {
return s.parameters.length > 0 && lastOrUndefined(s.parameters).dotDotDotToken !== undefined;
}
export function isJSDocConstructSignature(node: Node) {
return node.kind === SyntaxKind.JSDocFunctionType &&
(<JSDocFunctionType>node).parameters.length > 0 &&
(<JSDocFunctionType>node).parameters[0].type.kind === SyntaxKind.JSDocConstructorType;
}
function getJSDocTag(node: Node, kind: SyntaxKind): JSDocTag {
if (node && node.jsDocComment) {
for (let tag of node.jsDocComment.tags) {
if (tag.kind === kind) {
return tag;
}
}
}
}
export function getJSDocTypeTag(node: Node): JSDocTypeTag {
return <JSDocTypeTag>getJSDocTag(node, SyntaxKind.JSDocTypeTag);
}
export function getJSDocReturnTag(node: Node): JSDocReturnTag {
return <JSDocReturnTag>getJSDocTag(node, SyntaxKind.JSDocReturnTag);
}
export function getJSDocTemplateTag(node: Node): JSDocTemplateTag {
return <JSDocTemplateTag>getJSDocTag(node, SyntaxKind.JSDocTemplateTag);
}
export function getCorrespondingJSDocParameterTag(parameter: ParameterDeclaration): JSDocParameterTag {
if (parameter.name && parameter.name.kind === SyntaxKind.Identifier) {
// If it's a parameter, see if the parent has a jsdoc comment with an @param
// annotation.
let parameterName = (<Identifier>parameter.name).text;
let docComment = parameter.parent.jsDocComment;
if (docComment) {
return <JSDocParameterTag>forEach(docComment.tags, t => {
if (t.kind === SyntaxKind.JSDocParameterTag) {
let parameterTag = <JSDocParameterTag>t;
let name = parameterTag.preParameterName || parameterTag.postParameterName;
if (name.text === parameterName) {
return t;
}
}
});
}
}
}
export function hasRestParameter(s: SignatureDeclaration): boolean {
return isRestParameter(lastOrUndefined(s.parameters));
}
export function isRestParameter(node: ParameterDeclaration) {
if (node) {
if (node.parserContextFlags & ParserContextFlags.JavaScriptFile) {
if (node.type && node.type.kind === SyntaxKind.JSDocVariadicType) {
return true;
}
let paramTag = getCorrespondingJSDocParameterTag(node);
if (paramTag && paramTag.typeExpression) {
return paramTag.typeExpression.type.kind === SyntaxKind.JSDocVariadicType;
}
}
return node.dotDotDotToken !== undefined;
}
return false;
}
export function isLiteralKind(kind: SyntaxKind): boolean {
return SyntaxKind.FirstLiteralToken <= kind && kind <= SyntaxKind.LastLiteralToken;
}
@@ -1835,6 +1913,10 @@ module ts {
return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & NodeFlags.Default) ? symbol.valueDeclaration.localSymbol : undefined;
}
export function isJavaScript(fileName: string) {
return fileExtensionIs(fileName, ".js");
}
/**
* Replace each instance of non-ascii characters by one, two, three, or four escape sequences
* representing the UTF-8 encoding of the character, and return the expanded char code list.
@@ -2128,4 +2210,14 @@ module ts {
return createTextChangeRange(createTextSpanFromBounds(oldStartN, oldEndN), /*newLength:*/ newEndN - oldStartN);
}
export function getTypeParameterOwner(d: Declaration): Declaration {
if (d && d.kind === SyntaxKind.TypeParameter) {
for (let current: Node = d; current; current = current.parent) {
if (isFunctionLike(current) || isClassLike(current) || current.kind === SyntaxKind.InterfaceDeclaration) {
return <Declaration>current;
}
}
}
}
}
+9
View File
@@ -798,8 +798,17 @@ module FourSlash {
return "\nActual " + name + ":\n\t" + actualValue + "\nExpected value:\n\t" + expectedValue;
}
public getSyntacticDiagnostics(expected: string) {
var diagnostics = this.languageService.getSyntacticDiagnostics(this.activeFile.fileName);
this.testDiagnostics(expected, diagnostics);
}
public getSemanticDiagnostics(expected: string) {
var diagnostics = this.languageService.getSemanticDiagnostics(this.activeFile.fileName);
this.testDiagnostics(expected, diagnostics);
}
private testDiagnostics(expected: string, diagnostics: ts.Diagnostic[]) {
var realized = ts.realizeDiagnostics(diagnostics, "\r\n");
var actual = JSON.stringify(realized, null, " ");
assert.equal(actual, expected);
+13 -3
View File
@@ -193,12 +193,16 @@ module Utils {
};
}
export function sourceFileToJSON(file: ts.SourceFile): string {
export function sourceFileToJSON(file: ts.Node): string {
return JSON.stringify(file,(k, v) => {
return isNodeOrArray(v) ? serializeNode(v) : v;
}, " ");
function getKindName(k: number): string {
function getKindName(k: number | string): string {
if (typeof k === "string") {
return k;
}
return (<any>ts).SyntaxKind[k]
}
@@ -231,7 +235,9 @@ module Utils {
function serializeNode(n: ts.Node): any {
var o: any = { kind: getKindName(n.kind) };
o.containsParseError = ts.containsParseError(n);
if (ts.containsParseError(n)) {
o.containsParseError = true;
}
ts.forEach(Object.getOwnPropertyNames(n), propertyName => {
switch (propertyName) {
@@ -249,6 +255,10 @@ module Utils {
// Blacklist of items we never put in the baseline file.
break;
case "originalKeywordKind":
o[propertyName] = getKindName((<any>n)[propertyName]);
break;
case "flags":
// Print out flags with their enum names.
o[propertyName] = getNodeFlagName(n.flags);
+5
View File
@@ -316,6 +316,11 @@ interface Array<T> {
copyWithin(target: number, start: number, end?: number): T[];
}
interface IArguments {
/** Iterator */
[Symbol.iterator](): IterableIterator<any>;
}
interface ArrayConstructor {
/**
* Creates an array from an array-like object.
+8 -8
View File
@@ -62,10 +62,10 @@ declare module Intl {
resolvedOptions(): ResolvedNumberFormatOptions;
}
var NumberFormat: {
new (locales?: string[], options?: NumberFormatOptions): Collator;
new (locale?: string, options?: NumberFormatOptions): Collator;
(locales?: string[], options?: NumberFormatOptions): Collator;
(locale?: string, options?: NumberFormatOptions): Collator;
new (locales?: string[], options?: NumberFormatOptions): NumberFormat;
new (locale?: string, options?: NumberFormatOptions): NumberFormat;
(locales?: string[], options?: NumberFormatOptions): NumberFormat;
(locale?: string, options?: NumberFormatOptions): NumberFormat;
supportedLocalesOf(locales: string[], options?: NumberFormatOptions): string[];
supportedLocalesOf(locale: string, options?: NumberFormatOptions): string[];
}
@@ -107,10 +107,10 @@ declare module Intl {
resolvedOptions(): ResolvedDateTimeFormatOptions;
}
var DateTimeFormat: {
new (locales?: string[], options?: DateTimeFormatOptions): Collator;
new (locale?: string, options?: DateTimeFormatOptions): Collator;
(locales?: string[], options?: DateTimeFormatOptions): Collator;
(locale?: string, options?: DateTimeFormatOptions): Collator;
new (locales?: string[], options?: DateTimeFormatOptions): DateTimeFormat;
new (locale?: string, options?: DateTimeFormatOptions): DateTimeFormat;
(locales?: string[], options?: DateTimeFormatOptions): DateTimeFormat;
(locale?: string, options?: DateTimeFormatOptions): DateTimeFormat;
supportedLocalesOf(locales: string[], options?: DateTimeFormatOptions): string[];
supportedLocalesOf(locale: string, options?: DateTimeFormatOptions): string[];
}
+1 -1
View File
@@ -2698,7 +2698,7 @@ module ts {
return true;
}
if (parameter.questionToken) {
diagnostics.push(createDiagnosticForNode(parameter.questionToken, Diagnostics.can_only_be_used_in_a_ts_file));
diagnostics.push(createDiagnosticForNode(parameter.questionToken, Diagnostics._0_can_only_be_used_in_a_ts_file, '?'));
return true;
}
if (parameter.type) {
-4
View File
@@ -652,8 +652,4 @@ module ts {
typechecker.getSymbolDisplayBuilder().buildSignatureDisplay(signature, writer, enclosingDeclaration, flags);
});
}
export function isJavaScript(fileName: string) {
return fileExtensionIs(fileName, ".js");
}
}
@@ -0,0 +1,14 @@
tests/cases/compiler/argumentsObjectIterator01_ES5.ts(4,21): error TS2495: Type 'IArguments' is not an array type or a string type.
==== tests/cases/compiler/argumentsObjectIterator01_ES5.ts (1 errors) ====
function doubleAndReturnAsArray(x: number, y: number, z: number): [number, number, number] {
let result = [];
for (let arg of arguments) {
~~~~~~~~~
!!! error TS2495: Type 'IArguments' is not an array type or a string type.
result.push(arg + arg);
}
return <[any, any, any]>result;
}
@@ -0,0 +1,19 @@
//// [argumentsObjectIterator01_ES5.ts]
function doubleAndReturnAsArray(x: number, y: number, z: number): [number, number, number] {
let result = [];
for (let arg of arguments) {
result.push(arg + arg);
}
return <[any, any, any]>result;
}
//// [argumentsObjectIterator01_ES5.js]
function doubleAndReturnAsArray(x, y, z) {
var result = [];
for (var _i = 0; _i < arguments.length; _i++) {
var arg = arguments[_i];
result.push(arg + arg);
}
return result;
}
@@ -0,0 +1,18 @@
//// [argumentsObjectIterator01_ES6.ts]
function doubleAndReturnAsArray(x: number, y: number, z: number): [number, number, number] {
let result = [];
for (let arg of arguments) {
result.push(arg + arg);
}
return <[any, any, any]>result;
}
//// [argumentsObjectIterator01_ES6.js]
function doubleAndReturnAsArray(x, y, z) {
let result = [];
for (let arg of arguments) {
result.push(arg + arg);
}
return result;
}
@@ -0,0 +1,25 @@
=== tests/cases/compiler/argumentsObjectIterator01_ES6.ts ===
function doubleAndReturnAsArray(x: number, y: number, z: number): [number, number, number] {
>doubleAndReturnAsArray : Symbol(doubleAndReturnAsArray, Decl(argumentsObjectIterator01_ES6.ts, 0, 0))
>x : Symbol(x, Decl(argumentsObjectIterator01_ES6.ts, 1, 32))
>y : Symbol(y, Decl(argumentsObjectIterator01_ES6.ts, 1, 42))
>z : Symbol(z, Decl(argumentsObjectIterator01_ES6.ts, 1, 53))
let result = [];
>result : Symbol(result, Decl(argumentsObjectIterator01_ES6.ts, 2, 7))
for (let arg of arguments) {
>arg : Symbol(arg, Decl(argumentsObjectIterator01_ES6.ts, 3, 12))
>arguments : Symbol(arguments)
result.push(arg + arg);
>result.push : Symbol(Array.push, Decl(lib.d.ts, 1016, 29))
>result : Symbol(result, Decl(argumentsObjectIterator01_ES6.ts, 2, 7))
>push : Symbol(Array.push, Decl(lib.d.ts, 1016, 29))
>arg : Symbol(arg, Decl(argumentsObjectIterator01_ES6.ts, 3, 12))
>arg : Symbol(arg, Decl(argumentsObjectIterator01_ES6.ts, 3, 12))
}
return <[any, any, any]>result;
>result : Symbol(result, Decl(argumentsObjectIterator01_ES6.ts, 2, 7))
}
@@ -0,0 +1,29 @@
=== tests/cases/compiler/argumentsObjectIterator01_ES6.ts ===
function doubleAndReturnAsArray(x: number, y: number, z: number): [number, number, number] {
>doubleAndReturnAsArray : (x: number, y: number, z: number) => [number, number, number]
>x : number
>y : number
>z : number
let result = [];
>result : any[]
>[] : undefined[]
for (let arg of arguments) {
>arg : any
>arguments : IArguments
result.push(arg + arg);
>result.push(arg + arg) : number
>result.push : (...items: any[]) => number
>result : any[]
>push : (...items: any[]) => number
>arg + arg : any
>arg : any
>arg : any
}
return <[any, any, any]>result;
><[any, any, any]>result : [any, any, any]
>result : any[]
}
@@ -0,0 +1,18 @@
tests/cases/compiler/argumentsObjectIterator02_ES5.ts(3,26): error TS2304: Cannot find name 'Symbol'.
==== tests/cases/compiler/argumentsObjectIterator02_ES5.ts (1 errors) ====
function doubleAndReturnAsArray(x: number, y: number, z: number): [number, number, number] {
let blah = arguments[Symbol.iterator];
~~~~~~
!!! error TS2304: Cannot find name 'Symbol'.
let result = [];
for (let arg of blah()) {
result.push(arg + arg);
}
return <[any, any, any]>result;
}
@@ -0,0 +1,24 @@
//// [argumentsObjectIterator02_ES5.ts]
function doubleAndReturnAsArray(x: number, y: number, z: number): [number, number, number] {
let blah = arguments[Symbol.iterator];
let result = [];
for (let arg of blah()) {
result.push(arg + arg);
}
return <[any, any, any]>result;
}
//// [argumentsObjectIterator02_ES5.js]
function doubleAndReturnAsArray(x, y, z) {
var blah = arguments[Symbol.iterator];
var result = [];
for (var _i = 0, _a = blah(); _i < _a.length; _i++) {
var arg = _a[_i];
result.push(arg + arg);
}
return result;
}
@@ -0,0 +1,23 @@
//// [argumentsObjectIterator02_ES6.ts]
function doubleAndReturnAsArray(x: number, y: number, z: number): [number, number, number] {
let blah = arguments[Symbol.iterator];
let result = [];
for (let arg of blah()) {
result.push(arg + arg);
}
return <[any, any, any]>result;
}
//// [argumentsObjectIterator02_ES6.js]
function doubleAndReturnAsArray(x, y, z) {
let blah = arguments[Symbol.iterator];
let result = [];
for (let arg of blah()) {
result.push(arg + arg);
}
return result;
}
@@ -0,0 +1,34 @@
=== tests/cases/compiler/argumentsObjectIterator02_ES6.ts ===
function doubleAndReturnAsArray(x: number, y: number, z: number): [number, number, number] {
>doubleAndReturnAsArray : Symbol(doubleAndReturnAsArray, Decl(argumentsObjectIterator02_ES6.ts, 0, 0))
>x : Symbol(x, Decl(argumentsObjectIterator02_ES6.ts, 1, 32))
>y : Symbol(y, Decl(argumentsObjectIterator02_ES6.ts, 1, 42))
>z : Symbol(z, Decl(argumentsObjectIterator02_ES6.ts, 1, 53))
let blah = arguments[Symbol.iterator];
>blah : Symbol(blah, Decl(argumentsObjectIterator02_ES6.ts, 2, 7))
>arguments : Symbol(arguments)
>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31))
>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11))
>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31))
let result = [];
>result : Symbol(result, Decl(argumentsObjectIterator02_ES6.ts, 4, 7))
for (let arg of blah()) {
>arg : Symbol(arg, Decl(argumentsObjectIterator02_ES6.ts, 5, 12))
>blah : Symbol(blah, Decl(argumentsObjectIterator02_ES6.ts, 2, 7))
result.push(arg + arg);
>result.push : Symbol(Array.push, Decl(lib.d.ts, 1016, 29))
>result : Symbol(result, Decl(argumentsObjectIterator02_ES6.ts, 4, 7))
>push : Symbol(Array.push, Decl(lib.d.ts, 1016, 29))
>arg : Symbol(arg, Decl(argumentsObjectIterator02_ES6.ts, 5, 12))
>arg : Symbol(arg, Decl(argumentsObjectIterator02_ES6.ts, 5, 12))
}
return <[any, any, any]>result;
>result : Symbol(result, Decl(argumentsObjectIterator02_ES6.ts, 4, 7))
}
@@ -0,0 +1,40 @@
=== tests/cases/compiler/argumentsObjectIterator02_ES6.ts ===
function doubleAndReturnAsArray(x: number, y: number, z: number): [number, number, number] {
>doubleAndReturnAsArray : (x: number, y: number, z: number) => [number, number, number]
>x : number
>y : number
>z : number
let blah = arguments[Symbol.iterator];
>blah : () => IterableIterator<any>
>arguments[Symbol.iterator] : () => IterableIterator<any>
>arguments : IArguments
>Symbol.iterator : symbol
>Symbol : SymbolConstructor
>iterator : symbol
let result = [];
>result : any[]
>[] : undefined[]
for (let arg of blah()) {
>arg : any
>blah() : IterableIterator<any>
>blah : () => IterableIterator<any>
result.push(arg + arg);
>result.push(arg + arg) : number
>result.push : (...items: any[]) => number
>result : any[]
>push : (...items: any[]) => number
>arg + arg : any
>arg : any
>arg : any
}
return <[any, any, any]>result;
><[any, any, any]>result : [any, any, any]
>result : any[]
}
@@ -0,0 +1,14 @@
tests/cases/compiler/argumentsObjectIterator03_ES5.ts(3,9): error TS2461: Type 'IArguments' is not an array type.
==== tests/cases/compiler/argumentsObjectIterator03_ES5.ts (1 errors) ====
function asReversedTuple(a: number, b: string, c: boolean): [boolean, string, number] {
let [x, y, z] = arguments;
~~~~~~~~~
!!! error TS2461: Type 'IArguments' is not an array type.
return [z, y, x];
}
@@ -0,0 +1,15 @@
//// [argumentsObjectIterator03_ES5.ts]
function asReversedTuple(a: number, b: string, c: boolean): [boolean, string, number] {
let [x, y, z] = arguments;
return [z, y, x];
}
//// [argumentsObjectIterator03_ES5.js]
function asReversedTuple(a, b, c) {
var x = arguments[0], y = arguments[1], z = arguments[2];
return [z, y, x];
}
@@ -0,0 +1,15 @@
//// [argumentsObjectIterator03_ES6.ts]
function asReversedTuple(a: number, b: string, c: boolean): [boolean, string, number] {
let [x, y, z] = arguments;
return [z, y, x];
}
//// [argumentsObjectIterator03_ES6.js]
function asReversedTuple(a, b, c) {
let [x, y, z] = arguments;
return [z, y, x];
}
@@ -0,0 +1,21 @@
=== tests/cases/compiler/argumentsObjectIterator03_ES6.ts ===
function asReversedTuple(a: number, b: string, c: boolean): [boolean, string, number] {
>asReversedTuple : Symbol(asReversedTuple, Decl(argumentsObjectIterator03_ES6.ts, 0, 0))
>a : Symbol(a, Decl(argumentsObjectIterator03_ES6.ts, 1, 25))
>b : Symbol(b, Decl(argumentsObjectIterator03_ES6.ts, 1, 35))
>c : Symbol(c, Decl(argumentsObjectIterator03_ES6.ts, 1, 46))
let [x, y, z] = arguments;
>x : Symbol(x, Decl(argumentsObjectIterator03_ES6.ts, 2, 9))
>y : Symbol(y, Decl(argumentsObjectIterator03_ES6.ts, 2, 11))
>z : Symbol(z, Decl(argumentsObjectIterator03_ES6.ts, 2, 14))
>arguments : Symbol(arguments)
return [z, y, x];
>z : Symbol(z, Decl(argumentsObjectIterator03_ES6.ts, 2, 14))
>y : Symbol(y, Decl(argumentsObjectIterator03_ES6.ts, 2, 11))
>x : Symbol(x, Decl(argumentsObjectIterator03_ES6.ts, 2, 9))
}
@@ -0,0 +1,22 @@
=== tests/cases/compiler/argumentsObjectIterator03_ES6.ts ===
function asReversedTuple(a: number, b: string, c: boolean): [boolean, string, number] {
>asReversedTuple : (a: number, b: string, c: boolean) => [boolean, string, number]
>a : number
>b : string
>c : boolean
let [x, y, z] = arguments;
>x : any
>y : any
>z : any
>arguments : IArguments
return [z, y, x];
>[z, y, x] : [any, any, any]
>z : any
>y : any
>x : any
}
@@ -79,7 +79,7 @@ interface myArray2 extends Array<Number|String> { }
>myArray2 : Symbol(myArray2, Decl(arrayLiterals2ES6.ts, 42, 43))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1439, 1))
>Number : Symbol(Number, Decl(lib.d.ts, 456, 40), Decl(lib.d.ts, 518, 11))
>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1538, 1))
>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1543, 1))
var d0 = [1, true, ...temp, ]; // has type (string|number|boolean)[]
>d0 : Symbol(d0, Decl(arrayLiterals2ES6.ts, 44, 3))
@@ -9,17 +9,17 @@
type arrayString = Array<String>
>arrayString : Symbol(arrayString, Decl(destructuringParameterDeclaration3ES5.ts, 0, 0))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1439, 1))
>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1538, 1))
>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1543, 1))
type someArray = Array<String> | number[];
>someArray : Symbol(someArray, Decl(destructuringParameterDeclaration3ES5.ts, 7, 32))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1439, 1))
>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1538, 1))
>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1543, 1))
type stringOrNumArray = Array<String|Number>;
>stringOrNumArray : Symbol(stringOrNumArray, Decl(destructuringParameterDeclaration3ES5.ts, 8, 42))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1439, 1))
>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1538, 1))
>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1543, 1))
>Number : Symbol(Number, Decl(lib.d.ts, 456, 40), Decl(lib.d.ts, 518, 11))
function a1(...x: (number|string)[]) { }
@@ -34,7 +34,7 @@ function a3(...a: Array<String>) { }
>a3 : Symbol(a3, Decl(destructuringParameterDeclaration3ES5.ts, 12, 21))
>a : Symbol(a, Decl(destructuringParameterDeclaration3ES5.ts, 13, 12))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1439, 1))
>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1538, 1))
>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1543, 1))
function a4(...a: arrayString) { }
>a4 : Symbol(a4, Decl(destructuringParameterDeclaration3ES5.ts, 13, 36))
@@ -9,17 +9,17 @@
type arrayString = Array<String>
>arrayString : Symbol(arrayString, Decl(destructuringParameterDeclaration3ES6.ts, 0, 0))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1439, 1))
>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1538, 1))
>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1543, 1))
type someArray = Array<String> | number[];
>someArray : Symbol(someArray, Decl(destructuringParameterDeclaration3ES6.ts, 7, 32))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1439, 1))
>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1538, 1))
>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1543, 1))
type stringOrNumArray = Array<String|Number>;
>stringOrNumArray : Symbol(stringOrNumArray, Decl(destructuringParameterDeclaration3ES6.ts, 8, 42))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1439, 1))
>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1538, 1))
>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1543, 1))
>Number : Symbol(Number, Decl(lib.d.ts, 456, 40), Decl(lib.d.ts, 518, 11))
function a1(...x: (number|string)[]) { }
@@ -34,7 +34,7 @@ function a3(...a: Array<String>) { }
>a3 : Symbol(a3, Decl(destructuringParameterDeclaration3ES6.ts, 12, 21))
>a : Symbol(a, Decl(destructuringParameterDeclaration3ES6.ts, 13, 12))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1439, 1))
>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1538, 1))
>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1543, 1))
function a4(...a: arrayString) { }
>a4 : Symbol(a4, Decl(destructuringParameterDeclaration3ES6.ts, 13, 36))
+1 -1
View File
@@ -1,7 +1,7 @@
=== tests/cases/conformance/es6/for-ofStatements/for-of57.ts ===
var iter: Iterable<number>;
>iter : Symbol(iter, Decl(for-of57.ts, 0, 3))
>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1663, 1))
>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1668, 1))
for (let num of iter) { }
>num : Symbol(num, Decl(for-of57.ts, 1, 8))
@@ -1,7 +1,7 @@
=== tests/cases/conformance/expressions/contextualTyping/iterableContextualTyping1.ts ===
var iter: Iterable<(x: string) => number> = [s => s.length];
>iter : Symbol(iter, Decl(iterableContextualTyping1.ts, 0, 3))
>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1663, 1))
>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1668, 1))
>x : Symbol(x, Decl(iterableContextualTyping1.ts, 0, 20))
>s : Symbol(s, Decl(iterableContextualTyping1.ts, 0, 45))
>s.length : Symbol(String.length, Decl(lib.d.ts, 414, 19))
@@ -1,7 +1,7 @@
=== tests/cases/conformance/es6/spread/iteratorSpreadInArray11.ts ===
var iter: Iterable<number>;
>iter : Symbol(iter, Decl(iteratorSpreadInArray11.ts, 0, 3))
>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1663, 1))
>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1668, 1))
var array = [...iter];
>array : Symbol(array, Decl(iteratorSpreadInArray11.ts, 1, 3))
@@ -1,5 +1,5 @@
=== tests/cases/conformance/es6/templates/templateStringWithEmbeddedNewOperatorES6.ts ===
var x = `abc${ new String("Hi") }def`;
>x : Symbol(x, Decl(templateStringWithEmbeddedNewOperatorES6.ts, 0, 3))
>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1538, 1))
>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1543, 1))
@@ -0,0 +1,9 @@
//@target: ES5
function doubleAndReturnAsArray(x: number, y: number, z: number): [number, number, number] {
let result = [];
for (let arg of arguments) {
result.push(arg + arg);
}
return <[any, any, any]>result;
}
@@ -0,0 +1,9 @@
//@target: ES6
function doubleAndReturnAsArray(x: number, y: number, z: number): [number, number, number] {
let result = [];
for (let arg of arguments) {
result.push(arg + arg);
}
return <[any, any, any]>result;
}
@@ -0,0 +1,12 @@
//@target: ES5
function doubleAndReturnAsArray(x: number, y: number, z: number): [number, number, number] {
let blah = arguments[Symbol.iterator];
let result = [];
for (let arg of blah()) {
result.push(arg + arg);
}
return <[any, any, any]>result;
}
@@ -0,0 +1,12 @@
//@target: ES6
function doubleAndReturnAsArray(x: number, y: number, z: number): [number, number, number] {
let blah = arguments[Symbol.iterator];
let result = [];
for (let arg of blah()) {
result.push(arg + arg);
}
return <[any, any, any]>result;
}
@@ -0,0 +1,8 @@
//@target: ES5
function asReversedTuple(a: number, b: string, c: boolean): [boolean, string, number] {
let [x, y, z] = arguments;
return [z, y, x];
}
@@ -0,0 +1,8 @@
//@target: ES6
function asReversedTuple(a: number, b: string, c: boolean): [boolean, string, number] {
let [x, y, z] = arguments;
return [z, y, x];
}
+4
View File
@@ -448,6 +448,10 @@ module FourSlashInterface {
FourSlash.currentTestState.verifyQuickInfoDisplayParts(kind, kindModifiers, textSpan, displayParts, documentation);
}
public getSyntacticDiagnostics(expected: string) {
FourSlash.currentTestState.getSyntacticDiagnostics(expected);
}
public getSemanticDiagnostics(expected: string) {
FourSlash.currentTestState.getSemanticDiagnostics(expected);
}
@@ -10,6 +10,6 @@ verify.getSemanticDiagnostics(`[
"start": 12,
"length": 1,
"category": "error",
"code": 8013
"code": 8009
}
]`);
@@ -0,0 +1,7 @@
/// <reference path="fourslash.ts" />
// @allowNonTsExtensions: true
// @Filename: a.js
//// function foo(...a) {}
verify.getSemanticDiagnostics(`[]`);
@@ -0,0 +1,19 @@
/// <reference path="fourslash.ts" />
// @allowNonTsExtensions: true
// @Filename: a.js
//// /**
//// * @type {number}
//// * @type {string}
//// */
//// var v;
verify.getSyntacticDiagnostics(`[
{
"message": "\'type\' tag already specified.",
"start": 26,
"length": 4,
"category": "error",
"code": 1219
}
]`);
File diff suppressed because it is too large Load Diff