Merged branch 'master' into resolveDecoratorAsCall

This commit is contained in:
Ron Buckton
2015-05-29 12:25:25 -07:00
33 changed files with 3600 additions and 111 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",
+2
View File
@@ -5,6 +5,8 @@
[![Downloads](http://img.shields.io/npm/dm/TypeScript.svg)](https://npmjs.org/package/typescript)
# TypeScript
[![Join the chat at https://gitter.im/Microsoft/TypeScript](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/Microsoft/TypeScript?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[TypeScript](http://www.typescriptlang.org/) is a language for application-scale JavaScript. TypeScript adds optional types, classes, and modules to JavaScript. TypeScript supports tools for large-scale JavaScript applications for any browser, for any host, on any OS. TypeScript compiles to readable, standards-based JavaScript. Try it out at the [playground](http://www.typescriptlang.org/Playground), and stay up to date via [our blog](http://blogs.msdn.com/typescript) and [twitter account](https://twitter.com/typescriptlang).
+13
View File
@@ -3873,6 +3873,18 @@ module ts {
}
function instantiateAnonymousType(type: ObjectType, mapper: TypeMapper): ObjectType {
// If this type has already been instantiated using this mapper, returned the cached result. This guards against
// infinite instantiations of cyclic types, e.g. "var x: { a: T, b: typeof x };"
if (mapper.mappings) {
let cached = <ObjectType>mapper.mappings[type.id];
if (cached) {
return cached;
}
}
else {
mapper.mappings = {};
}
// Instantiate the given type using the given mapper and cache the result
let result = <ResolvedType>createObjectType(TypeFlags.Anonymous, type.symbol);
result.properties = instantiateList(getPropertiesOfObjectType(type), mapper, instantiateSymbol);
result.members = createSymbolTable(result.properties);
@@ -3882,6 +3894,7 @@ module ts {
let numberIndexType = getIndexTypeOfType(type, IndexKind.Number);
if (stringIndexType) result.stringIndexType = instantiateType(stringIndexType, mapper);
if (numberIndexType) result.numberIndexType = instantiateType(numberIndexType, mapper);
mapper.mappings[type.id] = result;
return result;
}
+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);
@@ -174,12 +174,13 @@ module ts {
Type_expected_0_is_a_reserved_word_in_strict_mode: { code: 1215, category: DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode" },
Type_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1216, category: DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." },
Export_assignment_is_not_supported_when_module_flag_is_system: { code: 1218, category: DiagnosticCategory.Error, key: "Export assignment is not supported when '--module' flag is 'system'." },
The_return_type_of_a_property_decorator_function_must_be_either_void_or_any: { code: 1219, category: DiagnosticCategory.Error, key: "The return type of a property decorator function must be either 'void' or 'any'." },
The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any: { code: 1220, category: DiagnosticCategory.Error, key: "The return type of a parameter decorator function must be either 'void' or 'any'." },
Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression: { code: 1221, category: DiagnosticCategory.Error, key: "Unable to resolve signature of class decorator when called as an expression." },
Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression: { code: 1222, category: DiagnosticCategory.Error, key: "Unable to resolve signature of parameter decorator when called as an expression." },
Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression: { code: 1223, category: DiagnosticCategory.Error, key: "Unable to resolve signature of property decorator when called as an expression." },
Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression: { code: 1224, category: DiagnosticCategory.Error, key: "Unable to resolve signature of method decorator when called as an expression." },
_0_tag_already_specified: { code: 1219, category: DiagnosticCategory.Error, key: "'{0}' tag already specified." },
The_return_type_of_a_property_decorator_function_must_be_either_void_or_any: { code: 1220, category: DiagnosticCategory.Error, key: "The return type of a property decorator function must be either 'void' or 'any'." },
The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any: { code: 1221, category: DiagnosticCategory.Error, key: "The return type of a parameter decorator function must be either 'void' or 'any'." },
Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression: { code: 1222, category: DiagnosticCategory.Error, key: "Unable to resolve signature of class decorator when called as an expression." },
Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression: { code: 1223, category: DiagnosticCategory.Error, key: "Unable to resolve signature of parameter decorator when called as an expression." },
Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression: { code: 1224, category: DiagnosticCategory.Error, key: "Unable to resolve signature of property decorator when called as an expression." },
Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression: { code: 1225, category: DiagnosticCategory.Error, key: "Unable to resolve signature of method decorator when called as an expression." },
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." },
+10 -10
View File
@@ -683,30 +683,34 @@
"category": "Error",
"code": 1218
},
"The return type of a property decorator function must be either 'void' or 'any'.": {
"'{0}' tag already specified.": {
"category": "Error",
"code": 1219
},
"The return type of a parameter decorator function must be either 'void' or 'any'.": {
"The return type of a property decorator function must be either 'void' or 'any'.": {
"category": "Error",
"code": 1220
},
"Unable to resolve signature of class decorator when called as an expression.": {
"The return type of a parameter decorator function must be either 'void' or 'any'.": {
"category": "Error",
"code": 1221
},
"Unable to resolve signature of parameter decorator when called as an expression.": {
"Unable to resolve signature of class decorator when called as an expression.": {
"category": "Error",
"code": 1222
},
"Unable to resolve signature of property decorator when called as an expression.": {
"Unable to resolve signature of parameter decorator when called as an expression.": {
"category": "Error",
"code": 1223
},
"Unable to resolve signature of method decorator when called as an expression.": {
"Unable to resolve signature of property decorator when called as an expression.": {
"category": "Error",
"code": 1224
},
"Unable to resolve signature of method decorator when called as an expression.": {
"category": "Error",
"code": 1225
},
"Duplicate identifier '{0}'.": {
"category": "Error",
@@ -2156,10 +2160,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
+1 -1
View File
@@ -2536,7 +2536,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
write(";");
}
function emitWithStatement(node: WhileStatement) {
function emitWithStatement(node: WithStatement) {
write("with (");
emit(node.expression);
write(")");
+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;
+144 -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>;
@@ -1589,6 +1722,7 @@ module ts {
/* @internal */
export interface TypeMapper {
(t: TypeParameter): Type;
mappings?: Map<Type>; // Type mapping cache
}
/* @internal */
+93 -1
View File
@@ -468,6 +468,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) {
@@ -830,7 +836,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) {
@@ -856,6 +862,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;
}
@@ -1707,6 +1785,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.
@@ -2000,4 +2082,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);
+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[];
}
+5 -1
View File
@@ -231,7 +231,7 @@ module ts.formatting {
this.NoSpaceBeforeOpenBracket = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.OpenBracketToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
this.NoSpaceAfterOpenBracket = new Rule(RuleDescriptor.create3(SyntaxKind.OpenBracketToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
this.NoSpaceBeforeCloseBracket = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.CloseBracketToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
this.NoSpaceAfterCloseBracket = new Rule(RuleDescriptor.create3(SyntaxKind.CloseBracketToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
this.NoSpaceAfterCloseBracket = new Rule(RuleDescriptor.create3(SyntaxKind.CloseBracketToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBeforeBlockInFunctionDeclarationContext), RuleAction.Delete));
// Place a space before open brace in a function declaration
this.FunctionOpenBraceLeftTokenRange = Shared.TokenRange.AnyIncludingMultilineComments;
@@ -650,6 +650,10 @@ module ts.formatting {
return context.TokensAreOnSameLine();
}
static IsNotBeforeBlockInFunctionDeclarationContext(context: FormattingContext): boolean {
return !Rules.IsFunctionDeclContext(context) && !Rules.IsBeforeBlockContext(context)
}
static IsEndOfDecoratorContextOnSameLine(context: FormattingContext): boolean {
return context.TokensAreOnSameLine() &&
context.contextNode.decorators &&
+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,36 @@
//// [cyclicTypeInstantiation.ts]
function foo<T>() {
var x: {
a: T;
b: typeof x;
};
return x;
}
function bar<T>() {
var x: {
a: T;
b: typeof x;
};
return x;
}
var a = foo<string>();
var b = bar<string>();
// Relating types of a and b produces instantiations of the cyclic anonymous types in foo and bar
a = b;
//// [cyclicTypeInstantiation.js]
function foo() {
var x;
return x;
}
function bar() {
var x;
return x;
}
var a = foo();
var b = bar();
// Relating types of a and b produces instantiations of the cyclic anonymous types in foo and bar
a = b;
@@ -0,0 +1,54 @@
=== tests/cases/compiler/cyclicTypeInstantiation.ts ===
function foo<T>() {
>foo : Symbol(foo, Decl(cyclicTypeInstantiation.ts, 0, 0))
>T : Symbol(T, Decl(cyclicTypeInstantiation.ts, 0, 13))
var x: {
>x : Symbol(x, Decl(cyclicTypeInstantiation.ts, 1, 7))
a: T;
>a : Symbol(a, Decl(cyclicTypeInstantiation.ts, 1, 12))
>T : Symbol(T, Decl(cyclicTypeInstantiation.ts, 0, 13))
b: typeof x;
>b : Symbol(b, Decl(cyclicTypeInstantiation.ts, 2, 13))
>x : Symbol(x, Decl(cyclicTypeInstantiation.ts, 1, 7))
};
return x;
>x : Symbol(x, Decl(cyclicTypeInstantiation.ts, 1, 7))
}
function bar<T>() {
>bar : Symbol(bar, Decl(cyclicTypeInstantiation.ts, 6, 1))
>T : Symbol(T, Decl(cyclicTypeInstantiation.ts, 8, 13))
var x: {
>x : Symbol(x, Decl(cyclicTypeInstantiation.ts, 9, 7))
a: T;
>a : Symbol(a, Decl(cyclicTypeInstantiation.ts, 9, 12))
>T : Symbol(T, Decl(cyclicTypeInstantiation.ts, 8, 13))
b: typeof x;
>b : Symbol(b, Decl(cyclicTypeInstantiation.ts, 10, 13))
>x : Symbol(x, Decl(cyclicTypeInstantiation.ts, 9, 7))
};
return x;
>x : Symbol(x, Decl(cyclicTypeInstantiation.ts, 9, 7))
}
var a = foo<string>();
>a : Symbol(a, Decl(cyclicTypeInstantiation.ts, 16, 3))
>foo : Symbol(foo, Decl(cyclicTypeInstantiation.ts, 0, 0))
var b = bar<string>();
>b : Symbol(b, Decl(cyclicTypeInstantiation.ts, 17, 3))
>bar : Symbol(bar, Decl(cyclicTypeInstantiation.ts, 6, 1))
// Relating types of a and b produces instantiations of the cyclic anonymous types in foo and bar
a = b;
>a : Symbol(a, Decl(cyclicTypeInstantiation.ts, 16, 3))
>b : Symbol(b, Decl(cyclicTypeInstantiation.ts, 17, 3))
@@ -0,0 +1,57 @@
=== tests/cases/compiler/cyclicTypeInstantiation.ts ===
function foo<T>() {
>foo : <T>() => { a: T; b: any; }
>T : T
var x: {
>x : { a: T; b: any; }
a: T;
>a : T
>T : T
b: typeof x;
>b : { a: T; b: any; }
>x : { a: T; b: any; }
};
return x;
>x : { a: T; b: any; }
}
function bar<T>() {
>bar : <T>() => { a: T; b: any; }
>T : T
var x: {
>x : { a: T; b: any; }
a: T;
>a : T
>T : T
b: typeof x;
>b : { a: T; b: any; }
>x : { a: T; b: any; }
};
return x;
>x : { a: T; b: any; }
}
var a = foo<string>();
>a : { a: string; b: any; }
>foo<string>() : { a: string; b: any; }
>foo : <T>() => { a: T; b: any; }
var b = bar<string>();
>b : { a: string; b: any; }
>bar<string>() : { a: string; b: any; }
>bar : <T>() => { a: T; b: any; }
// Relating types of a and b produces instantiations of the cyclic anonymous types in foo and bar
a = b;
>a = b : { a: string; b: any; }
>a : { a: string; b: any; }
>b : { a: string; b: any; }
@@ -1,4 +1,4 @@
tests/cases/conformance/decorators/class/decoratorOnClass8.ts(3,1): error TS1221: Unable to resolve signature of class decorator when called as an expression.
tests/cases/conformance/decorators/class/decoratorOnClass8.ts(3,1): error TS1222: Unable to resolve signature of class decorator when called as an expression.
Supplied parameters do not match any signature of call target.
@@ -7,7 +7,7 @@ tests/cases/conformance/decorators/class/decoratorOnClass8.ts(3,1): error TS1221
@dec()
~~~~~~
!!! error TS1221: Unable to resolve signature of class decorator when called as an expression.
!!! error TS1221: Supplied parameters do not match any signature of call target.
!!! error TS1222: Unable to resolve signature of class decorator when called as an expression.
!!! error TS1222: Supplied parameters do not match any signature of call target.
class C {
}
@@ -1,4 +1,4 @@
tests/cases/conformance/decorators/class/method/decoratorOnClassMethod6.ts(4,5): error TS1224: Unable to resolve signature of method decorator when called as an expression.
tests/cases/conformance/decorators/class/method/decoratorOnClassMethod6.ts(4,5): error TS1225: Unable to resolve signature of method decorator when called as an expression.
Supplied parameters do not match any signature of call target.
@@ -8,6 +8,6 @@ tests/cases/conformance/decorators/class/method/decoratorOnClassMethod6.ts(4,5):
class C {
@dec ["method"]() {}
~~~~
!!! error TS1224: Unable to resolve signature of method decorator when called as an expression.
!!! error TS1224: Supplied parameters do not match any signature of call target.
!!! error TS1225: Unable to resolve signature of method decorator when called as an expression.
!!! error TS1225: Supplied parameters do not match any signature of call target.
}
@@ -1,4 +1,4 @@
tests/cases/conformance/decorators/class/method/decoratorOnClassMethod8.ts(4,5): error TS1224: Unable to resolve signature of method decorator when called as an expression.
tests/cases/conformance/decorators/class/method/decoratorOnClassMethod8.ts(4,5): error TS1225: Unable to resolve signature of method decorator when called as an expression.
Supplied parameters do not match any signature of call target.
@@ -8,6 +8,6 @@ tests/cases/conformance/decorators/class/method/decoratorOnClassMethod8.ts(4,5):
class C {
@dec method() {}
~~~~
!!! error TS1224: Unable to resolve signature of method decorator when called as an expression.
!!! error TS1224: Supplied parameters do not match any signature of call target.
!!! error TS1225: Unable to resolve signature of method decorator when called as an expression.
!!! error TS1225: Supplied parameters do not match any signature of call target.
}
@@ -1,4 +1,4 @@
tests/cases/conformance/decorators/class/property/decoratorOnClassProperty11.ts(4,5): error TS1223: Unable to resolve signature of property decorator when called as an expression.
tests/cases/conformance/decorators/class/property/decoratorOnClassProperty11.ts(4,5): error TS1224: Unable to resolve signature of property decorator when called as an expression.
Supplied parameters do not match any signature of call target.
@@ -8,6 +8,6 @@ tests/cases/conformance/decorators/class/property/decoratorOnClassProperty11.ts(
class C {
@dec prop;
~~~~
!!! error TS1223: Unable to resolve signature of property decorator when called as an expression.
!!! error TS1223: Supplied parameters do not match any signature of call target.
!!! error TS1224: Unable to resolve signature of property decorator when called as an expression.
!!! error TS1224: Supplied parameters do not match any signature of call target.
}
@@ -1,4 +1,4 @@
tests/cases/conformance/decorators/class/property/decoratorOnClassProperty6.ts(4,5): error TS1223: Unable to resolve signature of property decorator when called as an expression.
tests/cases/conformance/decorators/class/property/decoratorOnClassProperty6.ts(4,5): error TS1224: Unable to resolve signature of property decorator when called as an expression.
Supplied parameters do not match any signature of call target.
@@ -8,6 +8,6 @@ tests/cases/conformance/decorators/class/property/decoratorOnClassProperty6.ts(4
class C {
@dec prop;
~~~~
!!! error TS1223: Unable to resolve signature of property decorator when called as an expression.
!!! error TS1223: Supplied parameters do not match any signature of call target.
!!! error TS1224: Unable to resolve signature of property decorator when called as an expression.
!!! error TS1224: Supplied parameters do not match any signature of call target.
}
@@ -1,4 +1,4 @@
tests/cases/conformance/decorators/class/property/decoratorOnClassProperty7.ts(4,5): error TS1223: Unable to resolve signature of property decorator when called as an expression.
tests/cases/conformance/decorators/class/property/decoratorOnClassProperty7.ts(4,5): error TS1224: Unable to resolve signature of property decorator when called as an expression.
Supplied parameters do not match any signature of call target.
@@ -8,6 +8,6 @@ tests/cases/conformance/decorators/class/property/decoratorOnClassProperty7.ts(4
class C {
@dec prop;
~~~~
!!! error TS1223: Unable to resolve signature of property decorator when called as an expression.
!!! error TS1223: Supplied parameters do not match any signature of call target.
!!! error TS1224: Unable to resolve signature of property decorator when called as an expression.
!!! error TS1224: Supplied parameters do not match any signature of call target.
}
@@ -0,0 +1,20 @@
function foo<T>() {
var x: {
a: T;
b: typeof x;
};
return x;
}
function bar<T>() {
var x: {
a: T;
b: typeof x;
};
return x;
}
var a = foo<string>();
var b = bar<string>();
// Relating types of a and b produces instantiations of the cyclic anonymous types in foo and bar
a = b;
@@ -0,0 +1,8 @@
/// <reference path="fourslash.ts"/>
/////*0*/function listAPIFiles(path: string): string[] {/*1*/ }
goTo.marker("1");
edit.insertLine("");
goTo.marker("0");
verify.currentLineContentIs("function listAPIFiles(path: string): string[] {");
+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