Merge branch 'master' into tupleTypes

This commit is contained in:
Anders Hejlsberg
2014-09-15 11:04:58 -07:00
343 changed files with 9089 additions and 5260 deletions
+57 -52
View File
@@ -3807,30 +3807,42 @@ declare var Window: {
new(): Window;
}
interface FormData {
append(name: any, value: any, blobName?: string): void;
interface HTMLCollection extends MSHTMLCollectionExtensions {
/**
* Sets or retrieves the number of objects in a collection.
*/
length: number;
/**
* Retrieves an object from various collections.
*/
item(nameOrIndex?: any, optionalIndex?: any): Element;
/**
* Retrieves a select object or an object from an options collection.
*/
namedItem(name: string): Element;
// [name: string]: Element;
[index: number]: Element;
}
declare var FormData: {
prototype: FormData;
new (form?: HTMLFormElement): FormData;
declare var HTMLCollection: {
prototype: HTMLCollection;
new(): HTMLCollection;
}
interface SourceBuffer extends EventTarget {
updating: boolean;
appendWindowStart: number;
appendWindowEnd: number;
buffered: TimeRanges;
timestampOffset: number;
audioTracks: AudioTrackList;
appendBuffer(data: ArrayBufferView): void;
appendBuffer(data: ArrayBuffer): void;
remove(start: number, end: number): void;
abort(): void;
appendStream(stream: MSStream, maxSize?: number): void;
interface BlobPropertyBag {
type?: string;
endings?: string;
}
declare var SourceBuffer: {
prototype: SourceBuffer;
new(): SourceBuffer;
interface Blob {
type: string;
size: number;
msDetachStream(): any;
slice(start?: number, end?: number, contentType?: string): Blob;
msClose(): void;
}
declare var Blob: {
prototype: Blob;
new (blobParts?: any[], options?: BlobPropertyBag): Blob;
}
interface NavigatorID {
@@ -5739,26 +5751,6 @@ declare var MSCSSProperties: {
new(): MSCSSProperties;
}
interface HTMLCollection extends MSHTMLCollectionExtensions {
/**
* Sets or retrieves the number of objects in a collection.
*/
length: number;
/**
* Retrieves an object from various collections.
*/
item(nameOrIndex?: any, optionalIndex?: any): Element;
/**
* Retrieves a select object or an object from an options collection.
*/
namedItem(name: string): Element;
// [name: string]: Element;
}
declare var HTMLCollection: {
prototype: HTMLCollection;
new(): HTMLCollection;
}
interface SVGExternalResourcesRequired {
externalResourcesRequired: SVGAnimatedBoolean;
}
@@ -11994,18 +11986,6 @@ declare var FileReader: {
new(): FileReader;
}
interface Blob {
type: string;
size: number;
msDetachStream(): any;
slice(start?: number, end?: number, contentType?: string): Blob;
msClose(): void;
}
declare var Blob: {
prototype: Blob;
new(): Blob;
}
interface ApplicationCache extends EventTarget {
status: number;
ondownloading: (ev: Event) => any;
@@ -12164,6 +12144,14 @@ declare var MSManipulationEvent: {
MS_MANIPULATION_STATE_CANCELLED: number;
}
interface FormData {
append(name: any, value: any, blobName?: string): void;
}
declare var FormData: {
prototype: FormData;
new(): FormData;
}
interface HTMLDataListElement extends HTMLElement {
options: HTMLCollection;
}
@@ -12582,6 +12570,23 @@ interface RandomSource {
getRandomValues(array: ArrayBufferView): ArrayBufferView;
}
interface SourceBuffer extends EventTarget {
updating: boolean;
appendWindowStart: number;
appendWindowEnd: number;
buffered: TimeRanges;
timestampOffset: number;
audioTracks: AudioTrackList;
appendBuffer(data: ArrayBuffer): void;
remove(start: number, end: number): void;
abort(): void;
appendStream(stream: MSStream, maxSize?: number): void;
}
declare var SourceBuffer: {
prototype: SourceBuffer;
new(): SourceBuffer;
}
interface MSInputMethodContext extends EventTarget {
oncandidatewindowshow: (ev: any) => any;
target: HTMLElement;
+57 -52
View File
@@ -2704,30 +2704,42 @@ declare var Window: {
new(): Window;
}
interface FormData {
append(name: any, value: any, blobName?: string): void;
interface HTMLCollection extends MSHTMLCollectionExtensions {
/**
* Sets or retrieves the number of objects in a collection.
*/
length: number;
/**
* Retrieves an object from various collections.
*/
item(nameOrIndex?: any, optionalIndex?: any): Element;
/**
* Retrieves a select object or an object from an options collection.
*/
namedItem(name: string): Element;
// [name: string]: Element;
[index: number]: Element;
}
declare var FormData: {
prototype: FormData;
new (form?: HTMLFormElement): FormData;
declare var HTMLCollection: {
prototype: HTMLCollection;
new(): HTMLCollection;
}
interface SourceBuffer extends EventTarget {
updating: boolean;
appendWindowStart: number;
appendWindowEnd: number;
buffered: TimeRanges;
timestampOffset: number;
audioTracks: AudioTrackList;
appendBuffer(data: ArrayBufferView): void;
appendBuffer(data: ArrayBuffer): void;
remove(start: number, end: number): void;
abort(): void;
appendStream(stream: MSStream, maxSize?: number): void;
interface BlobPropertyBag {
type?: string;
endings?: string;
}
declare var SourceBuffer: {
prototype: SourceBuffer;
new(): SourceBuffer;
interface Blob {
type: string;
size: number;
msDetachStream(): any;
slice(start?: number, end?: number, contentType?: string): Blob;
msClose(): void;
}
declare var Blob: {
prototype: Blob;
new (blobParts?: any[], options?: BlobPropertyBag): Blob;
}
interface NavigatorID {
@@ -4636,26 +4648,6 @@ declare var MSCSSProperties: {
new(): MSCSSProperties;
}
interface HTMLCollection extends MSHTMLCollectionExtensions {
/**
* Sets or retrieves the number of objects in a collection.
*/
length: number;
/**
* Retrieves an object from various collections.
*/
item(nameOrIndex?: any, optionalIndex?: any): Element;
/**
* Retrieves a select object or an object from an options collection.
*/
namedItem(name: string): Element;
// [name: string]: Element;
}
declare var HTMLCollection: {
prototype: HTMLCollection;
new(): HTMLCollection;
}
interface SVGExternalResourcesRequired {
externalResourcesRequired: SVGAnimatedBoolean;
}
@@ -10891,18 +10883,6 @@ declare var FileReader: {
new(): FileReader;
}
interface Blob {
type: string;
size: number;
msDetachStream(): any;
slice(start?: number, end?: number, contentType?: string): Blob;
msClose(): void;
}
declare var Blob: {
prototype: Blob;
new(): Blob;
}
interface ApplicationCache extends EventTarget {
status: number;
ondownloading: (ev: Event) => any;
@@ -11061,6 +11041,14 @@ declare var MSManipulationEvent: {
MS_MANIPULATION_STATE_CANCELLED: number;
}
interface FormData {
append(name: any, value: any, blobName?: string): void;
}
declare var FormData: {
prototype: FormData;
new(): FormData;
}
interface HTMLDataListElement extends HTMLElement {
options: HTMLCollection;
}
@@ -11479,6 +11467,23 @@ interface RandomSource {
getRandomValues(array: ArrayBufferView): ArrayBufferView;
}
interface SourceBuffer extends EventTarget {
updating: boolean;
appendWindowStart: number;
appendWindowEnd: number;
buffered: TimeRanges;
timestampOffset: number;
audioTracks: AudioTrackList;
appendBuffer(data: ArrayBuffer): void;
remove(start: number, end: number): void;
abort(): void;
appendStream(stream: MSStream, maxSize?: number): void;
}
declare var SourceBuffer: {
prototype: SourceBuffer;
new(): SourceBuffer;
}
interface MSInputMethodContext extends EventTarget {
oncandidatewindowshow: (ev: any) => any;
target: HTMLElement;
+6 -1
View File
@@ -1453,6 +1453,11 @@ declare var FileReader: {
new(): FileReader;
}
interface BlobPropertyBag {
type?: string;
endings?: string;
}
interface Blob {
type: string;
size: number;
@@ -1462,7 +1467,7 @@ interface Blob {
}
declare var Blob: {
prototype: Blob;
new(): Blob;
new (blobParts?: any[], options?: BlobPropertyBag): Blob;
}
interface MSStream {
+398 -259
View File
File diff suppressed because it is too large Load Diff
+1140 -626
View File
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
+1 -1
View File
@@ -2,7 +2,7 @@
"name": "typescript",
"author": "Microsoft Corp.",
"homepage": "http://typescriptlang.org/",
"version": "1.0.1",
"version": "1.1.0",
"licenses": [
{
"type": "Apache License 2.0",
+40 -39
View File
@@ -33,44 +33,44 @@ function importDefinitelyTypedTest(testCaseName: string, testFiles: string[], re
fs.mkdirSync(testDirectoryPath);
child_process.exec(cmd, {
maxBuffer: 1 * 1024 * 1024,
cwd: testDirectoryPath
}, (error, stdout, stderr) => {
//console.log("importing " + testCaseName + " ...");
//console.log(cmd);
if (error) {
console.log("importing " + testCaseName + " ...");
console.log(cmd);
console.log("==> error " + JSON.stringify(error));
console.log("==> stdout " + String(stdout));
console.log("==> stderr " + String(stderr));
console.log("\r\n");
return;
}
// copy generated file to output location
var outputFilePath = path.join(testDirectoryPath, "iocapture0.json");
var testCasePath = path.join(rwcTestPath, "DefinitelyTyped_" + testCaseName + ".json");
copyFileSync(outputFilePath, testCasePath);
//console.log("output generated at: " + outputFilePath);
if (!fs.existsSync(testCasePath)) {
throw new Error("could not find test case at: " + testCasePath);
}
else {
fs.unlinkSync(outputFilePath);
fs.rmdirSync(testDirectoryPath);
//console.log("testcase generated at: " + testCasePath);
//console.log("Done.");
}
//console.log("\r\n");
})
.on('error', function (error) {
console.log("==> error " + JSON.stringify(error));
console.log("\r\n");
maxBuffer: 1 * 1024 * 1024,
cwd: testDirectoryPath
}, (error, stdout, stderr) => {
console.log("importing " + testCaseName + " ...");
console.log(cmd);
if (error) {
console.log("importing " + testCaseName + " ...");
console.log(cmd);
console.log("==> error " + JSON.stringify(error));
console.log("==> stdout " + String(stdout));
console.log("==> stderr " + String(stderr));
console.log("\r\n");
return;
}
// copy generated file to output location
var outputFilePath = path.join(testDirectoryPath, "iocapture0.json");
var testCasePath = path.join(rwcTestPath, "DefinitelyTyped_" + testCaseName + ".json");
copyFileSync(outputFilePath, testCasePath);
//console.log("output generated at: " + outputFilePath);
if (!fs.existsSync(testCasePath)) {
throw new Error("could not find test case at: " + testCasePath);
}
else {
fs.unlinkSync(outputFilePath);
fs.rmdirSync(testDirectoryPath);
//console.log("testcase generated at: " + testCasePath);
//console.log("Done.");
}
//console.log("\r\n");
})
.on('error', function (error) {
console.log("==> error " + JSON.stringify(error));
console.log("\r\n");
});
}
@@ -79,7 +79,8 @@ function importDefinitelyTypedTests(definitelyTypedRoot: string): void {
if (err) throw err;
subDirectorys
.filter(d => ["_infrastructure", "node_modules", ".git"].indexOf(d) >= 0)
.filter(d => ["_infrastructure", "node_modules", ".git"].indexOf(d) < 0)
.filter(i => i.indexOf("sipml") >=0 )
.filter(i => fs.statSync(path.join(definitelyTypedRoot, i)).isDirectory())
.forEach(d => {
var directoryPath = path.join(definitelyTypedRoot, d);
+279 -212
View File
@@ -24,9 +24,9 @@ module ts {
}
/// fullTypeCheck denotes if this instance of the typechecker will be used to get semantic diagnostics.
/// If fullTypeCheck === true - then typechecker should do every possible check to produce all errors
/// If fullTypeCheck === false - typechecker can shortcut and skip checks that only produce errors.
/// NOTE: checks that somehow affects decisions being made during typechecking should be executed in both cases.
/// If fullTypeCheck === true, then the typechecker should do every possible check to produce all errors
/// If fullTypeCheck === false, the typechecker can take shortcuts and skip checks that only produce errors.
/// NOTE: checks that somehow affect decisions being made during typechecking should be executed in both cases.
export function createTypeChecker(program: Program, fullTypeCheck: boolean): TypeChecker {
var Symbol = objectAllocator.getSymbolConstructor();
@@ -37,7 +37,9 @@ module ts {
var emptyArray: any[] = [];
var emptySymbols: SymbolTable = {};
var compilerOptions = program.getCompilerOptions();
var checker: TypeChecker = {
getProgram: () => program,
getDiagnostics: getDiagnostics,
@@ -412,7 +414,7 @@ module ts {
}
}
function getFullyQualifiedName(symbol: Symbol) {
function getFullyQualifiedName(symbol: Symbol): string {
return symbol.parent ? getFullyQualifiedName(symbol.parent) + "." + symbolToString(symbol) : symbolToString(symbol);
}
@@ -574,7 +576,7 @@ module ts {
return (resolveImport(symbol).flags & SymbolFlags.Value) !== 0;
}
// If it is an instantiated symbol, then it is a value if hte symbol it is an
// If it is an instantiated symbol, then it is a value if the symbol it is an
// instantiation of is a value.
if (symbol.flags & SymbolFlags.Instantiated) {
return (getSymbolLinks(symbol).target.flags & SymbolFlags.Value) !== 0;
@@ -697,7 +699,7 @@ module ts {
function getAccessibleSymbolChain(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags): Symbol[] {
function getAccessibleSymbolChainFromSymbolTable(symbols: SymbolTable): Symbol[] {
function canQualifySymbol(symbolFromSymbolTable: Symbol, meaning: SymbolFlags) {
// If the symbol is equivalent and doesnt need futher qualification, this symbol is accessible
// If the symbol is equivalent and doesn't need further qualification, this symbol is accessible
if (!needsQualification(symbolFromSymbolTable, enclosingDeclaration, meaning)) {
return true;
}
@@ -793,9 +795,9 @@ module ts {
return { accessibility: SymbolAccessibility.Accessible, aliasesToMakeVisible: hasAccessibleDeclarations.aliasesToMakeVisible };
}
// If we havent got the accessible symbol doesnt mean the symbol is actually inaccessible.
// It could be qualified symbol and hence verify the path
// eg:
// If we haven't got the accessible symbol, it doesn't mean the symbol is actually inaccessible.
// It could be a qualified symbol and hence verify the path
// e.g.:
// module m {
// export class c {
// }
@@ -803,7 +805,7 @@ module ts {
// var x: typeof m.c
// In the above example when we start with checking if typeof m.c symbol is accessible,
// we are going to see if c can be accessed in scope directly.
// But it cant, hence the accessible is going to be undefined, but that doesnt mean m.c is accessible
// But it can't, hence the accessible is going to be undefined, but that doesn't mean m.c is inaccessible
// It is accessible if the parent m is accessible because then m.c can be accessed through qualification
meaningToLook = getQualifiedLeftMeaning(meaning);
symbol = getParentOfSymbol(symbol);
@@ -815,7 +817,7 @@ module ts {
if (symbolExternalModule) {
var enclosingExternalModule = getExternalModuleContainer(enclosingDeclaration);
if (symbolExternalModule !== enclosingExternalModule) {
// name from different external module that is not visibile
// name from different external module that is not visible
return {
accessibility: SymbolAccessibility.CannotBeNamed,
errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning),
@@ -892,7 +894,7 @@ module ts {
{ accessibility: SymbolAccessibility.NotAccessible, errorSymbolName: firstIdentifierName };
}
// Enclosing declaration is optional when we dont want to get qualified name in the enclosing declaration scope
// Enclosing declaration is optional when we don't want to get qualified name in the enclosing declaration scope
// Meaning needs to be specified if the enclosing declaration is given
function symbolToString(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags) {
function getSymbolName(symbol: Symbol) {
@@ -907,8 +909,8 @@ module ts {
// Get qualified name
if (enclosingDeclaration &&
// Properties/methods/Signatures/Constructors/TypeParameters do not need qualification
!(symbol.flags & (SymbolFlags.PropertyOrAccessor | SymbolFlags.Signature | SymbolFlags.Constructor | SymbolFlags.Method | SymbolFlags.TypeParameter))) {
// TypeParameters do not need qualification
!(symbol.flags & SymbolFlags.TypeParameter)) {
var symbolName: string;
while (symbol) {
var isFirstName = !symbolName;
@@ -919,7 +921,7 @@ module ts {
currentSymbolName = ts.map(accessibleSymbolChain, accessibleSymbol => getSymbolName(accessibleSymbol)).join(".");
}
else {
// If we didnt find accessible symbol chain for this symbol, break if this is external module
// If we didn't find accessible symbol chain for this symbol, break if this is external module
if (!isFirstName && ts.forEach(symbol.declarations, declaration => hasExternalModuleSymbol(declaration))) {
break;
}
@@ -943,20 +945,37 @@ module ts {
writer.write(symbolToString(symbol, enclosingDeclaration, meaning));
}
function createSingleLineTextWriter() {
function createSingleLineTextWriter(maxLength?: number) {
var result = "";
var overflow = false;
function write(s: string) {
if (!overflow) {
result += s;
if (result.length > maxLength) {
result = result.substr(0, maxLength - 3) + "...";
overflow = true;
}
}
}
return {
write(s: string) { result += s; },
writeSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags) { writeSymbolToTextWriter(symbol, enclosingDeclaration, meaning, this); },
writeLine() { result += " "; },
write: write,
writeSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags) {
writeSymbolToTextWriter(symbol, enclosingDeclaration, meaning, this);
},
writeLine() {
write(" ");
},
increaseIndent() { },
decreaseIndent() { },
getText() { return result; }
getText() {
return result;
}
};
}
function typeToString(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string {
var stringWriter = createSingleLineTextWriter();
var maxLength = compilerOptions.noErrorTruncation || flags & TypeFormatFlags.NoTruncation ? undefined : 100;
var stringWriter = createSingleLineTextWriter(maxLength);
// TODO(shkamat): typeToString should take enclosingDeclaration as input, once we have implemented enclosingDeclaration
writeTypeToTextWriter(type, enclosingDeclaration, flags, stringWriter);
return stringWriter.getText();
@@ -1003,7 +1022,7 @@ module ts {
function writeTypeReference(type: TypeReference) {
if (type.target === globalArrayType && !(flags & TypeFormatFlags.WriteArrayAsGenericType)) {
// If we are writing array element type the arrow style signatures are not allowed as
// we need to surround it by curlies, eg. { (): T; }[]; as () => T[] would mean something different
// we need to surround it by curlies, e.g. { (): T; }[]; as () => T[] would mean something different
writeType(type.typeArguments[0], /*allowFunctionOrConstructorTypeLiteral*/ false);
writer.write("[]");
}
@@ -1257,7 +1276,7 @@ module ts {
!(node.kind !== SyntaxKind.ImportDeclaration && parent.kind !== SyntaxKind.SourceFile && isInAmbientContext(parent))) {
return isGlobalSourceFile(parent) || isUsedInExportAssignment(node);
}
// Exported members/ambient module elements (exception import declaraiton) are visible if parent is visible
// Exported members/ambient module elements (exception import declaration) are visible if parent is visible
return isDeclarationVisible(parent);
case SyntaxKind.Property:
@@ -1348,10 +1367,14 @@ module ts {
}
// Use the type of the initializer expression if one is present
if (declaration.initializer) {
var unwidenedType = checkAndMarkExpression(declaration.initializer);
var type = getWidenedType(unwidenedType);
if (type !== unwidenedType) {
checkImplicitAny(type);
var type = checkAndMarkExpression(declaration.initializer);
// Widening of property assignments is handled by checkObjectLiteral, exclude them here
if (declaration.kind !== SyntaxKind.PropertyAssignment) {
var unwidenedType = type;
type = getWidenedType(type);
if (type !== unwidenedType) {
checkImplicitAny(type);
}
}
return type;
}
@@ -1361,7 +1384,7 @@ module ts {
return type;
function checkImplicitAny(type: Type) {
if (!fullTypeCheck || !program.getCompilerOptions().noImplicitAny) {
if (!fullTypeCheck || !compilerOptions.noImplicitAny) {
return;
}
// We need to have ended up with 'any', 'any[]', 'any[][]', etc.
@@ -1410,6 +1433,12 @@ module ts {
}
else if (links.type === resolvingType) {
links.type = anyType;
if (compilerOptions.noImplicitAny) {
var diagnostic = (<VariableDeclaration>symbol.valueDeclaration).type ?
Diagnostics._0_implicitly_has_type_any_because_it_is_referenced_directly_or_indirectly_in_its_own_type_annotation :
Diagnostics._0_implicitly_has_type_any_because_it_is_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer;
error(symbol.valueDeclaration, diagnostic, symbolToString(symbol));
}
}
return links.type;
}
@@ -1464,8 +1493,8 @@ module ts {
}
// Otherwise, fall back to 'any'.
else {
if (program.getCompilerOptions().noImplicitAny) {
error(setter, Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_type_annotation, symbol.name);
if (compilerOptions.noImplicitAny) {
error(setter, Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_type_annotation, symbolToString(symbol));
}
type = anyType;
@@ -1479,6 +1508,10 @@ module ts {
}
else if (links.type === resolvingType) {
links.type = anyType;
if (compilerOptions.noImplicitAny) {
var getter = <AccessorDeclaration>getDeclarationOfKind(symbol, SyntaxKind.GetAccessor);
error(getter, Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol));
}
}
}
@@ -1542,7 +1575,7 @@ module ts {
function hasBaseType(type: InterfaceType, checkBase: InterfaceType) {
return check(type);
function check(type: InterfaceType) {
function check(type: InterfaceType): boolean {
var target = <InterfaceType>getTargetType(type);
return target === checkBase || forEach(target.baseTypes, check);
}
@@ -2046,6 +2079,15 @@ module ts {
}
else if (signature.resolvedReturnType === resolvingType) {
signature.resolvedReturnType = anyType;
if (compilerOptions.noImplicitAny) {
var declaration = <Declaration>signature.declaration;
if (declaration.name) {
error(declaration.name, Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, identifierToString(declaration.name));
}
else {
error(declaration, Diagnostics.Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions);
}
}
}
return signature.resolvedReturnType;
}
@@ -3188,45 +3230,6 @@ module ts {
return (type.flags & TypeFlags.Anonymous) && type.symbol && (type.symbol.flags & SymbolFlags.ObjectLiteral) ? true : false;
}
function getWidenedTypeOfObjectLiteral(type: Type): Type {
var properties = getPropertiesOfType(type);
if (properties.length) {
var widenedTypes: Type[] = [];
var propTypeWasWidened: boolean = false;
forEach(properties, p => {
var propType = getTypeOfSymbol(p);
var widenedType = getWidenedType(propType);
if (propType !== widenedType) {
propTypeWasWidened = true;
if (program.getCompilerOptions().noImplicitAny && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) {
error(p.valueDeclaration, Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, p.name, typeToString(widenedType));
}
}
widenedTypes.push(widenedType);
});
if (propTypeWasWidened) {
var members: SymbolTable = {};
var index = 0;
forEach(properties, p => {
var symbol = <TransientSymbol>createSymbol(SymbolFlags.Property | SymbolFlags.Transient, p.name);
symbol.declarations = p.declarations;
symbol.parent = p.parent;
symbol.type = widenedTypes[index++];
symbol.target = p;
if (p.valueDeclaration) symbol.valueDeclaration = p.valueDeclaration;
members[symbol.name] = symbol;
});
var stringIndexType = getIndexTypeOfType(type, IndexKind.String);
var numberIndexType = getIndexTypeOfType(type, IndexKind.Number);
if (stringIndexType) stringIndexType = getWidenedType(stringIndexType);
if (numberIndexType) numberIndexType = getWidenedType(numberIndexType);
type = createAnonymousType(type.symbol, members, emptyArray, emptyArray, stringIndexType, numberIndexType);
}
}
return type;
}
function isArrayType(type: Type): boolean {
return type.flags & TypeFlags.Reference && (<TypeReference>type).target === globalArrayType;
}
@@ -3238,14 +3241,8 @@ module ts {
return type;
}
function getWidenedTypeOfArrayLiteral(type: Type): Type {
var elementType = (<TypeReference>type).typeArguments[0];
var widenedType = getWidenedType(elementType);
type = elementType !== widenedType ? createArrayType(widenedType) : type;
return type;
}
function getWidenedType(type: Type): Type {
/* If we are widening on a literal, then we may need to the 'node' parameter for reporting purposes */
function getWidenedType(type: Type, supressNoImplicitAnyErrors?: boolean): Type {
if (type.flags & (TypeFlags.Undefined | TypeFlags.Null)) {
return anyType;
}
@@ -3256,6 +3253,54 @@ module ts {
return getWidenedTypeOfArrayLiteral(type);
}
return type;
function getWidenedTypeOfObjectLiteral(type: Type): Type {
var properties = getPropertiesOfType(type);
if (properties.length) {
var widenedTypes: Type[] = [];
var propTypeWasWidened: boolean = false;
forEach(properties, p => {
var propType = getTypeOfSymbol(p);
var widenedType = getWidenedType(propType);
if (propType !== widenedType) {
propTypeWasWidened = true;
if (!supressNoImplicitAnyErrors && program.getCompilerOptions().noImplicitAny && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) {
error(p.valueDeclaration, Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, p.name, typeToString(widenedType));
}
}
widenedTypes.push(widenedType);
});
if (propTypeWasWidened) {
var members: SymbolTable = {};
var index = 0;
forEach(properties, p => {
var symbol = <TransientSymbol>createSymbol(SymbolFlags.Property | SymbolFlags.Transient, p.name);
symbol.declarations = p.declarations;
symbol.parent = p.parent;
symbol.type = widenedTypes[index++];
symbol.target = p;
if (p.valueDeclaration) symbol.valueDeclaration = p.valueDeclaration;
members[symbol.name] = symbol;
});
var stringIndexType = getIndexTypeOfType(type, IndexKind.String);
var numberIndexType = getIndexTypeOfType(type, IndexKind.Number);
if (stringIndexType) stringIndexType = getWidenedType(stringIndexType);
if (numberIndexType) numberIndexType = getWidenedType(numberIndexType);
type = createAnonymousType(type.symbol, members, emptyArray, emptyArray, stringIndexType, numberIndexType);
}
}
return type;
}
function getWidenedTypeOfArrayLiteral(type: Type): Type {
var elementType = (<TypeReference>type).typeArguments[0];
var widenedType = getWidenedType(elementType, supressNoImplicitAnyErrors);
type = elementType !== widenedType ? createArrayType(widenedType) : type;
return type;
}
}
function forEachMatchingParameterType(source: Signature, target: Signature, callback: (s: Type, t: Type) => void) {
@@ -3501,29 +3546,6 @@ module ts {
return getTypeOfSymbol(getExportSymbolOfValueSymbolIfExported(symbol));
}
function getThisContainer(node: Node): Node {
while (true) {
node = node.parent;
if (!node) {
return node;
}
switch (node.kind) {
case SyntaxKind.FunctionDeclaration:
case SyntaxKind.FunctionExpression:
case SyntaxKind.ModuleDeclaration:
case SyntaxKind.Property:
case SyntaxKind.Method:
case SyntaxKind.Constructor:
case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor:
case SyntaxKind.EnumDeclaration:
case SyntaxKind.SourceFile:
case SyntaxKind.ArrowFunction:
return node;
}
}
}
function captureLexicalThis(node: Node, container: Node): void {
var classNode = container.parent && container.parent.kind === SyntaxKind.ClassDeclaration ? container.parent : undefined;
getNodeLinks(node).flags |= NodeCheckFlags.LexicalThis;
@@ -3536,11 +3558,14 @@ module ts {
}
function checkThisExpression(node: Node): Type {
var container = getThisContainer(node);
// Stop at the first arrow function so that we can
// tell whether 'this' needs to be captured.
var container = getThisContainer(node, /* includeArrowFunctions */ true);
var needToCaptureLexicalThis = false;
// skip arrow functions
while (container.kind === SyntaxKind.ArrowFunction) {
container = getThisContainer(container);
// Now skip arrow functions to get the "real" owner of 'this'.
if (container.kind === SyntaxKind.ArrowFunction) {
container = getThisContainer(container, /* includeArrowFunctions */ false);
needToCaptureLexicalThis = true;
}
@@ -4059,7 +4084,7 @@ module ts {
}
// Fall back to any.
if (program.getCompilerOptions().noImplicitAny && objectType !== anyType) {
if (compilerOptions.noImplicitAny && objectType !== anyType) {
error(node, Diagnostics.Index_signature_of_object_type_implicitly_has_an_any_type);
}
@@ -4120,7 +4145,7 @@ module ts {
}
else {
// current declaration belongs to a different symbol
// set cutoffPos so reorderings in the future won't change result set from 0 to cutoffPos
// set cutoffPos so re-orderings in the future won't change result set from 0 to cutoffPos
pos = cutoffPos = result.length;
lastParent = parent;
}
@@ -4157,19 +4182,6 @@ module ts {
return getSignatureInstantiation(signature, getInferredTypes(context));
}
// Inferentially type an expression by a contextual parameter type (section 4.12.2 in TypeScript spec)
function inferentiallyTypeExpession(expr: Expression, contextualType: Type, contextualMapper: TypeMapper): Type {
var type = checkExpressionWithContextualType(expr, contextualType, contextualMapper);
var signature = getSingleCallSignature(type);
if (signature && signature.typeParameters) {
var contextualSignature = getSingleCallSignature(contextualType);
if (contextualSignature && !contextualSignature.typeParameters) {
type = getOrCreateTypeFromSignature(instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper));
}
}
return type;
}
function inferTypeArguments(signature: Signature, args: Expression[], excludeArgument?: boolean[]): Type[] {
var typeParameters = signature.typeParameters;
var context = createInferenceContext(typeParameters);
@@ -4178,7 +4190,7 @@ module ts {
for (var i = 0; i < args.length; i++) {
if (!excludeArgument || excludeArgument[i] === undefined) {
var parameterType = getTypeAtPosition(signature, i);
inferTypes(context, inferentiallyTypeExpession(args[i], parameterType, mapper), parameterType);
inferTypes(context, checkExpressionWithContextualType(args[i], parameterType, mapper), parameterType);
}
}
// Next, infer from those context sensitive arguments that are no longer excluded
@@ -4186,7 +4198,7 @@ module ts {
for (var i = 0; i < args.length; i++) {
if (excludeArgument[i] === false) {
var parameterType = getTypeAtPosition(signature, i);
inferTypes(context, inferentiallyTypeExpession(args[i], parameterType, mapper), parameterType);
inferTypes(context, checkExpressionWithContextualType(args[i], parameterType, mapper), parameterType);
}
}
}
@@ -4404,7 +4416,7 @@ module ts {
var declaration = signature.declaration;
if (declaration && (declaration.kind !== SyntaxKind.Constructor && declaration.kind !== SyntaxKind.ConstructSignature)) {
// When resolved signature is a call signature (and not a construct signature) the result type is any
if (program.getCompilerOptions().noImplicitAny) {
if (compilerOptions.noImplicitAny) {
error(node, Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type);
}
return anyType;
@@ -4417,9 +4429,9 @@ module ts {
var exprType = checkExpression(node.operand);
var targetType = getTypeFromTypeNode(node.type);
if (fullTypeCheck && targetType !== unknownType) {
var widenedType = getWidenedType(exprType);
if (!(isTypeAssignableTo(exprType, targetType) || isTypeAssignableTo(targetType, widenedType))) {
checkTypeAssignableTo(targetType, widenedType, node, Diagnostics.Neither_type_0_nor_type_1_is_assignable_to_the_other_Colon, Diagnostics.Neither_type_0_nor_type_1_is_assignable_to_the_other);
var widenedType = getWidenedType(exprType, /*supressNoImplicitAnyErrors*/ true);
if (!(isTypeAssignableTo(targetType, widenedType))) {
checkTypeAssignableTo(exprType, targetType, node, Diagnostics.Neither_type_0_nor_type_1_is_assignable_to_the_other_Colon, Diagnostics.Neither_type_0_nor_type_1_is_assignable_to_the_other);
}
}
return targetType;
@@ -4450,7 +4462,7 @@ module ts {
var unwidenedType = checkAndMarkExpression(func.body, contextualMapper);
var widenedType = getWidenedType(unwidenedType);
if (fullTypeCheck && program.getCompilerOptions().noImplicitAny && widenedType !== unwidenedType && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) {
if (fullTypeCheck && compilerOptions.noImplicitAny && widenedType !== unwidenedType && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) {
error(func, Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeToString(widenedType));
}
@@ -4472,7 +4484,7 @@ module ts {
var widenedType = getWidenedType(commonType);
// Check and report for noImplicitAny if the best common type implicitly gets widened to an 'any'/arrays-of-'any' type.
if (fullTypeCheck && program.getCompilerOptions().noImplicitAny && widenedType !== commonType && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) {
if (fullTypeCheck && compilerOptions.noImplicitAny && widenedType !== commonType && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) {
var typeName = typeToString(widenedType);
if (func.name) {
@@ -4489,37 +4501,6 @@ module ts {
return voidType;
}
// WARNING: This has the same semantics as the forEach family of functions,
// in that traversal terminates in the event that 'visitor' supplies a truthy value.
function forEachReturnStatement<T>(body: Block, visitor: (stmt: ReturnStatement) => T): T {
return traverse(body);
function traverse(node: Node): T {
switch (node.kind) {
case SyntaxKind.ReturnStatement:
return visitor(node);
case SyntaxKind.Block:
case SyntaxKind.FunctionBlock:
case SyntaxKind.IfStatement:
case SyntaxKind.DoStatement:
case SyntaxKind.WhileStatement:
case SyntaxKind.ForStatement:
case SyntaxKind.ForInStatement:
case SyntaxKind.WithStatement:
case SyntaxKind.SwitchStatement:
case SyntaxKind.CaseClause:
case SyntaxKind.DefaultClause:
case SyntaxKind.LabelledStatement:
case SyntaxKind.TryStatement:
case SyntaxKind.TryBlock:
case SyntaxKind.CatchBlock:
case SyntaxKind.FinallyBlock:
return forEachChild(node, traverse);
}
}
}
/// Returns a set of types relating to every return expression relating to a function block.
function checkAndAggregateReturnExpressionTypes(body: Block, contextualMapper?: TypeMapper): Type[] {
var aggregatedTypes: Type[] = [];
@@ -4612,27 +4593,28 @@ module ts {
}
}
}
checkSignatureDeclaration(node);
}
}
if (fullTypeCheck && !(links.flags & NodeCheckFlags.TypeChecked)) {
checkSignatureDeclaration(node);
if (node.type) {
checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNode(node.type));
}
if (node.body.kind === SyntaxKind.FunctionBlock) {
checkSourceElement(node.body);
}
else {
var exprType = checkExpression(node.body);
if (node.type) {
checkTypeAssignableTo(exprType, getTypeFromTypeNode(node.type), node.body, undefined, undefined);
}
}
links.flags |= NodeCheckFlags.TypeChecked;
}
return type;
}
function checkFunctionExpressionBody(node: FunctionExpression) {
if (node.type) {
checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNode(node.type));
}
if (node.body.kind === SyntaxKind.FunctionBlock) {
checkSourceElement(node.body);
}
else {
var exprType = checkExpression(node.body);
if (node.type) {
checkTypeAssignableTo(exprType, getTypeFromTypeNode(node.type), node.body, undefined, undefined);
}
checkFunctionExpressionBodies(node.body);
}
}
function checkArithmeticOperandType(operand: Node, type: Type, diagnostic: DiagnosticMessage): boolean {
if (!(type.flags & (TypeFlags.Any | TypeFlags.NumberLike))) {
error(operand, diagnostic);
@@ -4869,7 +4851,7 @@ module ts {
var ok = checkReferenceExpression(node.left, Diagnostics.Invalid_left_hand_side_of_assignment_expression);
// Use default messages
if (ok) {
// to avoid cascading errors check assignability only if 'isReference' check succeded and no errors were reported
// to avoid cascading errors check assignability only if 'isReference' check succeeded and no errors were reported
checkTypeAssignableTo(valueType, leftType, node.left, /*chainedMessage*/ undefined, /*terminalMessage*/ undefined);
}
}
@@ -4915,11 +4897,28 @@ module ts {
// Checks an expression and returns its type. The contextualMapper parameter serves two purposes: When
// contextualMapper is not undefined and not equal to the identityMapper function object it indicates that the
// expression is being inferentially typed (section 4.12.2 in spec) and provides the type mapper to use in
// conjuction with the generic contextual type. When contextualMapper is equal to the identityMapper function
// conjunction with the generic contextual type. When contextualMapper is equal to the identityMapper function
// object, it serves as an indicator that all contained function and arrow expressions should be considered to
// have the wildcard function type; this form of type check is used during overload resolution to exclude
// contextually typed function and arrow expressions in the initial phase.
function checkExpression(node: Expression, contextualMapper?: TypeMapper): Type {
var type = checkExpressionNode(node, contextualMapper);
if (contextualMapper && contextualMapper !== identityMapper) {
var signature = getSingleCallSignature(type);
if (signature && signature.typeParameters) {
var contextualType = getContextualType(node);
if (contextualType) {
var contextualSignature = getSingleCallSignature(contextualType);
if (contextualSignature && !contextualSignature.typeParameters) {
type = getOrCreateTypeFromSignature(instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper));
}
}
}
}
return type;
}
function checkExpressionNode(node: Expression, contextualMapper: TypeMapper): Type {
switch (node.kind) {
case SyntaxKind.Identifier:
return checkIdentifier(<Identifier>node);
@@ -5020,7 +5019,7 @@ module ts {
// legal case - parameter initializer references some parameter strictly on left of current parameter declaration
return;
}
// fallthrough to error reporting
// fall through to error reporting
}
error(n, Diagnostics.Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it, identifierToString(parameterDeclaration.name), identifierToString(<Identifier>n));
@@ -5047,7 +5046,7 @@ module ts {
checkCollisionWithCapturedThisVariable(node, node.name);
checkCollistionWithRequireExportsInGeneratedCode(node, node.name);
checkCollisionWithArgumentsInGeneratedCode(node);
if (program.getCompilerOptions().noImplicitAny && !node.type) {
if (compilerOptions.noImplicitAny && !node.type) {
switch (node.kind) {
case SyntaxKind.ConstructSignature:
error(node, Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type);
@@ -5416,7 +5415,7 @@ module ts {
}
// when checking exported function declarations across modules check only duplicate implementations
// names and consistensy of modifiers are verified when we check local symbol
// names and consistency of modifiers are verified when we check local symbol
var isExportSymbolInsideModule = symbol.parent && symbol.parent.flags & SymbolFlags.Module;
for (var i = 0; i < declarations.length; i++) {
var node = <FunctionDeclaration>declarations[i];
@@ -5512,7 +5511,7 @@ module ts {
var symbol: Symbol;
// Exports should be checked only if enclosing module contains both exported and non exported declarations.
// In case if all declarations are non-exported check is unnecesary.
// In case if all declarations are non-exported check is unnecessary.
// if localSymbol is defined on node then node itself is exported - check is required
var symbol = node.localSymbol;
@@ -5607,7 +5606,7 @@ module ts {
}
// If there is no body and no explicit return type, then report an error.
if (fullTypeCheck && program.getCompilerOptions().noImplicitAny && !node.body && !node.type) {
if (fullTypeCheck && compilerOptions.noImplicitAny && !node.body && !node.type) {
// Ignore privates within ambient contexts; they exist purely for documentative purposes to avoid name clashing.
// (e.g. privates within .d.ts files do not expose type information)
if (!isPrivateWithinAmbient(node)) {
@@ -5924,17 +5923,6 @@ module ts {
// TODO: Check that target label is valid
}
function getContainingFunction(node: Node): SignatureDeclaration {
while (true) {
node = node.parent;
if (!node || node.kind === SyntaxKind.FunctionDeclaration || node.kind === SyntaxKind.FunctionExpression ||
node.kind === SyntaxKind.ArrowFunction || node.kind === SyntaxKind.Method || node.kind === SyntaxKind.Constructor ||
node.kind === SyntaxKind.GetAccessor || node.kind === SyntaxKind.SetAccessor) {
return <SignatureDeclaration>node;
}
}
}
function checkReturnStatement(node: ReturnStatement) {
if (node.expression && !(getNodeLinks(node.expression).flags & NodeCheckFlags.TypeChecked)) {
var func = getContainingFunction(node);
@@ -5957,7 +5945,7 @@ module ts {
checkTypeAssignableTo(checkExpression(node.expression), returnType, node.expression, /*chainedMessage*/ undefined, /*terminalMessage*/ undefined);
}
else if (func.kind == SyntaxKind.Constructor) {
// constructor doesn't have explicit return type annontation and yet its return type is known - declaring type
// constructor doesn't have explicit return type annotation and yet its return type is known - declaring type
// handle constructors and issue specialized error message for them.
if (!isTypeAssignableTo(checkExpression(node.expression), returnType)) {
error(node.expression, Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class);
@@ -6204,7 +6192,7 @@ module ts {
}
if ((base.flags & derived.flags & SymbolFlags.Method) || ((base.flags & SymbolFlags.PropertyOrAccessor) && (derived.flags & SymbolFlags.PropertyOrAccessor))) {
// method is overridden with method or property\accessor is overridden with property\accessor - correct case
// method is overridden with method or property/accessor is overridden with property/accessor - correct case
continue;
}
@@ -6532,9 +6520,10 @@ module ts {
case SyntaxKind.FunctionDeclaration:
return checkFunctionDeclaration(<FunctionDeclaration>node);
case SyntaxKind.Block:
return checkBlock(<Block>node);
case SyntaxKind.FunctionBlock:
case SyntaxKind.ModuleBlock:
return checkBlock(<Block>node);
return checkBody(<Block>node);
case SyntaxKind.VariableStatement:
return checkVariableStatement(<VariableStatement>node);
case SyntaxKind.ExpressionStatement:
@@ -6581,13 +6570,91 @@ module ts {
}
}
// Function expression bodies are checked after all statements in the enclosing body. This is to ensure
// constructs like the following are permitted:
// var foo = function () {
// var s = foo();
// return "hello";
// }
// Here, performing a full type check of the body of the function expression whilst in the process of
// determining the type of foo would cause foo to be given type any because of the recursive reference.
// Delaying the type check of the body ensures foo has been assigned a type.
function checkFunctionExpressionBodies(node: Node): void {
switch (node.kind) {
case SyntaxKind.FunctionExpression:
case SyntaxKind.ArrowFunction:
forEach((<FunctionDeclaration>node).parameters, checkFunctionExpressionBodies);
checkFunctionExpressionBody(<FunctionExpression>node);
break;
case SyntaxKind.Method:
case SyntaxKind.Constructor:
case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor:
case SyntaxKind.FunctionDeclaration:
forEach((<FunctionDeclaration>node).parameters, checkFunctionExpressionBodies);
break;
case SyntaxKind.WithStatement:
checkFunctionExpressionBodies((<WithStatement>node).expression);
break;
case SyntaxKind.Parameter:
case SyntaxKind.Property:
case SyntaxKind.ArrayLiteral:
case SyntaxKind.ObjectLiteral:
case SyntaxKind.PropertyAssignment:
case SyntaxKind.PropertyAccess:
case SyntaxKind.IndexedAccess:
case SyntaxKind.CallExpression:
case SyntaxKind.NewExpression:
case SyntaxKind.TypeAssertion:
case SyntaxKind.ParenExpression:
case SyntaxKind.PrefixOperator:
case SyntaxKind.PostfixOperator:
case SyntaxKind.BinaryExpression:
case SyntaxKind.ConditionalExpression:
case SyntaxKind.Block:
case SyntaxKind.FunctionBlock:
case SyntaxKind.ModuleBlock:
case SyntaxKind.VariableStatement:
case SyntaxKind.ExpressionStatement:
case SyntaxKind.IfStatement:
case SyntaxKind.DoStatement:
case SyntaxKind.WhileStatement:
case SyntaxKind.ForStatement:
case SyntaxKind.ForInStatement:
case SyntaxKind.ContinueStatement:
case SyntaxKind.BreakStatement:
case SyntaxKind.ReturnStatement:
case SyntaxKind.SwitchStatement:
case SyntaxKind.CaseClause:
case SyntaxKind.DefaultClause:
case SyntaxKind.LabelledStatement:
case SyntaxKind.ThrowStatement:
case SyntaxKind.TryStatement:
case SyntaxKind.TryBlock:
case SyntaxKind.CatchBlock:
case SyntaxKind.FinallyBlock:
case SyntaxKind.VariableDeclaration:
case SyntaxKind.ClassDeclaration:
case SyntaxKind.EnumDeclaration:
case SyntaxKind.EnumMember:
case SyntaxKind.SourceFile:
forEachChild(node, checkFunctionExpressionBodies);
break;
}
}
function checkBody(node: Block) {
checkBlock(node);
checkFunctionExpressionBodies(node);
}
// Fully type check a source file and collect the relevant diagnostics.
function checkSourceFile(node: SourceFile) {
var links = getNodeLinks(node);
if (!(links.flags & NodeCheckFlags.TypeChecked)) {
emitExtends = false;
potentialThisCollisions.length = 0;
forEach(node.statements, checkSourceElement);
checkBody(node);
if (isExternalModule(node)) {
var symbol = getExportAssignmentSymbol(node.symbol);
if (symbol && symbol.flags & SymbolFlags.Import) {
@@ -6636,7 +6703,7 @@ module ts {
// Language service support
function getNodeAtPosition(sourceFile: SourceFile, position: number): Node {
function findChildAtPosition(parent: Node) {
function findChildAtPosition(parent: Node): Node {
var child = forEachChild(parent, node => {
if (position >= node.pos && position <= node.end && position >= getTokenPosOfNode(node)) {
return findChildAtPosition(node);
@@ -6979,7 +7046,7 @@ module ts {
return moduleType ? moduleType.symbol : undefined;
}
// Intentinal fallthrough
// Intentional fall-through
case SyntaxKind.NumericLiteral:
// index access
if (node.parent.kind == SyntaxKind.IndexedAccess && (<IndexedAccess>node.parent).index === node) {
@@ -7044,7 +7111,7 @@ module ts {
var apparentType = getApparentType(type);
if (apparentType.flags & TypeFlags.ObjectType) {
// Augment the apprent type with Function and Object memeber as applicaple
// Augment the apparent type with Function and Object members as applicable
var propertiesByName: Map<Symbol> = {};
var results: Symbol[] = [];
@@ -7175,7 +7242,7 @@ module ts {
function shouldEmitDeclarations() {
// If the declaration emit and there are no errors being reported in program or by checker
// declarations can be emitted
return program.getCompilerOptions().declaration &&
return compilerOptions.declaration &&
!program.getDiagnostics().length &&
!getDiagnostics().length;
}
@@ -7201,17 +7268,17 @@ module ts {
var symbol = getSymbolOfNode(node);
var signaturesOfSymbol = getSignaturesOfSymbol(symbol);
// If this function body corresponds to function with multiple signature, it is implementation of overload
// eg: function foo(a: string): string;
// function foo(a: number): number;
// function foo(a: any) { // This is implementation of the overloads
// return a;
// }
// e.g.: function foo(a: string): string;
// function foo(a: number): number;
// function foo(a: any) { // This is implementation of the overloads
// return a;
// }
return signaturesOfSymbol.length > 1 ||
// If there is single signature for the symbol, it is overload if that signature isnt coming from the node
// eg: function foo(a: string): string;
// function foo(a: any) { // This is implementation of the overloads
// return a;
// }
// If there is single signature for the symbol, it is overload if that signature isn't coming from the node
// e.g.: function foo(a: string): string;
// function foo(a: any) { // This is implementation of the overloads
// return a;
// }
(signaturesOfSymbol.length === 1 && signaturesOfSymbol[0].declaration !== node);
}
return false;
+6
View File
@@ -204,6 +204,9 @@ module ts {
export function createFileDiagnostic(file: SourceFile, start: number, length: number, message: DiagnosticMessage, ...args: any[]): Diagnostic;
export function createFileDiagnostic(file: SourceFile, start: number, length: number, message: DiagnosticMessage): Diagnostic {
Debug.assert(start >= 0, "start must be non-negative, is " + start);
Debug.assert(length >= 0, "length must be non-negative, is " + length);
var text = getLocaleSpecificMessage(message.key);
if (arguments.length > 4) {
@@ -258,6 +261,9 @@ module ts {
}
export function flattenDiagnosticChain(file: SourceFile, start: number, length: number, diagnosticChain: DiagnosticMessageChain, newLine: string): Diagnostic {
Debug.assert(start >= 0, "start must be non-negative, is " + start);
Debug.assert(length >= 0, "length must be non-negative, is " + length);
var code = diagnosticChain.code;
var category = diagnosticChain.category;
var messageText = "";
@@ -391,6 +391,10 @@ module ts {
Object_literal_s_property_0_implicitly_has_an_1_type: { code: 7018, category: DiagnosticCategory.Error, key: "Object literal's property '{0}' implicitly has an '{1}' type." },
Rest_parameter_0_implicitly_has_an_any_type: { code: 7019, category: DiagnosticCategory.Error, key: "Rest parameter '{0}' implicitly has an 'any[]' type." },
Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: { code: 7020, category: DiagnosticCategory.Error, key: "Call signature, which lacks return-type annotation, implicitly has an 'any' return type." },
_0_implicitly_has_type_any_because_it_is_referenced_directly_or_indirectly_in_its_own_type_annotation: { code: 7021, category: DiagnosticCategory.Error, key: "'{0}' implicitly has type 'any' because it is referenced directly or indirectly in its own type annotation." },
_0_implicitly_has_type_any_because_it_is_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer: { code: 7022, category: DiagnosticCategory.Error, key: "'{0}' implicitly has type 'any' because it is does not have a type annotation and is referenced directly or indirectly in its own initializer." },
_0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7023, category: DiagnosticCategory.Error, key: "'{0}' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." },
Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7024, category: DiagnosticCategory.Error, key: "Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." },
You_cannot_rename_this_element: { code: 8000, category: DiagnosticCategory.Error, key: "You cannot rename this element." },
};
}
+16
View File
@@ -1561,6 +1561,22 @@
"category": "Error",
"code": 7020
},
"'{0}' implicitly has type 'any' because it is referenced directly or indirectly in its own type annotation.": {
"category": "Error",
"code": 7021
},
"'{0}' implicitly has type 'any' because it is does not have a type annotation and is referenced directly or indirectly in its own initializer.": {
"category": "Error",
"code": 7022
},
"'{0}' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.": {
"category": "Error",
"code": 7023
},
"Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.": {
"category": "Error",
"code": 7024
},
"You cannot rename this element.": {
"category": "Error",
"code": 8000
+50 -57
View File
@@ -266,7 +266,7 @@ module ts {
}
}
else {
// Single line comment of styly //....
// Single line comment of style //....
writer.write(currentSourceFile.text.substring(comment.pos, comment.end));
}
@@ -393,7 +393,7 @@ module ts {
}
var prevEncodedEmittedColumn = lastEncodedSourceMapSpan.emittedColumn;
// Line/Comma deliminators
// Line/Comma delimiters
if (lastEncodedSourceMapSpan.emittedLine == lastRecordedSourceMapSpan.emittedLine) {
// Emit comma to separate the entry
if (sourceMapData.sourceMapMappings) {
@@ -401,7 +401,7 @@ module ts {
}
}
else {
// Emit line deliminators
// Emit line delimiters
for (var encodedLine = lastEncodedSourceMapSpan.emittedLine; encodedLine < lastRecordedSourceMapSpan.emittedLine; encodedLine++) {
sourceMapData.sourceMapMappings += ";";
}
@@ -470,7 +470,7 @@ module ts {
var emittedLine = writer.getLine();
var emittedColumn = writer.getColumn();
// If this location wasnt recorded or the location in source is going backwards, record the span
// If this location wasn't recorded or the location in source is going backwards, record the span
if (!lastRecordedSourceMapSpan ||
lastRecordedSourceMapSpan.emittedLine != emittedLine ||
lastRecordedSourceMapSpan.emittedColumn != emittedColumn ||
@@ -516,7 +516,7 @@ module ts {
}
function recordNewSourceFileStart(node: SourceFile) {
// Add the the file to tsFilePaths
// Add the file to tsFilePaths
// If sourceroot option: Use the relative path corresponding to the common directory path
// otherwise source locations relative to map file location
var sourcesDirectoryPath = compilerOptions.sourceRoot ? program.getCommonSourceDirectory() : sourceMapDir;
@@ -953,7 +953,7 @@ module ts {
write(tokenToString(node.operator));
}
// In some cases, we need to emit a space between the operator and the operand. One obvious case
// is when the operator is an identifer, like delete or typeof. We also need to do this for plus
// is when the operator is an identifier, like delete or typeof. We also need to do this for plus
// and minus expressions in certain cases. Specifically, consider the following two cases (parens
// are just for clarity of exposition, and not part of the source code):
//
@@ -1755,16 +1755,13 @@ module ts {
if (!isInstantiated(node)) {
return emitPinnedOrTripleSlashComments(node);
}
emitLeadingComments(node);
if (!(node.flags & NodeFlags.Export)) {
emitStart(node);
write("var ");
emit(node.name);
write(";");
emitEnd(node);
writeLine();
}
emitStart(node);
write("var ");
emit(node.name);
write(";");
emitEnd(node);
writeLine();
emitStart(node);
write("(function (");
emitStart(node.name);
@@ -1788,21 +1785,15 @@ module ts {
scopeEmitEnd();
}
write(")(");
if (node.flags & NodeFlags.Export) {
emit(node.name);
write(" = ");
}
emitModuleMemberName(node);
write(" || (");
emitModuleMemberName(node);
write(" = {}));");
emitEnd(node);
if (node.flags & NodeFlags.Export) {
writeLine();
emitStart(node);
write("var ");
emit(node.name);
write(" = ");
emitModuleMemberName(node);
emitEnd(node);
write(";");
}
emitTrailingComments(node);
}
@@ -1982,7 +1973,7 @@ module ts {
}
}
function emitNode(node: Node) {
function emitNode(node: Node): void {
if (!node) {
return;
}
@@ -2125,7 +2116,7 @@ module ts {
}
function getLeadingCommentsToEmit(node: Node) {
// Emit the leading comments only if the parent's pos doesnt match because parent should take care of emitting these comments
// Emit the leading comments only if the parent's pos doesn't match because parent should take care of emitting these comments
if (node.parent.kind === SyntaxKind.SourceFile || node.pos !== node.parent.pos) {
var leadingComments: Comment[];
if (hasDetachedComments(node.pos)) {
@@ -2148,7 +2139,7 @@ module ts {
}
function emitTrailingDeclarationComments(node: Node) {
// Emit the trailing comments only if the parent's end doesnt match
// Emit the trailing comments only if the parent's end doesn't match
if (node.parent.kind === SyntaxKind.SourceFile || node.end !== node.parent.end) {
var trailingComments = getTrailingComments(currentSourceFile.text, node.end);
// trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/
@@ -2224,7 +2215,7 @@ module ts {
return currentSourceFile.text.charCodeAt(comment.pos + 2) === CharacterCodes.exclamation;
}
// Verify this is /// comment, but do the regexp match only when we first can find /// in the comment text
// so that we dont end up computing comment string and doing match for all // comments
// so that we don't end up computing comment string and doing match for all // comments
else if (currentSourceFile.text.charCodeAt(comment.pos + 1) === CharacterCodes.slash &&
comment.pos + 2 < comment.end &&
currentSourceFile.text.charCodeAt(comment.pos + 2) === CharacterCodes.slash &&
@@ -2700,7 +2691,7 @@ module ts {
}
function emitVariableDeclaration(node: VariableDeclaration) {
// If we are emitting property it isnt moduleElement and hence we already know it needs to be emitted
// 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)) {
emitSourceTextOfNode(node.name);
@@ -2724,7 +2715,7 @@ module ts {
Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 :
Diagnostics.Exported_variable_0_has_or_is_using_private_name_1;
}
// This check is to ensure we dont report error on constructor parameter property as that error would be reported during parameter emit
// This check is to ensure we don't report error on constructor parameter property as that error would be reported during parameter emit
else if (node.kind === SyntaxKind.Property) {
if (node.flags & NodeFlags.Static) {
diagnosticMessage = symbolAccesibilityResult.errorModuleName ?
@@ -2829,7 +2820,7 @@ module ts {
}
function emitFunctionDeclaration(node: FunctionDeclaration) {
// If we are emitting Method/Constructor it isnt moduleElement and hence already determined to be emitting
// 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)) &&
!resolver.isImplementationOfOverload(node)) {
@@ -3080,9 +3071,7 @@ module ts {
}
function resolveScriptReference(sourceFile: SourceFile, reference: FileReference) {
var referenceFileName = compilerOptions.noResolve
? reference.filename
: normalizePath(combinePaths(getDirectoryPath(sourceFile.filename), reference.filename));
var referenceFileName = normalizePath(combinePaths(getDirectoryPath(sourceFile.filename), reference.filename));
return program.getSourceFile(referenceFileName);
}
@@ -3107,22 +3096,24 @@ module ts {
}
if (root) {
// Emiting single file so emit references in this file only
var addedGlobalFileReference = false;
forEach(root.referencedFiles, fileReference => {
var referencedFile = resolveScriptReference(root, fileReference);
// Emitting just a single file, so emit references in this file only
if (!compilerOptions.noResolve) {
var addedGlobalFileReference = false;
forEach(root.referencedFiles, fileReference => {
var referencedFile = resolveScriptReference(root, fileReference);
// All the references that are not going to be part of same file
if ((referencedFile.flags & NodeFlags.DeclarationFile) || // This is a declare file reference
shouldEmitToOwnFile(referencedFile) || // This is referenced file is emitting its own js file
!addedGlobalFileReference) { // Or the global out file corresponding to this reference was not added
// All the references that are not going to be part of same file
if ((referencedFile.flags & NodeFlags.DeclarationFile) || // This is a declare file reference
shouldEmitToOwnFile(referencedFile) || // This is referenced file is emitting its own js file
!addedGlobalFileReference) { // Or the global out file corresponding to this reference was not added
writeReferencePath(referencedFile);
if (!isExternalModuleOrDeclarationFile(referencedFile)) {
addedGlobalFileReference = true;
writeReferencePath(referencedFile);
if (!isExternalModuleOrDeclarationFile(referencedFile)) {
addedGlobalFileReference = true;
}
}
}
});
});
}
emitNode(root);
}
@@ -3132,17 +3123,19 @@ module ts {
forEach(program.getSourceFiles(), sourceFile => {
if (!isExternalModuleOrDeclarationFile(sourceFile)) {
// Check what references need to be added
forEach(sourceFile.referencedFiles, fileReference => {
var referencedFile = resolveScriptReference(sourceFile, fileReference);
if (!compilerOptions.noResolve) {
forEach(sourceFile.referencedFiles, fileReference => {
var referencedFile = resolveScriptReference(sourceFile, fileReference);
// If the reference file is declaration file or external module emit that reference
if (isExternalModuleOrDeclarationFile(referencedFile) &&
!contains(emittedReferencedFiles, referencedFile)) { // If the file refernece was not already emitted
// If the reference file is a declaration file or an external module, emit that reference
if (isExternalModuleOrDeclarationFile(referencedFile) &&
!contains(emittedReferencedFiles, referencedFile)) { // If the file reference was not already emitted
writeReferencePath(referencedFile);
emittedReferencedFiles.push(referencedFile);
}
});
writeReferencePath(referencedFile);
emittedReferencedFiles.push(referencedFile);
}
});
}
emitNode(sourceFile);
}
+119 -17
View File
@@ -81,7 +81,7 @@ module ts {
export function createDiagnosticForNode(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): Diagnostic {
node = getErrorSpanForNode(node);
var file = getSourceFileOfNode(node);
var start = skipTrivia(file.text, node.pos);
var start = node.kind === SyntaxKind.Missing ? node.pos : skipTrivia(file.text, node.pos);
var length = node.end - start;
return createFileDiagnostic(file, start, length, message, arg0, arg1, arg2);
@@ -141,11 +141,11 @@ module ts {
export function getLeadingCommentsOfNode(node: Node, sourceFileOfNode: SourceFile) {
// If parameter/type parameter, the prev token trailing comments are part of this node too
if (node.kind === SyntaxKind.Parameter || node.kind === SyntaxKind.TypeParameter) {
// eg (/** blah */ a, /** blah */ b);
// e.g. (/** blah */ a, /** blah */ b);
return concatenate(getTrailingComments(sourceFileOfNode.text, node.pos),
// eg: (
// /** blah */ a,
// /** blah */ b);
// e.g.: (
// /** blah */ a,
// /** blah */ b);
getLeadingComments(sourceFileOfNode.text, node.pos));
}
else {
@@ -157,7 +157,7 @@ module ts {
return filter(getLeadingCommentsOfNode(node, sourceFileOfNode), comment => isJsDocComment(comment));
function isJsDocComment(comment: Comment) {
// js doc is if comment is starting with /** but not if it is /**/
// True if the comment starts with '/**' but not if it is '/**/'
return sourceFileOfNode.text.charCodeAt(comment.pos + 1) === CharacterCodes.asterisk &&
sourceFileOfNode.text.charCodeAt(comment.pos + 2) === CharacterCodes.asterisk &&
sourceFileOfNode.text.charCodeAt(comment.pos + 3) !== CharacterCodes.slash;
@@ -352,6 +352,107 @@ module ts {
}
}
// Warning: This has the same semantics as the forEach family of functions,
// in that traversal terminates in the event that 'visitor' supplies a truthy value.
export function forEachReturnStatement<T>(body: Block, visitor: (stmt: ReturnStatement) => T): T {
return traverse(body);
function traverse(node: Node): T {
switch (node.kind) {
case SyntaxKind.ReturnStatement:
return visitor(node);
case SyntaxKind.Block:
case SyntaxKind.FunctionBlock:
case SyntaxKind.IfStatement:
case SyntaxKind.DoStatement:
case SyntaxKind.WhileStatement:
case SyntaxKind.ForStatement:
case SyntaxKind.ForInStatement:
case SyntaxKind.WithStatement:
case SyntaxKind.SwitchStatement:
case SyntaxKind.CaseClause:
case SyntaxKind.DefaultClause:
case SyntaxKind.LabelledStatement:
case SyntaxKind.TryStatement:
case SyntaxKind.TryBlock:
case SyntaxKind.CatchBlock:
case SyntaxKind.FinallyBlock:
return forEachChild(node, traverse);
}
}
}
export function isAnyFunction(node: Node): boolean {
if (node) {
switch (node.kind) {
case SyntaxKind.FunctionExpression:
case SyntaxKind.FunctionDeclaration:
case SyntaxKind.ArrowFunction:
case SyntaxKind.Method:
case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor:
case SyntaxKind.Constructor:
return true;
}
}
return false;
}
export function getContainingFunction(node: Node): SignatureDeclaration {
while (true) {
node = node.parent;
if (!node || isAnyFunction(node)) {
return <SignatureDeclaration>node;
}
}
}
export function getThisContainer(node: Node, includeArrowFunctions: boolean): Node {
while (true) {
node = node.parent;
if (!node) {
return undefined;
}
switch (node.kind) {
case SyntaxKind.ArrowFunction:
if (!includeArrowFunctions) {
continue;
}
// Fall through
case SyntaxKind.FunctionDeclaration:
case SyntaxKind.FunctionExpression:
case SyntaxKind.ModuleDeclaration:
case SyntaxKind.Property:
case SyntaxKind.Method:
case SyntaxKind.Constructor:
case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor:
case SyntaxKind.EnumDeclaration:
case SyntaxKind.SourceFile:
return node;
}
}
}
export function getSuperContainer(node: Node): Node {
while (true) {
node = node.parent;
if (!node) {
return undefined;
}
switch (node.kind) {
case SyntaxKind.Property:
case SyntaxKind.Method:
case SyntaxKind.Constructor:
case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor:
return node;
}
}
}
export function hasRestParameters(s: SignatureDeclaration): boolean {
return s.parameters.length > 0 && (s.parameters[s.parameters.length - 1].flags & NodeFlags.Rest) !== 0;
}
@@ -665,7 +766,7 @@ module ts {
}
function reportInvalidUseInStrictMode(node: Identifier): void {
// identifierToString cannot be used here since it uses backreference to 'parent' that is not yet set
// identifierToString cannot be used here since it uses a backreference to 'parent' that is not yet set
var name = sourceText.substring(skipTrivia(sourceText, node.pos), node.end);
grammarErrorOnNode(node, Diagnostics.Invalid_use_of_0_in_strict_mode, name);
}
@@ -736,7 +837,7 @@ module ts {
lookAheadMode = LookAheadMode.NoErrorYet;
var result = callback();
// If we switched from 1 to to -1 then a parse error occurred during the callback.
// If we switched from 1 to -1 then a parse error occurred during the callback.
// If that's the case, then we want to act as if we never got any result at all.
Debug.assert(lookAheadMode === LookAheadMode.Error || lookAheadMode === LookAheadMode.NoErrorYet);
if (lookAheadMode === LookAheadMode.Error) {
@@ -1654,7 +1755,7 @@ module ts {
// (i.e. they're both BinaryExpressions with an assignment operator in it).
// First, check if we have an arrow function (production '4') that starts with a parenthesized
// parameter list. If we do, we must *not* recurse for productsion 1, 2 or 3. An ArrowFunction is
// parameter list. If we do, we must *not* recurse for productions 1, 2 or 3. An ArrowFunction is
// not a LeftHandSideExpression, nor does it start a ConditionalExpression. So we are done
// with AssignmentExpression if we see one.
var arrowExpression = tryParseParenthesizedArrowFunctionExpression();
@@ -1842,7 +1943,7 @@ module ts {
if (token === SyntaxKind.EqualsGreaterThanToken) {
// ERROR RECOVERY TWEAK:
// If we see a standalone => try to parse it as an arrow function expression as that's
// likely whatthe user intended to write.
// likely what the user intended to write.
return Tristate.True;
}
// Definitely not a parenthesized arrow function.
@@ -2745,8 +2846,8 @@ module ts {
switch (token) {
case SyntaxKind.SemicolonToken:
// If we're in error recovery, then we don't want to treat ';' as an empty statement.
// The problem is that ';' can show up in far too many contexts, and if we see one
// and assume it's a statement, then we may bail out innapropriately from whatever
// The problem is that ';' can show up in far too many contexts, and if we see one
// and assume it's a statement, then we may bail out inappropriately from whatever
// we're parsing. For example, if we have a semicolon in the middle of a class, then
// we really don't want to assume the class is over and we're on a statement in the
// outer module. We just want to consume and move on.
@@ -2896,10 +2997,11 @@ module ts {
parseExpected(SyntaxKind.VarKeyword);
node.declarations = parseVariableDeclarationList(flags, /*noIn*/false);
parseSemicolon();
finishNode(node);
if (!node.declarations.length && file.syntacticErrors.length === errorCountBeforeVarStatement) {
grammarErrorOnNode(node, Diagnostics.Variable_declaration_list_cannot_be_empty);
}
return finishNode(node);
return node;
}
function parseFunctionDeclaration(pos?: number, flags?: NodeFlags): FunctionDeclaration {
@@ -3306,7 +3408,7 @@ module ts {
function isIntegerLiteral(expression: Expression): boolean {
function isInteger(literalExpression: LiteralExpression): boolean {
// Allows for scientific notation since literalExpression.text was formed by
// coercing a number to a string. Sometimes this coersion can yield a string
// coercing a number to a string. Sometimes this coercion can yield a string
// in scientific notation.
// We also don't need special logic for hex because a hex integer is converted
// to decimal when it is coerced.
@@ -3328,7 +3430,7 @@ module ts {
var inConstantEnumMemberSection = true;
// In an ambient declaration, the grammar only allows integer literals as initializers.
// In a nonambient declaration, the grammar allows uninitialized members only in a
// In a non-ambient declaration, the grammar allows uninitialized members only in a
// ConstantEnumMemberSection, which starts at the beginning of an enum declaration
// or any time an integer literal initializer is encountered.
function parseAndCheckEnumMember(): EnumMember {
@@ -3451,7 +3553,7 @@ module ts {
return finishNode(node);
}
function isDeclaration() {
function isDeclaration(): boolean {
switch (token) {
case SyntaxKind.VarKeyword:
case SyntaxKind.FunctionKeyword:
@@ -3868,7 +3970,7 @@ module ts {
commonSourceDirectory = getNormalizedPathFromPathCompoments(commonPathComponents);
if (commonSourceDirectory) {
// Make sure directory path ends with directory separator so this string can directly
// used to replace with "" to get the relative path of the source file and the relative path doesnt
// used to replace with "" to get the relative path of the source file and the relative path doesn't
// start with / making it rooted path
commonSourceDirectory += directorySeparator;
}
+4 -4
View File
@@ -192,7 +192,7 @@ module ts {
return false;
}
// Perform binary search in one of the unicode range maps
// Perform binary search in one of the Unicode range maps
var lo: number = 0;
var hi: number = map.length;
var mid: number;
@@ -281,8 +281,8 @@ module ts {
if (lineNumber < 0) {
// If the actual position was not found,
// the binary search returns the negative value of the next line start
// eg. if line starts at [5, 10, 23, 80] and position requested was 20
// the search will return -2
// e.g. if the line starts at [5, 10, 23, 80] and the position requested was 20
// then the search will return -2
lineNumber = (~lineNumber) - 1;
}
return {
@@ -369,7 +369,7 @@ module ts {
// Extract comments from the given source text starting at the given position. If trailing is false, whitespace is skipped until
// the first line break and comments between that location and the next token are returned. If trailing is true, comments occurring
// between the given position and the next line break are returned. The return value is an array containing a TextRange for each
// comment. Single-line comment ranges include the the beginning '//' characters but not the ending line break. Multi-line comment
// comment. Single-line comment ranges include the beginning '//' characters but not the ending line break. Multi-line comment
// ranges include the beginning '/* and ending '*/' characters. The return value is undefined if no comments were found.
function getCommentRanges(text: string, pos: number, trailing: boolean): Comment[] {
var result: Comment[];
+8 -10
View File
@@ -220,8 +220,8 @@ module ts {
FirstFutureReservedWord = ImplementsKeyword,
LastFutureReservedWord = YieldKeyword,
FirstTypeNode = TypeReference,
LastTypeNode = ArrayType,
FirstPunctuation= OpenBraceToken,
LastTypeNode = TupleType,
FirstPunctuation = OpenBraceToken,
LastPunctuation = CaretEqualsToken
}
@@ -636,12 +636,10 @@ module ts {
}
export enum TypeFormatFlags {
None = 0x00000000,
/** writes Array<T> instead T[] */
WriteArrayAsGenericType = 0x00000001, // Declarations
UseTypeOfFunction = 0x00000002, // instead of writing signature type of function use typeof
None = 0x00000000,
WriteArrayAsGenericType = 0x00000001, // Write Array<T> instead T[]
UseTypeOfFunction = 0x00000002, // Write typeof instead of function type literal
NoTruncation = 0x00000004, // Don't truncate typeToString result
}
export enum SymbolAccessibility {
@@ -653,7 +651,7 @@ module ts {
export interface SymbolAccessiblityResult {
accessibility: SymbolAccessibility;
errorSymbolName?: string // Optional symbol name that results in error
errorModuleName?: string // If the symbol is not visibile from module, module's name
errorModuleName?: string // If the symbol is not visible from module, module's name
aliasesToMakeVisible?: ImportDeclaration[]; // aliases that need to have this symbol visible
}
@@ -968,6 +966,7 @@ module ts {
locale?: string;
mapRoot?: string;
module?: ModuleKind;
noErrorTruncation?: boolean;
noImplicitAny?: boolean;
noLib?: boolean;
noLibCheck?: boolean;
@@ -980,7 +979,6 @@ module ts {
target?: ScriptTarget;
version?: boolean;
watch?: boolean;
[option: string]: any;
}
+2
View File
@@ -1084,6 +1084,8 @@ module FourSlash {
// Make the edit
var ch = text.charAt(i);
this.languageServiceShimHost.editScript(this.activeFile.fileName, offset, offset, ch);
this.languageService.getBraceMatchingAtPosition(this.activeFile.fileName, offset);
this.updateMarkersForEdit(this.activeFile.fileName, offset, offset, ch);
this.editCheckpoint(this.activeFile.fileName);
offset++;
+6 -1
View File
@@ -622,6 +622,7 @@ module Harness {
options = options || { noResolve: false };
options.target = options.target || ts.ScriptTarget.ES3;
options.module = options.module || ts.ModuleKind.None;
options.noErrorTruncation = true;
if (settingsCallback) {
settingsCallback(null);
@@ -725,6 +726,10 @@ module Harness {
options.emitBOM = !!setting.value;
break;
case 'errortruncation':
options.noErrorTruncation = setting.value === 'false';
break;
default:
throw new Error('Unsupported compiler setting ' + setting.flag);
}
@@ -1030,7 +1035,7 @@ module Harness {
var optionRegex = /^[\/]{2}\s*@(\w+)\s*:\s*(\S*)/gm; // multiple matches on multiple lines
// List of allowed metadata names
var fileMetadataNames = ["filename", "comments", "declaration", "module", "nolib", "sourcemap", "target", "out", "outDir", "noimplicitany", "noresolve", "newline", "newlines", "emitbom"];
var fileMetadataNames = ["filename", "comments", "declaration", "module", "nolib", "sourcemap", "target", "out", "outDir", "noimplicitany", "noresolve", "newline", "newlines", "emitbom", "errortruncation"];
function extractCompilerSettings(content: string): CompilerSetting[] {
+1 -1
View File
@@ -86,7 +86,7 @@ class TypeWriterWalker {
column: lineAndCharacter.character,
syntaxKind: ts.SyntaxKind[node.kind],
sourceText: sourceText,
type: this.checker.typeToString(type, node.parent, ts.TypeFormatFlags.None)
type: this.checker.typeToString(type, node.parent, ts.TypeFormatFlags.NoTruncation)
});
}
+57 -52
View File
@@ -1865,30 +1865,42 @@ declare var Window: {
new(): Window;
}
interface FormData {
append(name: any, value: any, blobName?: string): void;
interface HTMLCollection extends MSHTMLCollectionExtensions {
/**
* Sets or retrieves the number of objects in a collection.
*/
length: number;
/**
* Retrieves an object from various collections.
*/
item(nameOrIndex?: any, optionalIndex?: any): Element;
/**
* Retrieves a select object or an object from an options collection.
*/
namedItem(name: string): Element;
// [name: string]: Element;
[index: number]: Element;
}
declare var FormData: {
prototype: FormData;
new (form?: HTMLFormElement): FormData;
declare var HTMLCollection: {
prototype: HTMLCollection;
new(): HTMLCollection;
}
interface SourceBuffer extends EventTarget {
updating: boolean;
appendWindowStart: number;
appendWindowEnd: number;
buffered: TimeRanges;
timestampOffset: number;
audioTracks: AudioTrackList;
appendBuffer(data: ArrayBufferView): void;
appendBuffer(data: ArrayBuffer): void;
remove(start: number, end: number): void;
abort(): void;
appendStream(stream: MSStream, maxSize?: number): void;
interface BlobPropertyBag {
type?: string;
endings?: string;
}
declare var SourceBuffer: {
prototype: SourceBuffer;
new(): SourceBuffer;
interface Blob {
type: string;
size: number;
msDetachStream(): any;
slice(start?: number, end?: number, contentType?: string): Blob;
msClose(): void;
}
declare var Blob: {
prototype: Blob;
new (blobParts?: any[], options?: BlobPropertyBag): Blob;
}
interface NavigatorID {
@@ -3797,26 +3809,6 @@ declare var MSCSSProperties: {
new(): MSCSSProperties;
}
interface HTMLCollection extends MSHTMLCollectionExtensions {
/**
* Sets or retrieves the number of objects in a collection.
*/
length: number;
/**
* Retrieves an object from various collections.
*/
item(nameOrIndex?: any, optionalIndex?: any): Element;
/**
* Retrieves a select object or an object from an options collection.
*/
namedItem(name: string): Element;
// [name: string]: Element;
}
declare var HTMLCollection: {
prototype: HTMLCollection;
new(): HTMLCollection;
}
interface SVGExternalResourcesRequired {
externalResourcesRequired: SVGAnimatedBoolean;
}
@@ -10052,18 +10044,6 @@ declare var FileReader: {
new(): FileReader;
}
interface Blob {
type: string;
size: number;
msDetachStream(): any;
slice(start?: number, end?: number, contentType?: string): Blob;
msClose(): void;
}
declare var Blob: {
prototype: Blob;
new(): Blob;
}
interface ApplicationCache extends EventTarget {
status: number;
ondownloading: (ev: Event) => any;
@@ -10222,6 +10202,14 @@ declare var MSManipulationEvent: {
MS_MANIPULATION_STATE_CANCELLED: number;
}
interface FormData {
append(name: any, value: any, blobName?: string): void;
}
declare var FormData: {
prototype: FormData;
new(): FormData;
}
interface HTMLDataListElement extends HTMLElement {
options: HTMLCollection;
}
@@ -10640,6 +10628,23 @@ interface RandomSource {
getRandomValues(array: ArrayBufferView): ArrayBufferView;
}
interface SourceBuffer extends EventTarget {
updating: boolean;
appendWindowStart: number;
appendWindowEnd: number;
buffered: TimeRanges;
timestampOffset: number;
audioTracks: AudioTrackList;
appendBuffer(data: ArrayBuffer): void;
remove(start: number, end: number): void;
abort(): void;
appendStream(stream: MSStream, maxSize?: number): void;
}
declare var SourceBuffer: {
prototype: SourceBuffer;
new(): SourceBuffer;
}
interface MSInputMethodContext extends EventTarget {
oncandidatewindowshow: (ev: any) => any;
target: HTMLElement;
+6 -1
View File
@@ -614,6 +614,11 @@ declare var FileReader: {
new(): FileReader;
}
interface BlobPropertyBag {
type?: string;
endings?: string;
}
interface Blob {
type: string;
size: number;
@@ -623,7 +628,7 @@ interface Blob {
}
declare var Blob: {
prototype: Blob;
new(): Blob;
new (blobParts?: any[], options?: BlobPropertyBag): Blob;
}
interface MSStream {
+283 -76
View File
@@ -1312,20 +1312,6 @@ module ts {
return node.parent.kind === SyntaxKind.NewExpression && (<CallExpression>node.parent).func === node;
}
function isAnyFunction(node: Node): boolean {
switch (node.kind) {
case SyntaxKind.FunctionExpression:
case SyntaxKind.FunctionDeclaration:
case SyntaxKind.ArrowFunction:
case SyntaxKind.Method:
case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor:
case SyntaxKind.Constructor:
return true;
}
return false;
}
function isNameOfFunctionDeclaration(node: Node): boolean {
return node.kind === SyntaxKind.Identifier &&
isAnyFunction(node.parent) && (<FunctionDeclaration>node.parent).name === node;
@@ -2148,7 +2134,6 @@ module ts {
return result;
}
/// Find references
function getOccurrencesAtPosition(filename: string, position: number): ReferenceEntry[] {
synchronizeHostData();
@@ -2160,11 +2145,23 @@ module ts {
return undefined;
}
if (node.kind === SyntaxKind.Identifier || isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) {
if (node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.ThisKeyword || node.kind === SyntaxKind.SuperKeyword ||
isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) {
return getReferencesForNode(node, [sourceFile]);
}
switch (node.kind) {
case SyntaxKind.IfKeyword:
case SyntaxKind.ElseKeyword:
if (hasKind(node.parent, SyntaxKind.IfStatement)) {
return getIfElseOccurrences(<IfStatement>node.parent);
}
break;
case SyntaxKind.ReturnKeyword:
if (hasKind(node.parent, SyntaxKind.ReturnStatement)) {
return getReturnOccurrences(<ReturnStatement>node.parent);
}
break;
case SyntaxKind.TryKeyword:
case SyntaxKind.CatchKeyword:
case SyntaxKind.FinallyKeyword:
@@ -2188,10 +2185,91 @@ module ts {
return getBreakStatementOccurences(<BreakOrContinueStatement>node.parent);
}
break;
case SyntaxKind.ConstructorKeyword:
if (hasKind(node.parent, SyntaxKind.Constructor)) {
return getConstructorOccurrences(<ConstructorDeclaration>node.parent);
}
break;
}
return undefined;
function getIfElseOccurrences(ifStatement: IfStatement): ReferenceEntry[] {
var keywords: Node[] = [];
// Traverse upwards through all parent if-statements linked by their else-branches.
while (hasKind(ifStatement.parent, SyntaxKind.IfStatement) && (<IfStatement>ifStatement.parent).elseStatement === ifStatement) {
ifStatement = <IfStatement>ifStatement.parent;
}
// Now traverse back down through the else branches, aggregating if/else keywords of if-statements.
while (ifStatement) {
var children = ifStatement.getChildren();
pushKeywordIf(keywords, children[0], SyntaxKind.IfKeyword);
// Generally the 'else' keyword is second-to-last, so we traverse backwards.
for (var i = children.length - 1; i >= 0; i--) {
if (pushKeywordIf(keywords, children[i], SyntaxKind.ElseKeyword)) {
break;
}
}
if (!hasKind(ifStatement.elseStatement, SyntaxKind.IfStatement)) {
break
}
ifStatement = <IfStatement>ifStatement.elseStatement;
}
var result: ReferenceEntry[] = [];
// We'd like to highlight else/ifs together if they are only separated by whitespace
// (i.e. the keywords are separated by no comments, no newlines).
for (var i = 0; i < keywords.length; i++) {
if (keywords[i].kind === SyntaxKind.ElseKeyword && i < keywords.length - 1) {
var elseKeyword = keywords[i];
var ifKeyword = keywords[i + 1]; // this *should* always be an 'if' keyword.
var shouldHighlightNextKeyword = true;
// Avoid recalculating getStart() by iterating backwards.
for (var j = ifKeyword.getStart() - 1; j >= elseKeyword.end; j--) {
if (!isWhiteSpace(sourceFile.text.charCodeAt(j))) {
shouldHighlightNextKeyword = false;
break;
}
}
if (shouldHighlightNextKeyword) {
result.push(new ReferenceEntry(filename, TypeScript.TextSpan.fromBounds(elseKeyword.getStart(), ifKeyword.end), /* isWriteAccess */ false));
i++; // skip the next keyword
continue;
}
}
// Ordinary case: just highlight the keyword.
result.push(getReferenceEntryFromNode(keywords[i]));
}
return result;
}
function getReturnOccurrences(returnStatement: ReturnStatement): ReferenceEntry[] {
var func = <FunctionDeclaration>getContainingFunction(returnStatement);
// If we didn't find a containing function with a block body, bail out.
if (!(func && hasKind(func.body, SyntaxKind.FunctionBlock))) {
return undefined;
}
var keywords: Node[] = []
forEachReturnStatement(<Block>(<FunctionDeclaration>func).body, returnStatement => {
pushKeywordIf(keywords, returnStatement.getFirstToken(), SyntaxKind.ReturnKeyword);
});
return map(keywords, getReferenceEntryFromNode);
}
function getTryCatchFinallyOccurrences(tryStatement: TryStatement): ReferenceEntry[] {
var keywords: Node[] = [];
@@ -2205,7 +2283,7 @@ module ts {
pushKeywordIf(keywords, tryStatement.finallyBlock.getFirstToken(), SyntaxKind.FinallyKeyword);
}
return keywordsToReferenceEntries(keywords);
return map(keywords, getReferenceEntryFromNode);
}
function getSwitchCaseDefaultOccurrences(switchStatement: SwitchStatement) {
@@ -2241,10 +2319,10 @@ module ts {
});
});
return keywordsToReferenceEntries(keywords);
return map(keywords, getReferenceEntryFromNode);
}
function getBreakStatementOccurences(breakStatement: BreakOrContinueStatement): ReferenceEntry[]{
function getBreakStatementOccurences(breakStatement: BreakOrContinueStatement): ReferenceEntry[] {
// TODO (drosen): Deal with labeled statements.
if (breakStatement.label) {
return undefined;
@@ -2272,6 +2350,20 @@ module ts {
return undefined;
}
function getConstructorOccurrences(constructorDeclaration: ConstructorDeclaration): ReferenceEntry[] {
var declarations = constructorDeclaration.symbol.getDeclarations()
var keywords: Node[] = [];
forEach(declarations, declaration => {
forEach(declaration.getChildren(), token => {
return pushKeywordIf(keywords, token, SyntaxKind.ConstructorKeyword);
});
});
return map(keywords, getReferenceEntryFromNode);
}
// returns true if 'node' is defined and has a matching 'kind'.
function hasKind(node: Node, kind: SyntaxKind) {
return !!(node && node.kind === kind);
@@ -2282,20 +2374,13 @@ module ts {
return node && node.parent;
}
function pushKeywordIf(keywordList: Node[], token: Node, ...expected: SyntaxKind[]): void {
if (!token) {
return;
}
if (contains(<SyntaxKind[]>expected, token.kind)) {
function pushKeywordIf(keywordList: Node[], token: Node, ...expected: SyntaxKind[]): boolean {
if (token && contains(expected, token.kind)) {
keywordList.push(token);
return true;
}
}
function keywordsToReferenceEntries(keywords: Node[]): ReferenceEntry[]{
return map(keywords, keyword =>
new ReferenceEntry(filename, TypeScript.TextSpan.fromBounds(keyword.getStart(), keyword.end), /* isWriteAccess */ false)
);
return false;
}
}
@@ -2311,6 +2396,9 @@ module ts {
}
if (node.kind !== SyntaxKind.Identifier &&
// TODO (drosen): This should be enabled in a later release - currently breaks rename.
//node.kind !== SyntaxKind.ThisKeyword &&
//node.kind !== SyntaxKind.SuperKeyword &&
!isLiteralNameOfPropertyDeclarationOrIndexAccess(node) &&
!isNameOfExternalModuleImportOrDeclaration(node)) {
return undefined;
@@ -2326,7 +2414,7 @@ module ts {
var labelDefinition = getTargetLabel((<BreakOrContinueStatement>node.parent), (<Identifier>node).text);
// if we have a label definition, look within its statement for references, if not, then
// the label is undefined, just return a set of one for the current node.
return labelDefinition ? getLabelReferencesInNode(labelDefinition.parent, labelDefinition) : [getReferenceEntry(node)];
return labelDefinition ? getLabelReferencesInNode(labelDefinition.parent, labelDefinition) : [getReferenceEntryFromNode(node)];
}
else {
// it is a label definition and not a target, search within the parent labeledStatement
@@ -2334,13 +2422,21 @@ module ts {
}
}
if (node.kind === SyntaxKind.ThisKeyword) {
return getReferencesForThisKeyword(node, sourceFiles);
}
if (node.kind === SyntaxKind.SuperKeyword) {
return getReferencesForSuperKeyword(node);
}
var symbol = typeInfoResolver.getSymbolInfo(node);
// Could not find a symbol e.g. unknown identifier
if (!symbol) {
// Even if we did not find a symbol, we have an identifer, so there is at least
// one reference that we know of. return than instead of undefined.
return [getReferenceEntry(node)];
// one reference that we know of. return that instead of undefined.
return [getReferenceEntryFromNode(node)];
}
// the symbol was an internal symbol and does not have a declaration e.g.undefined symbol
@@ -2484,7 +2580,7 @@ module ts {
// Only pick labels that are either the target label, or have a target that is the target label
if (node === targetLabel ||
(isJumpStatementTarget(node) && getTargetLabel(node, labelName) === targetLabel)) {
result.push(getReferenceEntry(node));
result.push(getReferenceEntryFromNode(node));
}
});
return result;
@@ -2549,7 +2645,132 @@ module ts {
}
if (isRelatableToSearchSet(searchSymbols, referenceSymbol, referenceLocation)) {
result.push(getReferenceEntry(referenceLocation));
result.push(getReferenceEntryFromNode(referenceLocation));
}
});
}
}
function getReferencesForSuperKeyword(superKeyword: Node): ReferenceEntry[]{
var searchSpaceNode = getSuperContainer(superKeyword);
if (!searchSpaceNode) {
return undefined;
}
// Whether 'super' occurs in a static context within a class.
var staticFlag = NodeFlags.Static;
switch (searchSpaceNode.kind) {
case SyntaxKind.Property:
case SyntaxKind.Method:
case SyntaxKind.Constructor:
case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor:
staticFlag &= searchSpaceNode.flags;
searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class
break;
default:
return undefined;
}
var result: ReferenceEntry[] = [];
var sourceFile = searchSpaceNode.getSourceFile();
var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "super", searchSpaceNode.getStart(), searchSpaceNode.getEnd());
forEach(possiblePositions, position => {
cancellationToken.throwIfCancellationRequested();
var node = getNodeAtPosition(sourceFile, position);
if (!node || node.kind !== SyntaxKind.SuperKeyword) {
return;
}
var container = getSuperContainer(node);
// 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
// and has the same static qualifier as the original 'super's owner.
if (container && (NodeFlags.Static & container.flags) === staticFlag && container.parent.symbol === searchSpaceNode.symbol) {
result.push(getReferenceEntryFromNode(node));
}
});
return result;
}
function getReferencesForThisKeyword(thisOrSuperKeyword: Node, sourceFiles: SourceFile[]): ReferenceEntry[] {
var searchSpaceNode = getThisContainer(thisOrSuperKeyword, /* includeArrowFunctions */ false);
// Whether 'this' occurs in a static context within a class.
var staticFlag = NodeFlags.Static;
switch (searchSpaceNode.kind) {
case SyntaxKind.Property:
case SyntaxKind.Method:
case SyntaxKind.Constructor:
case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor:
staticFlag &= searchSpaceNode.flags
searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class
break;
case SyntaxKind.SourceFile:
if (isExternalModule(<SourceFile>searchSpaceNode)) {
return undefined;
}
// Fall through
case SyntaxKind.FunctionDeclaration:
case SyntaxKind.FunctionExpression:
break;
default:
return undefined;
}
var result: ReferenceEntry[] = [];
if (searchSpaceNode.kind === SyntaxKind.SourceFile) {
forEach(sourceFiles, sourceFile => {
var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd());
getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, result);
});
}
else {
var sourceFile = searchSpaceNode.getSourceFile();
var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", searchSpaceNode.getStart(), searchSpaceNode.getEnd());
getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, result);
}
return result;
function getThisReferencesInFile(sourceFile: SourceFile, searchSpaceNode: Node, possiblePositions: number[], result: ReferenceEntry[]): void {
forEach(possiblePositions, position => {
cancellationToken.throwIfCancellationRequested();
var node = getNodeAtPosition(sourceFile, position);
if (!node || node.kind !== SyntaxKind.ThisKeyword) {
return;
}
var container = getThisContainer(node, /* includeArrowFunctions */ false);
switch (searchSpaceNode.kind) {
case SyntaxKind.FunctionExpression:
case SyntaxKind.FunctionDeclaration:
if (searchSpaceNode.symbol === container.symbol) {
result.push(getReferenceEntryFromNode(node));
}
break;
case SyntaxKind.ClassDeclaration:
// Make sure the container belongs to the same class
// and has the appropriate static modifier from the original container.
if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (container.flags & NodeFlags.Static) === staticFlag) {
result.push(getReferenceEntryFromNode(node));
}
break;
case SyntaxKind.SourceFile:
if (container.kind === SyntaxKind.SourceFile && !isExternalModule(<SourceFile>container)) {
result.push(getReferenceEntryFromNode(node));
}
break;
}
});
}
@@ -2651,18 +2872,6 @@ module ts {
return undefined;
}
function getReferenceEntry(node: Node): ReferenceEntry {
var start = node.getStart();
var end = node.getEnd();
if (node.kind === SyntaxKind.StringLiteral) {
start += 1;
end -= 1;
}
return new ReferenceEntry(node.getSourceFile().filename, TypeScript.TextSpan.fromBounds(start, end), isWriteAccess(node));
}
function getMeaningFromDeclaration(node: Declaration): SearchMeaning {
switch (node.kind) {
case SyntaxKind.Parameter:
@@ -2799,40 +3008,38 @@ module ts {
}
return meaning;
}
}
/// A node is considedered a writeAccess iff it is a name of a declaration or a target of an assignment
function isWriteAccess(node: Node): boolean {
if (node.kind === SyntaxKind.Identifier && isDeclarationOrFunctionExpressionOrCatchVariableName(node)) {
function getReferenceEntryFromNode(node: Node): ReferenceEntry {
var start = node.getStart();
var end = node.getEnd();
if (node.kind === SyntaxKind.StringLiteral) {
start += 1;
end -= 1;
}
return new ReferenceEntry(node.getSourceFile().filename, TypeScript.TextSpan.fromBounds(start, end), isWriteAccess(node));
}
/// A node is considedered a writeAccess iff it is a name of a declaration or a target of an assignment
function isWriteAccess(node: Node): boolean {
if (node.kind === SyntaxKind.Identifier && isDeclarationOrFunctionExpressionOrCatchVariableName(node)) {
return true;
}
var parent = node.parent;
if (parent) {
if (parent.kind === SyntaxKind.PostfixOperator || parent.kind === SyntaxKind.PrefixOperator) {
return true;
}
var parent = node.parent;
if (parent) {
if (parent.kind === SyntaxKind.PostfixOperator || parent.kind === SyntaxKind.PrefixOperator) {
return true;
}
else if (parent.kind === SyntaxKind.BinaryExpression && (<BinaryExpression>parent).left === node) {
var operator = (<BinaryExpression>parent).operator;
switch (operator) {
case SyntaxKind.AsteriskEqualsToken:
case SyntaxKind.SlashEqualsToken:
case SyntaxKind.PercentEqualsToken:
case SyntaxKind.MinusEqualsToken:
case SyntaxKind.LessThanLessThanEqualsToken:
case SyntaxKind.GreaterThanGreaterThanEqualsToken:
case SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken:
case SyntaxKind.BarEqualsToken:
case SyntaxKind.CaretEqualsToken:
case SyntaxKind.AmpersandEqualsToken:
case SyntaxKind.PlusEqualsToken:
case SyntaxKind.EqualsToken:
return true;
}
}
return false;
else if (parent.kind === SyntaxKind.BinaryExpression && (<BinaryExpression>parent).left === node) {
var operator = (<BinaryExpression>parent).operator;
return SyntaxKind.FirstAssignment <= operator && operator <= SyntaxKind.LastAssignment;
}
}
return false;
}
/// Syntactic features
+19 -8
View File
@@ -544,18 +544,29 @@ module TypeScript.Parser {
}
}
function replaceTokenInParent(oldToken: ISyntaxToken, newToken: ISyntaxToken): void {
function replaceTokenInParent(node: ISyntaxNode, oldToken: ISyntaxToken, newToken: ISyntaxToken): void {
// oldToken may be parented by a node or a list.
replaceTokenInParentWorker(oldToken, newToken);
var parent = oldToken.parent;
newToken.parent = parent;
// Parent must be a list or a node. All of those have a 'data' element.
Debug.assert(isNode(parent) || isList(parent) || isSeparatedList(parent));
var dataElement = <{ data: number }><any>parent;
if (dataElement.data) {
dataElement.data &= SyntaxConstants.NodeParsedInStrictModeMask
// Walk upwards to our outermost node, clearing hte cached 'data' in it. This will
// make sure that the fullWidths and incrementally unusable bits are computed correctly
// when next requested.
while (true) {
// Parent must be a list or a node. All of those have a 'data' element.
Debug.assert(isNode(parent) || isList(parent) || isSeparatedList(parent));
var dataElement = <{ data: number }><any>parent;
if (dataElement.data) {
dataElement.data &= SyntaxConstants.NodeParsedInStrictModeMask
}
if (parent === node) {
break;
}
parent = parent.parent;
}
}
@@ -602,7 +613,7 @@ module TypeScript.Parser {
var oldToken = lastToken(node);
var newToken = addSkippedTokenAfterToken(oldToken, skippedToken);
replaceTokenInParent(oldToken, newToken);
replaceTokenInParent(node, oldToken, newToken);
return node;
}
@@ -611,7 +622,7 @@ module TypeScript.Parser {
var oldToken = firstToken(node);
var newToken = addSkippedTokensBeforeToken(oldToken, skippedTokens);
replaceTokenInParent(oldToken, newToken);
replaceTokenInParent(node, oldToken, newToken);
}
return node;
@@ -53,11 +53,11 @@ var A;
return Point;
})();
A.Point = Point;
var Point;
(function (Point) {
function Origin() {
return "";
}
Point.Origin = Origin; //expected duplicate identifier error
})(A.Point || (A.Point = {}));
var Point = A.Point;
})(Point = A.Point || (A.Point = {}));
})(A || (A = {}));
@@ -52,10 +52,10 @@ var A;
return Point;
})();
A.Point = Point;
var Point;
(function (Point) {
function Origin() {
return "";
} // not an error since not exported
})(A.Point || (A.Point = {}));
var Point = A.Point;
})(Point = A.Point || (A.Point = {}));
})(A || (A = {}));
@@ -46,8 +46,8 @@ var A;
return Point;
})();
A.Point = Point;
var Point;
(function (Point) {
Point.Origin = ""; //expected duplicate identifier error
})(A.Point || (A.Point = {}));
var Point = A.Point;
})(Point = A.Point || (A.Point = {}));
})(A || (A = {}));
@@ -46,8 +46,8 @@ var A;
return Point;
})();
A.Point = Point;
var Point;
(function (Point) {
var Origin = ""; // not an error since not exported
})(A.Point || (A.Point = {}));
var Point = A.Point;
})(Point = A.Point || (A.Point = {}));
})(A || (A = {}));
@@ -43,6 +43,7 @@ var a: { id: string };
//// [class.js]
var X;
(function (X) {
var Y;
(function (Y) {
var Point = (function () {
function Point(x, y) {
@@ -52,19 +53,18 @@ var X;
return Point;
})();
Y.Point = Point;
})(X.Y || (X.Y = {}));
var Y = X.Y;
})(Y = X.Y || (X.Y = {}));
})(X || (X = {}));
//// [module.js]
var X;
(function (X) {
var Y;
(function (Y) {
var Point;
(function (Point) {
Point.Origin = new Point(0, 0);
})(Y.Point || (Y.Point = {}));
var Point = Y.Point;
})(X.Y || (X.Y = {}));
var Y = X.Y;
})(Point = Y.Point || (Y.Point = {}));
})(Y = X.Y || (X.Y = {}));
})(X || (X = {}));
//// [test.js]
//var cl: { x: number; y: number; }
@@ -31,6 +31,7 @@ var A;
return Point;
})();
A.Point = Point;
var B;
(function (B) {
B.Origin = new Point(0, 0);
var Line = (function () {
@@ -42,6 +43,5 @@ var A;
return Line;
})();
B.Line = Line;
})(A.B || (A.B = {}));
var B = A.B;
})(B = A.B || (A.B = {}));
})(A || (A = {}));
@@ -54,10 +54,10 @@ var A;
//// [module.js]
var A;
(function (A) {
var Point;
(function (Point) {
Point.Origin = { x: 0, y: 0 };
})(A.Point || (A.Point = {}));
var Point = A.Point;
})(Point = A.Point || (A.Point = {}));
})(A || (A = {}));
//// [test.js]
var fn;
@@ -72,10 +72,10 @@ var B;
return { x: 0, y: 0 };
}
B.Point = Point;
var Point;
(function (Point) {
Point.Origin = { x: 0, y: 0 };
})(B.Point || (B.Point = {}));
var Point = B.Point;
})(Point = B.Point || (B.Point = {}));
})(B || (B = {}));
var fn;
var fn = B.Point; // not expected to be an error. bug 840000: [corelang] Function of fundule not assignalbe as expected
@@ -33,10 +33,10 @@ var A;
//// [module.js]
var B;
(function (B) {
var Point;
(function (Point) {
Point.Origin = { x: 0, y: 0 };
})(B.Point || (B.Point = {}));
var Point = B.Point;
})(Point = B.Point || (B.Point = {}));
})(B || (B = {}));
//// [test.js]
var fn;
@@ -34,17 +34,18 @@ class A {
//// [module.js]
var X;
(function (X) {
var Y;
(function (Y) {
var Point;
(function (Point) {
Point.Origin = new Point(0, 0);
})(Y.Point || (Y.Point = {}));
var Point = Y.Point;
})(X.Y || (X.Y = {}));
var Y = X.Y;
})(Point = Y.Point || (Y.Point = {}));
})(Y = X.Y || (X.Y = {}));
})(X || (X = {}));
//// [classPoint.js]
var X;
(function (X) {
var Y;
(function (Y) {
// duplicate identifier
var Point = (function () {
@@ -55,8 +56,7 @@ var X;
return Point;
})();
Y.Point = Point;
})(X.Y || (X.Y = {}));
var Y = X.Y;
})(Y = X.Y || (X.Y = {}));
})(X || (X = {}));
//// [simple.js]
var A;
@@ -32,10 +32,10 @@ module B {
//// [module.js]
var A;
(function (A) {
var Point;
(function (Point) {
Point.Origin = { x: 0, y: 0 };
})(A.Point || (A.Point = {}));
var Point = A.Point;
})(Point = A.Point || (A.Point = {}));
})(A || (A = {}));
//// [function.js]
var A;
@@ -49,10 +49,10 @@ var A;
//// [simple.js]
var B;
(function (B) {
var Point;
(function (Point) {
Point.Origin = { x: 0, y: 0 };
})(B.Point || (B.Point = {}));
var Point = B.Point;
})(Point = B.Point || (B.Point = {}));
// duplicate identifier error
function Point() {
return { x: 0, y: 0 };
@@ -66,7 +66,9 @@ var p;
var p;
var X;
(function (X) {
var Y;
(function (Y) {
var Z;
(function (Z) {
var Line = (function () {
function Line() {
@@ -74,24 +76,22 @@ var X;
return Line;
})();
Z.Line = Line;
})(Y.Z || (Y.Z = {}));
var Z = Y.Z;
})(X.Y || (X.Y = {}));
var Y = X.Y;
})(Z = Y.Z || (Y.Z = {}));
})(Y = X.Y || (X.Y = {}));
})(X || (X = {}));
var X;
(function (X) {
var Y;
(function (Y) {
var Z;
(function (Z) {
var Line = (function () {
function Line() {
}
return Line;
})();
})(Y.Z || (Y.Z = {}));
var Z = Y.Z;
})(X.Y || (X.Y = {}));
var Y = X.Y;
})(Z = Y.Z || (Y.Z = {}));
})(Y = X.Y || (X.Y = {}));
})(X || (X = {}));
// ensure merges as expected
var l;
@@ -44,13 +44,13 @@ var p = new A.Utils.Plane(o, { x: 1, y: 1 });
//// [part1.js]
var A;
(function (A) {
var Utils;
(function (Utils) {
function mirror(p) {
return { x: p.y, y: p.x };
}
Utils.mirror = mirror;
})(A.Utils || (A.Utils = {}));
var Utils = A.Utils;
})(Utils = A.Utils || (A.Utils = {}));
A.Origin = { x: 0, y: 0 };
})(A || (A = {}));
//// [part2.js]
@@ -58,6 +58,7 @@ var A;
(function (A) {
// not a collision, since we don't export
var Origin = "0,0";
var Utils;
(function (Utils) {
var Plane = (function () {
function Plane(tl, br) {
@@ -67,8 +68,7 @@ var A;
return Plane;
})();
Utils.Plane = Plane;
})(A.Utils || (A.Utils = {}));
var Utils = A.Utils;
})(Utils = A.Utils || (A.Utils = {}));
})(A || (A = {}));
//// [part3.js]
// test the merging actually worked
@@ -54,7 +54,9 @@ var A;
})(A || (A = {}));
var X;
(function (X) {
var Y;
(function (Y) {
var Z;
(function (Z) {
var Line = (function () {
function Line() {
@@ -62,14 +64,14 @@ var X;
return Line;
})();
Z.Line = Line;
})(Y.Z || (Y.Z = {}));
var Z = Y.Z;
})(X.Y || (X.Y = {}));
var Y = X.Y;
})(Z = Y.Z || (Y.Z = {}));
})(Y = X.Y || (X.Y = {}));
})(X || (X = {}));
var X;
(function (X) {
var Y;
(function (Y) {
var Z;
(function (Z) {
// expected error
var Line = (function () {
@@ -78,8 +80,6 @@ var X;
return Line;
})();
Z.Line = Line;
})(Y.Z || (Y.Z = {}));
var Z = Y.Z;
})(X.Y || (X.Y = {}));
var Y = X.Y;
})(Z = Y.Z || (Y.Z = {}));
})(Y = X.Y || (X.Y = {}));
})(X || (X = {}));
@@ -37,10 +37,10 @@ var l: X.Y.Z.Line;
//// [TwoInternalModulesThatMergeEachWithExportedModulesOfTheSameName.js]
var A;
(function (A) {
var B;
(function (B) {
B.x;
})(A.B || (A.B = {}));
var B = A.B;
})(B = A.B || (A.B = {}));
})(A || (A = {}));
var A;
(function (A) {
@@ -54,7 +54,9 @@ var x;
var x = A.B.x;
var X;
(function (X) {
var Y;
(function (Y) {
var Z;
(function (Z) {
var Line = (function () {
function Line() {
@@ -62,13 +64,12 @@ var X;
return Line;
})();
Z.Line = Line;
})(Y.Z || (Y.Z = {}));
var Z = Y.Z;
})(X.Y || (X.Y = {}));
var Y = X.Y;
})(Z = Y.Z || (Y.Z = {}));
})(Y = X.Y || (X.Y = {}));
})(X || (X = {}));
var X;
(function (X) {
var Y;
(function (Y) {
var Z;
(function (Z) {
@@ -79,8 +80,7 @@ var X;
})();
Z.Line = Line;
})(Z || (Z = {}));
})(X.Y || (X.Y = {}));
var Y = X.Y;
})(Y = X.Y || (X.Y = {}));
})(X || (X = {}));
// make sure merging works as expected
var l;
@@ -33,23 +33,25 @@ module otherRoot {
//// [part1.js]
var Root;
(function (Root) {
var A;
(function (A) {
var Utils;
(function (Utils) {
function mirror(p) {
return { x: p.y, y: p.x };
}
Utils.mirror = mirror;
})(A.Utils || (A.Utils = {}));
var Utils = A.Utils;
})(Root.A || (Root.A = {}));
var A = Root.A;
})(Utils = A.Utils || (A.Utils = {}));
})(A = Root.A || (Root.A = {}));
})(Root || (Root = {}));
//// [part2.js]
var otherRoot;
(function (otherRoot) {
var A;
(function (A) {
// have to be fully qualified since in different root
A.Origin = { x: 0, y: 0 };
var Utils;
(function (Utils) {
var Plane = (function () {
function Plane(tl, br) {
@@ -59,8 +61,6 @@ var otherRoot;
return Plane;
})();
Utils.Plane = Plane;
})(A.Utils || (A.Utils = {}));
var Utils = A.Utils;
})(otherRoot.A || (otherRoot.A = {}));
var A = otherRoot.A;
})(Utils = A.Utils || (A.Utils = {}));
})(A = otherRoot.A || (otherRoot.A = {}));
})(otherRoot || (otherRoot = {}));
@@ -42,18 +42,19 @@ var p = new A.Utils.Plane(o, { x: 1, y: 1 });
//// [part1.js]
var A;
(function (A) {
var Utils;
(function (Utils) {
function mirror(p) {
return { x: p.y, y: p.x };
}
Utils.mirror = mirror;
})(A.Utils || (A.Utils = {}));
var Utils = A.Utils;
})(Utils = A.Utils || (A.Utils = {}));
})(A || (A = {}));
//// [part2.js]
var A;
(function (A) {
A.Origin = { x: 0, y: 0 };
var Utils;
(function (Utils) {
var Plane = (function () {
function Plane(tl, br) {
@@ -63,8 +64,7 @@ var A;
return Plane;
})();
Utils.Plane = Plane;
})(A.Utils || (A.Utils = {}));
var Utils = A.Utils;
})(Utils = A.Utils || (A.Utils = {}));
})(A || (A = {}));
//// [part3.js]
// test the merging actually worked
+4 -4
View File
@@ -29,7 +29,9 @@ var foo;
return Provide;
})();
foo.Provide = Provide;
var bar;
(function (bar) {
var baz;
(function (baz) {
var boo = (function () {
function boo() {
@@ -37,10 +39,8 @@ var foo;
return boo;
})();
baz.boo = boo;
})(bar.baz || (bar.baz = {}));
var baz = bar.baz;
})(foo.bar || (foo.bar = {}));
var bar = foo.bar;
})(baz = bar.baz || (bar.baz = {}));
})(bar = foo.bar || (foo.bar = {}));
})(foo || (foo = {}));
var provide = foo;
var booz = foo.bar.baz;
@@ -0,0 +1,6 @@
==== tests/cases/conformance/ambient/ambientExternalModuleInsideNonAmbient.ts (1 errors) ====
module M {
export declare module "M" { }
~~~
!!! Ambient external modules cannot be nested in other modules.
}
@@ -0,0 +1,6 @@
//// [ambientExternalModuleInsideNonAmbient.ts]
module M {
export declare module "M" { }
}
//// [ambientExternalModuleInsideNonAmbient.js]
@@ -0,0 +1,4 @@
==== tests/cases/conformance/ambient/ambientExternalModuleInsideNonAmbientExternalModule.ts (1 errors) ====
export declare module "M" { }
~~~
!!! Ambient external modules cannot be nested in other modules.
@@ -0,0 +1,6 @@
//// [ambientExternalModuleInsideNonAmbientExternalModule.ts]
export declare module "M" { }
//// [ambientExternalModuleInsideNonAmbientExternalModule.js]
define(["require", "exports"], function (require, exports) {
});
@@ -0,0 +1,25 @@
//// [tests/cases/conformance/ambient/ambientExternalModuleMerging.ts] ////
//// [ambientExternalModuleMerging_use.ts]
import M = require("M");
// Should be strings
var x = M.x;
var y = M.y;
//// [ambientExternalModuleMerging_declare.ts]
declare module "M" {
export var x: string;
}
// Merge
declare module "M" {
export var y: string;
}
//// [ambientExternalModuleMerging_use.js]
define(["require", "exports", "M"], function (require, exports, M) {
// Should be strings
var x = M.x;
var y = M.y;
});
//// [ambientExternalModuleMerging_declare.js]
@@ -0,0 +1,28 @@
=== tests/cases/conformance/ambient/ambientExternalModuleMerging_use.ts ===
import M = require("M");
>M : typeof M
// Should be strings
var x = M.x;
>x : string
>M.x : string
>M : typeof M
>x : string
var y = M.y;
>y : string
>M.y : string
>M : typeof M
>y : string
=== tests/cases/conformance/ambient/ambientExternalModuleMerging_declare.ts ===
declare module "M" {
export var x: string;
>x : string
}
// Merge
declare module "M" {
export var y: string;
>y : string
}
@@ -0,0 +1,24 @@
//// [ambientInsideNonAmbient.ts]
module M {
export declare var x;
export declare function f();
export declare class C { }
export declare enum E { }
export declare module M { }
}
module M2 {
declare var x;
declare function f();
declare class C { }
declare enum E { }
declare module M { }
}
//// [ambientInsideNonAmbient.js]
var M;
(function (M) {
})(M || (M = {}));
var M2;
(function (M2) {
})(M2 || (M2 = {}));
@@ -0,0 +1,38 @@
=== tests/cases/conformance/ambient/ambientInsideNonAmbient.ts ===
module M {
>M : typeof M
export declare var x;
>x : any
export declare function f();
>f : () => any
export declare class C { }
>C : C
export declare enum E { }
>E : E
export declare module M { }
>M : unknown
}
module M2 {
>M2 : typeof M2
declare var x;
>x : any
declare function f();
>f : () => any
declare class C { }
>C : C
declare enum E { }
>E : E
declare module M { }
>M : unknown
}
@@ -0,0 +1,10 @@
//// [ambientInsideNonAmbientExternalModule.ts]
export declare var x;
export declare function f();
export declare class C { }
export declare enum E { }
export declare module M { }
//// [ambientInsideNonAmbientExternalModule.js]
define(["require", "exports"], function (require, exports) {
});
@@ -0,0 +1,16 @@
=== tests/cases/conformance/ambient/ambientInsideNonAmbientExternalModule.ts ===
export declare var x;
>x : any
export declare function f();
>f : () => any
export declare class C { }
>C : C
export declare enum E { }
>E : E
export declare module M { }
>M : unknown
@@ -222,7 +222,7 @@ class f {
>base : base
>[ { x: undefined, y: new base() }, { x: '', y: new derived() } ] : { x: string; y: base; }[]
>{ x: undefined, y: new base() } : { x: undefined; y: base; }
>x : any
>x : undefined
>undefined : undefined
>y : base
>new base() : base
@@ -3,8 +3,9 @@
// has type { foo: string }[], which is not assignable to { id: number }[].
<{ id: number; }[]>[{ foo: "s" }];
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! Neither type '{ id: number; }[]' nor type '{ foo: string; }[]' is assignable to the other:
!!! Type '{ id: number; }' is not assignable to type '{ foo: string; }'.
!!! Neither type '{ foo: string; }[]' nor type '{ id: number; }[]' is assignable to the other:
!!! Type '{ foo: string; }' is not assignable to type '{ id: number; }':
!!! Property 'id' is missing in type '{ foo: string; }'.
// Should succeed, as the {} element causes the type of the array to be {}[]
<{ id: number; }[]>[{ foo: "s" }, {}];
@@ -91,10 +91,10 @@ M = { y: 3 }; // Error
(M) = { y: 3 }; // Error
var M2;
(function (M2) {
var M3;
(function (M3) {
M3.x;
})(M2.M3 || (M2.M3 = {}));
var M3 = M2.M3;
})(M3 = M2.M3 || (M2.M3 = {}));
M3 = { x: 3 }; // Error
})(M2 || (M2 = {}));
M2.M3 = { x: 3 }; // OK
@@ -1,4 +1,4 @@
==== tests/cases/compiler/augmentedTypeAssignmentCompatIndexSignature.ts (2 errors) ====
==== tests/cases/conformance/types/members/augmentedTypeAssignmentCompatIndexSignature.ts (2 errors) ====
interface Foo { a }
interface Bar { b }
@@ -1,4 +1,4 @@
=== tests/cases/compiler/augmentedTypeBracketAccessIndexSignature.ts ===
=== tests/cases/conformance/types/members/augmentedTypeBracketAccessIndexSignature.ts ===
interface Foo { a }
>Foo : Foo
>a : any
@@ -12,12 +12,12 @@ y.m.foo();
//// [chainedImportAlias_file0.js]
var m;
(function (m) {
function foo() {
}
m.foo = foo;
})(exports.m || (exports.m = {}));
var m = exports.m;
})(m = exports.m || (exports.m = {}));
//// [chainedImportAlias_file1.js]
var x = require('chainedImportAlias_file0');
var y = x;
@@ -26,10 +26,10 @@ var M;
return N;
})();
M.N = N;
var N;
(function (N) {
N.v = 0;
})(M.N || (M.N = {}));
var N = M.N;
})(N = M.N || (M.N = {}));
})(M || (M = {}));
var M;
(function (M) {
@@ -0,0 +1,26 @@
//// [classDoesNotDependOnPrivateMember.ts]
module M {
interface I { }
export class C {
private x: I;
}
}
//// [classDoesNotDependOnPrivateMember.js]
var M;
(function (M) {
var C = (function () {
function C() {
}
return C;
})();
M.C = C;
})(M || (M = {}));
//// [classDoesNotDependOnPrivateMember.d.ts]
declare module M {
class C {
private x;
}
}
@@ -0,0 +1,15 @@
=== tests/cases/conformance/declarationEmit/classDoesNotDependOnPrivateMember.ts ===
module M {
>M : typeof M
interface I { }
>I : I
export class C {
>C : C
private x: I;
>x : I
>I : I
}
}
@@ -31,9 +31,9 @@ var A;
})(A || (A = {}));
var A;
(function (A) {
var B;
(function (B) {
B.x = 1;
})(A.B || (A.B = {}));
var B = A.B;
})(B = A.B || (A.B = {}));
})(A || (A = {}));
var b; // ok
@@ -16,8 +16,8 @@ var M;
return C;
})();
M.C = C;
var C;
(function (_C) {
_C.C = M.C;
})(M.C || (M.C = {}));
var C = M.C;
})(C = M.C || (M.C = {}));
})(M || (M = {}));
@@ -36,13 +36,13 @@ var Shape = (function () {
})();
var Shape;
(function (Shape) {
var Utils;
(function (Utils) {
function convert() {
return null;
}
Utils.convert = convert;
})(Shape.Utils || (Shape.Utils = {}));
var Utils = Shape.Utils;
})(Utils = Shape.Utils || (Shape.Utils = {}));
})(Shape || (Shape = {}));
var Path = (function (_super) {
__extends(Path, _super);
@@ -53,11 +53,11 @@ var Path = (function (_super) {
})(Shape);
var Path;
(function (Path) {
var Utils;
(function (Utils) {
function convert2() {
return null;
}
Utils.convert2 = convert2;
})(Path.Utils || (Path.Utils = {}));
var Utils = Path.Utils;
})(Utils = Path.Utils || (Path.Utils = {}));
})(Path || (Path = {}));
@@ -24,6 +24,7 @@ module m2 {
//// [collisionExportsRequireAndInternalModuleAlias.js]
define(["require", "exports"], function (require, exports) {
var m;
(function (m) {
var c = (function () {
function c() {
@@ -31,8 +32,7 @@ define(["require", "exports"], function (require, exports) {
return c;
})();
m.c = c;
})(exports.m || (exports.m = {}));
var m = exports.m;
})(m = exports.m || (exports.m = {}));
var exports = m.c;
var require = m.c;
new exports();
@@ -93,6 +93,7 @@ module m4 {
//// [collisionExportsRequireAndModule_externalmodule.js]
define(["require", "exports"], function (require, exports) {
var require;
(function (require) {
var C = (function () {
function C() {
@@ -100,12 +101,12 @@ define(["require", "exports"], function (require, exports) {
return C;
})();
require.C = C;
})(exports.require || (exports.require = {}));
var require = exports.require;
})(require = exports.require || (exports.require = {}));
function foo() {
return null;
}
exports.foo = foo;
var exports;
(function (exports) {
var C = (function () {
function C() {
@@ -113,8 +114,7 @@ define(["require", "exports"], function (require, exports) {
return C;
})();
exports.C = C;
})(exports.exports || (exports.exports = {}));
var exports = exports.exports;
})(exports = exports.exports || (exports.exports = {}));
function foo2() {
return null;
}
@@ -142,6 +142,7 @@ define(["require", "exports"], function (require, exports) {
})(m1 || (m1 = {}));
var m2;
(function (m2) {
var require;
(function (require) {
var C = (function () {
function C() {
@@ -149,8 +150,8 @@ define(["require", "exports"], function (require, exports) {
return C;
})();
require.C = C;
})(m2.require || (m2.require = {}));
var require = m2.require;
})(require = m2.require || (m2.require = {}));
var exports;
(function (exports) {
var C = (function () {
function C() {
@@ -158,8 +159,7 @@ define(["require", "exports"], function (require, exports) {
return C;
})();
exports.C = C;
})(m2.exports || (m2.exports = {}));
var exports = m2.exports;
})(exports = m2.exports || (m2.exports = {}));
})(m2 || (m2 = {}));
});
//// [collisionExportsRequireAndModule_globalFile.js]
@@ -204,6 +204,7 @@ var m3;
})(m3 || (m3 = {}));
var m4;
(function (m4) {
var require;
(function (require) {
var C = (function () {
function C() {
@@ -211,8 +212,8 @@ var m4;
return C;
})();
require.C = C;
})(m4.require || (m4.require = {}));
var require = m4.require;
})(require = m4.require || (m4.require = {}));
var exports;
(function (exports) {
var C = (function () {
function C() {
@@ -220,6 +221,5 @@ var m4;
return C;
})();
exports.C = C;
})(m4.exports || (m4.exports = {}));
var exports = m4.exports;
})(exports = m4.exports || (m4.exports = {}));
})(m4 || (m4 = {}));
@@ -557,11 +557,11 @@ declare var i1_ncf: (b: number) => number;
declare var i1_ncr: number;
declare var i1_ncprop: number;
declare var i1_s_p: number;
declare var i1_s_f: typeof s2;
declare var i1_s_f: typeof c1.s2;
declare var i1_s_r: number;
declare var i1_s_prop: number;
declare var i1_s_nc_p: number;
declare var i1_s_ncf: typeof nc_s2;
declare var i1_s_ncf: typeof c1.nc_s2;
declare var i1_s_ncr: number;
declare var i1_s_ncprop: number;
declare var i1_c: typeof c1;
@@ -577,111 +577,3 @@ declare class cProperties {
private y;
}
declare var cProperties_i: cProperties;
//// [DtsFileErrors]
==== tests/cases/compiler/commentsClassMembers.d.ts (2 errors) ====
/** This is comment for c1*/
declare class c1 {
/** p1 is property of c1*/
p1: number;
/** sum with property*/
p2(/** number to add*/ b: number): number;
/** getter property*/
/** setter property*/
p3: number;
/** pp1 is property of c1*/
private pp1;
/** sum with property*/
private pp2(/** number to add*/ b);
/** getter property*/
/** setter property*/
private pp3;
/** Constructor method*/
constructor();
/** s1 is static property of c1*/
static s1: number;
/** static sum with property*/
static s2(/** number to add*/ b: number): number;
/** static getter property*/
/** setter property*/
static s3: number;
nc_p1: number;
nc_p2(b: number): number;
nc_p3: number;
private nc_pp1;
private nc_pp2(b);
private nc_pp3;
static nc_s1: number;
static nc_s2(b: number): number;
static nc_s3: number;
a_p1: number;
a_p2(b: number): number;
a_p3: number;
private a_pp1;
private a_pp2(b);
private a_pp3;
static a_s1: number;
static a_s2(b: number): number;
static a_s3: number;
/** p1 is property of c1 */
b_p1: number;
/** sum with property */
b_p2(b: number): number;
/** getter property */
/** setter property */
b_p3: number;
/** pp1 is property of c1 */
private b_pp1;
/** sum with property */
private b_pp2(b);
/** getter property */
/** setter property */
private b_pp3;
/** s1 is static property of c1 */
static b_s1: number;
/** static sum with property */
static b_s2(b: number): number;
/** static getter property
*/
/** setter property
*/
static b_s3: number;
}
declare var i1: c1;
declare var i1_p: number;
declare var i1_f: (b: number) => number;
declare var i1_r: number;
declare var i1_prop: number;
declare var i1_nc_p: number;
declare var i1_ncf: (b: number) => number;
declare var i1_ncr: number;
declare var i1_ncprop: number;
declare var i1_s_p: number;
declare var i1_s_f: typeof s2;
~~
!!! Cannot find name 's2'.
declare var i1_s_r: number;
declare var i1_s_prop: number;
declare var i1_s_nc_p: number;
declare var i1_s_ncf: typeof nc_s2;
~~~~~
!!! Cannot find name 'nc_s2'.
declare var i1_s_ncr: number;
declare var i1_s_ncprop: number;
declare var i1_c: typeof c1;
declare class cProperties {
private val;
/** getter only property*/
p1: number;
nc_p1: number;
/**setter only property*/
p2: number;
nc_p2: number;
x: number;
private y;
}
declare var cProperties_i: cProperties;
@@ -10,7 +10,9 @@ export module outerModule.InnerModule {
//// [commentsDottedModuleName.js]
define(["require", "exports"], function (require, exports) {
/** this is multi declare module*/
var outerModule;
(function (outerModule) {
var InnerModule;
(function (InnerModule) {
/// class b comment
var b = (function () {
@@ -19,10 +21,8 @@ define(["require", "exports"], function (require, exports) {
return b;
})();
InnerModule.b = b;
})(outerModule.InnerModule || (outerModule.InnerModule = {}));
var InnerModule = outerModule.InnerModule;
})(exports.outerModule || (exports.outerModule = {}));
var outerModule = exports.outerModule;
})(InnerModule = outerModule.InnerModule || (outerModule.InnerModule = {}));
})(outerModule = exports.outerModule || (exports.outerModule = {}));
});
@@ -64,6 +64,7 @@ var newVar2 = new extMod.m4.m2.c();
//// [commentsExternalModules_0.js]
define(["require", "exports"], function (require, exports) {
/** Module comment*/
var m1;
(function (m1) {
/** b's comment*/
m1.b;
@@ -72,6 +73,7 @@ define(["require", "exports"], function (require, exports) {
return m1.b;
}
/** m2 comments*/
var m2;
(function (m2) {
/** class comment;*/
var c = (function () {
@@ -83,18 +85,17 @@ define(["require", "exports"], function (require, exports) {
;
/** i*/
m2.i = new c();
})(m1.m2 || (m1.m2 = {}));
var m2 = m1.m2;
})(m2 = m1.m2 || (m1.m2 = {}));
/** exported function*/
function fooExport() {
return foo();
}
m1.fooExport = fooExport;
})(exports.m1 || (exports.m1 = {}));
var m1 = exports.m1;
})(m1 = exports.m1 || (exports.m1 = {}));
m1.fooExport();
var myvar = new m1.m2.c();
/** Module comment */
var m4;
(function (m4) {
/** b's comment */
m4.b;
@@ -105,6 +106,7 @@ define(["require", "exports"], function (require, exports) {
}
/** m2 comments
*/
var m2;
(function (m2) {
/** class comment; */
var c = (function () {
@@ -116,15 +118,13 @@ define(["require", "exports"], function (require, exports) {
;
/** i */
m2.i = new c();
})(m4.m2 || (m4.m2 = {}));
var m2 = m4.m2;
})(m2 = m4.m2 || (m4.m2 = {}));
/** exported function */
function fooExport() {
return foo();
}
m4.fooExport = fooExport;
})(exports.m4 || (exports.m4 = {}));
var m4 = exports.m4;
})(m4 = exports.m4 || (exports.m4 = {}));
m4.fooExport();
var myvar2 = new m4.m2.c();
});
@@ -64,6 +64,7 @@ export var newVar2 = new extMod.m4.m2.c();
//// [commentsExternalModules2_0.js]
define(["require", "exports"], function (require, exports) {
/** Module comment*/
var m1;
(function (m1) {
/** b's comment*/
m1.b;
@@ -72,6 +73,7 @@ define(["require", "exports"], function (require, exports) {
return m1.b;
}
/** m2 comments*/
var m2;
(function (m2) {
/** class comment;*/
var c = (function () {
@@ -83,18 +85,17 @@ define(["require", "exports"], function (require, exports) {
;
/** i*/
m2.i = new c();
})(m1.m2 || (m1.m2 = {}));
var m2 = m1.m2;
})(m2 = m1.m2 || (m1.m2 = {}));
/** exported function*/
function fooExport() {
return foo();
}
m1.fooExport = fooExport;
})(exports.m1 || (exports.m1 = {}));
var m1 = exports.m1;
})(m1 = exports.m1 || (exports.m1 = {}));
m1.fooExport();
var myvar = new m1.m2.c();
/** Module comment */
var m4;
(function (m4) {
/** b's comment */
m4.b;
@@ -105,6 +106,7 @@ define(["require", "exports"], function (require, exports) {
}
/** m2 comments
*/
var m2;
(function (m2) {
/** class comment; */
var c = (function () {
@@ -116,15 +118,13 @@ define(["require", "exports"], function (require, exports) {
;
/** i */
m2.i = new c();
})(m4.m2 || (m4.m2 = {}));
var m2 = m4.m2;
})(m2 = m4.m2 || (m4.m2 = {}));
/** exported function */
function fooExport() {
return foo();
}
m4.fooExport = fooExport;
})(exports.m4 || (exports.m4 = {}));
var m4 = exports.m4;
})(m4 = exports.m4 || (exports.m4 = {}));
m4.fooExport();
var myvar2 = new m4.m2.c();
});
@@ -63,6 +63,7 @@ export var newVar2 = new extMod.m4.m2.c();
//// [commentsExternalModules2_0.js]
/** Module comment*/
var m1;
(function (m1) {
/** b's comment*/
m1.b;
@@ -71,6 +72,7 @@ export var newVar2 = new extMod.m4.m2.c();
return m1.b;
}
/** m2 comments*/
var m2;
(function (m2) {
/** class comment;*/
var c = (function () {
@@ -82,18 +84,17 @@ export var newVar2 = new extMod.m4.m2.c();
;
/** i*/
m2.i = new c();
})(m1.m2 || (m1.m2 = {}));
var m2 = m1.m2;
})(m2 = m1.m2 || (m1.m2 = {}));
/** exported function*/
function fooExport() {
return foo();
}
m1.fooExport = fooExport;
})(exports.m1 || (exports.m1 = {}));
var m1 = exports.m1;
})(m1 = exports.m1 || (exports.m1 = {}));
m1.fooExport();
var myvar = new m1.m2.c();
/** Module comment */
var m4;
(function (m4) {
/** b's comment */
m4.b;
@@ -104,6 +105,7 @@ var myvar = new m1.m2.c();
}
/** m2 comments
*/
var m2;
(function (m2) {
/** class comment; */
var c = (function () {
@@ -115,15 +117,13 @@ var myvar = new m1.m2.c();
;
/** i */
m2.i = new c();
})(m4.m2 || (m4.m2 = {}));
var m2 = m4.m2;
})(m2 = m4.m2 || (m4.m2 = {}));
/** exported function */
function fooExport() {
return foo();
}
m4.fooExport = fooExport;
})(exports.m4 || (exports.m4 = {}));
var m4 = exports.m4;
})(m4 = exports.m4 || (exports.m4 = {}));
m4.fooExport();
var myvar2 = new m4.m2.c();
//// [commentsExternalModules_1.js]
+28 -28
View File
@@ -108,6 +108,7 @@ var m1;
return m1.b;
}
/** m2 comments*/
var m2;
(function (m2) {
/** class comment;*/
var c = (function () {
@@ -119,8 +120,7 @@ var m1;
;
/** i*/
m2.i = new c();
})(m1.m2 || (m1.m2 = {}));
var m2 = m1.m2;
})(m2 = m1.m2 || (m1.m2 = {}));
/** exported function*/
function fooExport() {
return foo();
@@ -147,6 +147,7 @@ var myvar = new m1.m2.c();
/** module comment of m2.m3*/
var m2;
(function (m2) {
var m3;
(function (m3) {
/** Exported class comment*/
var c = (function () {
@@ -155,14 +156,15 @@ var m2;
return c;
})();
m3.c = c;
})(m2.m3 || (m2.m3 = {}));
var m3 = m2.m3;
})(m3 = m2.m3 || (m2.m3 = {}));
})(m2 || (m2 = {})); /* trailing dotted module comment*/
new m2.m3.c();
/** module comment of m3.m4.m5*/
var m3;
(function (m3) {
var m4;
(function (m4) {
var m5;
(function (m5) {
/** Exported class comment*/
var c = (function () {
@@ -171,17 +173,18 @@ var m3;
return c;
})();
m5.c = c;
})(m4.m5 || (m4.m5 = {}));
var m5 = m4.m5;
})(m3.m4 || (m3.m4 = {}));
var m4 = m3.m4;
})(m5 = m4.m5 || (m4.m5 = {}));
})(m4 = m3.m4 || (m3.m4 = {}));
})(m3 || (m3 = {})); // trailing dotted module 2
new m3.m4.m5.c();
/** module comment of m4.m5.m6*/
var m4;
(function (m4) {
var m5;
(function (m5) {
var m6;
(function (m6) {
var m7;
(function (m7) {
/** Exported class comment*/
var c = (function () {
@@ -190,20 +193,20 @@ var m4;
return c;
})();
m7.c = c;
})(m6.m7 || (m6.m7 = {}));
var m7 = m6.m7; /* trailing inner module */ /* multiple comments*/
})(m5.m6 || (m5.m6 = {}));
var m6 = m5.m6;
})(m4.m5 || (m4.m5 = {}));
var m5 = m4.m5;
})(m7 = m6.m7 || (m6.m7 = {})); /* trailing inner module */ /* multiple comments*/
})(m6 = m5.m6 || (m5.m6 = {}));
})(m5 = m4.m5 || (m4.m5 = {}));
})(m4 || (m4 = {}));
new m4.m5.m6.m7.c();
/** module comment of m5.m6.m7*/
var m5;
(function (m5) {
var m6;
(function (m6) {
var m7;
(function (m7) {
/** module m8 comment*/
var m8;
(function (m8) {
/** Exported class comment*/
var c = (function () {
@@ -212,17 +215,16 @@ var m5;
return c;
})();
m8.c = c;
})(m7.m8 || (m7.m8 = {}));
var m8 = m7.m8;
})(m6.m7 || (m6.m7 = {}));
var m7 = m6.m7;
})(m5.m6 || (m5.m6 = {}));
var m6 = m5.m6;
})(m8 = m7.m8 || (m7.m8 = {}));
})(m7 = m6.m7 || (m6.m7 = {}));
})(m6 = m5.m6 || (m5.m6 = {}));
})(m5 || (m5 = {}));
new m5.m6.m7.m8.c();
var m6;
(function (m6) {
var m7;
(function (m7) {
var m8;
(function (m8) {
/** Exported class comment*/
var c = (function () {
@@ -231,16 +233,16 @@ var m6;
return c;
})();
m8.c = c;
})(m7.m8 || (m7.m8 = {}));
var m8 = m7.m8;
})(m6.m7 || (m6.m7 = {}));
var m7 = m6.m7;
})(m8 = m7.m8 || (m7.m8 = {}));
})(m7 = m6.m7 || (m6.m7 = {}));
})(m6 || (m6 = {}));
new m6.m7.m8.c();
var m7;
(function (m7) {
var m8;
(function (m8) {
/** module m9 comment*/
var m9;
(function (m9) {
/** Exported class comment*/
var c = (function () {
@@ -262,10 +264,8 @@ var m7;
return e;
})();
m9.e = e;
})(m8.m9 || (m8.m9 = {}));
var m9 = m8.m9;
})(m7.m8 || (m7.m8 = {}));
var m8 = m7.m8;
})(m9 = m8.m9 || (m8.m9 = {}));
})(m8 = m7.m8 || (m7.m8 = {}));
})(m7 || (m7 = {}));
new m7.m8.m9.c();
@@ -39,6 +39,7 @@ new multiM.d();
//// [commentsMultiModuleMultiFile_0.js]
define(["require", "exports"], function (require, exports) {
/** this is multi declare module*/
var multiM;
(function (multiM) {
/// class b comment
var b = (function () {
@@ -47,9 +48,9 @@ define(["require", "exports"], function (require, exports) {
return b;
})();
multiM.b = b;
})(exports.multiM || (exports.multiM = {}));
var multiM = exports.multiM;
})(multiM = exports.multiM || (exports.multiM = {}));
/** thi is multi module 2*/
var multiM;
(function (multiM) {
/** class c comment*/
var c = (function () {
@@ -65,14 +66,14 @@ define(["require", "exports"], function (require, exports) {
return e;
})();
multiM.e = e;
})(exports.multiM || (exports.multiM = {}));
var multiM = exports.multiM;
})(multiM = exports.multiM || (exports.multiM = {}));
new multiM.b();
new multiM.c();
});
//// [commentsMultiModuleMultiFile_1.js]
define(["require", "exports"], function (require, exports) {
/** this is multi module 3 comment*/
var multiM;
(function (multiM) {
/** class d comment*/
var d = (function () {
@@ -88,8 +89,7 @@ define(["require", "exports"], function (require, exports) {
return f;
})();
multiM.f = f;
})(exports.multiM || (exports.multiM = {}));
var multiM = exports.multiM;
})(multiM = exports.multiM || (exports.multiM = {}));
new multiM.d();
});
@@ -1,4 +1,5 @@
==== tests/cases/compiler/contextualTyping39.ts (1 errors) ====
var foo = <{ (): number; }> function() { return "err"; };
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! Neither type '() => number' nor type '() => string' is assignable to the other.
!!! Neither type '() => string' nor type '() => number' is assignable to the other:
!!! Type 'string' is not assignable to type 'number'.
@@ -1,4 +1,5 @@
==== tests/cases/compiler/contextualTyping41.ts (1 errors) ====
var foo = <{():number; (i:number):number; }> (function(){return "err";});
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! Neither type '{ (): number; (i: number): number; }' nor type '() => string' is assignable to the other.
!!! Neither type '() => string' nor type '{ (): number; (i: number): number; }' is assignable to the other:
!!! Type 'string' is not assignable to type 'number'.
@@ -0,0 +1,28 @@
//// [contextuallyTypedFunctionExpressionsAndReturnAnnotations.ts]
declare function foo(x: (y: string) => (y2: number) => void);
// Contextually type the parameter even if there is a return annotation
foo((y): (y2: number) => void => {
var z = y.charAt(0); // Should be string
return null;
});
foo((y: string) => {
return y2 => {
var z = y2.toFixed(); // Should be string
return 0;
};
});
//// [contextuallyTypedFunctionExpressionsAndReturnAnnotations.js]
// Contextually type the parameter even if there is a return annotation
foo(function (y) {
var z = y.charAt(0); // Should be string
return null;
});
foo(function (y) {
return function (y2) {
var z = y2.toFixed(); // Should be string
return 0;
};
});
@@ -0,0 +1,45 @@
=== tests/cases/conformance/expressions/functions/contextuallyTypedFunctionExpressionsAndReturnAnnotations.ts ===
declare function foo(x: (y: string) => (y2: number) => void);
>foo : (x: (y: string) => (y2: number) => void) => any
>x : (y: string) => (y2: number) => void
>y : string
>y2 : number
// Contextually type the parameter even if there is a return annotation
foo((y): (y2: number) => void => {
>foo((y): (y2: number) => void => { var z = y.charAt(0); // Should be string return null;}) : any
>foo : (x: (y: string) => (y2: number) => void) => any
>(y): (y2: number) => void => { var z = y.charAt(0); // Should be string return null;} : (y: string) => (y2: number) => void
>y : string
>y2 : number
var z = y.charAt(0); // Should be string
>z : string
>y.charAt(0) : string
>y.charAt : (pos: number) => string
>y : string
>charAt : (pos: number) => string
return null;
});
foo((y: string) => {
>foo((y: string) => { return y2 => { var z = y2.toFixed(); // Should be string return 0; };}) : any
>foo : (x: (y: string) => (y2: number) => void) => any
>(y: string) => { return y2 => { var z = y2.toFixed(); // Should be string return 0; };} : (y: string) => (y2: number) => number
>y : string
return y2 => {
>y2 => { var z = y2.toFixed(); // Should be string return 0; } : (y2: number) => number
>y2 : number
var z = y2.toFixed(); // Should be string
>z : string
>y2.toFixed() : string
>y2.toFixed : (fractionDigits?: number) => string
>y2 : number
>toFixed : (fractionDigits?: number) => string
return 0;
};
});
@@ -28,7 +28,9 @@ module MsPortal.Util.TemplateEngine {
//// [crashRegressionTest.js]
var MsPortal;
(function (MsPortal) {
var Util;
(function (Util) {
var TemplateEngine;
(function (TemplateEngine) {
"use strict";
var StringTemplate = (function () {
@@ -48,8 +50,6 @@ var MsPortal;
return TemplateStorage;
})();
TemplateEngine.TemplateStorage = TemplateStorage;
})(Util.TemplateEngine || (Util.TemplateEngine = {}));
var TemplateEngine = Util.TemplateEngine;
})(MsPortal.Util || (MsPortal.Util = {}));
var Util = MsPortal.Util;
})(TemplateEngine = Util.TemplateEngine || (Util.TemplateEngine = {}));
})(Util = MsPortal.Util || (MsPortal.Util = {}));
})(MsPortal || (MsPortal = {}));
@@ -28,6 +28,7 @@ export var x: c.b1.a.m2.c1;
define(["require", "exports"], function (require, exports) {
var m1;
(function (m1) {
var m2;
(function (m2) {
var c1 = (function () {
function c1() {
@@ -35,8 +36,7 @@ define(["require", "exports"], function (require, exports) {
return c1;
})();
m2.c1 = c1;
})(m1.m2 || (m1.m2 = {}));
var m2 = m1.m2;
})(m2 = m1.m2 || (m1.m2 = {}));
})(m1 || (m1 = {}));
return m1;
});
@@ -25,6 +25,7 @@ export var x: c.b.m2.c1;
define(["require", "exports"], function (require, exports) {
var m1;
(function (m1) {
var m2;
(function (m2) {
var c1 = (function () {
function c1() {
@@ -32,8 +33,7 @@ define(["require", "exports"], function (require, exports) {
return c1;
})();
m2.c1 = c1;
})(m1.m2 || (m1.m2 = {}));
var m2 = m1.m2;
})(m2 = m1.m2 || (m1.m2 = {}));
})(m1 || (m1 = {}));
return m1;
});
@@ -46,6 +46,7 @@ var __extends = this.__extends || function (d, b) {
__.prototype = b.prototype;
d.prototype = new __();
};
var C;
(function (C) {
var A = (function () {
function A() {
@@ -90,8 +91,7 @@ var __extends = this.__extends || function (d, b) {
return D;
})();
C.D = D;
})(exports.C || (exports.C = {}));
var C = exports.C;
})(C = exports.C || (exports.C = {}));
exports.a;
exports.b = C.F;
exports.c = C.F2;
@@ -52,7 +52,9 @@ var __extends = this.__extends || function (d, b) {
// Module
var templa;
(function (templa) {
var dom;
(function (dom) {
var mvc;
(function (mvc) {
var AbstractElementController = (function (_super) {
__extends(AbstractElementController, _super);
@@ -62,16 +64,17 @@ var templa;
return AbstractElementController;
})(templa.mvc.AbstractController);
mvc.AbstractElementController = AbstractElementController;
})(dom.mvc || (dom.mvc = {}));
var mvc = dom.mvc;
})(templa.dom || (templa.dom = {}));
var dom = templa.dom;
})(mvc = dom.mvc || (dom.mvc = {}));
})(dom = templa.dom || (templa.dom = {}));
})(templa || (templa = {}));
// Module
var templa;
(function (templa) {
var dom;
(function (dom) {
var mvc;
(function (mvc) {
var composite;
(function (composite) {
var AbstractCompositeElementController = (function (_super) {
__extends(AbstractCompositeElementController, _super);
@@ -82,12 +85,9 @@ var templa;
return AbstractCompositeElementController;
})(templa.dom.mvc.AbstractElementController);
composite.AbstractCompositeElementController = AbstractCompositeElementController;
})(mvc.composite || (mvc.composite = {}));
var composite = mvc.composite;
})(dom.mvc || (dom.mvc = {}));
var mvc = dom.mvc;
})(templa.dom || (templa.dom = {}));
var dom = templa.dom;
})(composite = mvc.composite || (mvc.composite = {}));
})(mvc = dom.mvc || (dom.mvc = {}));
})(dom = templa.dom || (templa.dom = {}));
})(templa || (templa = {}));
@@ -12,6 +12,7 @@ export = b;
//// [declFileImportChainInExportAssignment.js]
var m;
(function (m) {
var c;
(function (_c) {
var c = (function () {
function c() {
@@ -19,8 +20,7 @@ var m;
return c;
})();
_c.c = c;
})(m.c || (m.c = {}));
var c = m.c;
})(c = m.c || (m.c = {}));
})(m || (m = {}));
var a = m.c;
var b = a;
@@ -12,7 +12,9 @@ module A.B.C {
//// [declFileModuleContinuation.js]
var A;
(function (A) {
var B;
(function (B) {
var C;
(function (C) {
var W = (function () {
function W() {
@@ -20,10 +22,8 @@ var A;
return W;
})();
C.W = W;
})(B.C || (B.C = {}));
var C = B.C;
})(A.B || (A.B = {}));
var B = A.B;
})(C = B.C || (B.C = {}));
})(B = A.B || (A.B = {}));
})(A || (A = {}));
@@ -4,7 +4,7 @@
var n = { w: null, x: '', y: () => { }, z: 32 };
>n : { w: any; x: string; y: () => void; z: number; }
>{ w: null, x: '', y: () => { }, z: 32 } : { w: null; x: string; y: () => void; z: number; }
>w : any
>w : null
>x : string
>y : () => void
>() => { } : () => void
@@ -73,6 +73,6 @@ declare function b1(): typeof b1;
declare function foo(): typeof foo;
declare var foo1: typeof foo;
declare var foo2: typeof foo;
declare var foo3: any;
declare var x: any;
declare var foo3: () => any;
declare var x: () => any;
declare function foo5(x: number): (x: number) => number;
@@ -54,18 +54,18 @@ var foo2 = foo;
>foo : () => typeof foo
var foo3 = function () {
>foo3 : any
>foo3 : () => any
>function () { return foo3;} : () => any
return foo3;
>foo3 : any
>foo3 : () => any
}
var x = () => {
>x : any
>x : () => any
>() => { return x;} : () => any
return x;
>x : any
>x : () => any
}
function foo5(x: number) {
@@ -29,7 +29,9 @@ var __extends = this.__extends || function (d, b) {
};
var X;
(function (X) {
var Y;
(function (Y) {
var base;
(function (base) {
var W = (function (_super) {
__extends(W, _super);
@@ -39,15 +41,16 @@ var X;
return W;
})(A.B.Base.W);
base.W = W;
})(Y.base || (Y.base = {}));
var base = Y.base;
})(X.Y || (X.Y = {}));
var Y = X.Y;
})(base = Y.base || (Y.base = {}));
})(Y = X.Y || (X.Y = {}));
})(X || (X = {}));
var X;
(function (X) {
var Y;
(function (Y) {
var base;
(function (base) {
var Z;
(function (Z) {
var W = (function (_super) {
__extends(W, _super);
@@ -57,12 +60,9 @@ var X;
return W;
})(X.Y.base.W);
Z.W = W;
})(base.Z || (base.Z = {}));
var Z = base.Z;
})(Y.base || (Y.base = {}));
var base = Y.base;
})(X.Y || (X.Y = {}));
var Y = X.Y;
})(Z = base.Z || (base.Z = {}));
})(base = Y.base || (Y.base = {}));
})(Y = X.Y || (X.Y = {}));
})(X || (X = {}));
@@ -27,6 +27,7 @@ var __extends = this.__extends || function (d, b) {
};
var A;
(function (A) {
var B;
(function (B) {
var EventManager = (function () {
function EventManager() {
@@ -34,12 +35,13 @@ var A;
return EventManager;
})();
B.EventManager = EventManager;
})(A.B || (A.B = {}));
var B = A.B;
})(B = A.B || (A.B = {}));
})(A || (A = {}));
var A;
(function (A) {
var B;
(function (B) {
var C;
(function (C) {
var ContextMenu = (function (_super) {
__extends(ContextMenu, _super);
@@ -49,10 +51,8 @@ var A;
return ContextMenu;
})(B.EventManager);
C.ContextMenu = ContextMenu;
})(B.C || (B.C = {}));
var C = B.C;
})(A.B || (A.B = {}));
var B = A.B;
})(C = B.C || (B.C = {}));
})(B = A.B || (A.B = {}));
})(A || (A = {}));
@@ -14,8 +14,11 @@ module X.A.B.C {
//// [declFileWithInternalModuleNameConflictsInExtendsClause1.js]
var X;
(function (X) {
var A;
(function (A) {
var B;
(function (B) {
var C;
(function (C) {
var W = (function () {
function W() {
@@ -23,12 +26,9 @@ var X;
return W;
})();
C.W = W;
})(B.C || (B.C = {}));
var C = B.C;
})(A.B || (A.B = {}));
var B = A.B;
})(X.A || (X.A = {}));
var A = X.A;
})(C = B.C || (B.C = {}));
})(B = A.B || (A.B = {}));
})(A = X.A || (X.A = {}));
})(X || (X = {}));
@@ -17,8 +17,11 @@ module X.A.B.C {
//// [declFileWithInternalModuleNameConflictsInExtendsClause2.js]
var X;
(function (X) {
var A;
(function (A) {
var B;
(function (B) {
var C;
(function (C) {
var W = (function () {
function W() {
@@ -26,12 +29,9 @@ var X;
return W;
})();
C.W = W;
})(B.C || (B.C = {}));
var C = B.C;
})(A.B || (A.B = {}));
var B = A.B;
})(X.A || (X.A = {}));
var A = X.A;
})(C = B.C || (B.C = {}));
})(B = A.B || (A.B = {}));
})(A = X.A || (X.A = {}));
})(X || (X = {}));
@@ -17,8 +17,11 @@ module X.A.B.C {
//// [declFileWithInternalModuleNameConflictsInExtendsClause3.js]
var X;
(function (X) {
var A;
(function (A) {
var B;
(function (B) {
var C;
(function (C) {
var W = (function () {
function W() {
@@ -26,12 +29,9 @@ var X;
return W;
})();
C.W = W;
})(B.C || (B.C = {}));
var C = B.C;
})(A.B || (A.B = {}));
var B = A.B;
})(X.A || (X.A = {}));
var A = X.A;
})(C = B.C || (B.C = {}));
})(B = A.B || (A.B = {}));
})(A = X.A || (X.A = {}));
})(X || (X = {}));
+2 -2
View File
@@ -16,9 +16,9 @@ class bar {
>a : bar
><bar>null : bar
>bar : bar
>b : any
>b : undefined
>undefined : undefined
>c : any
>c : undefined
>void 4 : undefined
public h(x = 4, y = null, z = '') { x++; }
@@ -0,0 +1,11 @@
//// [declarationEmit_invalidReference.ts]
/// <reference path="invalid.ts" />
var x = 0;
//// [declarationEmit_invalidReference.js]
/// <reference path="invalid.ts" />
var x = 0;
//// [declarationEmit_invalidReference.d.ts]
declare var x: number;
@@ -0,0 +1,5 @@
=== tests/cases/compiler/declarationEmit_invalidReference.ts ===
/// <reference path="invalid.ts" />
var x = 0;
>x : number
@@ -0,0 +1,5 @@
==== tests/cases/compiler/declarationEmit_invalidReference2.ts (1 errors) ====
/// <reference path="invalid.ts" />
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! File 'invalid.ts' not found.
var x = 0;
@@ -62,6 +62,7 @@ var f;
module.exports = f;
//// [declarationEmit_nameConflicts_0.js]
var im = require('declarationEmit_nameConflicts_1');
var M;
(function (M) {
function f() {
}
@@ -72,20 +73,21 @@ var im = require('declarationEmit_nameConflicts_1');
return C;
})();
M.C = C;
var N;
(function (N) {
function g() {
}
N.g = g;
;
})(M.N || (M.N = {}));
var N = M.N;
})(N = M.N || (M.N = {}));
M.a = M.f;
M.b = M.C;
M.c = N;
M.d = im;
})(exports.M || (exports.M = {}));
var M = exports.M;
})(M = exports.M || (exports.M = {}));
var M;
(function (M) {
var P;
(function (P) {
function f() {
}
@@ -96,24 +98,24 @@ var M = exports.M;
return C;
})();
P.C = C;
var N;
(function (N) {
function g() {
}
N.g = g;
;
})(P.N || (P.N = {}));
var N = P.N;
})(N = P.N || (P.N = {}));
P.im = M.P.f;
P.a = M.a; // emitted incorrectly as typeof f
P.b = M.b; // ok
P.c = M.c; // ok
P.g = M.c.g; // ok
P.d = M.d; // emitted incorrectly as typeof im
})(M.P || (M.P = {}));
var P = M.P;
})(exports.M || (exports.M = {}));
var M = exports.M;
})(P = M.P || (M.P = {}));
})(M = exports.M || (exports.M = {}));
var M;
(function (M) {
var Q;
(function (Q) {
function f() {
}
@@ -124,17 +126,15 @@ var M = exports.M;
return C;
})();
Q.C = C;
var N;
(function (N) {
function g() {
}
N.g = g;
;
})(Q.N || (Q.N = {}));
var N = Q.N;
})(M.Q || (M.Q = {}));
var Q = M.Q;
})(exports.M || (exports.M = {}));
var M = exports.M;
})(N = Q.N || (Q.N = {}));
})(Q = M.Q || (M.Q = {}));
})(M = exports.M || (exports.M = {}));
//// [declarationEmit_nameConflicts_1.d.ts]
@@ -18,7 +18,9 @@ module X.Y.base.Z {
//// [declarationEmit_nameConflicts2.js]
var X;
(function (X) {
var Y;
(function (Y) {
var base;
(function (base) {
function f() {
}
@@ -29,33 +31,31 @@ var X;
return C;
})();
base.C = C;
var M;
(function (M) {
M.v;
})(base.M || (base.M = {}));
var M = base.M;
})(M = base.M || (base.M = {}));
(function (E) {
})(base.E || (base.E = {}));
var E = base.E;
})(Y.base || (Y.base = {}));
var base = Y.base;
})(X.Y || (X.Y = {}));
var Y = X.Y;
})(base = Y.base || (Y.base = {}));
})(Y = X.Y || (X.Y = {}));
})(X || (X = {}));
var X;
(function (X) {
var Y;
(function (Y) {
var base;
(function (base) {
var Z;
(function (Z) {
Z.f = X.Y.base.f; // Should be base.f
Z.C = X.Y.base.C; // Should be base.C
Z.M = X.Y.base.M; // Should be base.M
Z.E = X.Y.base.E; // Should be base.E
})(base.Z || (base.Z = {}));
var Z = base.Z;
})(Y.base || (Y.base = {}));
var base = Y.base;
})(X.Y || (X.Y = {}));
var Y = X.Y;
})(Z = base.Z || (base.Z = {}));
})(base = Y.base || (Y.base = {}));
})(Y = X.Y || (X.Y = {}));
})(X || (X = {}));
@@ -35,27 +35,28 @@ var __extends = this.__extends || function (d, b) {
};
var M;
(function (M) {
var D;
(function (D) {
function f() {
}
D.f = f;
})(M.D || (M.D = {}));
var D = M.D;
})(D = M.D || (M.D = {}));
var C;
(function (C) {
function f() {
}
C.f = f;
})(M.C || (M.C = {}));
var C = M.C;
})(C = M.C || (M.C = {}));
var E;
(function (E) {
function f() {
}
E.f = f;
})(M.E || (M.E = {}));
var E = M.E;
})(E = M.E || (M.E = {}));
})(M || (M = {}));
var M;
(function (M) {
var P;
(function (P) {
var C = (function () {
function C() {
@@ -81,8 +82,7 @@ var M;
P.w = M.D.f; // error, should be typeof M.D.f
P.x = M.C.f; // error, should be typeof M.C.f
P.x = M.E.f; // error, should be typeof M.E.f
})(M.P || (M.P = {}));
var P = M.P;
})(P = M.P || (M.P = {}));
})(M || (M = {}));

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