mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-22 12:03:44 -05:00
merge with master
This commit is contained in:
10
.gitignore
vendored
10
.gitignore
vendored
@@ -1,15 +1,5 @@
|
||||
node_modules/
|
||||
built/*
|
||||
tests/cases/*.js
|
||||
tests/cases/*/*.js
|
||||
tests/cases/*/*/*.js
|
||||
tests/cases/*/*/*/*.js
|
||||
tests/cases/*/*/*/*/*.js
|
||||
tests/cases/*.js.map
|
||||
tests/cases/*/*.js.map
|
||||
tests/cases/*/*/*.js.map
|
||||
tests/cases/*/*/*/*.js.map
|
||||
tests/cases/*/*/*/*/*.js.map
|
||||
tests/cases/rwc/*
|
||||
tests/cases/test262/*
|
||||
tests/cases/perf/*
|
||||
|
||||
@@ -196,7 +196,7 @@ namespace ts {
|
||||
}
|
||||
if (node.name.kind === SyntaxKind.ComputedPropertyName) {
|
||||
const nameExpression = (<ComputedPropertyName>node.name).expression;
|
||||
// treat computed property names where expression is string/numeric literal as just string/numeric literal
|
||||
// treat computed property names where expression is string/numeric literal as just string/numeric literal
|
||||
if (isStringOrNumericLiteral(nameExpression.kind)) {
|
||||
return (<LiteralExpression>nameExpression).text;
|
||||
}
|
||||
@@ -457,7 +457,7 @@ namespace ts {
|
||||
|
||||
/**
|
||||
* Returns true if node and its subnodes were successfully traversed.
|
||||
* Returning false means that node was not examined and caller needs to dive into the node himself.
|
||||
* Returning false means that node was not examined and caller needs to dive into the node himself.
|
||||
*/
|
||||
function bindReachableStatement(node: Node): void {
|
||||
if (checkUnreachable(node)) {
|
||||
@@ -567,7 +567,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function bindIfStatement(n: IfStatement): void {
|
||||
// denotes reachability state when entering 'thenStatement' part of the if statement:
|
||||
// denotes reachability state when entering 'thenStatement' part of the if statement:
|
||||
// i.e. if condition is false then thenStatement is unreachable
|
||||
const ifTrueState = n.expression.kind === SyntaxKind.FalseKeyword ? Reachability.Unreachable : currentReachabilityState;
|
||||
// denotes reachability state when entering 'elseStatement':
|
||||
@@ -1186,7 +1186,7 @@ namespace ts {
|
||||
return checkStrictModePrefixUnaryExpression(<PrefixUnaryExpression>node);
|
||||
case SyntaxKind.WithStatement:
|
||||
return checkStrictModeWithStatement(<WithStatement>node);
|
||||
case SyntaxKind.ThisKeyword:
|
||||
case SyntaxKind.ThisType:
|
||||
seenThisKeyword = true;
|
||||
return;
|
||||
|
||||
@@ -1535,7 +1535,7 @@ namespace ts {
|
||||
|
||||
// unreachable code is reported if
|
||||
// - user has explicitly asked about it AND
|
||||
// - statement is in not ambient context (statements in ambient context is already an error
|
||||
// - statement is in not ambient context (statements in ambient context is already an error
|
||||
// so we should not report extras) AND
|
||||
// - node is not variable statement OR
|
||||
// - node is block scoped variable statement OR
|
||||
|
||||
@@ -4585,7 +4585,7 @@ namespace ts {
|
||||
return esSymbolType;
|
||||
case SyntaxKind.VoidKeyword:
|
||||
return voidType;
|
||||
case SyntaxKind.ThisKeyword:
|
||||
case SyntaxKind.ThisType:
|
||||
return getTypeFromThisTypeNode(node);
|
||||
case SyntaxKind.StringLiteral:
|
||||
return getTypeFromStringLiteral(<StringLiteral>node);
|
||||
@@ -6427,6 +6427,8 @@ namespace ts {
|
||||
// Only narrow when symbol is variable of type any or an object, union, or type parameter type
|
||||
if (node && symbol.flags & SymbolFlags.Variable) {
|
||||
if (isTypeAny(type) || type.flags & (TypeFlags.ObjectType | TypeFlags.Union | TypeFlags.TypeParameter)) {
|
||||
const declaration = getDeclarationOfKind(symbol, SyntaxKind.VariableDeclaration);
|
||||
const top = declaration && getDeclarationContainer(declaration);
|
||||
const originalType = type;
|
||||
const nodeStack: {node: Node, child: Node}[] = [];
|
||||
loop: while (node.parent) {
|
||||
@@ -6440,15 +6442,12 @@ namespace ts {
|
||||
break;
|
||||
case SyntaxKind.SourceFile:
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.MethodSignature:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
case SyntaxKind.Constructor:
|
||||
// Stop at the first containing function or module declaration
|
||||
// Stop at the first containing file or module declaration
|
||||
break loop;
|
||||
}
|
||||
if (node === top) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
let nodes: {node: Node, child: Node};
|
||||
@@ -10209,7 +10208,7 @@ namespace ts {
|
||||
checkDestructuringAssignment(<ShorthandPropertyAssignment>p, type);
|
||||
}
|
||||
else {
|
||||
// non-shorthand property assignments should always have initializers
|
||||
// non-shorthand property assignments should always have initializers
|
||||
checkDestructuringAssignment((<PropertyAssignment>p).initializer, type);
|
||||
}
|
||||
}
|
||||
@@ -11035,6 +11034,7 @@ namespace ts {
|
||||
|
||||
const symbol = getSymbolOfNode(node);
|
||||
const firstDeclaration = getDeclarationOfKind(symbol, node.kind);
|
||||
|
||||
// Only type check the symbol once
|
||||
if (node === firstDeclaration) {
|
||||
checkFunctionOrConstructorSymbol(symbol);
|
||||
@@ -12065,7 +12065,14 @@ namespace ts {
|
||||
const symbol = getSymbolOfNode(node);
|
||||
const localSymbol = node.localSymbol || symbol;
|
||||
|
||||
const firstDeclaration = getDeclarationOfKind(localSymbol, node.kind);
|
||||
// Since the javascript won't do semantic analysis like typescript,
|
||||
// if the javascript file comes before the typescript file and both contain same name functions,
|
||||
// checkFunctionOrConstructorSymbol wouldn't be called if we didnt ignore javascript function.
|
||||
const firstDeclaration = forEach(localSymbol.declarations,
|
||||
// Get first non javascript function declaration
|
||||
declaration => declaration.kind === node.kind && !isSourceFileJavaScript(getSourceFile(declaration)) ?
|
||||
declaration : undefined);
|
||||
|
||||
// Only type check the symbol once
|
||||
if (node === firstDeclaration) {
|
||||
checkFunctionOrConstructorSymbol(localSymbol);
|
||||
@@ -14683,6 +14690,9 @@ namespace ts {
|
||||
const type = isExpression(node) ? checkExpression(<Expression>node) : getTypeFromTypeNode(<TypeNode>node);
|
||||
return type.symbol;
|
||||
|
||||
case SyntaxKind.ThisType:
|
||||
return getTypeFromTypeNode(<TypeNode>node).symbol;
|
||||
|
||||
case SyntaxKind.ConstructorKeyword:
|
||||
// constructor keyword for an overload, should take us to the definition if it exist
|
||||
const constructorDeclaration = node.parent;
|
||||
|
||||
@@ -301,6 +301,11 @@ namespace ts {
|
||||
name: "rootDirs",
|
||||
type: "object",
|
||||
isTSConfigOnly: true
|
||||
},
|
||||
{
|
||||
name: "allowJs",
|
||||
type: "boolean",
|
||||
description: Diagnostics.Allow_javascript_files_to_be_compiled,
|
||||
}
|
||||
];
|
||||
|
||||
@@ -500,9 +505,10 @@ namespace ts {
|
||||
* @param basePath A root directory to resolve relative path entries in the config
|
||||
* file to. e.g. outDir
|
||||
*/
|
||||
export function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string): ParsedCommandLine {
|
||||
const { options, errors } = convertCompilerOptionsFromJson(json["compilerOptions"], basePath);
|
||||
export function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions: CompilerOptions = {}): ParsedCommandLine {
|
||||
const { options: optionsFromJsonConfigFile, errors } = convertCompilerOptionsFromJson(json["compilerOptions"], basePath);
|
||||
|
||||
const options = extend(existingOptions, optionsFromJsonConfigFile);
|
||||
// set basePath as inferredBaseUrl so baseUrl module resolution strategy can still work even if user have not specified baseUrl explicity
|
||||
options.inferredBaseUrl = basePath;
|
||||
|
||||
@@ -523,23 +529,32 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
else {
|
||||
const filesSeen: Map<boolean> = {};
|
||||
const exclude = json["exclude"] instanceof Array ? map(<string[]>json["exclude"], normalizeSlashes) : undefined;
|
||||
const sysFiles = host.readDirectory(basePath, ".ts", exclude).concat(host.readDirectory(basePath, ".tsx", exclude));
|
||||
for (let i = 0; i < sysFiles.length; i++) {
|
||||
const name = sysFiles[i];
|
||||
if (fileExtensionIs(name, ".d.ts")) {
|
||||
const baseName = name.substr(0, name.length - ".d.ts".length);
|
||||
if (!contains(sysFiles, baseName + ".tsx") && !contains(sysFiles, baseName + ".ts")) {
|
||||
fileNames.push(name);
|
||||
const supportedExtensions = getSupportedExtensions(options);
|
||||
Debug.assert(indexOf(supportedExtensions, ".ts") < indexOf(supportedExtensions, ".d.ts"), "Changed priority of extensions to pick");
|
||||
|
||||
// Get files of supported extensions in their order of resolution
|
||||
for (const extension of supportedExtensions) {
|
||||
const filesInDirWithExtension = host.readDirectory(basePath, extension, exclude);
|
||||
for (const fileName of filesInDirWithExtension) {
|
||||
// .ts extension would read the .d.ts extension files too but since .d.ts is lower priority extension,
|
||||
// lets pick them when its turn comes up
|
||||
if (extension === ".ts" && fileExtensionIs(fileName, ".d.ts")) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if (fileExtensionIs(name, ".ts")) {
|
||||
if (!contains(sysFiles, name + "x")) {
|
||||
fileNames.push(name);
|
||||
|
||||
// If this is one of the output extension (which would be .d.ts and .js if we are allowing compilation of js files)
|
||||
// do not include this file if we included .ts or .tsx file with same base name as it could be output of the earlier compilation
|
||||
if (extension === ".d.ts" || (options.allowJs && contains(supportedJavascriptExtensions, extension))) {
|
||||
const baseName = fileName.substr(0, fileName.length - extension.length);
|
||||
if (hasProperty(filesSeen, baseName + ".ts") || hasProperty(filesSeen, baseName + ".tsx")) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
fileNames.push(name);
|
||||
|
||||
filesSeen[fileName] = true;
|
||||
fileNames.push(fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -297,8 +297,8 @@ namespace ts {
|
||||
return <T>result;
|
||||
}
|
||||
|
||||
export function extend<T1, T2>(first: Map<T1>, second: Map<T2>): Map<T1 & T2> {
|
||||
const result: Map<T1 & T2> = {};
|
||||
export function extend<T1 extends Map<{}>, T2 extends Map<{}>>(first: T1 , second: T2): T1 & T2 {
|
||||
const result: T1 & T2 = <any>{};
|
||||
for (const id in first) {
|
||||
(result as any)[id] = first[id];
|
||||
}
|
||||
@@ -714,7 +714,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function getBaseFileName(path: string) {
|
||||
if (!path) {
|
||||
if (path === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
const i = path.lastIndexOf(directorySeparator);
|
||||
@@ -738,13 +738,18 @@ namespace ts {
|
||||
/**
|
||||
* List of supported extensions in order of file resolution precedence.
|
||||
*/
|
||||
export const supportedExtensions = [".ts", ".tsx", ".d.ts"];
|
||||
export const supportedJsExtensions = supportedExtensions.concat(".js", ".jsx");
|
||||
export const supportedTypeScriptExtensions = [".ts", ".tsx", ".d.ts"];
|
||||
export const supportedJavascriptExtensions = [".js", ".jsx"];
|
||||
const allSupportedExtensions = supportedTypeScriptExtensions.concat(supportedJavascriptExtensions);
|
||||
|
||||
export function isSupportedSourceFileName(fileName: string) {
|
||||
export function getSupportedExtensions(options?: CompilerOptions): string[] {
|
||||
return options && options.allowJs ? allSupportedExtensions : supportedTypeScriptExtensions;
|
||||
}
|
||||
|
||||
export function isSupportedSourceFileName(fileName: string, compilerOptions?: CompilerOptions) {
|
||||
if (!fileName) { return false; }
|
||||
|
||||
for (const extension of supportedExtensions) {
|
||||
for (const extension of getSupportedExtensions(compilerOptions)) {
|
||||
if (fileExtensionIs(fileName, extension)) {
|
||||
return true;
|
||||
}
|
||||
@@ -855,4 +860,4 @@ namespace ts {
|
||||
}
|
||||
return copiedList;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,13 +31,17 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function getDeclarationDiagnostics(host: EmitHost, resolver: EmitResolver, targetSourceFile: SourceFile): Diagnostic[] {
|
||||
const diagnostics: Diagnostic[] = [];
|
||||
const jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, host, ".js");
|
||||
emitDeclarations(host, resolver, diagnostics, jsFilePath, targetSourceFile);
|
||||
return diagnostics;
|
||||
const declarationDiagnostics = createDiagnosticCollection();
|
||||
forEachExpectedEmitFile(host, getDeclarationDiagnosticsFromFile, targetSourceFile);
|
||||
return declarationDiagnostics.getDiagnostics(targetSourceFile.fileName);
|
||||
|
||||
function getDeclarationDiagnosticsFromFile({ declarationFilePath }, sources: SourceFile[], isBundledEmit: boolean) {
|
||||
emitDeclarations(host, resolver, declarationDiagnostics, declarationFilePath, sources, isBundledEmit);
|
||||
}
|
||||
}
|
||||
|
||||
function emitDeclarations(host: EmitHost, resolver: EmitResolver, diagnostics: Diagnostic[], jsFilePath: string, root?: SourceFile): DeclarationEmit {
|
||||
function emitDeclarations(host: EmitHost, resolver: EmitResolver, emitterDiagnostics: DiagnosticCollection, declarationFilePath: string,
|
||||
sourceFiles: SourceFile[], isBundledEmit: boolean): DeclarationEmit {
|
||||
const newLine = host.getNewLine();
|
||||
const compilerOptions = host.getCompilerOptions();
|
||||
|
||||
@@ -58,7 +62,7 @@ namespace ts {
|
||||
let errorNameNode: DeclarationName;
|
||||
const emitJsDocComments = compilerOptions.removeComments ? function (declaration: Node) { } : writeJsDocComments;
|
||||
const emit = compilerOptions.stripInternal ? stripInternal : emitNode;
|
||||
let noDeclare = !root;
|
||||
let noDeclare: boolean;
|
||||
|
||||
let moduleElementDeclarationEmitInfo: ModuleElementDeclarationEmitInfo[] = [];
|
||||
let asynchronousSubModuleDeclarationEmitInfo: ModuleElementDeclarationEmitInfo[];
|
||||
@@ -68,105 +72,78 @@ namespace ts {
|
||||
// and we could be collecting these paths from multiple files into single one with --out option
|
||||
let referencePathsOutput = "";
|
||||
|
||||
if (root) {
|
||||
// Emitting just a single file, so emit references in this file only
|
||||
// Emit references corresponding to each file
|
||||
const emittedReferencedFiles: SourceFile[] = [];
|
||||
let addedGlobalFileReference = false;
|
||||
let allSourcesModuleElementDeclarationEmitInfo: ModuleElementDeclarationEmitInfo[] = [];
|
||||
forEach(sourceFiles, sourceFile => {
|
||||
// Dont emit for javascript file
|
||||
if (isSourceFileJavaScript(sourceFile)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check what references need to be added
|
||||
if (!compilerOptions.noResolve) {
|
||||
let addedGlobalFileReference = false;
|
||||
forEach(root.referencedFiles, fileReference => {
|
||||
const referencedFile = tryResolveScriptReference(host, root, fileReference);
|
||||
forEach(sourceFile.referencedFiles, fileReference => {
|
||||
const referencedFile = tryResolveScriptReference(host, sourceFile, fileReference);
|
||||
|
||||
// All the references that are not going to be part of same file
|
||||
if (referencedFile && ((referencedFile.flags & NodeFlags.DeclarationFile) || // This is a declare file reference
|
||||
shouldEmitToOwnFile(referencedFile, compilerOptions) || // 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)) {
|
||||
// Emit reference in dts, if the file reference was not already emitted
|
||||
if (referencedFile && !contains(emittedReferencedFiles, referencedFile)) {
|
||||
// Add a reference to generated dts file,
|
||||
// global file reference is added only
|
||||
// - if it is not bundled emit (because otherwise it would be self reference)
|
||||
// - and it is not already added
|
||||
if (writeReferencePath(referencedFile, !isBundledEmit && !addedGlobalFileReference)) {
|
||||
addedGlobalFileReference = true;
|
||||
}
|
||||
emittedReferencedFiles.push(referencedFile);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
emitSourceFile(root);
|
||||
if (!isBundledEmit || !isExternalModule(sourceFile)) {
|
||||
noDeclare = false;
|
||||
emitSourceFile(sourceFile);
|
||||
}
|
||||
else if (isExternalModule(sourceFile)) {
|
||||
noDeclare = true;
|
||||
write(`declare module "${getResolvedExternalModuleName(host, sourceFile)}" {`);
|
||||
writeLine();
|
||||
increaseIndent();
|
||||
emitSourceFile(sourceFile);
|
||||
decreaseIndent();
|
||||
write("}");
|
||||
writeLine();
|
||||
}
|
||||
|
||||
// create asynchronous output for the importDeclarations
|
||||
if (moduleElementDeclarationEmitInfo.length) {
|
||||
const oldWriter = writer;
|
||||
forEach(moduleElementDeclarationEmitInfo, aliasEmitInfo => {
|
||||
if (aliasEmitInfo.isVisible) {
|
||||
if (aliasEmitInfo.isVisible && !aliasEmitInfo.asynchronousOutput) {
|
||||
Debug.assert(aliasEmitInfo.node.kind === SyntaxKind.ImportDeclaration);
|
||||
createAndSetNewTextWriterWithSymbolWriter();
|
||||
Debug.assert(aliasEmitInfo.indent === 0);
|
||||
Debug.assert(aliasEmitInfo.indent === 0 || (aliasEmitInfo.indent === 1 && isBundledEmit));
|
||||
for (let i = 0; i < aliasEmitInfo.indent; i++) {
|
||||
increaseIndent();
|
||||
}
|
||||
writeImportDeclaration(<ImportDeclaration>aliasEmitInfo.node);
|
||||
aliasEmitInfo.asynchronousOutput = writer.getText();
|
||||
for (let i = 0; i < aliasEmitInfo.indent; i++) {
|
||||
decreaseIndent();
|
||||
}
|
||||
}
|
||||
});
|
||||
setWriter(oldWriter);
|
||||
|
||||
allSourcesModuleElementDeclarationEmitInfo = allSourcesModuleElementDeclarationEmitInfo.concat(moduleElementDeclarationEmitInfo);
|
||||
moduleElementDeclarationEmitInfo = [];
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Emit references corresponding to this file
|
||||
const emittedReferencedFiles: SourceFile[] = [];
|
||||
let prevModuleElementDeclarationEmitInfo: ModuleElementDeclarationEmitInfo[] = [];
|
||||
forEach(host.getSourceFiles(), sourceFile => {
|
||||
if (!isDeclarationFile(sourceFile)) {
|
||||
// Check what references need to be added
|
||||
if (!compilerOptions.noResolve) {
|
||||
forEach(sourceFile.referencedFiles, fileReference => {
|
||||
const referencedFile = tryResolveScriptReference(host, sourceFile, fileReference);
|
||||
|
||||
// If the reference file is a declaration file, emit that reference
|
||||
if (referencedFile && (isDeclarationFile(referencedFile) &&
|
||||
!contains(emittedReferencedFiles, referencedFile))) { // If the file reference was not already emitted
|
||||
|
||||
writeReferencePath(referencedFile);
|
||||
emittedReferencedFiles.push(referencedFile);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (!isExternalModuleOrDeclarationFile(sourceFile)) {
|
||||
noDeclare = false;
|
||||
emitSourceFile(sourceFile);
|
||||
}
|
||||
else if (isExternalModule(sourceFile)) {
|
||||
noDeclare = true;
|
||||
write(`declare module "${getResolvedExternalModuleName(host, sourceFile)}" {`);
|
||||
writeLine();
|
||||
increaseIndent();
|
||||
emitSourceFile(sourceFile);
|
||||
decreaseIndent();
|
||||
write("}");
|
||||
writeLine();
|
||||
|
||||
// create asynchronous output for the importDeclarations
|
||||
if (moduleElementDeclarationEmitInfo.length) {
|
||||
const oldWriter = writer;
|
||||
forEach(moduleElementDeclarationEmitInfo, aliasEmitInfo => {
|
||||
if (aliasEmitInfo.isVisible && !aliasEmitInfo.asynchronousOutput) {
|
||||
Debug.assert(aliasEmitInfo.node.kind === SyntaxKind.ImportDeclaration);
|
||||
createAndSetNewTextWriterWithSymbolWriter();
|
||||
Debug.assert(aliasEmitInfo.indent === 1);
|
||||
increaseIndent();
|
||||
writeImportDeclaration(<ImportDeclaration>aliasEmitInfo.node);
|
||||
aliasEmitInfo.asynchronousOutput = writer.getText();
|
||||
decreaseIndent();
|
||||
}
|
||||
});
|
||||
setWriter(oldWriter);
|
||||
}
|
||||
prevModuleElementDeclarationEmitInfo = prevModuleElementDeclarationEmitInfo.concat(moduleElementDeclarationEmitInfo);
|
||||
moduleElementDeclarationEmitInfo = [];
|
||||
}
|
||||
});
|
||||
moduleElementDeclarationEmitInfo = moduleElementDeclarationEmitInfo.concat(prevModuleElementDeclarationEmitInfo);
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
reportedDeclarationError,
|
||||
moduleElementDeclarationEmitInfo,
|
||||
moduleElementDeclarationEmitInfo: allSourcesModuleElementDeclarationEmitInfo,
|
||||
synchronousDeclarationOutput: writer.getText(),
|
||||
referencePathsOutput,
|
||||
};
|
||||
@@ -278,14 +255,14 @@ namespace ts {
|
||||
const errorInfo = writer.getSymbolAccessibilityDiagnostic(symbolAccesibilityResult);
|
||||
if (errorInfo) {
|
||||
if (errorInfo.typeName) {
|
||||
diagnostics.push(createDiagnosticForNode(symbolAccesibilityResult.errorNode || errorInfo.errorNode,
|
||||
emitterDiagnostics.add(createDiagnosticForNode(symbolAccesibilityResult.errorNode || errorInfo.errorNode,
|
||||
errorInfo.diagnosticMessage,
|
||||
getTextOfNodeFromSourceText(currentText, errorInfo.typeName),
|
||||
symbolAccesibilityResult.errorSymbolName,
|
||||
symbolAccesibilityResult.errorModuleName));
|
||||
}
|
||||
else {
|
||||
diagnostics.push(createDiagnosticForNode(symbolAccesibilityResult.errorNode || errorInfo.errorNode,
|
||||
emitterDiagnostics.add(createDiagnosticForNode(symbolAccesibilityResult.errorNode || errorInfo.errorNode,
|
||||
errorInfo.diagnosticMessage,
|
||||
symbolAccesibilityResult.errorSymbolName,
|
||||
symbolAccesibilityResult.errorModuleName));
|
||||
@@ -300,7 +277,8 @@ namespace ts {
|
||||
|
||||
function reportInaccessibleThisError() {
|
||||
if (errorNameNode) {
|
||||
diagnostics.push(createDiagnosticForNode(errorNameNode, Diagnostics.The_inferred_type_of_0_references_an_inaccessible_this_type_A_type_annotation_is_necessary,
|
||||
reportedDeclarationError = true;
|
||||
emitterDiagnostics.add(createDiagnosticForNode(errorNameNode, Diagnostics.The_inferred_type_of_0_references_an_inaccessible_this_type_A_type_annotation_is_necessary,
|
||||
declarationNameToString(errorNameNode)));
|
||||
}
|
||||
}
|
||||
@@ -378,7 +356,7 @@ namespace ts {
|
||||
case SyntaxKind.BooleanKeyword:
|
||||
case SyntaxKind.SymbolKeyword:
|
||||
case SyntaxKind.VoidKeyword:
|
||||
case SyntaxKind.ThisKeyword:
|
||||
case SyntaxKind.ThisType:
|
||||
case SyntaxKind.StringLiteral:
|
||||
return writeTextOfNode(currentText, type);
|
||||
case SyntaxKind.ExpressionWithTypeArguments:
|
||||
@@ -743,7 +721,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function emitExternalModuleSpecifier(moduleSpecifier: Expression) {
|
||||
if (moduleSpecifier.kind === SyntaxKind.StringLiteral && (!root) && (compilerOptions.out || compilerOptions.outFile)) {
|
||||
if (moduleSpecifier.kind === SyntaxKind.StringLiteral && isBundledEmit) {
|
||||
const moduleName = getExternalModuleNameFromDeclaration(host, resolver, moduleSpecifier.parent as (ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration));
|
||||
if (moduleName) {
|
||||
write("\"");
|
||||
@@ -1643,34 +1621,58 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function writeReferencePath(referencedFile: SourceFile) {
|
||||
let declFileName = referencedFile.flags & NodeFlags.DeclarationFile
|
||||
? referencedFile.fileName // Declaration file, use declaration file name
|
||||
: shouldEmitToOwnFile(referencedFile, compilerOptions)
|
||||
? getOwnEmitOutputFilePath(referencedFile, host, ".d.ts") // Own output file so get the .d.ts file
|
||||
: removeFileExtension(compilerOptions.outFile || compilerOptions.out) + ".d.ts"; // Global out file
|
||||
/**
|
||||
* Adds the reference to referenced file, returns true if global file reference was emitted
|
||||
* @param referencedFile
|
||||
* @param addBundledFileReference Determines if global file reference corresponding to bundled file should be emitted or not
|
||||
*/
|
||||
function writeReferencePath(referencedFile: SourceFile, addBundledFileReference: boolean): boolean {
|
||||
let declFileName: string;
|
||||
let addedBundledEmitReference = false;
|
||||
if (isDeclarationFile(referencedFile)) {
|
||||
// Declaration file, use declaration file name
|
||||
declFileName = referencedFile.fileName;
|
||||
}
|
||||
else {
|
||||
// Get the declaration file path
|
||||
forEachExpectedEmitFile(host, getDeclFileName, referencedFile);
|
||||
}
|
||||
|
||||
declFileName = getRelativePathToDirectoryOrUrl(
|
||||
getDirectoryPath(normalizeSlashes(jsFilePath)),
|
||||
declFileName,
|
||||
host.getCurrentDirectory(),
|
||||
host.getCanonicalFileName,
|
||||
/*isAbsolutePathAnUrl*/ false);
|
||||
if (declFileName) {
|
||||
declFileName = getRelativePathToDirectoryOrUrl(
|
||||
getDirectoryPath(normalizeSlashes(declarationFilePath)),
|
||||
declFileName,
|
||||
host.getCurrentDirectory(),
|
||||
host.getCanonicalFileName,
|
||||
/*isAbsolutePathAnUrl*/ false);
|
||||
|
||||
referencePathsOutput += "/// <reference path=\"" + declFileName + "\" />" + newLine;
|
||||
referencePathsOutput += "/// <reference path=\"" + declFileName + "\" />" + newLine;
|
||||
}
|
||||
return addedBundledEmitReference;
|
||||
|
||||
function getDeclFileName(emitFileNames: EmitFileNames, sourceFiles: SourceFile[], isBundledEmit: boolean) {
|
||||
// Dont add reference path to this file if it is a bundled emit and caller asked not emit bundled file path
|
||||
if (isBundledEmit && !addBundledFileReference) {
|
||||
return;
|
||||
}
|
||||
|
||||
Debug.assert(!!emitFileNames.declarationFilePath || isSourceFileJavaScript(referencedFile), "Declaration file is not present only for javascript files");
|
||||
declFileName = emitFileNames.declarationFilePath || emitFileNames.jsFilePath;
|
||||
addedBundledEmitReference = isBundledEmit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export function writeDeclarationFile(jsFilePath: string, sourceFile: SourceFile, host: EmitHost, resolver: EmitResolver, diagnostics: Diagnostic[]) {
|
||||
const emitDeclarationResult = emitDeclarations(host, resolver, diagnostics, jsFilePath, sourceFile);
|
||||
// TODO(shkamat): Should we not write any declaration file if any of them can produce error,
|
||||
// or should we just not write this file like we are doing now
|
||||
if (!emitDeclarationResult.reportedDeclarationError) {
|
||||
export function writeDeclarationFile(declarationFilePath: string, sourceFiles: SourceFile[], isBundledEmit: boolean, host: EmitHost, resolver: EmitResolver, emitterDiagnostics: DiagnosticCollection) {
|
||||
const emitDeclarationResult = emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFiles, isBundledEmit);
|
||||
const emitSkipped = emitDeclarationResult.reportedDeclarationError || host.isEmitBlocked(declarationFilePath);
|
||||
if (!emitSkipped) {
|
||||
const declarationOutput = emitDeclarationResult.referencePathsOutput
|
||||
+ getDeclarationOutput(emitDeclarationResult.synchronousDeclarationOutput, emitDeclarationResult.moduleElementDeclarationEmitInfo);
|
||||
writeFile(host, diagnostics, removeFileExtension(jsFilePath) + ".d.ts", declarationOutput, host.getCompilerOptions().emitBOM);
|
||||
writeFile(host, emitterDiagnostics, declarationFilePath, declarationOutput, host.getCompilerOptions().emitBOM);
|
||||
}
|
||||
return emitSkipped;
|
||||
|
||||
function getDeclarationOutput(synchronousDeclarationOutput: string, moduleElementDeclarationEmitInfo: ModuleElementDeclarationEmitInfo[]) {
|
||||
let appliedSyncOutputPos = 0;
|
||||
|
||||
@@ -2060,26 +2060,34 @@
|
||||
"category": "Error",
|
||||
"code": 5054
|
||||
},
|
||||
"Option '{0}' can only be used when option 'moduleResolution' is 'baseUrl'.": {
|
||||
"Cannot write file '{0}' because it would overwrite input file.": {
|
||||
"category": "Error",
|
||||
"code": 5055
|
||||
},
|
||||
"Pattern '{0}' can have at most one '*' character": {
|
||||
"Cannot write file '{0}' because it would be overwritten by multiple input files.": {
|
||||
"category": "Error",
|
||||
"code": 5056
|
||||
},
|
||||
"Substitution '{0}' in pattern '{1}' in can have at most one '*' character": {
|
||||
"Option '{0}' can only be used when option 'moduleResolution' is 'baseUrl'.": {
|
||||
"category": "Error",
|
||||
"code": 5057
|
||||
},
|
||||
"'moduleResolution' kind 'baseUrl' cannot be used without specifying '--baseUrl' option.": {
|
||||
"Pattern '{0}' can have at most one '*' character": {
|
||||
"category": "Error",
|
||||
"code": 5058
|
||||
},
|
||||
"Module resolution kind cannot be determined automatically. Please specify module resolution explicitly via 'moduleResolution' option.": {
|
||||
"Substitution '{0}' in pattern '{1}' in can have at most one '*' character": {
|
||||
"category": "Error",
|
||||
"code": 5059
|
||||
},
|
||||
"'moduleResolution' kind 'baseUrl' cannot be used without specifying '--baseUrl' option.": {
|
||||
"category": "Error",
|
||||
"code": 5060
|
||||
},
|
||||
"Module resolution kind cannot be determined automatically. Please specify module resolution explicitly via 'moduleResolution' option.": {
|
||||
"category": "Error",
|
||||
"code": 5061
|
||||
},
|
||||
"Concatenate and emit output to single file.": {
|
||||
"category": "Message",
|
||||
"code": 6001
|
||||
@@ -2345,9 +2353,13 @@
|
||||
"category": "Error",
|
||||
"code": 6082
|
||||
},
|
||||
"Base directory to resolve relative module names.": {
|
||||
"Allow javascript files to be compiled.": {
|
||||
"category": "Message",
|
||||
"code": 6083
|
||||
},
|
||||
"Base directory to resolve relative module names.": {
|
||||
"category": "Message",
|
||||
"code": 6084
|
||||
},
|
||||
"Variable '{0}' implicitly has an '{1}' type.": {
|
||||
"category": "Error",
|
||||
|
||||
@@ -3,10 +3,6 @@
|
||||
|
||||
/* @internal */
|
||||
namespace ts {
|
||||
export function isExternalModuleOrDeclarationFile(sourceFile: SourceFile) {
|
||||
return isExternalModule(sourceFile) || isDeclarationFile(sourceFile);
|
||||
}
|
||||
|
||||
export function getResolvedExternalModuleName(host: EmitHost, file: SourceFile): string {
|
||||
return file.moduleName || getExternalModuleNameFromPath(host, file.fileName);
|
||||
}
|
||||
@@ -337,47 +333,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
};`;
|
||||
|
||||
const compilerOptions = host.getCompilerOptions();
|
||||
const languageVersion = compilerOptions.target || ScriptTarget.ES3;
|
||||
const modulekind = compilerOptions.module ? compilerOptions.module : languageVersion === ScriptTarget.ES6 ? ModuleKind.ES6 : ModuleKind.None;
|
||||
const languageVersion = getEmitScriptTarget(compilerOptions);
|
||||
const modulekind = getEmitModuleKind(compilerOptions);
|
||||
const sourceMapDataList: SourceMapData[] = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? [] : undefined;
|
||||
let diagnostics: Diagnostic[] = [];
|
||||
const emitterDiagnostics = createDiagnosticCollection();
|
||||
let emitSkipped = false;
|
||||
const newLine = host.getNewLine();
|
||||
const jsxDesugaring = host.getCompilerOptions().jsx !== JsxEmit.Preserve;
|
||||
const shouldEmitJsx = (s: SourceFile) => (s.languageVariant === LanguageVariant.JSX && !jsxDesugaring);
|
||||
const outFile = compilerOptions.outFile || compilerOptions.out;
|
||||
|
||||
const emitJavaScript = createFileEmitter();
|
||||
|
||||
if (targetSourceFile === undefined) {
|
||||
if (outFile) {
|
||||
emitFile(outFile);
|
||||
}
|
||||
else {
|
||||
forEach(host.getSourceFiles(), sourceFile => {
|
||||
if (shouldEmitToOwnFile(sourceFile, compilerOptions)) {
|
||||
const jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, shouldEmitJsx(sourceFile) ? ".jsx" : ".js");
|
||||
emitFile(jsFilePath, sourceFile);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
else {
|
||||
// targetSourceFile is specified (e.g calling emitter from language service or calling getSemanticDiagnostic from language service)
|
||||
if (shouldEmitToOwnFile(targetSourceFile, compilerOptions)) {
|
||||
const jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, host, shouldEmitJsx(targetSourceFile) ? ".jsx" : ".js");
|
||||
emitFile(jsFilePath, targetSourceFile);
|
||||
}
|
||||
else if (!isDeclarationFile(targetSourceFile) && outFile) {
|
||||
emitFile(outFile);
|
||||
}
|
||||
}
|
||||
|
||||
// Sort and make the unique list of diagnostics
|
||||
diagnostics = sortAndDeduplicateDiagnostics(diagnostics);
|
||||
forEachExpectedEmitFile(host, emitFile, targetSourceFile);
|
||||
|
||||
return {
|
||||
emitSkipped: false,
|
||||
diagnostics,
|
||||
emitSkipped,
|
||||
diagnostics: emitterDiagnostics.getDiagnostics(),
|
||||
sourceMaps: sourceMapDataList
|
||||
};
|
||||
|
||||
@@ -428,7 +396,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
* var loop = function(x) { <code where 'arguments' is replaced witg 'arguments_1'> }
|
||||
* var arguments_1 = arguments
|
||||
* for (var x;;) loop(x);
|
||||
* otherwise semantics of the code will be different since 'arguments' inside converted loop body
|
||||
* otherwise semantics of the code will be different since 'arguments' inside converted loop body
|
||||
* will refer to function that holds converted loop.
|
||||
* This value is set on demand.
|
||||
*/
|
||||
@@ -436,10 +404,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
|
||||
/*
|
||||
* list of non-block scoped variable declarations that appear inside converted loop
|
||||
* such variable declarations should be moved outside the loop body
|
||||
* such variable declarations should be moved outside the loop body
|
||||
* for (let x;;) {
|
||||
* var y = 1;
|
||||
* ...
|
||||
* ...
|
||||
* }
|
||||
* should be converted to
|
||||
* var loop = function(x) {
|
||||
@@ -486,8 +454,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
}
|
||||
}
|
||||
|
||||
function createFileEmitter(): (jsFilePath: string, root?: SourceFile) => void {
|
||||
const writer: EmitTextWriter = createTextWriter(newLine);
|
||||
function createFileEmitter(): (jsFilePath: string, sourceMapFilePath: string, sourceFiles: SourceFile[], isBundledEmit: boolean) => void {
|
||||
const writer = createTextWriter(newLine);
|
||||
const { write, writeTextOfNode, writeLine, increaseIndent, decreaseIndent } = writer;
|
||||
|
||||
let currentSourceFile: SourceFile;
|
||||
@@ -559,8 +527,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
/** Sourcemap data that will get encoded */
|
||||
let sourceMapData: SourceMapData;
|
||||
|
||||
/** The root file passed to the emit function (if present) */
|
||||
let root: SourceFile;
|
||||
/** Is the file being emitted into its own file */
|
||||
let isOwnFileEmit: boolean;
|
||||
|
||||
/** If removeComments is true, no leading-comments needed to be emitted **/
|
||||
const emitLeadingCommentsOfPosition = compilerOptions.removeComments ? function (pos: number) { } : emitLeadingCommentsOfPositionWorker;
|
||||
@@ -581,32 +549,26 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
[ModuleKind.CommonJS]() {},
|
||||
};
|
||||
|
||||
|
||||
return doEmit;
|
||||
|
||||
function doEmit(jsFilePath: string, rootFile?: SourceFile) {
|
||||
function doEmit(jsFilePath: string, sourceMapFilePath: string, sourceFiles: SourceFile[], isBundledEmit: boolean) {
|
||||
generatedNameSet = {};
|
||||
nodeToGeneratedName = [];
|
||||
root = rootFile;
|
||||
isOwnFileEmit = !isBundledEmit;
|
||||
|
||||
if (compilerOptions.sourceMap || compilerOptions.inlineSourceMap) {
|
||||
initializeEmitterWithSourceMaps(jsFilePath, root);
|
||||
initializeEmitterWithSourceMaps(jsFilePath, sourceMapFilePath, sourceFiles, isBundledEmit);
|
||||
}
|
||||
|
||||
if (root) {
|
||||
// Do not call emit directly. It does not set the currentSourceFile.
|
||||
emitSourceFile(root);
|
||||
}
|
||||
else {
|
||||
if (modulekind) {
|
||||
forEach(host.getSourceFiles(), emitEmitHelpers);
|
||||
}
|
||||
forEach(host.getSourceFiles(), sourceFile => {
|
||||
if ((!isExternalModuleOrDeclarationFile(sourceFile)) || (modulekind && isExternalModule(sourceFile))) {
|
||||
emitSourceFile(sourceFile);
|
||||
}
|
||||
});
|
||||
// Emit helpers from all the files
|
||||
if (isBundledEmit && modulekind) {
|
||||
forEach(sourceFiles, emitEmitHelpers);
|
||||
}
|
||||
|
||||
// Do not call emit directly. It does not set the currentSourceFile.
|
||||
forEach(sourceFiles, emitSourceFile);
|
||||
|
||||
writeLine();
|
||||
writeEmittedFiles(writer.getText(), jsFilePath, /*writeByteOrderMark*/ compilerOptions.emitBOM);
|
||||
|
||||
@@ -636,7 +598,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
isEs6Module = false;
|
||||
renamedDependencies = undefined;
|
||||
isCurrentFileExternalModule = false;
|
||||
root = undefined;
|
||||
}
|
||||
|
||||
function emitSourceFile(sourceFile: SourceFile): void {
|
||||
@@ -747,7 +708,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
return nodeToGeneratedName[id] || (nodeToGeneratedName[id] = unescapeIdentifier(generateNameForNode(node)));
|
||||
}
|
||||
|
||||
function initializeEmitterWithSourceMaps(jsFilePath: string, root?: SourceFile) {
|
||||
function initializeEmitterWithSourceMaps(jsFilePath: string, sourceMapFilePath: string, sourceFiles: SourceFile[], isBundledEmit: boolean) {
|
||||
let sourceMapDir: string; // The directory in which sourcemap will be
|
||||
|
||||
// Current source map file and its index in the sources list
|
||||
@@ -1048,24 +1009,23 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
if (compilerOptions.inlineSourceMap) {
|
||||
// Encode the sourceMap into the sourceMap url
|
||||
const base64SourceMapText = convertToBase64(sourceMapText);
|
||||
sourceMapUrl = `//# sourceMappingURL=data:application/json;base64,${base64SourceMapText}`;
|
||||
sourceMapData.jsSourceMappingURL = `data:application/json;base64,${base64SourceMapText}`;
|
||||
}
|
||||
else {
|
||||
// Write source map file
|
||||
writeFile(host, diagnostics, sourceMapData.sourceMapFilePath, sourceMapText, /*writeByteOrderMark*/ false);
|
||||
sourceMapUrl = `//# sourceMappingURL=${sourceMapData.jsSourceMappingURL}`;
|
||||
writeFile(host, emitterDiagnostics, sourceMapData.sourceMapFilePath, sourceMapText, /*writeByteOrderMark*/ false);
|
||||
}
|
||||
sourceMapUrl = `//# sourceMappingURL=${sourceMapData.jsSourceMappingURL}`;
|
||||
|
||||
// Write sourcemap url to the js file and write the js file
|
||||
writeJavaScriptFile(emitOutput + sourceMapUrl, jsFilePath, writeByteOrderMark);
|
||||
}
|
||||
|
||||
// Initialize source map data
|
||||
const sourceMapJsFile = getBaseFileName(normalizeSlashes(jsFilePath));
|
||||
sourceMapData = {
|
||||
sourceMapFilePath: jsFilePath + ".map",
|
||||
jsSourceMappingURL: sourceMapJsFile + ".map",
|
||||
sourceMapFile: sourceMapJsFile,
|
||||
sourceMapFilePath: sourceMapFilePath,
|
||||
jsSourceMappingURL: !compilerOptions.inlineSourceMap ? getBaseFileName(normalizeSlashes(sourceMapFilePath)) : undefined,
|
||||
sourceMapFile: getBaseFileName(normalizeSlashes(jsFilePath)),
|
||||
sourceMapSourceRoot: compilerOptions.sourceRoot || "",
|
||||
sourceMapSources: [],
|
||||
inputSourceFileNames: [],
|
||||
@@ -1084,10 +1044,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
|
||||
if (compilerOptions.mapRoot) {
|
||||
sourceMapDir = normalizeSlashes(compilerOptions.mapRoot);
|
||||
if (root) { // emitting single module file
|
||||
if (!isBundledEmit) { // emitting single module file
|
||||
Debug.assert(sourceFiles.length === 1);
|
||||
// For modules or multiple emit files the mapRoot will have directory structure like the sources
|
||||
// So if src\a.ts and src\lib\b.ts are compiled together user would be moving the maps into mapRoot\a.js.map and mapRoot\lib\b.js.map
|
||||
sourceMapDir = getDirectoryPath(getSourceFilePathInNewDir(root, host, sourceMapDir));
|
||||
sourceMapDir = getDirectoryPath(getSourceFilePathInNewDir(sourceFiles[0], host, sourceMapDir));
|
||||
}
|
||||
|
||||
if (!isRootedDiskPath(sourceMapDir) && !isUrl(sourceMapDir)) {
|
||||
@@ -1140,7 +1101,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
}
|
||||
|
||||
function writeJavaScriptFile(emitOutput: string, jsFilePath: string, writeByteOrderMark: boolean) {
|
||||
writeFile(host, diagnostics, jsFilePath, emitOutput, writeByteOrderMark);
|
||||
writeFile(host, emitterDiagnostics, jsFilePath, emitOutput, writeByteOrderMark);
|
||||
}
|
||||
|
||||
// Create a temporary variable with a unique unused name.
|
||||
@@ -3229,7 +3190,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
}
|
||||
|
||||
if (convertedLoopState && (getCombinedNodeFlags(decl) & NodeFlags.BlockScoped) === 0) {
|
||||
// we are inside a converted loop - this can only happen in downlevel scenarios
|
||||
// we are inside a converted loop - this can only happen in downlevel scenarios
|
||||
// record names for all variable declarations
|
||||
for (const varDecl of decl.declarations) {
|
||||
hoistVariableDeclarationFromLoop(convertedLoopState, varDecl);
|
||||
@@ -3554,7 +3515,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
write(`case "${labelMarker}": `);
|
||||
// if there are no outer converted loop or outer label in question is located inside outer converted loop
|
||||
// then emit labeled break\continue
|
||||
// otherwise propagate pair 'label -> marker' to outer converted loop and emit 'return labelMarker' so outer loop can later decide what to do
|
||||
// otherwise propagate pair 'label -> marker' to outer converted loop and emit 'return labelMarker' so outer loop can later decide what to do
|
||||
if (!outerLoop || (outerLoop.labels && outerLoop.labels[labelText])) {
|
||||
if (isBreak) {
|
||||
write("break ");
|
||||
@@ -6011,6 +5972,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
case SyntaxKind.UnionType:
|
||||
case SyntaxKind.IntersectionType:
|
||||
case SyntaxKind.AnyKeyword:
|
||||
case SyntaxKind.ThisType:
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -7751,7 +7713,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
emitDetachedCommentsAndUpdateCommentsInfo(node);
|
||||
|
||||
if (isExternalModule(node) || compilerOptions.isolatedModules) {
|
||||
if (root || (!isExternalModule(node) && compilerOptions.isolatedModules)) {
|
||||
if (isOwnFileEmit || (!isExternalModule(node) && compilerOptions.isolatedModules)) {
|
||||
const emitModule = moduleEmitDelegates[modulekind] || moduleEmitDelegates[ModuleKind.CommonJS];
|
||||
emitModule(node);
|
||||
}
|
||||
@@ -8203,11 +8165,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
}
|
||||
}
|
||||
|
||||
function emitFile(jsFilePath: string, sourceFile?: SourceFile) {
|
||||
emitJavaScript(jsFilePath, sourceFile);
|
||||
function emitFile({ jsFilePath, sourceMapFilePath, declarationFilePath}: { jsFilePath: string, sourceMapFilePath: string, declarationFilePath: string },
|
||||
sourceFiles: SourceFile[], isBundledEmit: boolean) {
|
||||
// Make sure not to write js File and source map file if any of them cannot be written
|
||||
if (!host.isEmitBlocked(jsFilePath)) {
|
||||
emitJavaScript(jsFilePath, sourceMapFilePath, sourceFiles, isBundledEmit);
|
||||
}
|
||||
else {
|
||||
emitSkipped = true;
|
||||
}
|
||||
|
||||
if (compilerOptions.declaration) {
|
||||
writeDeclarationFile(jsFilePath, sourceFile, host, resolver, diagnostics);
|
||||
if (declarationFilePath) {
|
||||
emitSkipped = writeDeclarationFile(declarationFilePath, sourceFiles, isBundledEmit, host, resolver, emitterDiagnostics) || emitSkipped;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -544,6 +544,11 @@ namespace ts {
|
||||
return result;
|
||||
}
|
||||
|
||||
function getLanguageVariant(fileName: string) {
|
||||
// .tsx and .jsx files are treated as jsx language variant.
|
||||
return fileExtensionIs(fileName, ".tsx") || fileExtensionIs(fileName, ".jsx") ? LanguageVariant.JSX : LanguageVariant.Standard;
|
||||
}
|
||||
|
||||
function initializeState(fileName: string, _sourceText: string, languageVersion: ScriptTarget, isJavaScriptFile: boolean, _syntaxCursor: IncrementalParser.SyntaxCursor) {
|
||||
NodeConstructor = objectAllocator.getNodeConstructor();
|
||||
SourceFileConstructor = objectAllocator.getSourceFileConstructor();
|
||||
@@ -564,7 +569,7 @@ namespace ts {
|
||||
scanner.setText(sourceText);
|
||||
scanner.setOnError(scanError);
|
||||
scanner.setScriptTarget(languageVersion);
|
||||
scanner.setLanguageVariant(allowsJsxExpressions(fileName) ? LanguageVariant.JSX : LanguageVariant.Standard);
|
||||
scanner.setLanguageVariant(getLanguageVariant(fileName));
|
||||
}
|
||||
|
||||
function clearState() {
|
||||
@@ -682,7 +687,7 @@ namespace ts {
|
||||
sourceFile.languageVersion = languageVersion;
|
||||
sourceFile.fileName = normalizePath(fileName);
|
||||
sourceFile.flags = fileExtensionIs(sourceFile.fileName, ".d.ts") ? NodeFlags.DeclarationFile : 0;
|
||||
sourceFile.languageVariant = allowsJsxExpressions(sourceFile.fileName) ? LanguageVariant.JSX : LanguageVariant.Standard;
|
||||
sourceFile.languageVariant = getLanguageVariant(sourceFile.fileName);
|
||||
|
||||
return sourceFile;
|
||||
}
|
||||
@@ -1956,6 +1961,12 @@ namespace ts {
|
||||
return finishNode(node);
|
||||
}
|
||||
|
||||
function parseThisTypeNode(): TypeNode {
|
||||
const node = <TypeNode>createNode(SyntaxKind.ThisType);
|
||||
nextToken();
|
||||
return finishNode(node);
|
||||
}
|
||||
|
||||
function parseTypeQuery(): TypeQueryNode {
|
||||
const node = <TypeQueryNode>createNode(SyntaxKind.TypeQuery);
|
||||
parseExpected(SyntaxKind.TypeOfKeyword);
|
||||
@@ -2388,8 +2399,9 @@ namespace ts {
|
||||
case SyntaxKind.StringLiteral:
|
||||
return <StringLiteral>parseLiteralNode(/*internName*/ true);
|
||||
case SyntaxKind.VoidKeyword:
|
||||
case SyntaxKind.ThisKeyword:
|
||||
return parseTokenNode<TypeNode>();
|
||||
case SyntaxKind.ThisKeyword:
|
||||
return parseThisTypeNode();
|
||||
case SyntaxKind.TypeOfKeyword:
|
||||
return parseTypeQuery();
|
||||
case SyntaxKind.OpenBraceToken:
|
||||
|
||||
@@ -14,10 +14,10 @@ namespace ts {
|
||||
|
||||
export const version = "1.8.0";
|
||||
|
||||
export function findConfigFile(searchPath: string): string {
|
||||
export function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean): string {
|
||||
let fileName = "tsconfig.json";
|
||||
while (true) {
|
||||
if (sys.fileExists(fileName)) {
|
||||
if (fileExists(fileName)) {
|
||||
return fileName;
|
||||
}
|
||||
const parentPath = getDirectoryPath(searchPath);
|
||||
@@ -51,7 +51,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
switch (moduleResolution) {
|
||||
case ModuleResolutionKind.NodeJs: return nodeModuleNameResolver(moduleName, containingFile, host);
|
||||
case ModuleResolutionKind.NodeJs: return nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host);
|
||||
case ModuleResolutionKind.Classic: return classicNameResolver(moduleName, containingFile, compilerOptions, host);
|
||||
case ModuleResolutionKind.BaseUrl: return baseUrlModuleNameResolver(moduleName, containingFile, compilerOptions, host);
|
||||
}
|
||||
@@ -130,33 +130,35 @@ namespace ts {
|
||||
// '*' pattern will be matched ->
|
||||
// '*' substitution yields '/a/b/c/form1.content.ts' - file does not exists
|
||||
// 'generated/*' substitution yields '/a/b/c/generated/form1.content' - file exists - OK
|
||||
export function baseUrlModuleNameResolver(moduleName: string, containingFile: string, options: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations {
|
||||
const baseUrl = options.baseUrl !== undefined ? options.baseUrl : options.inferredBaseUrl;
|
||||
export function baseUrlModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations {
|
||||
const baseUrl = compilerOptions.baseUrl !== undefined ? compilerOptions.baseUrl : compilerOptions.inferredBaseUrl;
|
||||
Debug.assert(baseUrl !== undefined);
|
||||
|
||||
const supportedExtensions = getSupportedExtensions(compilerOptions);
|
||||
if (isRootedDiskPath(moduleName)) {
|
||||
return { resolvedModule: { resolvedFileName: moduleName }, failedLookupLocations: emptyArray };
|
||||
}
|
||||
|
||||
if (nameStartsWithDotSlashOrDotDotSlash(moduleName)) {
|
||||
// relative name
|
||||
return baseUrlResolveRelativeModuleName(moduleName, containingFile, baseUrl, options, host);
|
||||
return baseUrlResolveRelativeModuleName(moduleName, containingFile, baseUrl, compilerOptions, host);
|
||||
}
|
||||
else {
|
||||
// non-relative name
|
||||
return baseUrlResolveNonRelativeModuleName(moduleName, baseUrl, options, host);
|
||||
return baseUrlResolveNonRelativeModuleName(moduleName, baseUrl, supportedExtensions, compilerOptions, host);
|
||||
}
|
||||
}
|
||||
|
||||
export function baseUrlResolveRelativeModuleName(moduleName: string, containingFile: string, baseUrl: string, options: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations {
|
||||
export function baseUrlResolveRelativeModuleName(moduleName: string, containingFile: string, baseUrl: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations {
|
||||
const failedLookupLocations: string[] = [];
|
||||
|
||||
const containingDirectory = getDirectoryPath(containingFile);
|
||||
const candidate = normalizePath(combinePaths(containingDirectory, moduleName));
|
||||
const supportedExtensions = getSupportedExtensions(compilerOptions);
|
||||
|
||||
if (options.rootDirs) {
|
||||
if (compilerOptions.rootDirs) {
|
||||
let matchedPrefix: string;
|
||||
for (const rootDir of options.rootDirs) {
|
||||
for (const rootDir of compilerOptions.rootDirs) {
|
||||
let normalizedRoot = getNormalizedAbsolutePath(rootDir, baseUrl);
|
||||
if (!endsWith(normalizedRoot, directorySeparator)) {
|
||||
normalizedRoot += directorySeparator;
|
||||
@@ -167,7 +169,7 @@ namespace ts {
|
||||
}
|
||||
if (matchedPrefix) {
|
||||
const suffix = candidate.substr(matchedPrefix.length);
|
||||
return baseUrlResolveNonRelativeModuleName(suffix, baseUrl, options, host);
|
||||
return baseUrlResolveNonRelativeModuleName(suffix, baseUrl, supportedExtensions, compilerOptions, host);
|
||||
}
|
||||
return { resolvedModule: undefined, failedLookupLocations };
|
||||
}
|
||||
@@ -180,7 +182,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
export function baseUrlResolveNonRelativeModuleName(moduleName: string, baseUrl: string, options: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations {
|
||||
export function baseUrlResolveNonRelativeModuleName(moduleName: string, baseUrl: string, supportedExtensions: string[], options: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations {
|
||||
let longestMatchPrefixLength = -1;
|
||||
let matchedPattern: string;
|
||||
let matchedStar: string;
|
||||
@@ -245,19 +247,20 @@ namespace ts {
|
||||
return str.indexOf(suffix, expectedPos) === expectedPos;
|
||||
}
|
||||
|
||||
export function nodeModuleNameResolver(moduleName: string, containingFile: string, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations {
|
||||
export function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations {
|
||||
const containingDirectory = getDirectoryPath(containingFile);
|
||||
const supportedExtensions = getSupportedExtensions(compilerOptions);
|
||||
|
||||
if (isRootedDiskPath(moduleName) || nameStartsWithDotSlashOrDotDotSlash(moduleName)) {
|
||||
const failedLookupLocations: string[] = [];
|
||||
const candidate = normalizePath(combinePaths(containingDirectory, moduleName));
|
||||
let resolvedFileName = loadModuleFromFile(supportedJsExtensions, candidate, failedLookupLocations, host);
|
||||
let resolvedFileName = loadModuleFromFile(supportedExtensions, candidate, failedLookupLocations, host);
|
||||
|
||||
if (resolvedFileName) {
|
||||
return { resolvedModule: { resolvedFileName }, failedLookupLocations };
|
||||
}
|
||||
|
||||
resolvedFileName = loadNodeModuleFromDirectory(supportedJsExtensions, candidate, failedLookupLocations, host);
|
||||
resolvedFileName = loadNodeModuleFromDirectory(supportedExtensions, candidate, failedLookupLocations, host);
|
||||
return resolvedFileName
|
||||
? { resolvedModule: { resolvedFileName }, failedLookupLocations }
|
||||
: { resolvedModule: undefined, failedLookupLocations };
|
||||
@@ -320,12 +323,13 @@ namespace ts {
|
||||
if (baseName !== "node_modules") {
|
||||
const nodeModulesFolder = combinePaths(directory, "node_modules");
|
||||
const candidate = normalizePath(combinePaths(nodeModulesFolder, moduleName));
|
||||
let result = loadModuleFromFile(supportedExtensions, candidate, failedLookupLocations, host);
|
||||
// Load only typescript files irrespective of allowJs option if loading from node modules
|
||||
let result = loadModuleFromFile(supportedTypeScriptExtensions, candidate, failedLookupLocations, host);
|
||||
if (result) {
|
||||
return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations };
|
||||
}
|
||||
|
||||
result = loadNodeModuleFromDirectory(supportedExtensions, candidate, failedLookupLocations, host);
|
||||
result = loadNodeModuleFromDirectory(supportedTypeScriptExtensions, candidate, failedLookupLocations, host);
|
||||
if (result) {
|
||||
return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations };
|
||||
}
|
||||
@@ -376,10 +380,10 @@ namespace ts {
|
||||
const failedLookupLocations: string[] = [];
|
||||
|
||||
let referencedSourceFile: string;
|
||||
const extensions = compilerOptions.allowNonTsExtensions ? supportedJsExtensions : supportedExtensions;
|
||||
const supportedExtensions = getSupportedExtensions(compilerOptions);
|
||||
while (true) {
|
||||
searchName = normalizePath(combinePaths(searchPath, moduleName));
|
||||
referencedSourceFile = forEach(extensions, extension => {
|
||||
referencedSourceFile = forEach(supportedExtensions, extension => {
|
||||
if (extension === ".tsx" && !compilerOptions.jsx) {
|
||||
// resolve .tsx files only if jsx support is enabled
|
||||
// 'logical not' handles both undefined and None cases
|
||||
@@ -499,13 +503,13 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[] {
|
||||
const diagnostics = program.getOptionsDiagnostics(cancellationToken).concat(
|
||||
let diagnostics = program.getOptionsDiagnostics(cancellationToken).concat(
|
||||
program.getSyntacticDiagnostics(sourceFile, cancellationToken),
|
||||
program.getGlobalDiagnostics(cancellationToken),
|
||||
program.getSemanticDiagnostics(sourceFile, cancellationToken));
|
||||
|
||||
if (program.getCompilerOptions().declaration) {
|
||||
diagnostics.concat(program.getDeclarationDiagnostics(sourceFile, cancellationToken));
|
||||
diagnostics = diagnostics.concat(program.getDeclarationDiagnostics(sourceFile, cancellationToken));
|
||||
}
|
||||
|
||||
return sortAndDeduplicateDiagnostics(diagnostics);
|
||||
@@ -549,10 +553,13 @@ namespace ts {
|
||||
let classifiableNames: Map<string>;
|
||||
|
||||
let skipDefaultLib = options.noLib;
|
||||
const supportedExtensions = getSupportedExtensions(options);
|
||||
|
||||
const start = new Date().getTime();
|
||||
|
||||
host = host || createCompilerHost(options);
|
||||
// Map storing if there is emit blocking diagnostics for given input
|
||||
const hasEmitBlockingDiagnostics = createFileMap<boolean>(getCanonicalFileName);
|
||||
|
||||
const currentDirectory = host.getCurrentDirectory();
|
||||
const resolveModuleNamesWorker = host.resolveModuleNames
|
||||
@@ -572,7 +579,8 @@ namespace ts {
|
||||
(oldOptions.noResolve !== options.noResolve) ||
|
||||
(oldOptions.target !== options.target) ||
|
||||
(oldOptions.noLib !== options.noLib) ||
|
||||
(oldOptions.jsx !== options.jsx)) {
|
||||
(oldOptions.jsx !== options.jsx) ||
|
||||
(oldOptions.allowJs !== options.allowJs)) {
|
||||
oldProgram = undefined;
|
||||
}
|
||||
}
|
||||
@@ -588,13 +596,9 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
verifyCompilerOptions();
|
||||
|
||||
// unconditionally set oldProgram to undefined to prevent it from being captured in closure
|
||||
oldProgram = undefined;
|
||||
|
||||
programTime += new Date().getTime() - start;
|
||||
|
||||
program = {
|
||||
getRootFileNames: () => rootNames,
|
||||
getSourceFile,
|
||||
@@ -617,6 +621,11 @@ namespace ts {
|
||||
getTypeCount: () => getDiagnosticsProducingTypeChecker().getTypeCount(),
|
||||
getFileProcessingDiagnostics: () => fileProcessingDiagnostics
|
||||
};
|
||||
|
||||
verifyCompilerOptions();
|
||||
|
||||
programTime += new Date().getTime() - start;
|
||||
|
||||
return program;
|
||||
|
||||
function getClassifiableNames() {
|
||||
@@ -738,6 +747,7 @@ namespace ts {
|
||||
getSourceFiles: program.getSourceFiles,
|
||||
writeFile: writeFileCallback || (
|
||||
(fileName, data, writeByteOrderMark, onError) => host.writeFile(fileName, data, writeByteOrderMark, onError)),
|
||||
isEmitBlocked,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -753,6 +763,10 @@ namespace ts {
|
||||
return runWithCancellationToken(() => emitWorker(this, sourceFile, writeFileCallback, cancellationToken));
|
||||
}
|
||||
|
||||
function isEmitBlocked(emitFileName: string): boolean {
|
||||
return hasEmitBlockingDiagnostics.contains(toPath(emitFileName, currentDirectory, getCanonicalFileName));
|
||||
}
|
||||
|
||||
function emitWorker(program: Program, sourceFile: SourceFile, writeFileCallback: WriteFileCallback, cancellationToken: CancellationToken): EmitResult {
|
||||
// If the noEmitOnError flag is set, then check if we have any errors so far. If so,
|
||||
// immediately bail out. Note that we pass 'undefined' for 'sourceFile' so that we
|
||||
@@ -845,6 +859,13 @@ namespace ts {
|
||||
}
|
||||
|
||||
function getSemanticDiagnosticsForFile(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] {
|
||||
// For JavaScript files, we don't want to report the normal typescript semantic errors.
|
||||
// Instead, we just report errors for using TypeScript-only constructs from within a
|
||||
// JavaScript file.
|
||||
if (isSourceFileJavaScript(sourceFile)) {
|
||||
return getJavaScriptSemanticDiagnosticsForFile(sourceFile, cancellationToken);
|
||||
}
|
||||
|
||||
return runWithCancellationToken(() => {
|
||||
const typeChecker = getDiagnosticsProducingTypeChecker();
|
||||
|
||||
@@ -858,6 +879,165 @@ namespace ts {
|
||||
});
|
||||
}
|
||||
|
||||
function getJavaScriptSemanticDiagnosticsForFile(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] {
|
||||
return runWithCancellationToken(() => {
|
||||
const diagnostics: Diagnostic[] = [];
|
||||
walk(sourceFile);
|
||||
|
||||
return diagnostics;
|
||||
|
||||
function walk(node: Node): boolean {
|
||||
if (!node) {
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.ImportEqualsDeclaration:
|
||||
diagnostics.push(createDiagnosticForNode(node, Diagnostics.import_can_only_be_used_in_a_ts_file));
|
||||
return true;
|
||||
case SyntaxKind.ExportAssignment:
|
||||
diagnostics.push(createDiagnosticForNode(node, Diagnostics.export_can_only_be_used_in_a_ts_file));
|
||||
return true;
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
let classDeclaration = <ClassDeclaration>node;
|
||||
if (checkModifiers(classDeclaration.modifiers) ||
|
||||
checkTypeParameters(classDeclaration.typeParameters)) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.HeritageClause:
|
||||
let heritageClause = <HeritageClause>node;
|
||||
if (heritageClause.token === SyntaxKind.ImplementsKeyword) {
|
||||
diagnostics.push(createDiagnosticForNode(node, Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file));
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.InterfaceDeclaration:
|
||||
diagnostics.push(createDiagnosticForNode(node, Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file));
|
||||
return true;
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
diagnostics.push(createDiagnosticForNode(node, Diagnostics.module_declarations_can_only_be_used_in_a_ts_file));
|
||||
return true;
|
||||
case SyntaxKind.TypeAliasDeclaration:
|
||||
diagnostics.push(createDiagnosticForNode(node, Diagnostics.type_aliases_can_only_be_used_in_a_ts_file));
|
||||
return true;
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.MethodSignature:
|
||||
case SyntaxKind.Constructor:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.ArrowFunction:
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
const functionDeclaration = <FunctionLikeDeclaration>node;
|
||||
if (checkModifiers(functionDeclaration.modifiers) ||
|
||||
checkTypeParameters(functionDeclaration.typeParameters) ||
|
||||
checkTypeAnnotation(functionDeclaration.type)) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.VariableStatement:
|
||||
const variableStatement = <VariableStatement>node;
|
||||
if (checkModifiers(variableStatement.modifiers)) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.VariableDeclaration:
|
||||
const variableDeclaration = <VariableDeclaration>node;
|
||||
if (checkTypeAnnotation(variableDeclaration.type)) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.CallExpression:
|
||||
case SyntaxKind.NewExpression:
|
||||
const expression = <CallExpression>node;
|
||||
if (expression.typeArguments && expression.typeArguments.length > 0) {
|
||||
const start = expression.typeArguments.pos;
|
||||
diagnostics.push(createFileDiagnostic(sourceFile, start, expression.typeArguments.end - start,
|
||||
Diagnostics.type_arguments_can_only_be_used_in_a_ts_file));
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.Parameter:
|
||||
const parameter = <ParameterDeclaration>node;
|
||||
if (parameter.modifiers) {
|
||||
const start = parameter.modifiers.pos;
|
||||
diagnostics.push(createFileDiagnostic(sourceFile, start, parameter.modifiers.end - start,
|
||||
Diagnostics.parameter_modifiers_can_only_be_used_in_a_ts_file));
|
||||
return true;
|
||||
}
|
||||
if (parameter.questionToken) {
|
||||
diagnostics.push(createDiagnosticForNode(parameter.questionToken, Diagnostics._0_can_only_be_used_in_a_ts_file, "?"));
|
||||
return true;
|
||||
}
|
||||
if (parameter.type) {
|
||||
diagnostics.push(createDiagnosticForNode(parameter.type, Diagnostics.types_can_only_be_used_in_a_ts_file));
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
diagnostics.push(createDiagnosticForNode(node, Diagnostics.property_declarations_can_only_be_used_in_a_ts_file));
|
||||
return true;
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
diagnostics.push(createDiagnosticForNode(node, Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file));
|
||||
return true;
|
||||
case SyntaxKind.TypeAssertionExpression:
|
||||
let typeAssertionExpression = <TypeAssertion>node;
|
||||
diagnostics.push(createDiagnosticForNode(typeAssertionExpression.type, Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file));
|
||||
return true;
|
||||
case SyntaxKind.Decorator:
|
||||
diagnostics.push(createDiagnosticForNode(node, Diagnostics.decorators_can_only_be_used_in_a_ts_file));
|
||||
return true;
|
||||
}
|
||||
|
||||
return forEachChild(node, walk);
|
||||
}
|
||||
|
||||
function checkTypeParameters(typeParameters: NodeArray<TypeParameterDeclaration>): boolean {
|
||||
if (typeParameters) {
|
||||
const start = typeParameters.pos;
|
||||
diagnostics.push(createFileDiagnostic(sourceFile, start, typeParameters.end - start, Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function checkTypeAnnotation(type: TypeNode): boolean {
|
||||
if (type) {
|
||||
diagnostics.push(createDiagnosticForNode(type, Diagnostics.types_can_only_be_used_in_a_ts_file));
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function checkModifiers(modifiers: ModifiersArray): boolean {
|
||||
if (modifiers) {
|
||||
for (const modifier of modifiers) {
|
||||
switch (modifier.kind) {
|
||||
case SyntaxKind.PublicKeyword:
|
||||
case SyntaxKind.PrivateKeyword:
|
||||
case SyntaxKind.ProtectedKeyword:
|
||||
case SyntaxKind.DeclareKeyword:
|
||||
diagnostics.push(createDiagnosticForNode(modifier, Diagnostics._0_can_only_be_used_in_a_ts_file, tokenToString(modifier.kind)));
|
||||
return true;
|
||||
|
||||
// These are all legal modifiers.
|
||||
case SyntaxKind.StaticKeyword:
|
||||
case SyntaxKind.ExportKeyword:
|
||||
case SyntaxKind.ConstKeyword:
|
||||
case SyntaxKind.DefaultKeyword:
|
||||
case SyntaxKind.AbstractKeyword:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function getDeclarationDiagnosticsForFile(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] {
|
||||
return runWithCancellationToken(() => {
|
||||
if (!isDeclarationFile(sourceFile)) {
|
||||
@@ -1350,11 +1530,49 @@ namespace ts {
|
||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "declaration"));
|
||||
}
|
||||
}
|
||||
else if (options.allowJs && options.declaration) {
|
||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "allowJs", "declaration"));
|
||||
}
|
||||
|
||||
if (options.emitDecoratorMetadata &&
|
||||
!options.experimentalDecorators) {
|
||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators"));
|
||||
}
|
||||
|
||||
// If the emit is enabled make sure that every output file is unique and not overwriting any of the input files
|
||||
if (!options.noEmit) {
|
||||
const emitHost = getEmitHost();
|
||||
const emitFilesSeen = createFileMap<boolean>(!host.useCaseSensitiveFileNames() ? key => key.toLocaleLowerCase() : undefined);
|
||||
forEachExpectedEmitFile(emitHost, (emitFileNames, sourceFiles, isBundledEmit) => {
|
||||
verifyEmitFilePath(emitFileNames.jsFilePath, emitFilesSeen);
|
||||
verifyEmitFilePath(emitFileNames.declarationFilePath, emitFilesSeen);
|
||||
});
|
||||
}
|
||||
|
||||
// Verify that all the emit files are unique and don't overwrite input files
|
||||
function verifyEmitFilePath(emitFileName: string, emitFilesSeen: FileMap<boolean>) {
|
||||
if (emitFileName) {
|
||||
const emitFilePath = toPath(emitFileName, currentDirectory, getCanonicalFileName);
|
||||
// Report error if the output overwrites input file
|
||||
if (filesByName.contains(emitFilePath)) {
|
||||
createEmitBlockingDiagnostics(emitFileName, emitFilePath, Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file);
|
||||
}
|
||||
|
||||
// Report error if multiple files write into same file
|
||||
if (emitFilesSeen.contains(emitFilePath)) {
|
||||
// Already seen the same emit file - report error
|
||||
createEmitBlockingDiagnostics(emitFileName, emitFilePath, Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files);
|
||||
}
|
||||
else {
|
||||
emitFilesSeen.set(emitFilePath, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function createEmitBlockingDiagnostics(emitFileName: string, emitFilePath: Path, message: DiagnosticMessage) {
|
||||
hasEmitBlockingDiagnostics.set(toPath(emitFileName, currentDirectory, getCanonicalFileName), true);
|
||||
programDiagnostics.add(createCompilerDiagnostic(message, emitFileName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -280,7 +280,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
if (commandLine.options.version) {
|
||||
reportDiagnostic(createCompilerDiagnostic(Diagnostics.Version_0, ts.version), /* compilerHost */ undefined);
|
||||
printVersion();
|
||||
return sys.exit(ExitStatus.Success);
|
||||
}
|
||||
|
||||
@@ -303,7 +303,7 @@ namespace ts {
|
||||
}
|
||||
else if (commandLine.fileNames.length === 0 && isJSONSupported()) {
|
||||
const searchPath = normalizePath(sys.getCurrentDirectory());
|
||||
configFileName = findConfigFile(searchPath);
|
||||
configFileName = findConfigFile(searchPath, sys.fileExists);
|
||||
}
|
||||
|
||||
if (commandLine.fileNames.length === 0 && !configFileName) {
|
||||
@@ -360,7 +360,7 @@ namespace ts {
|
||||
sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
|
||||
return;
|
||||
}
|
||||
const configParseResult = parseJsonConfigFileContent(configObject, sys, getNormalizedAbsolutePath(getDirectoryPath(configFileName), sys.getCurrentDirectory()));
|
||||
const configParseResult = parseJsonConfigFileContent(configObject, sys, getNormalizedAbsolutePath(getDirectoryPath(configFileName), sys.getCurrentDirectory()), commandLine.options);
|
||||
if (configParseResult.errors.length > 0) {
|
||||
reportDiagnostics(configParseResult.errors, /* compilerHost */ undefined);
|
||||
sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
|
||||
@@ -376,7 +376,7 @@ namespace ts {
|
||||
if (configFileName) {
|
||||
const configParseResult = parseConfigFile();
|
||||
rootFileNames = configParseResult.fileNames;
|
||||
compilerOptions = extend(commandLine.options, configParseResult.options);
|
||||
compilerOptions = configParseResult.options;
|
||||
}
|
||||
else {
|
||||
rootFileNames = commandLine.fileNames;
|
||||
@@ -469,7 +469,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function watchedDirectoryChanged(fileName: string) {
|
||||
if (fileName && !ts.isSupportedSourceFileName(fileName)) {
|
||||
if (fileName && !ts.isSupportedSourceFileName(fileName, commandLine.options)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -204,6 +204,7 @@ namespace ts {
|
||||
UnionType,
|
||||
IntersectionType,
|
||||
ParenthesizedType,
|
||||
ThisType,
|
||||
// Binding patterns
|
||||
ObjectBindingPattern,
|
||||
ArrayBindingPattern,
|
||||
@@ -349,7 +350,7 @@ namespace ts {
|
||||
FirstFutureReservedWord = ImplementsKeyword,
|
||||
LastFutureReservedWord = YieldKeyword,
|
||||
FirstTypeNode = TypePredicate,
|
||||
LastTypeNode = ParenthesizedType,
|
||||
LastTypeNode = ThisType,
|
||||
FirstPunctuation = OpenBraceToken,
|
||||
LastPunctuation = CaretEqualsToken,
|
||||
FirstToken = Unknown,
|
||||
@@ -726,6 +727,7 @@ namespace ts {
|
||||
// @kind(SyntaxKind.StringKeyword)
|
||||
// @kind(SyntaxKind.SymbolKeyword)
|
||||
// @kind(SyntaxKind.VoidKeyword)
|
||||
// @kind(SyntaxKind.ThisType)
|
||||
export interface TypeNode extends Node {
|
||||
_typeNodeBrand: any;
|
||||
}
|
||||
@@ -1075,7 +1077,6 @@ namespace ts {
|
||||
export interface DebuggerStatement extends Statement { }
|
||||
|
||||
// @kind(SyntaxKind.MissingDeclaration)
|
||||
// @factoryhidden("name", true)
|
||||
export interface MissingDeclaration extends DeclarationStatement, ClassElement, ObjectLiteralElement, TypeElement {
|
||||
name?: Identifier;
|
||||
}
|
||||
@@ -1232,7 +1233,6 @@ namespace ts {
|
||||
export interface TypeElement extends Declaration {
|
||||
_typeElementBrand: any;
|
||||
name?: PropertyName;
|
||||
// @factoryparam
|
||||
questionToken?: Node;
|
||||
}
|
||||
|
||||
@@ -2368,6 +2368,7 @@ namespace ts {
|
||||
baseUrl?: string;
|
||||
paths?: PathSubstitutions;
|
||||
rootDirs?: RootPaths;
|
||||
allowJs?: boolean;
|
||||
/* @internal */ stripInternal?: boolean;
|
||||
|
||||
// Skip checking lib.d.ts to help speed up tests.
|
||||
|
||||
@@ -38,6 +38,8 @@ namespace ts {
|
||||
getCanonicalFileName(fileName: string): string;
|
||||
getNewLine(): string;
|
||||
|
||||
isEmitBlocked(emitFileName: string): boolean;
|
||||
|
||||
writeFile: WriteFileCallback;
|
||||
}
|
||||
|
||||
@@ -1885,15 +1887,85 @@ namespace ts {
|
||||
return emitOutputFilePathWithoutExtension + extension;
|
||||
}
|
||||
|
||||
export function getEmitScriptTarget(compilerOptions: CompilerOptions) {
|
||||
return compilerOptions.target || ScriptTarget.ES3;
|
||||
}
|
||||
|
||||
export function getEmitModuleKind(compilerOptions: CompilerOptions) {
|
||||
return compilerOptions.module ?
|
||||
compilerOptions.module :
|
||||
getEmitScriptTarget(compilerOptions) === ScriptTarget.ES6 ? ModuleKind.ES6 : ModuleKind.None;
|
||||
}
|
||||
|
||||
export interface EmitFileNames {
|
||||
jsFilePath: string;
|
||||
sourceMapFilePath: string;
|
||||
declarationFilePath: string;
|
||||
}
|
||||
|
||||
export function forEachExpectedEmitFile(host: EmitHost,
|
||||
action: (emitFileNames: EmitFileNames, sourceFiles: SourceFile[], isBundledEmit: boolean) => void,
|
||||
targetSourceFile?: SourceFile) {
|
||||
const options = host.getCompilerOptions();
|
||||
// Emit on each source file
|
||||
if (options.outFile || options.out) {
|
||||
onBundledEmit(host);
|
||||
}
|
||||
else {
|
||||
const sourceFiles = targetSourceFile === undefined ? host.getSourceFiles() : [targetSourceFile];
|
||||
for (const sourceFile of sourceFiles) {
|
||||
if (!isDeclarationFile(sourceFile)) {
|
||||
onSingleFileEmit(host, sourceFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onSingleFileEmit(host: EmitHost, sourceFile: SourceFile) {
|
||||
const jsFilePath = getOwnEmitOutputFilePath(sourceFile, host,
|
||||
sourceFile.languageVariant === LanguageVariant.JSX && options.jsx === JsxEmit.Preserve ? ".jsx" : ".js");
|
||||
const emitFileNames: EmitFileNames = {
|
||||
jsFilePath,
|
||||
sourceMapFilePath: getSourceMapFilePath(jsFilePath, options),
|
||||
declarationFilePath: !isSourceFileJavaScript(sourceFile) ? getDeclarationEmitFilePath(jsFilePath, options) : undefined
|
||||
};
|
||||
action(emitFileNames, [sourceFile], /*isBundledEmit*/false);
|
||||
}
|
||||
|
||||
function onBundledEmit(host: EmitHost) {
|
||||
// Can emit only sources that are not declaration file and are either non module code or module with --module or --target es6 specified
|
||||
const bundledSources = filter(host.getSourceFiles(),
|
||||
sourceFile => !isDeclarationFile(sourceFile) && // Not a declaration file
|
||||
(!isExternalModule(sourceFile) || // non module file
|
||||
(getEmitModuleKind(options) && isExternalModule(sourceFile)))); // module that can emit - note falsy value from getEmitModuleKind means the module kind that shouldn't be emitted
|
||||
if (bundledSources.length) {
|
||||
const jsFilePath = options.outFile || options.out;
|
||||
const emitFileNames: EmitFileNames = {
|
||||
jsFilePath,
|
||||
sourceMapFilePath: getSourceMapFilePath(jsFilePath, options),
|
||||
declarationFilePath: getDeclarationEmitFilePath(jsFilePath, options)
|
||||
};
|
||||
action(emitFileNames, bundledSources, /*isBundledEmit*/true);
|
||||
}
|
||||
}
|
||||
|
||||
function getSourceMapFilePath(jsFilePath: string, options: CompilerOptions) {
|
||||
return options.sourceMap ? jsFilePath + ".map" : undefined;
|
||||
}
|
||||
|
||||
function getDeclarationEmitFilePath(jsFilePath: string, options: CompilerOptions) {
|
||||
return options.declaration ? removeFileExtension(jsFilePath) + ".d.ts" : undefined;
|
||||
}
|
||||
}
|
||||
|
||||
export function getSourceFilePathInNewDir(sourceFile: SourceFile, host: EmitHost, newDirPath: string) {
|
||||
let sourceFilePath = getNormalizedAbsolutePath(sourceFile.fileName, host.getCurrentDirectory());
|
||||
sourceFilePath = sourceFilePath.replace(host.getCommonSourceDirectory(), "");
|
||||
return combinePaths(newDirPath, sourceFilePath);
|
||||
}
|
||||
|
||||
export function writeFile(host: EmitHost, diagnostics: Diagnostic[], fileName: string, data: string, writeByteOrderMark: boolean) {
|
||||
export function writeFile(host: EmitHost, diagnostics: DiagnosticCollection, fileName: string, data: string, writeByteOrderMark: boolean) {
|
||||
host.writeFile(fileName, data, writeByteOrderMark, hostErrorMessage => {
|
||||
diagnostics.push(createCompilerDiagnostic(Diagnostics.Could_not_write_file_0_Colon_1, fileName, hostErrorMessage));
|
||||
diagnostics.add(createCompilerDiagnostic(Diagnostics.Could_not_write_file_0_Colon_1, fileName, hostErrorMessage));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1917,18 +1989,6 @@ namespace ts {
|
||||
return accessor && accessor.parameters.length > 0 && accessor.parameters[0].type;
|
||||
}
|
||||
|
||||
export function shouldEmitToOwnFile(sourceFile: SourceFile, compilerOptions: CompilerOptions): boolean {
|
||||
if (!isDeclarationFile(sourceFile)) {
|
||||
if ((isExternalModule(sourceFile) || !(compilerOptions.outFile || compilerOptions.out))) {
|
||||
// 1. in-browser single file compilation scenario
|
||||
// 2. non .js file
|
||||
return compilerOptions.isolatedModules || !fileExtensionIs(sourceFile.fileName, ".js");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export function getAllAccessorDeclarations(declarations: NodeArray<Declaration>, accessor: AccessorDeclaration) {
|
||||
let firstAccessor: AccessorDeclaration;
|
||||
let secondAccessor: AccessorDeclaration;
|
||||
@@ -2273,11 +2333,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function hasJavaScriptFileExtension(fileName: string) {
|
||||
return fileExtensionIs(fileName, ".js") || fileExtensionIs(fileName, ".jsx");
|
||||
}
|
||||
|
||||
export function allowsJsxExpressions(fileName: string) {
|
||||
return fileExtensionIs(fileName, ".tsx") || fileExtensionIs(fileName, ".jsx");
|
||||
return forEach(supportedJavascriptExtensions, extension => fileExtensionIs(fileName, extension));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -51,6 +51,7 @@ class CompilerBaselineRunner extends RunnerBase {
|
||||
let justName: string;
|
||||
let lastUnit: Harness.TestCaseParser.TestUnitData;
|
||||
let harnessSettings: Harness.TestCaseParser.CompilerSettings;
|
||||
let hasNonDtsFiles: boolean;
|
||||
|
||||
let result: Harness.Compiler.CompilerResult;
|
||||
let options: ts.CompilerOptions;
|
||||
@@ -80,6 +81,7 @@ class CompilerBaselineRunner extends RunnerBase {
|
||||
}
|
||||
|
||||
lastUnit = units[units.length - 1];
|
||||
hasNonDtsFiles = ts.forEach(units, unit => !ts.fileExtensionIs(unit.name, ".d.ts"));
|
||||
// We need to assemble the list of input files for the compiler and other related files on the 'filesystem' (ie in a multi-file test)
|
||||
// If the last file in a test uses require or a triple slash reference we'll assume all other files will be brought in via references,
|
||||
// otherwise, assume all files are just meant to be in the same compilation session without explicit references to one another.
|
||||
@@ -112,6 +114,7 @@ class CompilerBaselineRunner extends RunnerBase {
|
||||
// Therefore we have to clean out large objects after the test is done.
|
||||
justName = undefined;
|
||||
lastUnit = undefined;
|
||||
hasNonDtsFiles = undefined;
|
||||
result = undefined;
|
||||
options = undefined;
|
||||
toBeCompiled = undefined;
|
||||
@@ -151,7 +154,7 @@ class CompilerBaselineRunner extends RunnerBase {
|
||||
});
|
||||
|
||||
it("Correct JS output for " + fileName, () => {
|
||||
if (!ts.fileExtensionIs(lastUnit.name, ".d.ts") && this.emit) {
|
||||
if (hasNonDtsFiles && this.emit) {
|
||||
if (result.files.length === 0 && result.errors.length === 0) {
|
||||
throw new Error("Expected at least one js file to be emitted or at least one error to be created.");
|
||||
}
|
||||
|
||||
@@ -286,7 +286,7 @@ namespace FourSlash {
|
||||
// Fourslash insert tests/cases/fourslash into inputFile.unitName and import statement doesn't require ".ts"
|
||||
// so convert them before making appropriate comparison
|
||||
const importedFilePath = this.basePath + "/" + importedFile.fileName;
|
||||
this.addMatchedInputFile(importedFilePath, compilationOptions.allowNonTsExtensions ? ts.supportedJsExtensions : ts.supportedExtensions);
|
||||
this.addMatchedInputFile(importedFilePath, ts.getSupportedExtensions(compilationOptions));
|
||||
});
|
||||
|
||||
// Check if no-default-lib flag is false and if so add default library
|
||||
@@ -514,6 +514,15 @@ namespace FourSlash {
|
||||
}
|
||||
}
|
||||
|
||||
public verifyGetEmitOutputContentsForCurrentFile(expected: ts.OutputFile[]): void {
|
||||
const emit = this.languageService.getEmitOutput(this.activeFile.fileName);
|
||||
assert.equal(emit.outputFiles.length, expected.length, "Number of emit output files");
|
||||
for (let i = 0; i < emit.outputFiles.length; i++) {
|
||||
assert.equal(emit.outputFiles[i].name, expected[i].name, "FileName");
|
||||
assert.equal(emit.outputFiles[i].text, expected[i].text, "Content");
|
||||
}
|
||||
}
|
||||
|
||||
public verifyMemberListContains(symbol: string, text?: string, documentation?: string, kind?: string) {
|
||||
const members = this.getMemberListAtCaret();
|
||||
if (members) {
|
||||
@@ -2862,6 +2871,10 @@ namespace FourSlashInterface {
|
||||
this.state.verifyGetEmitOutputForCurrentFile(expected);
|
||||
}
|
||||
|
||||
public verifyGetEmitOutputContentsForCurrentFile(expected: ts.OutputFile[]): void {
|
||||
this.state.verifyGetEmitOutputContentsForCurrentFile(expected);
|
||||
}
|
||||
|
||||
public currentParameterHelpArgumentNameIs(name: string) {
|
||||
this.state.verifyCurrentParameterHelpName(name);
|
||||
}
|
||||
@@ -3274,4 +3287,4 @@ namespace FourSlashInterface {
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,7 +176,9 @@ namespace Utils {
|
||||
ts.forEachChild(node, child => { childNodesAndArrays.push(child); }, array => { childNodesAndArrays.push(array); });
|
||||
|
||||
for (const childName in node) {
|
||||
if (childName === "parent" || childName === "nextContainer" || childName === "modifiers" || childName === "externalModuleIndicator") {
|
||||
if (childName === "parent" || childName === "nextContainer" || childName === "modifiers" || childName === "externalModuleIndicator" ||
|
||||
// for now ignore jsdoc comments
|
||||
childName === "jsDocComment") {
|
||||
continue;
|
||||
}
|
||||
const child = (<any>node)[childName];
|
||||
@@ -1031,7 +1033,7 @@ namespace Harness {
|
||||
|
||||
const emitResult = program.emit();
|
||||
|
||||
const errors = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
|
||||
const errors = ts.getPreEmitDiagnostics(program);
|
||||
|
||||
const result = new CompilerResult(fileOutputs, errors, program, Harness.IO.getCurrentDirectory(), emitResult.sourceMaps);
|
||||
return { result, options };
|
||||
@@ -1056,7 +1058,6 @@ namespace Harness {
|
||||
ts.forEach(inputFiles, file => addDtsFile(file, declInputFiles));
|
||||
ts.forEach(otherFiles, file => addDtsFile(file, declOtherFiles));
|
||||
const output = compileFiles(declInputFiles, declOtherFiles, harnessSettings, options, currentDirectory);
|
||||
|
||||
return { declInputFiles, declOtherFiles, declResult: output.result };
|
||||
}
|
||||
|
||||
@@ -1078,7 +1079,7 @@ namespace Harness {
|
||||
// Is this file going to be emitted separately
|
||||
let sourceFileName: string;
|
||||
const outFile = options.outFile || options.out;
|
||||
if (ts.isExternalModule(sourceFile) || !outFile) {
|
||||
if (!outFile) {
|
||||
if (options.outDir) {
|
||||
let sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.fileName, result.currentDirectoryForProgram);
|
||||
sourceFilePath = sourceFilePath.replace(result.program.getCommonSourceDirectory(), "");
|
||||
@@ -1441,7 +1442,7 @@ namespace Harness {
|
||||
}
|
||||
|
||||
// normalize the fileName for the single file case
|
||||
currentFileName = testUnitData.length > 0 ? currentFileName : Path.getFileName(fileName);
|
||||
currentFileName = testUnitData.length > 0 || currentFileName ? currentFileName : Path.getFileName(fileName);
|
||||
|
||||
// EOF, push whatever remains
|
||||
const newTestFile2 = {
|
||||
@@ -1584,7 +1585,7 @@ namespace Harness {
|
||||
const encoded_actual = Utils.encodeString(actual);
|
||||
if (expected != encoded_actual) {
|
||||
// Overwrite & issue error
|
||||
const errMsg = "The baseline file " + relativeFileName + " has changed";
|
||||
const errMsg = "The baseline file " + relativeFileName + " has changed.";
|
||||
throw new Error(errMsg);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,19 +7,11 @@ interface ProjectRunnerTestCase {
|
||||
scenario: string;
|
||||
projectRoot: string; // project where it lives - this also is the current directory when compiling
|
||||
inputFiles: string[]; // list of input files to be given to program
|
||||
out?: string; // --out
|
||||
outDir?: string; // --outDir
|
||||
sourceMap?: boolean; // --map
|
||||
mapRoot?: string; // --mapRoot
|
||||
resolveMapRoot?: boolean; // should we resolve this map root and give compiler the absolute disk path as map root?
|
||||
sourceRoot?: string; // --sourceRoot
|
||||
resolveSourceRoot?: boolean; // should we resolve this source root and give compiler the absolute disk path as map root?
|
||||
declaration?: boolean; // --d
|
||||
baselineCheck?: boolean; // Verify the baselines of output files, if this is false, we will write to output to the disk but there is no verification of baselines
|
||||
runTest?: boolean; // Run the resulting test
|
||||
bug?: string; // If there is any bug associated with this test case
|
||||
noResolve?: boolean;
|
||||
rootDir?: string; // --rootDir
|
||||
}
|
||||
|
||||
interface ProjectRunnerTestCaseResolutionInfo extends ProjectRunnerTestCase {
|
||||
@@ -34,14 +26,14 @@ interface BatchCompileProjectTestCaseEmittedFile extends Harness.Compiler.Genera
|
||||
|
||||
interface CompileProjectFilesResult {
|
||||
moduleKind: ts.ModuleKind;
|
||||
program: ts.Program;
|
||||
program?: ts.Program;
|
||||
compilerOptions?: ts.CompilerOptions;
|
||||
errors: ts.Diagnostic[];
|
||||
sourceMapData: ts.SourceMapData[];
|
||||
sourceMapData?: ts.SourceMapData[];
|
||||
}
|
||||
|
||||
interface BatchCompileProjectTestCaseResult extends CompileProjectFilesResult {
|
||||
outputFiles: BatchCompileProjectTestCaseEmittedFile[];
|
||||
nonSubfolderDiskFiles: number;
|
||||
outputFiles?: BatchCompileProjectTestCaseEmittedFile[];
|
||||
}
|
||||
|
||||
class ProjectRunner extends RunnerBase {
|
||||
@@ -59,7 +51,7 @@ class ProjectRunner extends RunnerBase {
|
||||
}
|
||||
|
||||
private runProjectTestCase(testCaseFileName: string) {
|
||||
let testCase: ProjectRunnerTestCase;
|
||||
let testCase: ProjectRunnerTestCase & ts.CompilerOptions;
|
||||
|
||||
let testFileText: string = null;
|
||||
try {
|
||||
@@ -70,7 +62,7 @@ class ProjectRunner extends RunnerBase {
|
||||
}
|
||||
|
||||
try {
|
||||
testCase = <ProjectRunnerTestCase>JSON.parse(testFileText);
|
||||
testCase = <ProjectRunnerTestCase & ts.CompilerOptions>JSON.parse(testFileText);
|
||||
}
|
||||
catch (e) {
|
||||
assert(false, "Testcase: " + testCaseFileName + " does not contain valid json format: " + e.message);
|
||||
@@ -128,9 +120,10 @@ class ProjectRunner extends RunnerBase {
|
||||
|
||||
function compileProjectFiles(moduleKind: ts.ModuleKind, getInputFiles: () => string[],
|
||||
getSourceFileTextImpl: (fileName: string) => string,
|
||||
writeFile: (fileName: string, data: string, writeByteOrderMark: boolean) => void): CompileProjectFilesResult {
|
||||
writeFile: (fileName: string, data: string, writeByteOrderMark: boolean) => void,
|
||||
compilerOptions: ts.CompilerOptions): CompileProjectFilesResult {
|
||||
|
||||
const program = ts.createProgram(getInputFiles(), createCompilerOptions(), createCompilerHost());
|
||||
const program = ts.createProgram(getInputFiles(), compilerOptions, createCompilerHost());
|
||||
let errors = ts.getPreEmitDiagnostics(program);
|
||||
|
||||
const emitResult = program.emit();
|
||||
@@ -155,21 +148,6 @@ class ProjectRunner extends RunnerBase {
|
||||
sourceMapData
|
||||
};
|
||||
|
||||
function createCompilerOptions(): ts.CompilerOptions {
|
||||
return {
|
||||
declaration: !!testCase.declaration,
|
||||
sourceMap: !!testCase.sourceMap,
|
||||
outFile: testCase.out,
|
||||
outDir: testCase.outDir,
|
||||
mapRoot: testCase.resolveMapRoot && testCase.mapRoot ? Harness.IO.resolvePath(testCase.mapRoot) : testCase.mapRoot,
|
||||
sourceRoot: testCase.resolveSourceRoot && testCase.sourceRoot ? Harness.IO.resolvePath(testCase.sourceRoot) : testCase.sourceRoot,
|
||||
module: moduleKind,
|
||||
moduleResolution: ts.ModuleResolutionKind.Classic, // currently all tests use classic module resolution kind, this will change in the future
|
||||
noResolve: testCase.noResolve,
|
||||
rootDir: testCase.rootDir
|
||||
};
|
||||
}
|
||||
|
||||
function getSourceFileText(fileName: string): string {
|
||||
const text = getSourceFileTextImpl(fileName);
|
||||
return text !== undefined ? text : getSourceFileTextImpl(ts.getNormalizedAbsolutePath(fileName, getCurrentDirectory()));
|
||||
@@ -209,23 +187,105 @@ class ProjectRunner extends RunnerBase {
|
||||
let nonSubfolderDiskFiles = 0;
|
||||
|
||||
const outputFiles: BatchCompileProjectTestCaseEmittedFile[] = [];
|
||||
let inputFiles = testCase.inputFiles;
|
||||
let compilerOptions = createCompilerOptions();
|
||||
|
||||
const projectCompilerResult = compileProjectFiles(moduleKind, () => testCase.inputFiles, getSourceFileText, writeFile);
|
||||
let configFileName: string;
|
||||
if (compilerOptions.project) {
|
||||
// Parse project
|
||||
configFileName = ts.normalizePath(ts.combinePaths(compilerOptions.project, "tsconfig.json"));
|
||||
assert(!inputFiles || inputFiles.length === 0, "cannot specify input files and project option together");
|
||||
}
|
||||
else if (!inputFiles || inputFiles.length === 0) {
|
||||
configFileName = ts.findConfigFile("", fileExists);
|
||||
}
|
||||
|
||||
if (configFileName) {
|
||||
const result = ts.readConfigFile(configFileName, getSourceFileText);
|
||||
if (result.error) {
|
||||
return {
|
||||
moduleKind,
|
||||
errors: [result.error]
|
||||
};
|
||||
}
|
||||
|
||||
const configObject = result.config;
|
||||
const configParseResult = ts.parseJsonConfigFileContent(configObject, { readDirectory }, ts.getDirectoryPath(configFileName), compilerOptions);
|
||||
if (configParseResult.errors.length > 0) {
|
||||
return {
|
||||
moduleKind,
|
||||
errors: configParseResult.errors
|
||||
};
|
||||
}
|
||||
inputFiles = configParseResult.fileNames;
|
||||
compilerOptions = configParseResult.options;
|
||||
}
|
||||
|
||||
const projectCompilerResult = compileProjectFiles(moduleKind, () => inputFiles, getSourceFileText, writeFile, compilerOptions);
|
||||
return {
|
||||
moduleKind,
|
||||
program: projectCompilerResult.program,
|
||||
compilerOptions,
|
||||
sourceMapData: projectCompilerResult.sourceMapData,
|
||||
outputFiles,
|
||||
errors: projectCompilerResult.errors,
|
||||
nonSubfolderDiskFiles,
|
||||
};
|
||||
|
||||
function createCompilerOptions() {
|
||||
// Set the special options that depend on other testcase options
|
||||
const compilerOptions: ts.CompilerOptions = {
|
||||
mapRoot: testCase.resolveMapRoot && testCase.mapRoot ? Harness.IO.resolvePath(testCase.mapRoot) : testCase.mapRoot,
|
||||
sourceRoot: testCase.resolveSourceRoot && testCase.sourceRoot ? Harness.IO.resolvePath(testCase.sourceRoot) : testCase.sourceRoot,
|
||||
module: moduleKind,
|
||||
moduleResolution: ts.ModuleResolutionKind.Classic, // currently all tests use classic module resolution kind, this will change in the future
|
||||
};
|
||||
// Set the values specified using json
|
||||
const optionNameMap: ts.Map<ts.CommandLineOption> = {};
|
||||
ts.forEach(ts.optionDeclarations, option => {
|
||||
optionNameMap[option.name] = option;
|
||||
});
|
||||
for (const name in testCase) {
|
||||
if (name !== "mapRoot" && name !== "sourceRoot" && ts.hasProperty(optionNameMap, name)) {
|
||||
const option = optionNameMap[name];
|
||||
const optType = option.type;
|
||||
let value = <any>testCase[name];
|
||||
if (typeof optType !== "string") {
|
||||
const key = value.toLowerCase();
|
||||
if (ts.hasProperty(optType, key)) {
|
||||
value = optType[key];
|
||||
}
|
||||
}
|
||||
compilerOptions[option.name] = value;
|
||||
}
|
||||
}
|
||||
|
||||
return compilerOptions;
|
||||
}
|
||||
|
||||
function getFileNameInTheProjectTest(fileName: string): string {
|
||||
return ts.isRootedDiskPath(fileName)
|
||||
? fileName
|
||||
: ts.normalizeSlashes(testCase.projectRoot) + "/" + ts.normalizeSlashes(fileName);
|
||||
}
|
||||
|
||||
function readDirectory(rootDir: string, extension: string, exclude: string[]): string[] {
|
||||
const harnessReadDirectoryResult = Harness.IO.readDirectory(getFileNameInTheProjectTest(rootDir), extension, exclude);
|
||||
const result: string[] = [];
|
||||
for (let i = 0; i < harnessReadDirectoryResult.length; i++) {
|
||||
result[i] = ts.getRelativePathToDirectoryOrUrl(testCase.projectRoot, harnessReadDirectoryResult[i],
|
||||
getCurrentDirectory(), Harness.Compiler.getCanonicalFileName, /*isAbsolutePathAnUrl*/ false);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function fileExists(fileName: string): boolean {
|
||||
return Harness.IO.fileExists(getFileNameInTheProjectTest(fileName));
|
||||
}
|
||||
|
||||
function getSourceFileText(fileName: string): string {
|
||||
let text: string = undefined;
|
||||
try {
|
||||
text = Harness.IO.readFile(ts.isRootedDiskPath(fileName)
|
||||
? fileName
|
||||
: ts.normalizeSlashes(testCase.projectRoot) + "/" + ts.normalizeSlashes(fileName));
|
||||
text = Harness.IO.readFile(getFileNameInTheProjectTest(fileName));
|
||||
}
|
||||
catch (e) {
|
||||
// text doesn't get defined.
|
||||
@@ -288,13 +348,16 @@ class ProjectRunner extends RunnerBase {
|
||||
|
||||
function compileCompileDTsFiles(compilerResult: BatchCompileProjectTestCaseResult) {
|
||||
const allInputFiles: { emittedFileName: string; code: string; }[] = [];
|
||||
if (!compilerResult.program) {
|
||||
return;
|
||||
}
|
||||
const compilerOptions = compilerResult.program.getCompilerOptions();
|
||||
|
||||
ts.forEach(compilerResult.program.getSourceFiles(), sourceFile => {
|
||||
if (Harness.Compiler.isDTS(sourceFile.fileName)) {
|
||||
if (ts.isDeclarationFile(sourceFile)) {
|
||||
allInputFiles.unshift({ emittedFileName: sourceFile.fileName, code: sourceFile.text });
|
||||
}
|
||||
else if (ts.shouldEmitToOwnFile(sourceFile, compilerResult.program.getCompilerOptions())) {
|
||||
else if (!(compilerOptions.outFile || compilerOptions.out)) {
|
||||
let emitOutputFilePathWithoutExtension: string = undefined;
|
||||
if (compilerOptions.outDir) {
|
||||
let sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.fileName, compilerResult.program.getCurrentDirectory());
|
||||
@@ -320,7 +383,8 @@ class ProjectRunner extends RunnerBase {
|
||||
}
|
||||
});
|
||||
|
||||
return compileProjectFiles(compilerResult.moduleKind, getInputFiles, getSourceFileText, writeFile);
|
||||
// Dont allow config files since we are compiling existing source options
|
||||
return compileProjectFiles(compilerResult.moduleKind, getInputFiles, getSourceFileText, writeFile, compilerResult.compilerOptions);
|
||||
|
||||
function findOutpuDtsFile(fileName: string) {
|
||||
return ts.forEach(compilerResult.outputFiles, outputFile => outputFile.emittedFileName === fileName ? outputFile : undefined);
|
||||
@@ -346,11 +410,16 @@ class ProjectRunner extends RunnerBase {
|
||||
}
|
||||
|
||||
function getErrorsBaseline(compilerResult: CompileProjectFilesResult) {
|
||||
const inputFiles = ts.map(ts.filter(compilerResult.program.getSourceFiles(),
|
||||
const inputFiles = compilerResult.program ? ts.map(ts.filter(compilerResult.program.getSourceFiles(),
|
||||
sourceFile => sourceFile.fileName !== "lib.d.ts"),
|
||||
sourceFile => {
|
||||
return { unitName: RunnerBase.removeFullPaths(sourceFile.fileName), content: sourceFile.text, };
|
||||
});
|
||||
return {
|
||||
unitName: ts.isRootedDiskPath(sourceFile.fileName) ?
|
||||
RunnerBase.removeFullPaths(sourceFile.fileName) :
|
||||
sourceFile.fileName,
|
||||
content: sourceFile.text
|
||||
};
|
||||
}) : [];
|
||||
|
||||
return Harness.Compiler.getErrorBaseline(inputFiles, compilerResult.errors);
|
||||
}
|
||||
@@ -363,30 +432,13 @@ class ProjectRunner extends RunnerBase {
|
||||
let compilerResult: BatchCompileProjectTestCaseResult;
|
||||
|
||||
function getCompilerResolutionInfo() {
|
||||
const resolutionInfo: ProjectRunnerTestCaseResolutionInfo = {
|
||||
scenario: testCase.scenario,
|
||||
projectRoot: testCase.projectRoot,
|
||||
inputFiles: testCase.inputFiles,
|
||||
out: testCase.out,
|
||||
outDir: testCase.outDir,
|
||||
sourceMap: testCase.sourceMap,
|
||||
mapRoot: testCase.mapRoot,
|
||||
resolveMapRoot: testCase.resolveMapRoot,
|
||||
sourceRoot: testCase.sourceRoot,
|
||||
resolveSourceRoot: testCase.resolveSourceRoot,
|
||||
declaration: testCase.declaration,
|
||||
baselineCheck: testCase.baselineCheck,
|
||||
runTest: testCase.runTest,
|
||||
bug: testCase.bug,
|
||||
rootDir: testCase.rootDir,
|
||||
resolvedInputFiles: ts.map(compilerResult.program.getSourceFiles(), inputFile => {
|
||||
return ts.convertToRelativePath(inputFile.fileName, getCurrentDirectory(), path => Harness.Compiler.getCanonicalFileName(path));
|
||||
}),
|
||||
emittedFiles: ts.map(compilerResult.outputFiles, outputFile => {
|
||||
return ts.convertToRelativePath(outputFile.emittedFileName, getCurrentDirectory(), path => Harness.Compiler.getCanonicalFileName(path));
|
||||
})
|
||||
};
|
||||
|
||||
const resolutionInfo: ProjectRunnerTestCaseResolutionInfo & ts.CompilerOptions = JSON.parse(JSON.stringify(testCase));
|
||||
resolutionInfo.resolvedInputFiles = ts.map(compilerResult.program.getSourceFiles(), inputFile => {
|
||||
return ts.convertToRelativePath(inputFile.fileName, getCurrentDirectory(), path => Harness.Compiler.getCanonicalFileName(path));
|
||||
});
|
||||
resolutionInfo.emittedFiles = ts.map(compilerResult.outputFiles, outputFile => {
|
||||
return ts.convertToRelativePath(outputFile.emittedFileName, getCurrentDirectory(), path => Harness.Compiler.getCanonicalFileName(path));
|
||||
});
|
||||
return resolutionInfo;
|
||||
}
|
||||
|
||||
@@ -442,7 +494,7 @@ class ProjectRunner extends RunnerBase {
|
||||
it("Errors in generated Dts files for (" + moduleNameToString(moduleKind) + "): " + testCaseFileName, () => {
|
||||
if (!compilerResult.errors.length && testCase.declaration) {
|
||||
const dTsCompileResult = compileCompileDTsFiles(compilerResult);
|
||||
if (dTsCompileResult.errors.length) {
|
||||
if (dTsCompileResult && dTsCompileResult.errors.length) {
|
||||
Harness.Baseline.runBaseline("Errors in generated Dts files for (" + moduleNameToString(compilerResult.moduleKind) + "): " + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + testCaseJustName + ".dts.errors.txt", () => {
|
||||
return getErrorsBaseline(dTsCompileResult);
|
||||
});
|
||||
|
||||
@@ -564,7 +564,7 @@ namespace ts.server {
|
||||
// If a change was made inside "folder/file", node will trigger the callback twice:
|
||||
// one with the fileName being "folder/file", and the other one with "folder".
|
||||
// We don't respond to the second one.
|
||||
if (fileName && !ts.isSupportedSourceFileName(fileName)) {
|
||||
if (fileName && !ts.isSupportedSourceFileName(fileName, project.projectOptions ? project.projectOptions.compilerOptions : undefined)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
/* @internal */
|
||||
namespace ts.NavigationBar {
|
||||
export function getNavigationBarItems(sourceFile: SourceFile): ts.NavigationBarItem[] {
|
||||
export function getNavigationBarItems(sourceFile: SourceFile, compilerOptions: CompilerOptions): ts.NavigationBarItem[] {
|
||||
// If the source file has any child items, then it included in the tree
|
||||
// and takes lexical ownership of all other top-level items.
|
||||
let hasGlobalNode = false;
|
||||
|
||||
@@ -2023,7 +2023,7 @@ namespace ts {
|
||||
let getCanonicalFileName = createGetCanonicalFileName(!!useCaseSensitiveFileNames);
|
||||
|
||||
function getKeyFromCompilationSettings(settings: CompilerOptions): string {
|
||||
return "_" + settings.target + "|" + settings.module + "|" + settings.noResolve + "|" + settings.jsx;
|
||||
return "_" + settings.target + "|" + settings.module + "|" + settings.noResolve + "|" + settings.jsx + +"|" + settings.allowJs;
|
||||
}
|
||||
|
||||
function getBucketForCompilationSettings(settings: CompilerOptions, createIfMissing: boolean): FileMap<DocumentRegistryEntry> {
|
||||
@@ -2320,7 +2320,7 @@ namespace ts {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -2339,7 +2339,7 @@ namespace ts {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
function tryConsumeDefine(): boolean {
|
||||
let token = scanner.getToken();
|
||||
if (token === SyntaxKind.Identifier && scanner.getTokenValue() === "define") {
|
||||
@@ -2365,7 +2365,7 @@ namespace ts {
|
||||
if (token !== SyntaxKind.OpenBracketToken) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// skip open bracket
|
||||
token = scanner.scan();
|
||||
let i = 0;
|
||||
@@ -2380,7 +2380,7 @@ namespace ts {
|
||||
token = scanner.scan();
|
||||
}
|
||||
return true;
|
||||
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -2746,7 +2746,8 @@ namespace ts {
|
||||
(oldSettings.target !== newSettings.target ||
|
||||
oldSettings.module !== newSettings.module ||
|
||||
oldSettings.noResolve !== newSettings.noResolve ||
|
||||
oldSettings.jsx !== newSettings.jsx);
|
||||
oldSettings.jsx !== newSettings.jsx ||
|
||||
oldSettings.allowJs !== newSettings.allowJs);
|
||||
|
||||
// Now create a new compiler
|
||||
let compilerHost: CompilerHost = {
|
||||
@@ -2911,13 +2912,6 @@ namespace ts {
|
||||
|
||||
let targetSourceFile = getValidSourceFile(fileName);
|
||||
|
||||
// For JavaScript files, we don't want to report the normal typescript semantic errors.
|
||||
// Instead, we just report errors for using TypeScript-only constructs from within a
|
||||
// JavaScript file.
|
||||
if (isSourceFileJavaScript(targetSourceFile)) {
|
||||
return getJavaScriptSemanticDiagnostics(targetSourceFile);
|
||||
}
|
||||
|
||||
// Only perform the action per file regardless of '-out' flag as LanguageServiceHost is expected to call this function per file.
|
||||
// Therefore only get diagnostics for given file.
|
||||
|
||||
@@ -2931,163 +2925,6 @@ namespace ts {
|
||||
return concatenate(semanticDiagnostics, declarationDiagnostics);
|
||||
}
|
||||
|
||||
function getJavaScriptSemanticDiagnostics(sourceFile: SourceFile): Diagnostic[] {
|
||||
let diagnostics: Diagnostic[] = [];
|
||||
walk(sourceFile);
|
||||
|
||||
return diagnostics;
|
||||
|
||||
function walk(node: Node): boolean {
|
||||
if (!node) {
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.ImportEqualsDeclaration:
|
||||
diagnostics.push(createDiagnosticForNode(node, Diagnostics.import_can_only_be_used_in_a_ts_file));
|
||||
return true;
|
||||
case SyntaxKind.ExportAssignment:
|
||||
diagnostics.push(createDiagnosticForNode(node, Diagnostics.export_can_only_be_used_in_a_ts_file));
|
||||
return true;
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
let classDeclaration = <ClassDeclaration>node;
|
||||
if (checkModifiers(classDeclaration.modifiers) ||
|
||||
checkTypeParameters(classDeclaration.typeParameters)) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.HeritageClause:
|
||||
let heritageClause = <HeritageClause>node;
|
||||
if (heritageClause.token === SyntaxKind.ImplementsKeyword) {
|
||||
diagnostics.push(createDiagnosticForNode(node, Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file));
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.InterfaceDeclaration:
|
||||
diagnostics.push(createDiagnosticForNode(node, Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file));
|
||||
return true;
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
diagnostics.push(createDiagnosticForNode(node, Diagnostics.module_declarations_can_only_be_used_in_a_ts_file));
|
||||
return true;
|
||||
case SyntaxKind.TypeAliasDeclaration:
|
||||
diagnostics.push(createDiagnosticForNode(node, Diagnostics.type_aliases_can_only_be_used_in_a_ts_file));
|
||||
return true;
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.MethodSignature:
|
||||
case SyntaxKind.Constructor:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.ArrowFunction:
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
let functionDeclaration = <FunctionLikeDeclaration>node;
|
||||
if (checkModifiers(functionDeclaration.modifiers) ||
|
||||
checkTypeParameters(functionDeclaration.typeParameters) ||
|
||||
checkTypeAnnotation(functionDeclaration.type)) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.VariableStatement:
|
||||
let variableStatement = <VariableStatement>node;
|
||||
if (checkModifiers(variableStatement.modifiers)) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.VariableDeclaration:
|
||||
let variableDeclaration = <VariableDeclaration>node;
|
||||
if (checkTypeAnnotation(variableDeclaration.type)) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.CallExpression:
|
||||
case SyntaxKind.NewExpression:
|
||||
let expression = <CallExpression>node;
|
||||
if (expression.typeArguments && expression.typeArguments.length > 0) {
|
||||
let start = expression.typeArguments.pos;
|
||||
diagnostics.push(createFileDiagnostic(sourceFile, start, expression.typeArguments.end - start,
|
||||
Diagnostics.type_arguments_can_only_be_used_in_a_ts_file));
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.Parameter:
|
||||
let parameter = <ParameterDeclaration>node;
|
||||
if (parameter.modifiers) {
|
||||
let start = parameter.modifiers.pos;
|
||||
diagnostics.push(createFileDiagnostic(sourceFile, start, parameter.modifiers.end - start,
|
||||
Diagnostics.parameter_modifiers_can_only_be_used_in_a_ts_file));
|
||||
return true;
|
||||
}
|
||||
if (parameter.questionToken) {
|
||||
diagnostics.push(createDiagnosticForNode(parameter.questionToken, Diagnostics._0_can_only_be_used_in_a_ts_file, '?'));
|
||||
return true;
|
||||
}
|
||||
if (parameter.type) {
|
||||
diagnostics.push(createDiagnosticForNode(parameter.type, Diagnostics.types_can_only_be_used_in_a_ts_file));
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
diagnostics.push(createDiagnosticForNode(node, Diagnostics.property_declarations_can_only_be_used_in_a_ts_file));
|
||||
return true;
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
diagnostics.push(createDiagnosticForNode(node, Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file));
|
||||
return true;
|
||||
case SyntaxKind.TypeAssertionExpression:
|
||||
let typeAssertionExpression = <TypeAssertion>node;
|
||||
diagnostics.push(createDiagnosticForNode(typeAssertionExpression.type, Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file));
|
||||
return true;
|
||||
case SyntaxKind.Decorator:
|
||||
diagnostics.push(createDiagnosticForNode(node, Diagnostics.decorators_can_only_be_used_in_a_ts_file));
|
||||
return true;
|
||||
}
|
||||
|
||||
return forEachChild(node, walk);
|
||||
}
|
||||
|
||||
function checkTypeParameters(typeParameters: NodeArray<TypeParameterDeclaration>): boolean {
|
||||
if (typeParameters) {
|
||||
let start = typeParameters.pos;
|
||||
diagnostics.push(createFileDiagnostic(sourceFile, start, typeParameters.end - start, Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function checkTypeAnnotation(type: TypeNode): boolean {
|
||||
if (type) {
|
||||
diagnostics.push(createDiagnosticForNode(type, Diagnostics.types_can_only_be_used_in_a_ts_file));
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function checkModifiers(modifiers: ModifiersArray): boolean {
|
||||
if (modifiers) {
|
||||
for (let modifier of modifiers) {
|
||||
switch (modifier.kind) {
|
||||
case SyntaxKind.PublicKeyword:
|
||||
case SyntaxKind.PrivateKeyword:
|
||||
case SyntaxKind.ProtectedKeyword:
|
||||
case SyntaxKind.DeclareKeyword:
|
||||
diagnostics.push(createDiagnosticForNode(modifier, Diagnostics._0_can_only_be_used_in_a_ts_file, tokenToString(modifier.kind)));
|
||||
return true;
|
||||
|
||||
// These are all legal modifiers.
|
||||
case SyntaxKind.StaticKeyword:
|
||||
case SyntaxKind.ExportKeyword:
|
||||
case SyntaxKind.ConstKeyword:
|
||||
case SyntaxKind.DefaultKeyword:
|
||||
case SyntaxKind.AbstractKeyword:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function getCompilerOptionsDiagnostics() {
|
||||
synchronizeHostData();
|
||||
return program.getOptionsDiagnostics(cancellationToken).concat(
|
||||
@@ -3985,7 +3822,7 @@ namespace ts {
|
||||
let sourceFile = getValidSourceFile(fileName);
|
||||
|
||||
let entries: CompletionEntry[] = [];
|
||||
|
||||
|
||||
if (isRightOfDot && isSourceFileJavaScript(sourceFile)) {
|
||||
const uniqueNames = getCompletionEntriesFromSymbols(symbols, entries);
|
||||
addRange(entries, getJavaScriptCompletionEntries(sourceFile, uniqueNames));
|
||||
@@ -4604,6 +4441,7 @@ namespace ts {
|
||||
case SyntaxKind.PropertyAccessExpression:
|
||||
case SyntaxKind.QualifiedName:
|
||||
case SyntaxKind.ThisKeyword:
|
||||
case SyntaxKind.ThisType:
|
||||
case SyntaxKind.SuperKeyword:
|
||||
// For the identifiers/this/super etc get the type at position
|
||||
let type = typeChecker.getTypeAtLocation(node);
|
||||
@@ -4875,6 +4713,7 @@ namespace ts {
|
||||
function getSemanticDocumentHighlights(node: Node): DocumentHighlights[] {
|
||||
if (node.kind === SyntaxKind.Identifier ||
|
||||
node.kind === SyntaxKind.ThisKeyword ||
|
||||
node.kind === SyntaxKind.ThisType ||
|
||||
node.kind === SyntaxKind.SuperKeyword ||
|
||||
isLiteralNameOfPropertyDeclarationOrIndexAccess(node) ||
|
||||
isNameOfExternalModuleImportOrDeclaration(node)) {
|
||||
@@ -5570,7 +5409,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
if (node.kind === SyntaxKind.ThisKeyword) {
|
||||
if (node.kind === SyntaxKind.ThisKeyword || node.kind === SyntaxKind.ThisType) {
|
||||
return getReferencesForThisKeyword(node, sourceFiles);
|
||||
}
|
||||
|
||||
@@ -6052,7 +5891,7 @@ namespace ts {
|
||||
cancellationToken.throwIfCancellationRequested();
|
||||
|
||||
let node = getTouchingWord(sourceFile, position);
|
||||
if (!node || node.kind !== SyntaxKind.ThisKeyword) {
|
||||
if (!node || (node.kind !== SyntaxKind.ThisKeyword && node.kind !== SyntaxKind.ThisType)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -6414,7 +6253,8 @@ namespace ts {
|
||||
|
||||
return node.parent.kind === SyntaxKind.TypeReference ||
|
||||
(node.parent.kind === SyntaxKind.ExpressionWithTypeArguments && !isExpressionWithTypeArgumentsInClassExtendsClause(<ExpressionWithTypeArguments>node.parent)) ||
|
||||
node.kind === SyntaxKind.ThisKeyword && !isExpression(node);
|
||||
(node.kind === SyntaxKind.ThisKeyword && !isExpression(node)) ||
|
||||
node.kind === SyntaxKind.ThisType;
|
||||
}
|
||||
|
||||
function isNamespaceReference(node: Node): boolean {
|
||||
@@ -6534,6 +6374,7 @@ namespace ts {
|
||||
case SyntaxKind.NullKeyword:
|
||||
case SyntaxKind.SuperKeyword:
|
||||
case SyntaxKind.ThisKeyword:
|
||||
case SyntaxKind.ThisType:
|
||||
case SyntaxKind.Identifier:
|
||||
break;
|
||||
|
||||
@@ -6581,7 +6422,7 @@ namespace ts {
|
||||
function getNavigationBarItems(fileName: string): NavigationBarItem[] {
|
||||
let sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName);
|
||||
|
||||
return NavigationBar.getNavigationBarItems(sourceFile);
|
||||
return NavigationBar.getNavigationBarItems(sourceFile, host.getCompilationSettings());
|
||||
}
|
||||
|
||||
function getSemanticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[] {
|
||||
|
||||
@@ -1,108 +0,0 @@
|
||||
tests/cases/compiler/classdecl.ts(12,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/compiler/classdecl.ts(15,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/compiler/classdecl.ts(18,23): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/compiler/classdecl.ts(24,24): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
|
||||
|
||||
==== tests/cases/compiler/classdecl.ts (4 errors) ====
|
||||
class a {
|
||||
//constructor ();
|
||||
constructor (n: number);
|
||||
constructor (s: string);
|
||||
constructor (ns: any) {
|
||||
|
||||
}
|
||||
|
||||
public pgF() { }
|
||||
|
||||
public pv;
|
||||
public get d() {
|
||||
~
|
||||
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
return 30;
|
||||
}
|
||||
public set d() {
|
||||
~
|
||||
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
}
|
||||
|
||||
public static get p2() {
|
||||
~~
|
||||
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
return { x: 30, y: 40 };
|
||||
}
|
||||
|
||||
private static d2() {
|
||||
}
|
||||
private static get p3() {
|
||||
~~
|
||||
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
return "string";
|
||||
}
|
||||
private pv3;
|
||||
|
||||
private foo(n: number): string;
|
||||
private foo(s: string): string;
|
||||
private foo(ns: any) {
|
||||
return ns.toString();
|
||||
}
|
||||
}
|
||||
|
||||
class b extends a {
|
||||
}
|
||||
|
||||
module m1 {
|
||||
export class b {
|
||||
}
|
||||
class d {
|
||||
}
|
||||
|
||||
|
||||
export interface ib {
|
||||
}
|
||||
}
|
||||
|
||||
module m2 {
|
||||
|
||||
export module m3 {
|
||||
export class c extends b {
|
||||
}
|
||||
export class ib2 implements m1.ib {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class c extends m1.b {
|
||||
}
|
||||
|
||||
class ib2 implements m1.ib {
|
||||
}
|
||||
|
||||
declare class aAmbient {
|
||||
constructor (n: number);
|
||||
constructor (s: string);
|
||||
public pgF(): void;
|
||||
public pv;
|
||||
public d : number;
|
||||
static p2 : { x: number; y: number; };
|
||||
static d2();
|
||||
static p3;
|
||||
private pv3;
|
||||
private foo(s);
|
||||
}
|
||||
|
||||
class d {
|
||||
private foo(n: number): string;
|
||||
private foo(s: string): string;
|
||||
private foo(ns: any) {
|
||||
return ns.toString();
|
||||
}
|
||||
}
|
||||
|
||||
class e {
|
||||
private foo(s: string): string;
|
||||
private foo(n: number): string;
|
||||
private foo(ns: any) {
|
||||
return ns.toString();
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@ class a {
|
||||
public get d() {
|
||||
return 30;
|
||||
}
|
||||
public set d() {
|
||||
public set d(a: number) {
|
||||
}
|
||||
|
||||
public static get p2() {
|
||||
@@ -107,7 +107,7 @@ var a = (function () {
|
||||
get: function () {
|
||||
return 30;
|
||||
},
|
||||
set: function () {
|
||||
set: function (a) {
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
|
||||
198
tests/baselines/reference/classdecl.symbols
Normal file
198
tests/baselines/reference/classdecl.symbols
Normal file
@@ -0,0 +1,198 @@
|
||||
=== tests/cases/compiler/classdecl.ts ===
|
||||
class a {
|
||||
>a : Symbol(a, Decl(classdecl.ts, 0, 0))
|
||||
|
||||
//constructor ();
|
||||
constructor (n: number);
|
||||
>n : Symbol(n, Decl(classdecl.ts, 2, 17))
|
||||
|
||||
constructor (s: string);
|
||||
>s : Symbol(s, Decl(classdecl.ts, 3, 17))
|
||||
|
||||
constructor (ns: any) {
|
||||
>ns : Symbol(ns, Decl(classdecl.ts, 4, 17))
|
||||
|
||||
}
|
||||
|
||||
public pgF() { }
|
||||
>pgF : Symbol(pgF, Decl(classdecl.ts, 6, 5))
|
||||
|
||||
public pv;
|
||||
>pv : Symbol(pv, Decl(classdecl.ts, 8, 20))
|
||||
|
||||
public get d() {
|
||||
>d : Symbol(d, Decl(classdecl.ts, 10, 14), Decl(classdecl.ts, 13, 5))
|
||||
|
||||
return 30;
|
||||
}
|
||||
public set d(a: number) {
|
||||
>d : Symbol(d, Decl(classdecl.ts, 10, 14), Decl(classdecl.ts, 13, 5))
|
||||
>a : Symbol(a, Decl(classdecl.ts, 14, 17))
|
||||
}
|
||||
|
||||
public static get p2() {
|
||||
>p2 : Symbol(a.p2, Decl(classdecl.ts, 15, 5))
|
||||
|
||||
return { x: 30, y: 40 };
|
||||
>x : Symbol(x, Decl(classdecl.ts, 18, 16))
|
||||
>y : Symbol(y, Decl(classdecl.ts, 18, 23))
|
||||
}
|
||||
|
||||
private static d2() {
|
||||
>d2 : Symbol(a.d2, Decl(classdecl.ts, 19, 5))
|
||||
}
|
||||
private static get p3() {
|
||||
>p3 : Symbol(a.p3, Decl(classdecl.ts, 22, 5))
|
||||
|
||||
return "string";
|
||||
}
|
||||
private pv3;
|
||||
>pv3 : Symbol(pv3, Decl(classdecl.ts, 25, 5))
|
||||
|
||||
private foo(n: number): string;
|
||||
>foo : Symbol(foo, Decl(classdecl.ts, 26, 16), Decl(classdecl.ts, 28, 35), Decl(classdecl.ts, 29, 35))
|
||||
>n : Symbol(n, Decl(classdecl.ts, 28, 16))
|
||||
|
||||
private foo(s: string): string;
|
||||
>foo : Symbol(foo, Decl(classdecl.ts, 26, 16), Decl(classdecl.ts, 28, 35), Decl(classdecl.ts, 29, 35))
|
||||
>s : Symbol(s, Decl(classdecl.ts, 29, 16))
|
||||
|
||||
private foo(ns: any) {
|
||||
>foo : Symbol(foo, Decl(classdecl.ts, 26, 16), Decl(classdecl.ts, 28, 35), Decl(classdecl.ts, 29, 35))
|
||||
>ns : Symbol(ns, Decl(classdecl.ts, 30, 16))
|
||||
|
||||
return ns.toString();
|
||||
>ns : Symbol(ns, Decl(classdecl.ts, 30, 16))
|
||||
}
|
||||
}
|
||||
|
||||
class b extends a {
|
||||
>b : Symbol(b, Decl(classdecl.ts, 33, 1))
|
||||
>a : Symbol(a, Decl(classdecl.ts, 0, 0))
|
||||
}
|
||||
|
||||
module m1 {
|
||||
>m1 : Symbol(m1, Decl(classdecl.ts, 36, 1))
|
||||
|
||||
export class b {
|
||||
>b : Symbol(b, Decl(classdecl.ts, 38, 11))
|
||||
}
|
||||
class d {
|
||||
>d : Symbol(d, Decl(classdecl.ts, 40, 5))
|
||||
}
|
||||
|
||||
|
||||
export interface ib {
|
||||
>ib : Symbol(ib, Decl(classdecl.ts, 42, 5))
|
||||
}
|
||||
}
|
||||
|
||||
module m2 {
|
||||
>m2 : Symbol(m2, Decl(classdecl.ts, 47, 1))
|
||||
|
||||
export module m3 {
|
||||
>m3 : Symbol(m3, Decl(classdecl.ts, 49, 11))
|
||||
|
||||
export class c extends b {
|
||||
>c : Symbol(c, Decl(classdecl.ts, 51, 22))
|
||||
>b : Symbol(b, Decl(classdecl.ts, 33, 1))
|
||||
}
|
||||
export class ib2 implements m1.ib {
|
||||
>ib2 : Symbol(ib2, Decl(classdecl.ts, 53, 9))
|
||||
>m1.ib : Symbol(m1.ib, Decl(classdecl.ts, 42, 5))
|
||||
>m1 : Symbol(m1, Decl(classdecl.ts, 36, 1))
|
||||
>ib : Symbol(m1.ib, Decl(classdecl.ts, 42, 5))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class c extends m1.b {
|
||||
>c : Symbol(c, Decl(classdecl.ts, 57, 1))
|
||||
>m1.b : Symbol(m1.b, Decl(classdecl.ts, 38, 11))
|
||||
>m1 : Symbol(m1, Decl(classdecl.ts, 36, 1))
|
||||
>b : Symbol(m1.b, Decl(classdecl.ts, 38, 11))
|
||||
}
|
||||
|
||||
class ib2 implements m1.ib {
|
||||
>ib2 : Symbol(ib2, Decl(classdecl.ts, 60, 1))
|
||||
>m1.ib : Symbol(m1.ib, Decl(classdecl.ts, 42, 5))
|
||||
>m1 : Symbol(m1, Decl(classdecl.ts, 36, 1))
|
||||
>ib : Symbol(m1.ib, Decl(classdecl.ts, 42, 5))
|
||||
}
|
||||
|
||||
declare class aAmbient {
|
||||
>aAmbient : Symbol(aAmbient, Decl(classdecl.ts, 63, 1))
|
||||
|
||||
constructor (n: number);
|
||||
>n : Symbol(n, Decl(classdecl.ts, 66, 17))
|
||||
|
||||
constructor (s: string);
|
||||
>s : Symbol(s, Decl(classdecl.ts, 67, 17))
|
||||
|
||||
public pgF(): void;
|
||||
>pgF : Symbol(pgF, Decl(classdecl.ts, 67, 28))
|
||||
|
||||
public pv;
|
||||
>pv : Symbol(pv, Decl(classdecl.ts, 68, 23))
|
||||
|
||||
public d : number;
|
||||
>d : Symbol(d, Decl(classdecl.ts, 69, 14))
|
||||
|
||||
static p2 : { x: number; y: number; };
|
||||
>p2 : Symbol(aAmbient.p2, Decl(classdecl.ts, 70, 22))
|
||||
>x : Symbol(x, Decl(classdecl.ts, 71, 17))
|
||||
>y : Symbol(y, Decl(classdecl.ts, 71, 28))
|
||||
|
||||
static d2();
|
||||
>d2 : Symbol(aAmbient.d2, Decl(classdecl.ts, 71, 42))
|
||||
|
||||
static p3;
|
||||
>p3 : Symbol(aAmbient.p3, Decl(classdecl.ts, 72, 16))
|
||||
|
||||
private pv3;
|
||||
>pv3 : Symbol(pv3, Decl(classdecl.ts, 73, 14))
|
||||
|
||||
private foo(s);
|
||||
>foo : Symbol(foo, Decl(classdecl.ts, 74, 16))
|
||||
>s : Symbol(s, Decl(classdecl.ts, 75, 16))
|
||||
}
|
||||
|
||||
class d {
|
||||
>d : Symbol(d, Decl(classdecl.ts, 76, 1))
|
||||
|
||||
private foo(n: number): string;
|
||||
>foo : Symbol(foo, Decl(classdecl.ts, 78, 9), Decl(classdecl.ts, 79, 35), Decl(classdecl.ts, 80, 35))
|
||||
>n : Symbol(n, Decl(classdecl.ts, 79, 16))
|
||||
|
||||
private foo(s: string): string;
|
||||
>foo : Symbol(foo, Decl(classdecl.ts, 78, 9), Decl(classdecl.ts, 79, 35), Decl(classdecl.ts, 80, 35))
|
||||
>s : Symbol(s, Decl(classdecl.ts, 80, 16))
|
||||
|
||||
private foo(ns: any) {
|
||||
>foo : Symbol(foo, Decl(classdecl.ts, 78, 9), Decl(classdecl.ts, 79, 35), Decl(classdecl.ts, 80, 35))
|
||||
>ns : Symbol(ns, Decl(classdecl.ts, 81, 16))
|
||||
|
||||
return ns.toString();
|
||||
>ns : Symbol(ns, Decl(classdecl.ts, 81, 16))
|
||||
}
|
||||
}
|
||||
|
||||
class e {
|
||||
>e : Symbol(e, Decl(classdecl.ts, 84, 1))
|
||||
|
||||
private foo(s: string): string;
|
||||
>foo : Symbol(foo, Decl(classdecl.ts, 86, 9), Decl(classdecl.ts, 87, 35), Decl(classdecl.ts, 88, 35))
|
||||
>s : Symbol(s, Decl(classdecl.ts, 87, 16))
|
||||
|
||||
private foo(n: number): string;
|
||||
>foo : Symbol(foo, Decl(classdecl.ts, 86, 9), Decl(classdecl.ts, 87, 35), Decl(classdecl.ts, 88, 35))
|
||||
>n : Symbol(n, Decl(classdecl.ts, 88, 16))
|
||||
|
||||
private foo(ns: any) {
|
||||
>foo : Symbol(foo, Decl(classdecl.ts, 86, 9), Decl(classdecl.ts, 87, 35), Decl(classdecl.ts, 88, 35))
|
||||
>ns : Symbol(ns, Decl(classdecl.ts, 89, 16))
|
||||
|
||||
return ns.toString();
|
||||
>ns : Symbol(ns, Decl(classdecl.ts, 89, 16))
|
||||
}
|
||||
}
|
||||
212
tests/baselines/reference/classdecl.types
Normal file
212
tests/baselines/reference/classdecl.types
Normal file
@@ -0,0 +1,212 @@
|
||||
=== tests/cases/compiler/classdecl.ts ===
|
||||
class a {
|
||||
>a : a
|
||||
|
||||
//constructor ();
|
||||
constructor (n: number);
|
||||
>n : number
|
||||
|
||||
constructor (s: string);
|
||||
>s : string
|
||||
|
||||
constructor (ns: any) {
|
||||
>ns : any
|
||||
|
||||
}
|
||||
|
||||
public pgF() { }
|
||||
>pgF : () => void
|
||||
|
||||
public pv;
|
||||
>pv : any
|
||||
|
||||
public get d() {
|
||||
>d : number
|
||||
|
||||
return 30;
|
||||
>30 : number
|
||||
}
|
||||
public set d(a: number) {
|
||||
>d : number
|
||||
>a : number
|
||||
}
|
||||
|
||||
public static get p2() {
|
||||
>p2 : { x: number; y: number; }
|
||||
|
||||
return { x: 30, y: 40 };
|
||||
>{ x: 30, y: 40 } : { x: number; y: number; }
|
||||
>x : number
|
||||
>30 : number
|
||||
>y : number
|
||||
>40 : number
|
||||
}
|
||||
|
||||
private static d2() {
|
||||
>d2 : () => void
|
||||
}
|
||||
private static get p3() {
|
||||
>p3 : string
|
||||
|
||||
return "string";
|
||||
>"string" : string
|
||||
}
|
||||
private pv3;
|
||||
>pv3 : any
|
||||
|
||||
private foo(n: number): string;
|
||||
>foo : { (n: number): string; (s: string): string; }
|
||||
>n : number
|
||||
|
||||
private foo(s: string): string;
|
||||
>foo : { (n: number): string; (s: string): string; }
|
||||
>s : string
|
||||
|
||||
private foo(ns: any) {
|
||||
>foo : { (n: number): string; (s: string): string; }
|
||||
>ns : any
|
||||
|
||||
return ns.toString();
|
||||
>ns.toString() : any
|
||||
>ns.toString : any
|
||||
>ns : any
|
||||
>toString : any
|
||||
}
|
||||
}
|
||||
|
||||
class b extends a {
|
||||
>b : b
|
||||
>a : a
|
||||
}
|
||||
|
||||
module m1 {
|
||||
>m1 : typeof m1
|
||||
|
||||
export class b {
|
||||
>b : b
|
||||
}
|
||||
class d {
|
||||
>d : d
|
||||
}
|
||||
|
||||
|
||||
export interface ib {
|
||||
>ib : ib
|
||||
}
|
||||
}
|
||||
|
||||
module m2 {
|
||||
>m2 : typeof m2
|
||||
|
||||
export module m3 {
|
||||
>m3 : typeof m3
|
||||
|
||||
export class c extends b {
|
||||
>c : c
|
||||
>b : b
|
||||
}
|
||||
export class ib2 implements m1.ib {
|
||||
>ib2 : ib2
|
||||
>m1.ib : any
|
||||
>m1 : typeof m1
|
||||
>ib : m1.ib
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class c extends m1.b {
|
||||
>c : c
|
||||
>m1.b : m1.b
|
||||
>m1 : typeof m1
|
||||
>b : typeof m1.b
|
||||
}
|
||||
|
||||
class ib2 implements m1.ib {
|
||||
>ib2 : ib2
|
||||
>m1.ib : any
|
||||
>m1 : typeof m1
|
||||
>ib : m1.ib
|
||||
}
|
||||
|
||||
declare class aAmbient {
|
||||
>aAmbient : aAmbient
|
||||
|
||||
constructor (n: number);
|
||||
>n : number
|
||||
|
||||
constructor (s: string);
|
||||
>s : string
|
||||
|
||||
public pgF(): void;
|
||||
>pgF : () => void
|
||||
|
||||
public pv;
|
||||
>pv : any
|
||||
|
||||
public d : number;
|
||||
>d : number
|
||||
|
||||
static p2 : { x: number; y: number; };
|
||||
>p2 : { x: number; y: number; }
|
||||
>x : number
|
||||
>y : number
|
||||
|
||||
static d2();
|
||||
>d2 : () => any
|
||||
|
||||
static p3;
|
||||
>p3 : any
|
||||
|
||||
private pv3;
|
||||
>pv3 : any
|
||||
|
||||
private foo(s);
|
||||
>foo : (s: any) => any
|
||||
>s : any
|
||||
}
|
||||
|
||||
class d {
|
||||
>d : d
|
||||
|
||||
private foo(n: number): string;
|
||||
>foo : { (n: number): string; (s: string): string; }
|
||||
>n : number
|
||||
|
||||
private foo(s: string): string;
|
||||
>foo : { (n: number): string; (s: string): string; }
|
||||
>s : string
|
||||
|
||||
private foo(ns: any) {
|
||||
>foo : { (n: number): string; (s: string): string; }
|
||||
>ns : any
|
||||
|
||||
return ns.toString();
|
||||
>ns.toString() : any
|
||||
>ns.toString : any
|
||||
>ns : any
|
||||
>toString : any
|
||||
}
|
||||
}
|
||||
|
||||
class e {
|
||||
>e : e
|
||||
|
||||
private foo(s: string): string;
|
||||
>foo : { (s: string): string; (n: number): string; }
|
||||
>s : string
|
||||
|
||||
private foo(n: number): string;
|
||||
>foo : { (s: string): string; (n: number): string; }
|
||||
>n : number
|
||||
|
||||
private foo(ns: any) {
|
||||
>foo : { (s: string): string; (n: number): string; }
|
||||
>ns : any
|
||||
|
||||
return ns.toString();
|
||||
>ns.toString() : any
|
||||
>ns.toString : any
|
||||
>ns : any
|
||||
>toString : any
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
EmitSkipped: true
|
||||
Diagnostics:
|
||||
Cannot write file 'tests/cases/fourslash/b.js' because it would overwrite input file.
|
||||
|
||||
EmitSkipped: false
|
||||
FileName : tests/cases/fourslash/a.js
|
||||
function foo2() { return 30; } // no error - should emit a.js
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//// [constEnumMergingWithValues1.ts]
|
||||
//// [m1.ts]
|
||||
|
||||
function foo() {}
|
||||
module foo {
|
||||
@@ -7,7 +7,7 @@ module foo {
|
||||
|
||||
export = foo
|
||||
|
||||
//// [constEnumMergingWithValues1.js]
|
||||
//// [m1.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
function foo() { }
|
||||
return foo;
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
=== tests/cases/compiler/constEnumMergingWithValues1.ts ===
|
||||
=== tests/cases/compiler/m1.ts ===
|
||||
|
||||
function foo() {}
|
||||
>foo : Symbol(foo, Decl(constEnumMergingWithValues1.ts, 0, 0), Decl(constEnumMergingWithValues1.ts, 1, 17))
|
||||
>foo : Symbol(foo, Decl(m1.ts, 0, 0), Decl(m1.ts, 1, 17))
|
||||
|
||||
module foo {
|
||||
>foo : Symbol(foo, Decl(constEnumMergingWithValues1.ts, 0, 0), Decl(constEnumMergingWithValues1.ts, 1, 17))
|
||||
>foo : Symbol(foo, Decl(m1.ts, 0, 0), Decl(m1.ts, 1, 17))
|
||||
|
||||
const enum E { X }
|
||||
>E : Symbol(E, Decl(constEnumMergingWithValues1.ts, 2, 12))
|
||||
>X : Symbol(E.X, Decl(constEnumMergingWithValues1.ts, 3, 18))
|
||||
>E : Symbol(E, Decl(m1.ts, 2, 12))
|
||||
>X : Symbol(E.X, Decl(m1.ts, 3, 18))
|
||||
}
|
||||
|
||||
export = foo
|
||||
>foo : Symbol(foo, Decl(constEnumMergingWithValues1.ts, 0, 0), Decl(constEnumMergingWithValues1.ts, 1, 17))
|
||||
>foo : Symbol(foo, Decl(m1.ts, 0, 0), Decl(m1.ts, 1, 17))
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
=== tests/cases/compiler/constEnumMergingWithValues1.ts ===
|
||||
=== tests/cases/compiler/m1.ts ===
|
||||
|
||||
function foo() {}
|
||||
>foo : typeof foo
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//// [constEnumMergingWithValues2.ts]
|
||||
//// [m1.ts]
|
||||
|
||||
class foo {}
|
||||
module foo {
|
||||
@@ -7,7 +7,7 @@ module foo {
|
||||
|
||||
export = foo
|
||||
|
||||
//// [constEnumMergingWithValues2.js]
|
||||
//// [m1.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
var foo = (function () {
|
||||
function foo() {
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
=== tests/cases/compiler/constEnumMergingWithValues2.ts ===
|
||||
=== tests/cases/compiler/m1.ts ===
|
||||
|
||||
class foo {}
|
||||
>foo : Symbol(foo, Decl(constEnumMergingWithValues2.ts, 0, 0), Decl(constEnumMergingWithValues2.ts, 1, 12))
|
||||
>foo : Symbol(foo, Decl(m1.ts, 0, 0), Decl(m1.ts, 1, 12))
|
||||
|
||||
module foo {
|
||||
>foo : Symbol(foo, Decl(constEnumMergingWithValues2.ts, 0, 0), Decl(constEnumMergingWithValues2.ts, 1, 12))
|
||||
>foo : Symbol(foo, Decl(m1.ts, 0, 0), Decl(m1.ts, 1, 12))
|
||||
|
||||
const enum E { X }
|
||||
>E : Symbol(E, Decl(constEnumMergingWithValues2.ts, 2, 12))
|
||||
>X : Symbol(E.X, Decl(constEnumMergingWithValues2.ts, 3, 18))
|
||||
>E : Symbol(E, Decl(m1.ts, 2, 12))
|
||||
>X : Symbol(E.X, Decl(m1.ts, 3, 18))
|
||||
}
|
||||
|
||||
export = foo
|
||||
>foo : Symbol(foo, Decl(constEnumMergingWithValues2.ts, 0, 0), Decl(constEnumMergingWithValues2.ts, 1, 12))
|
||||
>foo : Symbol(foo, Decl(m1.ts, 0, 0), Decl(m1.ts, 1, 12))
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
=== tests/cases/compiler/constEnumMergingWithValues2.ts ===
|
||||
=== tests/cases/compiler/m1.ts ===
|
||||
|
||||
class foo {}
|
||||
>foo : foo
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//// [constEnumMergingWithValues3.ts]
|
||||
//// [m1.ts]
|
||||
|
||||
enum foo { A }
|
||||
module foo {
|
||||
@@ -7,7 +7,7 @@ module foo {
|
||||
|
||||
export = foo
|
||||
|
||||
//// [constEnumMergingWithValues3.js]
|
||||
//// [m1.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
var foo;
|
||||
(function (foo) {
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
=== tests/cases/compiler/constEnumMergingWithValues3.ts ===
|
||||
=== tests/cases/compiler/m1.ts ===
|
||||
|
||||
enum foo { A }
|
||||
>foo : Symbol(foo, Decl(constEnumMergingWithValues3.ts, 0, 0), Decl(constEnumMergingWithValues3.ts, 1, 14))
|
||||
>A : Symbol(foo.A, Decl(constEnumMergingWithValues3.ts, 1, 10))
|
||||
>foo : Symbol(foo, Decl(m1.ts, 0, 0), Decl(m1.ts, 1, 14))
|
||||
>A : Symbol(foo.A, Decl(m1.ts, 1, 10))
|
||||
|
||||
module foo {
|
||||
>foo : Symbol(foo, Decl(constEnumMergingWithValues3.ts, 0, 0), Decl(constEnumMergingWithValues3.ts, 1, 14))
|
||||
>foo : Symbol(foo, Decl(m1.ts, 0, 0), Decl(m1.ts, 1, 14))
|
||||
|
||||
const enum E { X }
|
||||
>E : Symbol(E, Decl(constEnumMergingWithValues3.ts, 2, 12))
|
||||
>X : Symbol(E.X, Decl(constEnumMergingWithValues3.ts, 3, 18))
|
||||
>E : Symbol(E, Decl(m1.ts, 2, 12))
|
||||
>X : Symbol(E.X, Decl(m1.ts, 3, 18))
|
||||
}
|
||||
|
||||
export = foo
|
||||
>foo : Symbol(foo, Decl(constEnumMergingWithValues3.ts, 0, 0), Decl(constEnumMergingWithValues3.ts, 1, 14))
|
||||
>foo : Symbol(foo, Decl(m1.ts, 0, 0), Decl(m1.ts, 1, 14))
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
=== tests/cases/compiler/constEnumMergingWithValues3.ts ===
|
||||
=== tests/cases/compiler/m1.ts ===
|
||||
|
||||
enum foo { A }
|
||||
>foo : foo
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//// [constEnumMergingWithValues4.ts]
|
||||
//// [m1.ts]
|
||||
|
||||
module foo {
|
||||
const enum E { X }
|
||||
@@ -11,7 +11,7 @@ module foo {
|
||||
|
||||
export = foo
|
||||
|
||||
//// [constEnumMergingWithValues4.js]
|
||||
//// [m1.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
var foo;
|
||||
(function (foo) {
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
=== tests/cases/compiler/constEnumMergingWithValues4.ts ===
|
||||
=== tests/cases/compiler/m1.ts ===
|
||||
|
||||
module foo {
|
||||
>foo : Symbol(foo, Decl(constEnumMergingWithValues4.ts, 0, 0), Decl(constEnumMergingWithValues4.ts, 3, 1))
|
||||
>foo : Symbol(foo, Decl(m1.ts, 0, 0), Decl(m1.ts, 3, 1))
|
||||
|
||||
const enum E { X }
|
||||
>E : Symbol(E, Decl(constEnumMergingWithValues4.ts, 1, 12))
|
||||
>X : Symbol(E.X, Decl(constEnumMergingWithValues4.ts, 2, 18))
|
||||
>E : Symbol(E, Decl(m1.ts, 1, 12))
|
||||
>X : Symbol(E.X, Decl(m1.ts, 2, 18))
|
||||
}
|
||||
|
||||
module foo {
|
||||
>foo : Symbol(foo, Decl(constEnumMergingWithValues4.ts, 0, 0), Decl(constEnumMergingWithValues4.ts, 3, 1))
|
||||
>foo : Symbol(foo, Decl(m1.ts, 0, 0), Decl(m1.ts, 3, 1))
|
||||
|
||||
var x = 1;
|
||||
>x : Symbol(x, Decl(constEnumMergingWithValues4.ts, 6, 7))
|
||||
>x : Symbol(x, Decl(m1.ts, 6, 7))
|
||||
}
|
||||
|
||||
|
||||
export = foo
|
||||
>foo : Symbol(foo, Decl(constEnumMergingWithValues4.ts, 0, 0), Decl(constEnumMergingWithValues4.ts, 3, 1))
|
||||
>foo : Symbol(foo, Decl(m1.ts, 0, 0), Decl(m1.ts, 3, 1))
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
=== tests/cases/compiler/constEnumMergingWithValues4.ts ===
|
||||
=== tests/cases/compiler/m1.ts ===
|
||||
|
||||
module foo {
|
||||
>foo : typeof foo
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//// [constEnumMergingWithValues5.ts]
|
||||
//// [m1.ts]
|
||||
|
||||
module foo {
|
||||
const enum E { X }
|
||||
@@ -6,7 +6,7 @@ module foo {
|
||||
|
||||
export = foo
|
||||
|
||||
//// [constEnumMergingWithValues5.js]
|
||||
//// [m1.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
var foo;
|
||||
(function (foo) {
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
=== tests/cases/compiler/constEnumMergingWithValues5.ts ===
|
||||
=== tests/cases/compiler/m1.ts ===
|
||||
|
||||
module foo {
|
||||
>foo : Symbol(foo, Decl(constEnumMergingWithValues5.ts, 0, 0))
|
||||
>foo : Symbol(foo, Decl(m1.ts, 0, 0))
|
||||
|
||||
const enum E { X }
|
||||
>E : Symbol(E, Decl(constEnumMergingWithValues5.ts, 1, 12))
|
||||
>X : Symbol(E.X, Decl(constEnumMergingWithValues5.ts, 2, 18))
|
||||
>E : Symbol(E, Decl(m1.ts, 1, 12))
|
||||
>X : Symbol(E.X, Decl(m1.ts, 2, 18))
|
||||
}
|
||||
|
||||
export = foo
|
||||
>foo : Symbol(foo, Decl(constEnumMergingWithValues5.ts, 0, 0))
|
||||
>foo : Symbol(foo, Decl(m1.ts, 0, 0))
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
=== tests/cases/compiler/constEnumMergingWithValues5.ts ===
|
||||
=== tests/cases/compiler/m1.ts ===
|
||||
|
||||
module foo {
|
||||
>foo : typeof foo
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
tests/cases/compiler/declFileObjectLiteralWithAccessors.ts(5,13): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/compiler/declFileObjectLiteralWithAccessors.ts(6,13): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
|
||||
|
||||
==== tests/cases/compiler/declFileObjectLiteralWithAccessors.ts (2 errors) ====
|
||||
|
||||
function /*1*/makePoint(x: number) {
|
||||
return {
|
||||
b: 10,
|
||||
get x() { return x; },
|
||||
~
|
||||
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
set x(a: number) { this.b = a; }
|
||||
~
|
||||
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
};
|
||||
};
|
||||
var /*4*/point = makePoint(2);
|
||||
var /*2*/x = point.x;
|
||||
point./*3*/x = 30;
|
||||
@@ -0,0 +1,36 @@
|
||||
=== tests/cases/compiler/declFileObjectLiteralWithAccessors.ts ===
|
||||
|
||||
function /*1*/makePoint(x: number) {
|
||||
>makePoint : Symbol(makePoint, Decl(declFileObjectLiteralWithAccessors.ts, 0, 0))
|
||||
>x : Symbol(x, Decl(declFileObjectLiteralWithAccessors.ts, 1, 24))
|
||||
|
||||
return {
|
||||
b: 10,
|
||||
>b : Symbol(b, Decl(declFileObjectLiteralWithAccessors.ts, 2, 12))
|
||||
|
||||
get x() { return x; },
|
||||
>x : Symbol(x, Decl(declFileObjectLiteralWithAccessors.ts, 3, 14), Decl(declFileObjectLiteralWithAccessors.ts, 4, 30))
|
||||
>x : Symbol(x, Decl(declFileObjectLiteralWithAccessors.ts, 1, 24))
|
||||
|
||||
set x(a: number) { this.b = a; }
|
||||
>x : Symbol(x, Decl(declFileObjectLiteralWithAccessors.ts, 3, 14), Decl(declFileObjectLiteralWithAccessors.ts, 4, 30))
|
||||
>a : Symbol(a, Decl(declFileObjectLiteralWithAccessors.ts, 5, 14))
|
||||
>a : Symbol(a, Decl(declFileObjectLiteralWithAccessors.ts, 5, 14))
|
||||
|
||||
};
|
||||
};
|
||||
var /*4*/point = makePoint(2);
|
||||
>point : Symbol(point, Decl(declFileObjectLiteralWithAccessors.ts, 8, 3))
|
||||
>makePoint : Symbol(makePoint, Decl(declFileObjectLiteralWithAccessors.ts, 0, 0))
|
||||
|
||||
var /*2*/x = point.x;
|
||||
>x : Symbol(x, Decl(declFileObjectLiteralWithAccessors.ts, 9, 3))
|
||||
>point.x : Symbol(x, Decl(declFileObjectLiteralWithAccessors.ts, 3, 14), Decl(declFileObjectLiteralWithAccessors.ts, 4, 30))
|
||||
>point : Symbol(point, Decl(declFileObjectLiteralWithAccessors.ts, 8, 3))
|
||||
>x : Symbol(x, Decl(declFileObjectLiteralWithAccessors.ts, 3, 14), Decl(declFileObjectLiteralWithAccessors.ts, 4, 30))
|
||||
|
||||
point./*3*/x = 30;
|
||||
>point./*3*/x : Symbol(x, Decl(declFileObjectLiteralWithAccessors.ts, 3, 14), Decl(declFileObjectLiteralWithAccessors.ts, 4, 30))
|
||||
>point : Symbol(point, Decl(declFileObjectLiteralWithAccessors.ts, 8, 3))
|
||||
>x : Symbol(x, Decl(declFileObjectLiteralWithAccessors.ts, 3, 14), Decl(declFileObjectLiteralWithAccessors.ts, 4, 30))
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
=== tests/cases/compiler/declFileObjectLiteralWithAccessors.ts ===
|
||||
|
||||
function /*1*/makePoint(x: number) {
|
||||
>makePoint : (x: number) => { b: number; x: number; }
|
||||
>x : number
|
||||
|
||||
return {
|
||||
>{ b: 10, get x() { return x; }, set x(a: number) { this.b = a; } } : { b: number; x: number; }
|
||||
|
||||
b: 10,
|
||||
>b : number
|
||||
>10 : number
|
||||
|
||||
get x() { return x; },
|
||||
>x : number
|
||||
>x : number
|
||||
|
||||
set x(a: number) { this.b = a; }
|
||||
>x : number
|
||||
>a : number
|
||||
>this.b = a : number
|
||||
>this.b : any
|
||||
>this : any
|
||||
>b : any
|
||||
>a : number
|
||||
|
||||
};
|
||||
};
|
||||
var /*4*/point = makePoint(2);
|
||||
>point : { b: number; x: number; }
|
||||
>makePoint(2) : { b: number; x: number; }
|
||||
>makePoint : (x: number) => { b: number; x: number; }
|
||||
>2 : number
|
||||
|
||||
var /*2*/x = point.x;
|
||||
>x : number
|
||||
>point.x : number
|
||||
>point : { b: number; x: number; }
|
||||
>x : number
|
||||
|
||||
point./*3*/x = 30;
|
||||
>point./*3*/x = 30 : number
|
||||
>point./*3*/x : number
|
||||
>point : { b: number; x: number; }
|
||||
>x : number
|
||||
>30 : number
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
tests/cases/compiler/declFileObjectLiteralWithOnlyGetter.ts(4,13): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
|
||||
|
||||
==== tests/cases/compiler/declFileObjectLiteralWithOnlyGetter.ts (1 errors) ====
|
||||
|
||||
function /*1*/makePoint(x: number) {
|
||||
return {
|
||||
get x() { return x; },
|
||||
~
|
||||
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
};
|
||||
};
|
||||
var /*4*/point = makePoint(2);
|
||||
var /*2*/x = point./*3*/x;
|
||||
|
||||
@@ -12,7 +12,7 @@ var /*2*/x = point./*3*/x;
|
||||
//// [declFileObjectLiteralWithOnlyGetter.js]
|
||||
function makePoint(x) {
|
||||
return {
|
||||
get x() { return x; }
|
||||
get x() { return x; },
|
||||
};
|
||||
}
|
||||
;
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
=== tests/cases/compiler/declFileObjectLiteralWithOnlyGetter.ts ===
|
||||
|
||||
function /*1*/makePoint(x: number) {
|
||||
>makePoint : Symbol(makePoint, Decl(declFileObjectLiteralWithOnlyGetter.ts, 0, 0))
|
||||
>x : Symbol(x, Decl(declFileObjectLiteralWithOnlyGetter.ts, 1, 24))
|
||||
|
||||
return {
|
||||
get x() { return x; },
|
||||
>x : Symbol(x, Decl(declFileObjectLiteralWithOnlyGetter.ts, 2, 12))
|
||||
>x : Symbol(x, Decl(declFileObjectLiteralWithOnlyGetter.ts, 1, 24))
|
||||
|
||||
};
|
||||
};
|
||||
var /*4*/point = makePoint(2);
|
||||
>point : Symbol(point, Decl(declFileObjectLiteralWithOnlyGetter.ts, 6, 3))
|
||||
>makePoint : Symbol(makePoint, Decl(declFileObjectLiteralWithOnlyGetter.ts, 0, 0))
|
||||
|
||||
var /*2*/x = point./*3*/x;
|
||||
>x : Symbol(x, Decl(declFileObjectLiteralWithOnlyGetter.ts, 7, 3))
|
||||
>point./*3*/x : Symbol(x, Decl(declFileObjectLiteralWithOnlyGetter.ts, 2, 12))
|
||||
>point : Symbol(point, Decl(declFileObjectLiteralWithOnlyGetter.ts, 6, 3))
|
||||
>x : Symbol(x, Decl(declFileObjectLiteralWithOnlyGetter.ts, 2, 12))
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
=== tests/cases/compiler/declFileObjectLiteralWithOnlyGetter.ts ===
|
||||
|
||||
function /*1*/makePoint(x: number) {
|
||||
>makePoint : (x: number) => { x: number; }
|
||||
>x : number
|
||||
|
||||
return {
|
||||
>{ get x() { return x; }, } : { x: number; }
|
||||
|
||||
get x() { return x; },
|
||||
>x : number
|
||||
>x : number
|
||||
|
||||
};
|
||||
};
|
||||
var /*4*/point = makePoint(2);
|
||||
>point : { x: number; }
|
||||
>makePoint(2) : { x: number; }
|
||||
>makePoint : (x: number) => { x: number; }
|
||||
>2 : number
|
||||
|
||||
var /*2*/x = point./*3*/x;
|
||||
>x : number
|
||||
>point./*3*/x : number
|
||||
>point : { x: number; }
|
||||
>x : number
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
tests/cases/compiler/declFileObjectLiteralWithOnlySetter.ts(5,13): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
|
||||
|
||||
==== tests/cases/compiler/declFileObjectLiteralWithOnlySetter.ts (1 errors) ====
|
||||
|
||||
function /*1*/makePoint(x: number) {
|
||||
return {
|
||||
b: 10,
|
||||
set x(a: number) { this.b = a; }
|
||||
~
|
||||
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
};
|
||||
};
|
||||
var /*3*/point = makePoint(2);
|
||||
point./*2*/x = 30;
|
||||
@@ -0,0 +1,26 @@
|
||||
=== tests/cases/compiler/declFileObjectLiteralWithOnlySetter.ts ===
|
||||
|
||||
function /*1*/makePoint(x: number) {
|
||||
>makePoint : Symbol(makePoint, Decl(declFileObjectLiteralWithOnlySetter.ts, 0, 0))
|
||||
>x : Symbol(x, Decl(declFileObjectLiteralWithOnlySetter.ts, 1, 24))
|
||||
|
||||
return {
|
||||
b: 10,
|
||||
>b : Symbol(b, Decl(declFileObjectLiteralWithOnlySetter.ts, 2, 12))
|
||||
|
||||
set x(a: number) { this.b = a; }
|
||||
>x : Symbol(x, Decl(declFileObjectLiteralWithOnlySetter.ts, 3, 14))
|
||||
>a : Symbol(a, Decl(declFileObjectLiteralWithOnlySetter.ts, 4, 14))
|
||||
>a : Symbol(a, Decl(declFileObjectLiteralWithOnlySetter.ts, 4, 14))
|
||||
|
||||
};
|
||||
};
|
||||
var /*3*/point = makePoint(2);
|
||||
>point : Symbol(point, Decl(declFileObjectLiteralWithOnlySetter.ts, 7, 3))
|
||||
>makePoint : Symbol(makePoint, Decl(declFileObjectLiteralWithOnlySetter.ts, 0, 0))
|
||||
|
||||
point./*2*/x = 30;
|
||||
>point./*2*/x : Symbol(x, Decl(declFileObjectLiteralWithOnlySetter.ts, 3, 14))
|
||||
>point : Symbol(point, Decl(declFileObjectLiteralWithOnlySetter.ts, 7, 3))
|
||||
>x : Symbol(x, Decl(declFileObjectLiteralWithOnlySetter.ts, 3, 14))
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
=== tests/cases/compiler/declFileObjectLiteralWithOnlySetter.ts ===
|
||||
|
||||
function /*1*/makePoint(x: number) {
|
||||
>makePoint : (x: number) => { b: number; x: number; }
|
||||
>x : number
|
||||
|
||||
return {
|
||||
>{ b: 10, set x(a: number) { this.b = a; } } : { b: number; x: number; }
|
||||
|
||||
b: 10,
|
||||
>b : number
|
||||
>10 : number
|
||||
|
||||
set x(a: number) { this.b = a; }
|
||||
>x : number
|
||||
>a : number
|
||||
>this.b = a : number
|
||||
>this.b : any
|
||||
>this : any
|
||||
>b : any
|
||||
>a : number
|
||||
|
||||
};
|
||||
};
|
||||
var /*3*/point = makePoint(2);
|
||||
>point : { b: number; x: number; }
|
||||
>makePoint(2) : { b: number; x: number; }
|
||||
>makePoint : (x: number) => { b: number; x: number; }
|
||||
>2 : number
|
||||
|
||||
point./*2*/x = 30;
|
||||
>point./*2*/x = 30 : number
|
||||
>point./*2*/x : number
|
||||
>point : { b: number; x: number; }
|
||||
>x : number
|
||||
>30 : number
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
tests/cases/compiler/declFilePrivateStatic.ts(9,24): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/compiler/declFilePrivateStatic.ts(10,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/compiler/declFilePrivateStatic.ts(12,24): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/compiler/declFilePrivateStatic.ts(13,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
|
||||
|
||||
==== tests/cases/compiler/declFilePrivateStatic.ts (4 errors) ====
|
||||
|
||||
class C {
|
||||
private static x = 1;
|
||||
static y = 1;
|
||||
|
||||
private static a() { }
|
||||
static b() { }
|
||||
|
||||
private static get c() { return 1; }
|
||||
~
|
||||
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
static get d() { return 1; }
|
||||
~
|
||||
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
|
||||
private static set e(v) { }
|
||||
~
|
||||
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
static set f(v) { }
|
||||
~
|
||||
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
}
|
||||
31
tests/baselines/reference/declFilePrivateStatic.symbols
Normal file
31
tests/baselines/reference/declFilePrivateStatic.symbols
Normal file
@@ -0,0 +1,31 @@
|
||||
=== tests/cases/compiler/declFilePrivateStatic.ts ===
|
||||
|
||||
class C {
|
||||
>C : Symbol(C, Decl(declFilePrivateStatic.ts, 0, 0))
|
||||
|
||||
private static x = 1;
|
||||
>x : Symbol(C.x, Decl(declFilePrivateStatic.ts, 1, 9))
|
||||
|
||||
static y = 1;
|
||||
>y : Symbol(C.y, Decl(declFilePrivateStatic.ts, 2, 25))
|
||||
|
||||
private static a() { }
|
||||
>a : Symbol(C.a, Decl(declFilePrivateStatic.ts, 3, 17))
|
||||
|
||||
static b() { }
|
||||
>b : Symbol(C.b, Decl(declFilePrivateStatic.ts, 5, 26))
|
||||
|
||||
private static get c() { return 1; }
|
||||
>c : Symbol(C.c, Decl(declFilePrivateStatic.ts, 6, 18))
|
||||
|
||||
static get d() { return 1; }
|
||||
>d : Symbol(C.d, Decl(declFilePrivateStatic.ts, 8, 40))
|
||||
|
||||
private static set e(v) { }
|
||||
>e : Symbol(C.e, Decl(declFilePrivateStatic.ts, 9, 32))
|
||||
>v : Symbol(v, Decl(declFilePrivateStatic.ts, 11, 25))
|
||||
|
||||
static set f(v) { }
|
||||
>f : Symbol(C.f, Decl(declFilePrivateStatic.ts, 11, 31))
|
||||
>v : Symbol(v, Decl(declFilePrivateStatic.ts, 12, 17))
|
||||
}
|
||||
35
tests/baselines/reference/declFilePrivateStatic.types
Normal file
35
tests/baselines/reference/declFilePrivateStatic.types
Normal file
@@ -0,0 +1,35 @@
|
||||
=== tests/cases/compiler/declFilePrivateStatic.ts ===
|
||||
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
private static x = 1;
|
||||
>x : number
|
||||
>1 : number
|
||||
|
||||
static y = 1;
|
||||
>y : number
|
||||
>1 : number
|
||||
|
||||
private static a() { }
|
||||
>a : () => void
|
||||
|
||||
static b() { }
|
||||
>b : () => void
|
||||
|
||||
private static get c() { return 1; }
|
||||
>c : number
|
||||
>1 : number
|
||||
|
||||
static get d() { return 1; }
|
||||
>d : number
|
||||
>1 : number
|
||||
|
||||
private static set e(v) { }
|
||||
>e : any
|
||||
>v : any
|
||||
|
||||
static set f(v) { }
|
||||
>f : any
|
||||
>v : any
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
tests/cases/compiler/declFile.d.ts(3,5): error TS1038: A 'declare' modifier cannot be used in an already ambient context.
|
||||
tests/cases/compiler/declFile.d.ts(4,5): error TS1038: A 'declare' modifier cannot be used in an already ambient context.
|
||||
tests/cases/compiler/declFile.d.ts(6,5): error TS1038: A 'declare' modifier cannot be used in an already ambient context.
|
||||
tests/cases/compiler/declFile.d.ts(8,5): error TS1038: A 'declare' modifier cannot be used in an already ambient context.
|
||||
|
||||
|
||||
==== tests/cases/compiler/client.ts (0 errors) ====
|
||||
///<reference path="declFile.d.ts"/>
|
||||
var x = new M.C(); // Declaration file wont get emitted because there are errors in declaration file
|
||||
|
||||
==== tests/cases/compiler/declFile.d.ts (4 errors) ====
|
||||
|
||||
declare module M {
|
||||
declare var x;
|
||||
~~~~~~~
|
||||
!!! error TS1038: A 'declare' modifier cannot be used in an already ambient context.
|
||||
declare function f();
|
||||
~~~~~~~
|
||||
!!! error TS1038: A 'declare' modifier cannot be used in an already ambient context.
|
||||
|
||||
declare module N { }
|
||||
~~~~~~~
|
||||
!!! error TS1038: A 'declare' modifier cannot be used in an already ambient context.
|
||||
|
||||
declare class C { }
|
||||
~~~~~~~
|
||||
!!! error TS1038: A 'declare' modifier cannot be used in an already ambient context.
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
//// [tests/cases/compiler/declFileWithErrorsInInputDeclarationFile.ts] ////
|
||||
|
||||
//// [declFile.d.ts]
|
||||
|
||||
declare module M {
|
||||
declare var x;
|
||||
declare function f();
|
||||
|
||||
declare module N { }
|
||||
|
||||
declare class C { }
|
||||
}
|
||||
|
||||
//// [client.ts]
|
||||
///<reference path="declFile.d.ts"/>
|
||||
var x = new M.C(); // Declaration file wont get emitted because there are errors in declaration file
|
||||
|
||||
|
||||
//// [client.js]
|
||||
///<reference path="declFile.d.ts"/>
|
||||
var x = new M.C(); // Declaration file wont get emitted because there are errors in declaration file
|
||||
|
||||
|
||||
//// [client.d.ts]
|
||||
/// <reference path="declFile.d.ts" />
|
||||
declare var x: M.C;
|
||||
@@ -0,0 +1,29 @@
|
||||
tests/cases/compiler/declFile.d.ts(3,5): error TS1038: A 'declare' modifier cannot be used in an already ambient context.
|
||||
tests/cases/compiler/declFile.d.ts(4,5): error TS1038: A 'declare' modifier cannot be used in an already ambient context.
|
||||
tests/cases/compiler/declFile.d.ts(6,5): error TS1038: A 'declare' modifier cannot be used in an already ambient context.
|
||||
tests/cases/compiler/declFile.d.ts(8,5): error TS1038: A 'declare' modifier cannot be used in an already ambient context.
|
||||
|
||||
|
||||
==== tests/cases/compiler/client.ts (0 errors) ====
|
||||
///<reference path="declFile.d.ts"/>
|
||||
var x = new M.C(); // Declaration file wont get emitted because there are errors in declaration file
|
||||
|
||||
==== tests/cases/compiler/declFile.d.ts (4 errors) ====
|
||||
|
||||
declare module M {
|
||||
declare var x;
|
||||
~~~~~~~
|
||||
!!! error TS1038: A 'declare' modifier cannot be used in an already ambient context.
|
||||
declare function f();
|
||||
~~~~~~~
|
||||
!!! error TS1038: A 'declare' modifier cannot be used in an already ambient context.
|
||||
|
||||
declare module N { }
|
||||
~~~~~~~
|
||||
!!! error TS1038: A 'declare' modifier cannot be used in an already ambient context.
|
||||
|
||||
declare class C { }
|
||||
~~~~~~~
|
||||
!!! error TS1038: A 'declare' modifier cannot be used in an already ambient context.
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
//// [tests/cases/compiler/declFileWithErrorsInInputDeclarationFileWithOut.ts] ////
|
||||
|
||||
//// [declFile.d.ts]
|
||||
|
||||
declare module M {
|
||||
declare var x;
|
||||
declare function f();
|
||||
|
||||
declare module N { }
|
||||
|
||||
declare class C { }
|
||||
}
|
||||
|
||||
//// [client.ts]
|
||||
///<reference path="declFile.d.ts"/>
|
||||
var x = new M.C(); // Declaration file wont get emitted because there are errors in declaration file
|
||||
|
||||
|
||||
//// [out.js]
|
||||
///<reference path="declFile.d.ts"/>
|
||||
var x = new M.C(); // Declaration file wont get emitted because there are errors in declaration file
|
||||
|
||||
|
||||
//// [out.d.ts]
|
||||
/// <reference path="tests/cases/compiler/declFile.d.ts" />
|
||||
declare var x: M.C;
|
||||
@@ -0,0 +1,12 @@
|
||||
error TS5055: Cannot write file 'tests/cases/compiler/a.d.ts' because it would overwrite input file.
|
||||
|
||||
|
||||
!!! error TS5055: Cannot write file 'a.d.ts' because it would overwrite input file.
|
||||
==== tests/cases/compiler/a.d.ts (0 errors) ====
|
||||
|
||||
declare class c {
|
||||
}
|
||||
|
||||
==== tests/cases/compiler/a.ts (0 errors) ====
|
||||
class d {
|
||||
}
|
||||
17
tests/baselines/reference/declarationFileOverwriteError.js
Normal file
17
tests/baselines/reference/declarationFileOverwriteError.js
Normal file
@@ -0,0 +1,17 @@
|
||||
//// [tests/cases/compiler/declarationFileOverwriteError.ts] ////
|
||||
|
||||
//// [a.d.ts]
|
||||
|
||||
declare class c {
|
||||
}
|
||||
|
||||
//// [a.ts]
|
||||
class d {
|
||||
}
|
||||
|
||||
//// [a.js]
|
||||
var d = (function () {
|
||||
function d() {
|
||||
}
|
||||
return d;
|
||||
})();
|
||||
@@ -0,0 +1,12 @@
|
||||
error TS5055: Cannot write file 'tests/cases/compiler/out.d.ts' because it would overwrite input file.
|
||||
|
||||
|
||||
!!! error TS5055: Cannot write file 'out.d.ts' because it would overwrite input file.
|
||||
==== tests/cases/compiler/out.d.ts (0 errors) ====
|
||||
|
||||
declare class c {
|
||||
}
|
||||
|
||||
==== tests/cases/compiler/a.ts (0 errors) ====
|
||||
class d {
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
//// [tests/cases/compiler/declarationFileOverwriteErrorWithOut.ts] ////
|
||||
|
||||
//// [out.d.ts]
|
||||
|
||||
declare class c {
|
||||
}
|
||||
|
||||
//// [a.ts]
|
||||
class d {
|
||||
}
|
||||
|
||||
//// [out.js]
|
||||
var d = (function () {
|
||||
function d() {
|
||||
}
|
||||
return d;
|
||||
})();
|
||||
@@ -88,48 +88,3 @@ var C4 = (function () {
|
||||
};
|
||||
return C4;
|
||||
})();
|
||||
|
||||
|
||||
//// [declarationFiles.d.ts]
|
||||
declare class C1 {
|
||||
x: this;
|
||||
f(x: this): this;
|
||||
constructor(x: this);
|
||||
}
|
||||
declare class C2 {
|
||||
[x: string]: this;
|
||||
}
|
||||
interface Foo<T> {
|
||||
x: T;
|
||||
y: this;
|
||||
}
|
||||
declare class C3 {
|
||||
a: this[];
|
||||
b: [this, this];
|
||||
c: this | Date;
|
||||
d: this & Date;
|
||||
e: (((this)));
|
||||
f: (x: this) => this;
|
||||
g: new (x: this) => this;
|
||||
h: Foo<this>;
|
||||
i: Foo<this | (() => this)>;
|
||||
j: (x: any) => x is this;
|
||||
}
|
||||
declare class C4 {
|
||||
x1: {
|
||||
a: this;
|
||||
};
|
||||
x2: this[];
|
||||
x3: {
|
||||
a: this;
|
||||
}[];
|
||||
x4: () => this;
|
||||
f1(): {
|
||||
a: this;
|
||||
};
|
||||
f2(): this[];
|
||||
f3(): {
|
||||
a: this;
|
||||
}[];
|
||||
f4(): () => this;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,10 @@ declare var decorator: any;
|
||||
class MyComponent {
|
||||
constructor(public Service: Service) {
|
||||
}
|
||||
|
||||
@decorator
|
||||
method(x: this) {
|
||||
}
|
||||
}
|
||||
|
||||
//// [service.js]
|
||||
@@ -37,6 +41,14 @@ var MyComponent = (function () {
|
||||
function MyComponent(Service) {
|
||||
this.Service = Service;
|
||||
}
|
||||
MyComponent.prototype.method = function (x) {
|
||||
};
|
||||
__decorate([
|
||||
decorator,
|
||||
__metadata('design:type', Function),
|
||||
__metadata('design:paramtypes', [Object]),
|
||||
__metadata('design:returntype', void 0)
|
||||
], MyComponent.prototype, "method", null);
|
||||
MyComponent = __decorate([
|
||||
decorator,
|
||||
__metadata('design:paramtypes', [service_1.default])
|
||||
|
||||
@@ -19,4 +19,12 @@ class MyComponent {
|
||||
>Service : Symbol(Service, Decl(component.ts, 6, 16))
|
||||
>Service : Symbol(Service, Decl(component.ts, 0, 6))
|
||||
}
|
||||
|
||||
@decorator
|
||||
>decorator : Symbol(decorator, Decl(component.ts, 2, 11))
|
||||
|
||||
method(x: this) {
|
||||
>method : Symbol(method, Decl(component.ts, 7, 5))
|
||||
>x : Symbol(x, Decl(component.ts, 10, 11))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,4 +19,12 @@ class MyComponent {
|
||||
>Service : Service
|
||||
>Service : Service
|
||||
}
|
||||
|
||||
@decorator
|
||||
>decorator : any
|
||||
|
||||
method(x: this) {
|
||||
>method : (x: this) => void
|
||||
>x : this
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//// [doNotEmitPinnedCommentOnNotEmittedNode.ts]
|
||||
//// [file1.ts]
|
||||
|
||||
class C {
|
||||
/*! remove pinned comment anywhere else */
|
||||
@@ -11,7 +11,7 @@ var x = 10;
|
||||
/*! remove pinned comment anywhere else */
|
||||
declare var OData: any;
|
||||
|
||||
//// [doNotEmitPinnedCommentOnNotEmittedNode.js]
|
||||
//// [file1.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
=== tests/cases/compiler/doNotEmitPinnedCommentOnNotEmittedNode.ts ===
|
||||
=== tests/cases/compiler/file1.ts ===
|
||||
|
||||
class C {
|
||||
>C : Symbol(C, Decl(doNotEmitPinnedCommentOnNotEmittedNode.ts, 0, 0))
|
||||
>C : Symbol(C, Decl(file1.ts, 0, 0))
|
||||
|
||||
/*! remove pinned comment anywhere else */
|
||||
public foo(x: string, y: any)
|
||||
>foo : Symbol(foo, Decl(doNotEmitPinnedCommentOnNotEmittedNode.ts, 1, 9), Decl(doNotEmitPinnedCommentOnNotEmittedNode.ts, 3, 33))
|
||||
>x : Symbol(x, Decl(doNotEmitPinnedCommentOnNotEmittedNode.ts, 3, 15))
|
||||
>y : Symbol(y, Decl(doNotEmitPinnedCommentOnNotEmittedNode.ts, 3, 25))
|
||||
>foo : Symbol(foo, Decl(file1.ts, 1, 9), Decl(file1.ts, 3, 33))
|
||||
>x : Symbol(x, Decl(file1.ts, 3, 15))
|
||||
>y : Symbol(y, Decl(file1.ts, 3, 25))
|
||||
|
||||
public foo(x: string, y: number) { }
|
||||
>foo : Symbol(foo, Decl(doNotEmitPinnedCommentOnNotEmittedNode.ts, 1, 9), Decl(doNotEmitPinnedCommentOnNotEmittedNode.ts, 3, 33))
|
||||
>x : Symbol(x, Decl(doNotEmitPinnedCommentOnNotEmittedNode.ts, 4, 15))
|
||||
>y : Symbol(y, Decl(doNotEmitPinnedCommentOnNotEmittedNode.ts, 4, 25))
|
||||
>foo : Symbol(foo, Decl(file1.ts, 1, 9), Decl(file1.ts, 3, 33))
|
||||
>x : Symbol(x, Decl(file1.ts, 4, 15))
|
||||
>y : Symbol(y, Decl(file1.ts, 4, 25))
|
||||
}
|
||||
|
||||
var x = 10;
|
||||
>x : Symbol(x, Decl(doNotEmitPinnedCommentOnNotEmittedNode.ts, 7, 3))
|
||||
>x : Symbol(x, Decl(file1.ts, 7, 3))
|
||||
|
||||
/*! remove pinned comment anywhere else */
|
||||
declare var OData: any;
|
||||
>OData : Symbol(OData, Decl(doNotEmitPinnedCommentOnNotEmittedNode.ts, 10, 11))
|
||||
>OData : Symbol(OData, Decl(file1.ts, 10, 11))
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
=== tests/cases/compiler/doNotEmitPinnedCommentOnNotEmittedNode.ts ===
|
||||
=== tests/cases/compiler/file1.ts ===
|
||||
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//// [duplicateIdentifierShouldNotShortCircuitBaseTypeBinding.ts]
|
||||
//// [duplicateIdentifierShouldNotShortCircuitBaseTypeBinding_0.ts]
|
||||
|
||||
|
||||
//// [duplicateIdentifierShouldNotShortCircuitBaseTypeBinding.js]
|
||||
//// [duplicateIdentifierShouldNotShortCircuitBaseTypeBinding_0.js]
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
=== tests/cases/compiler/duplicateIdentifierShouldNotShortCircuitBaseTypeBinding.ts ===
|
||||
=== tests/cases/compiler/duplicateIdentifierShouldNotShortCircuitBaseTypeBinding_0.ts ===
|
||||
|
||||
No type information for this code.
|
||||
@@ -1,3 +1,3 @@
|
||||
=== tests/cases/compiler/duplicateIdentifierShouldNotShortCircuitBaseTypeBinding.ts ===
|
||||
=== tests/cases/compiler/duplicateIdentifierShouldNotShortCircuitBaseTypeBinding_0.ts ===
|
||||
|
||||
No type information for this code.
|
||||
@@ -1,4 +1,4 @@
|
||||
//// [es6ExportClause.ts]
|
||||
//// [server.ts]
|
||||
|
||||
class c {
|
||||
}
|
||||
@@ -16,7 +16,7 @@ export { i, m as instantiatedModule };
|
||||
export { uninstantiated };
|
||||
export { x };
|
||||
|
||||
//// [es6ExportClause.js]
|
||||
//// [server.js]
|
||||
class c {
|
||||
}
|
||||
var m;
|
||||
@@ -30,7 +30,7 @@ export { m as instantiatedModule };
|
||||
export { x };
|
||||
|
||||
|
||||
//// [es6ExportClause.d.ts]
|
||||
//// [server.d.ts]
|
||||
declare class c {
|
||||
}
|
||||
interface i {
|
||||
|
||||
@@ -1,38 +1,38 @@
|
||||
=== tests/cases/compiler/es6ExportClause.ts ===
|
||||
=== tests/cases/compiler/server.ts ===
|
||||
|
||||
class c {
|
||||
>c : Symbol(c, Decl(es6ExportClause.ts, 0, 0))
|
||||
>c : Symbol(c, Decl(server.ts, 0, 0))
|
||||
}
|
||||
interface i {
|
||||
>i : Symbol(i, Decl(es6ExportClause.ts, 2, 1))
|
||||
>i : Symbol(i, Decl(server.ts, 2, 1))
|
||||
}
|
||||
module m {
|
||||
>m : Symbol(m, Decl(es6ExportClause.ts, 4, 1))
|
||||
>m : Symbol(m, Decl(server.ts, 4, 1))
|
||||
|
||||
export var x = 10;
|
||||
>x : Symbol(x, Decl(es6ExportClause.ts, 6, 14))
|
||||
>x : Symbol(x, Decl(server.ts, 6, 14))
|
||||
}
|
||||
var x = 10;
|
||||
>x : Symbol(x, Decl(es6ExportClause.ts, 8, 3))
|
||||
>x : Symbol(x, Decl(server.ts, 8, 3))
|
||||
|
||||
module uninstantiated {
|
||||
>uninstantiated : Symbol(uninstantiated, Decl(es6ExportClause.ts, 8, 11))
|
||||
>uninstantiated : Symbol(uninstantiated, Decl(server.ts, 8, 11))
|
||||
}
|
||||
export { c };
|
||||
>c : Symbol(c, Decl(es6ExportClause.ts, 11, 8))
|
||||
>c : Symbol(c, Decl(server.ts, 11, 8))
|
||||
|
||||
export { c as c2 };
|
||||
>c : Symbol(c2, Decl(es6ExportClause.ts, 12, 8))
|
||||
>c2 : Symbol(c2, Decl(es6ExportClause.ts, 12, 8))
|
||||
>c : Symbol(c2, Decl(server.ts, 12, 8))
|
||||
>c2 : Symbol(c2, Decl(server.ts, 12, 8))
|
||||
|
||||
export { i, m as instantiatedModule };
|
||||
>i : Symbol(i, Decl(es6ExportClause.ts, 13, 8))
|
||||
>m : Symbol(instantiatedModule, Decl(es6ExportClause.ts, 13, 11))
|
||||
>instantiatedModule : Symbol(instantiatedModule, Decl(es6ExportClause.ts, 13, 11))
|
||||
>i : Symbol(i, Decl(server.ts, 13, 8))
|
||||
>m : Symbol(instantiatedModule, Decl(server.ts, 13, 11))
|
||||
>instantiatedModule : Symbol(instantiatedModule, Decl(server.ts, 13, 11))
|
||||
|
||||
export { uninstantiated };
|
||||
>uninstantiated : Symbol(uninstantiated, Decl(es6ExportClause.ts, 14, 8))
|
||||
>uninstantiated : Symbol(uninstantiated, Decl(server.ts, 14, 8))
|
||||
|
||||
export { x };
|
||||
>x : Symbol(x, Decl(es6ExportClause.ts, 15, 8))
|
||||
>x : Symbol(x, Decl(server.ts, 15, 8))
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
=== tests/cases/compiler/es6ExportClause.ts ===
|
||||
=== tests/cases/compiler/server.ts ===
|
||||
|
||||
class c {
|
||||
>c : c
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//// [es6ExportClauseInEs5.ts]
|
||||
//// [server.ts]
|
||||
|
||||
class c {
|
||||
}
|
||||
@@ -16,7 +16,7 @@ export { i, m as instantiatedModule };
|
||||
export { uninstantiated };
|
||||
export { x };
|
||||
|
||||
//// [es6ExportClauseInEs5.js]
|
||||
//// [server.js]
|
||||
var c = (function () {
|
||||
function c() {
|
||||
}
|
||||
@@ -33,7 +33,7 @@ var x = 10;
|
||||
exports.x = x;
|
||||
|
||||
|
||||
//// [es6ExportClauseInEs5.d.ts]
|
||||
//// [server.d.ts]
|
||||
declare class c {
|
||||
}
|
||||
interface i {
|
||||
|
||||
@@ -1,38 +1,38 @@
|
||||
=== tests/cases/compiler/es6ExportClauseInEs5.ts ===
|
||||
=== tests/cases/compiler/server.ts ===
|
||||
|
||||
class c {
|
||||
>c : Symbol(c, Decl(es6ExportClauseInEs5.ts, 0, 0))
|
||||
>c : Symbol(c, Decl(server.ts, 0, 0))
|
||||
}
|
||||
interface i {
|
||||
>i : Symbol(i, Decl(es6ExportClauseInEs5.ts, 2, 1))
|
||||
>i : Symbol(i, Decl(server.ts, 2, 1))
|
||||
}
|
||||
module m {
|
||||
>m : Symbol(m, Decl(es6ExportClauseInEs5.ts, 4, 1))
|
||||
>m : Symbol(m, Decl(server.ts, 4, 1))
|
||||
|
||||
export var x = 10;
|
||||
>x : Symbol(x, Decl(es6ExportClauseInEs5.ts, 6, 14))
|
||||
>x : Symbol(x, Decl(server.ts, 6, 14))
|
||||
}
|
||||
var x = 10;
|
||||
>x : Symbol(x, Decl(es6ExportClauseInEs5.ts, 8, 3))
|
||||
>x : Symbol(x, Decl(server.ts, 8, 3))
|
||||
|
||||
module uninstantiated {
|
||||
>uninstantiated : Symbol(uninstantiated, Decl(es6ExportClauseInEs5.ts, 8, 11))
|
||||
>uninstantiated : Symbol(uninstantiated, Decl(server.ts, 8, 11))
|
||||
}
|
||||
export { c };
|
||||
>c : Symbol(c, Decl(es6ExportClauseInEs5.ts, 11, 8))
|
||||
>c : Symbol(c, Decl(server.ts, 11, 8))
|
||||
|
||||
export { c as c2 };
|
||||
>c : Symbol(c2, Decl(es6ExportClauseInEs5.ts, 12, 8))
|
||||
>c2 : Symbol(c2, Decl(es6ExportClauseInEs5.ts, 12, 8))
|
||||
>c : Symbol(c2, Decl(server.ts, 12, 8))
|
||||
>c2 : Symbol(c2, Decl(server.ts, 12, 8))
|
||||
|
||||
export { i, m as instantiatedModule };
|
||||
>i : Symbol(i, Decl(es6ExportClauseInEs5.ts, 13, 8))
|
||||
>m : Symbol(instantiatedModule, Decl(es6ExportClauseInEs5.ts, 13, 11))
|
||||
>instantiatedModule : Symbol(instantiatedModule, Decl(es6ExportClauseInEs5.ts, 13, 11))
|
||||
>i : Symbol(i, Decl(server.ts, 13, 8))
|
||||
>m : Symbol(instantiatedModule, Decl(server.ts, 13, 11))
|
||||
>instantiatedModule : Symbol(instantiatedModule, Decl(server.ts, 13, 11))
|
||||
|
||||
export { uninstantiated };
|
||||
>uninstantiated : Symbol(uninstantiated, Decl(es6ExportClauseInEs5.ts, 14, 8))
|
||||
>uninstantiated : Symbol(uninstantiated, Decl(server.ts, 14, 8))
|
||||
|
||||
export { x };
|
||||
>x : Symbol(x, Decl(es6ExportClauseInEs5.ts, 15, 8))
|
||||
>x : Symbol(x, Decl(server.ts, 15, 8))
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
=== tests/cases/compiler/es6ExportClauseInEs5.ts ===
|
||||
=== tests/cases/compiler/server.ts ===
|
||||
|
||||
class c {
|
||||
>c : c
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
tests/cases/conformance/externalModules/exportAssignmentAndDeclaration.ts(10,1): error TS2309: An export assignment cannot be used in a module with other exported elements.
|
||||
tests/cases/conformance/externalModules/foo_0.ts(10,1): error TS2309: An export assignment cannot be used in a module with other exported elements.
|
||||
|
||||
|
||||
==== tests/cases/conformance/externalModules/exportAssignmentAndDeclaration.ts (1 errors) ====
|
||||
==== tests/cases/conformance/externalModules/foo_0.ts (1 errors) ====
|
||||
export enum E1 {
|
||||
A,B,C
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//// [exportAssignmentAndDeclaration.ts]
|
||||
//// [foo_0.ts]
|
||||
export enum E1 {
|
||||
A,B,C
|
||||
}
|
||||
@@ -10,7 +10,7 @@ class C1 {
|
||||
// Invalid, as there is already an exported member.
|
||||
export = C1;
|
||||
|
||||
//// [exportAssignmentAndDeclaration.js]
|
||||
//// [foo_0.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
(function (E1) {
|
||||
E1[E1["A"] = 0] = "A";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//// [exportAssignmentError.ts]
|
||||
//// [exportEqualsModule_A.ts]
|
||||
module M {
|
||||
export var x;
|
||||
}
|
||||
@@ -8,7 +8,7 @@ import M2 = M;
|
||||
export = M2; // should not error
|
||||
|
||||
|
||||
//// [exportAssignmentError.js]
|
||||
//// [exportEqualsModule_A.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
var M;
|
||||
(function (M) {
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
=== tests/cases/compiler/exportAssignmentError.ts ===
|
||||
=== tests/cases/compiler/exportEqualsModule_A.ts ===
|
||||
module M {
|
||||
>M : Symbol(M, Decl(exportAssignmentError.ts, 0, 0))
|
||||
>M : Symbol(M, Decl(exportEqualsModule_A.ts, 0, 0))
|
||||
|
||||
export var x;
|
||||
>x : Symbol(x, Decl(exportAssignmentError.ts, 1, 11))
|
||||
>x : Symbol(x, Decl(exportEqualsModule_A.ts, 1, 11))
|
||||
}
|
||||
|
||||
import M2 = M;
|
||||
>M2 : Symbol(M2, Decl(exportAssignmentError.ts, 2, 1))
|
||||
>M : Symbol(M, Decl(exportAssignmentError.ts, 0, 0))
|
||||
>M2 : Symbol(M2, Decl(exportEqualsModule_A.ts, 2, 1))
|
||||
>M : Symbol(M, Decl(exportEqualsModule_A.ts, 0, 0))
|
||||
|
||||
export = M2; // should not error
|
||||
>M2 : Symbol(M2, Decl(exportAssignmentError.ts, 2, 1))
|
||||
>M2 : Symbol(M2, Decl(exportEqualsModule_A.ts, 2, 1))
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
=== tests/cases/compiler/exportAssignmentError.ts ===
|
||||
=== tests/cases/compiler/exportEqualsModule_A.ts ===
|
||||
module M {
|
||||
>M : typeof M
|
||||
|
||||
|
||||
34
tests/baselines/reference/fileReferencesWithNoExtensions.js
Normal file
34
tests/baselines/reference/fileReferencesWithNoExtensions.js
Normal file
@@ -0,0 +1,34 @@
|
||||
//// [tests/cases/compiler/fileReferencesWithNoExtensions.ts] ////
|
||||
|
||||
//// [t.ts]
|
||||
/// <reference path="a"/>
|
||||
/// <reference path="b"/>
|
||||
/// <reference path="c"/>
|
||||
var a = aa; // Check that a.ts is referenced
|
||||
var b = bb; // Check that b.d.ts is referenced
|
||||
var c = cc; // Check that c.ts has precedence over c.d.ts
|
||||
|
||||
//// [a.ts]
|
||||
var aa = 1;
|
||||
|
||||
//// [b.d.ts]
|
||||
declare var bb: number;
|
||||
|
||||
//// [c.ts]
|
||||
var cc = 1;
|
||||
|
||||
//// [c.d.ts]
|
||||
declare var xx: number;
|
||||
|
||||
|
||||
//// [a.js]
|
||||
var aa = 1;
|
||||
//// [c.js]
|
||||
var cc = 1;
|
||||
//// [t.js]
|
||||
/// <reference path="a"/>
|
||||
/// <reference path="b"/>
|
||||
/// <reference path="c"/>
|
||||
var a = aa; // Check that a.ts is referenced
|
||||
var b = bb; // Check that b.d.ts is referenced
|
||||
var c = cc; // Check that c.ts has precedence over c.d.ts
|
||||
@@ -0,0 +1,12 @@
|
||||
error TS5056: Cannot write file 'tests/cases/compiler/a.js' because it would be overwritten by multiple input files.
|
||||
|
||||
|
||||
!!! error TS5056: Cannot write file 'tests/cases/compiler/a.js' because it would be overwritten by multiple input files.
|
||||
==== tests/cases/compiler/a.ts (0 errors) ====
|
||||
class c {
|
||||
}
|
||||
|
||||
==== tests/cases/compiler/a.tsx (0 errors) ====
|
||||
function foo() {
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
//// [tests/cases/compiler/filesEmittingIntoSameOutputWithOutOption.ts] ////
|
||||
|
||||
//// [a.ts]
|
||||
export class c {
|
||||
}
|
||||
|
||||
//// [b.ts]
|
||||
function foo() {
|
||||
}
|
||||
|
||||
|
||||
//// [a.js]
|
||||
define("tests/cases/compiler/a", ["require", "exports"], function (require, exports) {
|
||||
var c = (function () {
|
||||
function c() {
|
||||
}
|
||||
return c;
|
||||
})();
|
||||
exports.c = c;
|
||||
});
|
||||
function foo() {
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
=== tests/cases/compiler/a.ts ===
|
||||
export class c {
|
||||
>c : Symbol(c, Decl(a.ts, 0, 0))
|
||||
}
|
||||
|
||||
=== tests/cases/compiler/b.ts ===
|
||||
function foo() {
|
||||
>foo : Symbol(foo, Decl(b.ts, 0, 0))
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
=== tests/cases/compiler/a.ts ===
|
||||
export class c {
|
||||
>c : c
|
||||
}
|
||||
|
||||
=== tests/cases/compiler/b.ts ===
|
||||
function foo() {
|
||||
>foo : () => void
|
||||
}
|
||||
|
||||
@@ -1,8 +1,30 @@
|
||||
EmitSkipped: false
|
||||
FileName : tests/cases/fourslash/inputFile3.js
|
||||
exports.foo = 10;
|
||||
exports.bar = "hello world";
|
||||
FileName : tests/cases/fourslash/inputFile3.d.ts
|
||||
export declare var foo: number;
|
||||
export declare var bar: string;
|
||||
FileName : declSingleFile.js
|
||||
var x = 5;
|
||||
var Bar = (function () {
|
||||
function Bar() {
|
||||
}
|
||||
return Bar;
|
||||
})();
|
||||
var x1 = "hello world";
|
||||
var Foo = (function () {
|
||||
function Foo() {
|
||||
}
|
||||
return Foo;
|
||||
})();
|
||||
FileName : declSingleFile.d.ts
|
||||
declare var x: number;
|
||||
declare class Bar {
|
||||
x: string;
|
||||
y: number;
|
||||
}
|
||||
declare var x1: string;
|
||||
declare class Foo {
|
||||
x: string;
|
||||
y: number;
|
||||
}
|
||||
declare module "tests/cases/fourslash/inputFile3" {
|
||||
export var foo: number;
|
||||
export var bar: string;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,10 +17,11 @@ declare class Bar {
|
||||
|
||||
EmitSkipped: false
|
||||
FileName : tests/cases/fourslash/inputFile2.js.map
|
||||
{"version":3,"file":"inputFile2.js","sourceRoot":"","sources":["inputFile2.tsx"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,QAAQ,CAAC;AACjB,IAAI,CAAC,GAAG,qBAAC,GAAG,IAAC,IAAI,EAAG,CAAE,EAAG,CAAA"}FileName : tests/cases/fourslash/inputFile2.js
|
||||
{"version":3,"file":"inputFile2.js","sourceRoot":"","sources":["inputFile2.tsx"],"names":[],"mappings":"AACA,IAAI,CAAC,GAAG,QAAQ,CAAC;AACjB,IAAI,CAAC,GAAG,qBAAC,GAAG,IAAC,IAAI,EAAG,CAAE,EAAG,CAAA"}FileName : tests/cases/fourslash/inputFile2.js
|
||||
var y = "my div";
|
||||
var x = React.createElement("div", {name: y});
|
||||
//# sourceMappingURL=inputFile2.js.mapFileName : tests/cases/fourslash/inputFile2.d.ts
|
||||
declare var React: any;
|
||||
declare var y: string;
|
||||
declare var x: any;
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
EmitSkipped: false
|
||||
EmitSkipped: true
|
||||
Diagnostics:
|
||||
Exported variable 'foo' has or is using private name 'C'.
|
||||
FileName : tests/cases/fourslash/inputFile.js
|
||||
var M;
|
||||
(function (M) {
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
EmitSkipped: false
|
||||
EmitSkipped: true
|
||||
Diagnostics:
|
||||
Exported variable 'foo' has or is using private name 'C'.
|
||||
FileName : tests/cases/fourslash/inputFile.js
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
var C = (function () {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
tests/cases/conformance/externalModules/importNonStringLiteral.ts(2,22): error TS1141: String literal expected.
|
||||
tests/cases/conformance/externalModules/vs/foo_0.ts(2,22): error TS1141: String literal expected.
|
||||
|
||||
|
||||
==== tests/cases/conformance/externalModules/importNonStringLiteral.ts (1 errors) ====
|
||||
==== tests/cases/conformance/externalModules/vs/foo_0.ts (1 errors) ====
|
||||
var x = "filename";
|
||||
import foo = require(x); // invalid
|
||||
~
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//// [importNonStringLiteral.ts]
|
||||
//// [foo_0.ts]
|
||||
var x = "filename";
|
||||
import foo = require(x); // invalid
|
||||
|
||||
|
||||
//// [importNonStringLiteral.js]
|
||||
//// [foo_0.js]
|
||||
var x = "filename";
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
tests/cases/conformance/externalModules/initializersInDeclarations.ts(5,9): error TS1039: Initializers are not allowed in ambient contexts.
|
||||
tests/cases/conformance/externalModules/initializersInDeclarations.ts(6,16): error TS1039: Initializers are not allowed in ambient contexts.
|
||||
tests/cases/conformance/externalModules/initializersInDeclarations.ts(7,16): error TS1183: An implementation cannot be declared in ambient contexts.
|
||||
tests/cases/conformance/externalModules/initializersInDeclarations.ts(12,15): error TS1039: Initializers are not allowed in ambient contexts.
|
||||
tests/cases/conformance/externalModules/initializersInDeclarations.ts(13,15): error TS1039: Initializers are not allowed in ambient contexts.
|
||||
tests/cases/conformance/externalModules/initializersInDeclarations.ts(16,2): error TS1036: Statements are not allowed in ambient contexts.
|
||||
tests/cases/conformance/externalModules/initializersInDeclarations.ts(18,16): error TS1039: Initializers are not allowed in ambient contexts.
|
||||
tests/cases/conformance/externalModules/file1.d.ts(5,9): error TS1039: Initializers are not allowed in ambient contexts.
|
||||
tests/cases/conformance/externalModules/file1.d.ts(6,16): error TS1039: Initializers are not allowed in ambient contexts.
|
||||
tests/cases/conformance/externalModules/file1.d.ts(7,16): error TS1183: An implementation cannot be declared in ambient contexts.
|
||||
tests/cases/conformance/externalModules/file1.d.ts(12,15): error TS1039: Initializers are not allowed in ambient contexts.
|
||||
tests/cases/conformance/externalModules/file1.d.ts(13,15): error TS1039: Initializers are not allowed in ambient contexts.
|
||||
tests/cases/conformance/externalModules/file1.d.ts(16,2): error TS1036: Statements are not allowed in ambient contexts.
|
||||
tests/cases/conformance/externalModules/file1.d.ts(18,16): error TS1039: Initializers are not allowed in ambient contexts.
|
||||
|
||||
|
||||
==== tests/cases/conformance/externalModules/initializersInDeclarations.ts (7 errors) ====
|
||||
==== tests/cases/conformance/externalModules/file1.d.ts (7 errors) ====
|
||||
|
||||
// Errors: Initializers & statements in declaration file
|
||||
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
//// [initializersInDeclarations.ts]
|
||||
|
||||
// Errors: Initializers & statements in declaration file
|
||||
|
||||
declare class Foo {
|
||||
name = "test";
|
||||
"some prop" = 42;
|
||||
fn(): boolean {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
declare var x = [];
|
||||
declare var y = {};
|
||||
|
||||
declare module M1 {
|
||||
while(true);
|
||||
|
||||
export var v1 = () => false;
|
||||
}
|
||||
|
||||
//// [initializersInDeclarations.js]
|
||||
// Errors: Initializers & statements in declaration file
|
||||
@@ -1,6 +1,6 @@
|
||||
===================================================================
|
||||
JsFile: inlineSourceMap.js
|
||||
mapUrl: inlineSourceMap.js.map
|
||||
mapUrl: data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5saW5lU291cmNlTWFwLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiaW5saW5lU291cmNlTWFwLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLElBQUksQ0FBQyxHQUFHLENBQUMsQ0FBQztBQUNWLE9BQU8sQ0FBQyxHQUFHLENBQUMsQ0FBQyxDQUFDLENBQUMifQ==
|
||||
sourceRoot:
|
||||
sources: inlineSourceMap.ts
|
||||
===================================================================
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
===================================================================
|
||||
JsFile: outfile.js
|
||||
mapUrl: file:///folder/outfile.js.map
|
||||
mapUrl: data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib3V0ZmlsZS5qcyIsInNvdXJjZVJvb3QiOiJmaWxlOi8vL2ZvbGRlci8iLCJzb3VyY2VzIjpbImlubGluZVNvdXJjZU1hcDIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsdUJBQXVCO0FBRXZCLElBQUksQ0FBQyxHQUFHLENBQUMsQ0FBQztBQUNWLE9BQU8sQ0FBQyxHQUFHLENBQUMsQ0FBQyxDQUFDLENBQUMifQ==
|
||||
sourceRoot: file:///folder/
|
||||
sources: inlineSourceMap2.ts
|
||||
===================================================================
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
===================================================================
|
||||
JsFile: out.js
|
||||
mapUrl: out.js.map
|
||||
mapUrl: data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib3V0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsidGVzdHMvY2FzZXMvY29tcGlsZXIvYS50cyIsInRlc3RzL2Nhc2VzL2NvbXBpbGVyL2IudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsSUFBSSxDQUFDLEdBQUcsQ0FBQyxDQUFDO0FBQ1YsT0FBTyxDQUFDLEdBQUcsQ0FBQyxDQUFDLENBQUMsQ0FBQztBQ0ZmLElBQUksQ0FBQyxHQUFHLENBQUMsQ0FBQztBQUNWLE9BQU8sQ0FBQyxHQUFHLENBQUMsQ0FBQyxDQUFDLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyJcbnZhciBhID0gMDtcbmNvbnNvbGUubG9nKGEpO1xuIiwidmFyIGIgPSAwO1xuY29uc29sZS5sb2coYik7Il19
|
||||
sourceRoot:
|
||||
sources: tests/cases/compiler/a.ts,tests/cases/compiler/b.ts
|
||||
sourcesContent: ["\nvar a = 0;\nconsole.log(a);\n","var b = 0;\nconsole.log(b);"]
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
tests/cases/compiler/isolatedModulesAmbientConstEnum.ts(3,20): error TS1209: Ambient const enums are not allowed when the '--isolatedModules' flag is provided.
|
||||
tests/cases/compiler/file1.ts(3,20): error TS1209: Ambient const enums are not allowed when the '--isolatedModules' flag is provided.
|
||||
|
||||
|
||||
==== tests/cases/compiler/isolatedModulesAmbientConstEnum.ts (1 errors) ====
|
||||
==== tests/cases/compiler/file1.ts (1 errors) ====
|
||||
|
||||
|
||||
declare const enum E { X = 1}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
//// [isolatedModulesAmbientConstEnum.ts]
|
||||
//// [file1.ts]
|
||||
|
||||
|
||||
declare const enum E { X = 1}
|
||||
export var y;
|
||||
|
||||
//// [isolatedModulesAmbientConstEnum.js]
|
||||
//// [file1.js]
|
||||
export var y;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user