Refactor declaration emitter into declaration transformer (#21930)

* Refactor declaration emitter into declaration transformer

* Slight cleanup from code review feedback

* Incorporate fix for new test

* Swaths of PR feedback

* Merge public methods

* Per-file output

* Preserve input import ordering more often

* Unify jsdoc comment start detection under more lenient rule

* Move to per-file transformations to reduce the memory that msut be retained

* Fix typo
This commit is contained in:
Wesley Wigham authored and GitHub committed 2018-03-15 22:23:10 -07:00
1 parent 162a273e43
commit 19ec83fcdf
124 files changed
+2656 -2729

No files matched your search

+32 -19
View File
@@ -3684,10 +3684,6 @@ namespace ts {
isExternalModuleAugmentation(node.parent.parent);
}
function literalTypeToString(type: LiteralType) {
return type.flags & TypeFlags.StringLiteral ? '"' + escapeString((<StringLiteralType>type).value) + '"' : "" + (<NumberLiteralType>type).value;
}
interface NodeBuilderContext {
enclosingDeclaration: Node | undefined;
flags: NodeBuilderFlags | undefined;
@@ -3748,7 +3744,7 @@ namespace ts {
return symbolName(symbol);
}
function isDeclarationVisible(node: Declaration): boolean {
function isDeclarationVisible(node: Declaration | AnyImportSyntax): boolean {
if (node) {
const links = getNodeLinks(node);
if (links.isVisible === undefined) {
@@ -25497,6 +25493,7 @@ namespace ts {
function isImplementationOfOverload(node: SignatureDeclaration) {
if (nodeIsPresent((node as FunctionLikeDeclaration).body)) {
if (isGetAccessor(node) || isSetAccessor(node)) return false; // Get or set accessors can never be overload implementations, but can have up to 2 signatures
const symbol = getSymbolOfNode(node);
const signaturesOfSymbol = getSignaturesOfSymbol(symbol);
// If this function body corresponds to function with multiple signature, it is implementation of overload
@@ -25636,7 +25633,11 @@ namespace ts {
}
}
function writeTypeOfDeclaration(declaration: AccessorDeclaration | VariableLikeDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: EmitTextWriter) {
function createTypeOfDeclaration(declaration: AccessorDeclaration | VariableLikeDeclaration, enclosingDeclaration: Node, flags: NodeBuilderFlags, tracker: SymbolTracker, addUndefined?: boolean) {
declaration = getParseTreeNode(declaration, isVariableLikeOrAccessor);
if (!declaration) {
return createToken(SyntaxKind.AnyKeyword) as KeywordTypeNode;
}
// Get type of the symbol if this is the valid symbol otherwise get type at location
const symbol = getSymbolOfNode(declaration);
let type = symbol && !(symbol.flags & (SymbolFlags.TypeLiteral | SymbolFlags.Signature))
@@ -25644,22 +25645,30 @@ namespace ts {
: unknownType;
if (type.flags & TypeFlags.UniqueESSymbol &&
type.symbol === symbol) {
flags |= TypeFormatFlags.AllowUniqueESSymbolType;
flags |= NodeBuilderFlags.AllowUniqueESSymbolType;
}
if (flags & TypeFormatFlags.AddUndefined) {
if (addUndefined) {
type = getOptionalType(type);
}
typeToString(type, enclosingDeclaration, flags | TypeFormatFlags.MultilineObjectLiterals, writer);
return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | NodeBuilderFlags.MultilineObjectLiterals, tracker);
}
function writeReturnTypeOfSignatureDeclaration(signatureDeclaration: SignatureDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: EmitTextWriter) {
function createReturnTypeOfSignatureDeclaration(signatureDeclaration: SignatureDeclaration, enclosingDeclaration: Node, flags: NodeBuilderFlags, tracker: SymbolTracker) {
signatureDeclaration = getParseTreeNode(signatureDeclaration, isFunctionLike);
if (!signatureDeclaration) {
return createToken(SyntaxKind.AnyKeyword) as KeywordTypeNode;
}
const signature = getSignatureFromDeclaration(signatureDeclaration);
typeToString(getReturnTypeOfSignature(signature), enclosingDeclaration, flags | TypeFormatFlags.MultilineObjectLiterals, writer);
return nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosingDeclaration, flags | NodeBuilderFlags.MultilineObjectLiterals, tracker);
}
function writeTypeOfExpression(expr: Expression, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: EmitTextWriter) {
function createTypeOfExpression(expr: Expression, enclosingDeclaration: Node, flags: NodeBuilderFlags, tracker: SymbolTracker) {
expr = getParseTreeNode(expr, isExpression);
if (!expr) {
return createToken(SyntaxKind.AnyKeyword) as KeywordTypeNode;
}
const type = getWidenedType(getRegularTypeOfExpression(expr));
typeToString(type, enclosingDeclaration, flags | TypeFormatFlags.MultilineObjectLiterals, writer);
return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | NodeBuilderFlags.MultilineObjectLiterals, tracker);
}
function hasGlobalName(name: string): boolean {
@@ -25707,9 +25716,13 @@ namespace ts {
return false;
}
function writeLiteralConstValue(node: VariableDeclaration | PropertyDeclaration | PropertySignature | ParameterDeclaration, writer: EmitTextWriter) {
function literalTypeToNode(type: LiteralType): Expression {
return createLiteral(type.value);
}
function createLiteralConstValue(node: VariableDeclaration | PropertyDeclaration | PropertySignature | ParameterDeclaration) {
const type = getTypeOfSymbol(getSymbolOfNode(node));
writer.writeStringLiteral(literalTypeToString(<LiteralType>type));
return literalTypeToNode(<LiteralType>type);
}
function createResolver(): EmitResolver {
@@ -25753,9 +25766,10 @@ namespace ts {
isImplementationOfOverload,
isRequiredInitializedParameter,
isOptionalUninitializedParameterProperty,
writeTypeOfDeclaration,
writeReturnTypeOfSignatureDeclaration,
writeTypeOfExpression,
createTypeOfDeclaration,
createReturnTypeOfSignatureDeclaration,
createTypeOfExpression,
createLiteralConstValue,
isSymbolAccessible,
isEntityNameVisible,
getConstantValue: node => {
@@ -25777,7 +25791,6 @@ namespace ts {
const symbol = node && getSymbolOfNode(node);
return !!(symbol && getCheckFlags(symbol) & CheckFlags.Late);
},
writeLiteralConstValue,
getJsxFactoryEntity: location => location ? (getJsxNamespace(location), (getSourceFileOfNode(location).localJsxFactory || _jsxFactoryEntity)) : _jsxFactoryEntity
};
+10
View File
@@ -260,7 +260,15 @@ namespace ts {
}
}
function shouldWriteComment(text: string, pos: number) {
if (printerOptions.onlyPrintJsDocStyle) {
return (isJSDocLikeText(text, pos) || isPinnedComment(text, pos));
}
return true;
}
function emitLeadingComment(commentPos: number, commentEnd: number, kind: SyntaxKind, hasTrailingNewLine: boolean, rangePos: number) {
if (!shouldWriteComment(currentText, commentPos)) return;
if (!hasWrittenComment) {
emitNewLineBeforeLeadingCommentOfPosition(currentLineMap, writer, rangePos, commentPos);
hasWrittenComment = true;
@@ -292,6 +300,7 @@ namespace ts {
}
function emitTrailingComment(commentPos: number, commentEnd: number, _kind: SyntaxKind, hasTrailingNewLine: boolean) {
if (!shouldWriteComment(currentText, commentPos)) return;
// trailing comments are emitted at space/*trailing comment1 */space/*trailing comment2*/
if (!writer.isAtStartOfLine()) {
writer.write(" ");
@@ -404,6 +413,7 @@ namespace ts {
}
function writeComment(text: string, lineMap: number[], writer: EmitTextWriter, commentPos: number, commentEnd: number, newLine: string) {
if (!shouldWriteComment(currentText, commentPos)) return;
if (emitPos) emitPos(commentPos);
writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine);
if (emitPos) emitPos(commentEnd);
File diff suppressed because it is too large. Load diff
+135 -80
View File
@@ -1,6 +1,5 @@
/// <reference path="checker.ts" />
/// <reference path="transformer.ts" />
/// <reference path="declarationEmitter.ts" />
/// <reference path="sourcemap.ts" />
/// <reference path="comments.ts" />
@@ -18,18 +17,16 @@ namespace ts {
* Else, calls `getSourceFilesToEmit` with the (optional) target source file to determine the list of source files to emit.
*/
export function forEachEmittedFile<T>(
host: EmitHost, action: (emitFileNames: EmitFileNames, sourceFileOrBundle: SourceFile | Bundle, emitOnlyDtsFiles: boolean) => T,
sourceFilesOrTargetSourceFile?: SourceFile[] | SourceFile,
host: EmitHost, action: (emitFileNames: EmitFileNames, sourceFileOrBundle: SourceFile | Bundle) => T,
sourceFilesOrTargetSourceFile?: ReadonlyArray<SourceFile> | SourceFile,
emitOnlyDtsFiles?: boolean) {
const sourceFiles = isArray(sourceFilesOrTargetSourceFile) ? sourceFilesOrTargetSourceFile : getSourceFilesToEmit(host, sourceFilesOrTargetSourceFile);
const options = host.getCompilerOptions();
if (options.outFile || options.out) {
if (sourceFiles.length) {
const jsFilePath = options.outFile || options.out;
const sourceMapFilePath = getSourceMapFilePath(jsFilePath, options);
const declarationFilePath = options.declaration ? removeFileExtension(jsFilePath) + Extension.Dts : "";
const result = action({ jsFilePath, sourceMapFilePath, declarationFilePath }, createBundle(sourceFiles), emitOnlyDtsFiles);
const bundle = createBundle(sourceFiles);
const result = action(getOutputPathsFor(bundle, host, emitOnlyDtsFiles), bundle);
if (result) {
return result;
}
@@ -37,10 +34,7 @@ namespace ts {
}
else {
for (const sourceFile of sourceFiles) {
const jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, getOutputExtension(sourceFile, options));
const sourceMapFilePath = getSourceMapFilePath(jsFilePath, options);
const declarationFilePath = !isSourceFileJavaScript(sourceFile) && (emitOnlyDtsFiles || options.declaration) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined;
const result = action({ jsFilePath, sourceMapFilePath, declarationFilePath }, sourceFile, emitOnlyDtsFiles);
const result = action(getOutputPathsFor(sourceFile, host, emitOnlyDtsFiles), sourceFile);
if (result) {
return result;
}
@@ -48,6 +42,25 @@ namespace ts {
}
}
/*@internal*/
export function getOutputPathsFor(sourceFile: SourceFile | Bundle, host: EmitHost, forceDtsPaths: boolean) {
const options = host.getCompilerOptions();
if (sourceFile.kind === SyntaxKind.Bundle) {
const jsFilePath = options.outFile || options.out;
const sourceMapFilePath = getSourceMapFilePath(jsFilePath, options);
const declarationFilePath = (forceDtsPaths || options.declaration) ? removeFileExtension(jsFilePath) + Extension.Dts : undefined;
return { jsFilePath, sourceMapFilePath, declarationFilePath };
}
else {
const jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, getOutputExtension(sourceFile, options));
const sourceMapFilePath = getSourceMapFilePath(jsFilePath, options);
// For legacy reasons (ie, we have baselines capturing the behavior), js files don't report a .d.ts output path - this would only matter if `declaration` and `allowJs` were both on, which is currently an error
const isJs = isSourceFileJavaScript(sourceFile);
const declarationFilePath = ((forceDtsPaths || options.declaration) && !isJs) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined;
return { jsFilePath, sourceMapFilePath, declarationFilePath };
}
}
function getSourceMapFilePath(jsFilePath: string, options: CompilerOptions) {
return options.sourceMap ? jsFilePath + ".map" : undefined;
}
@@ -70,13 +83,6 @@ namespace ts {
return Extension.Js;
}
function getOriginalSourceFileOrBundle(sourceFileOrBundle: SourceFile | Bundle) {
if (sourceFileOrBundle.kind === SyntaxKind.Bundle) {
return updateBundle(sourceFileOrBundle, sameMap(sourceFileOrBundle.sourceFiles, getOriginalSourceFile));
}
return getOriginalSourceFile(sourceFileOrBundle);
}
/*@internal*/
// targetSourceFile is when users only want one file in entire project to be emitted. This is used in compileOnSave feature
export function emitFiles(resolver: EmitResolver, host: EmitHost, targetSourceFile: SourceFile, emitOnlyDtsFiles?: boolean, transformers?: TransformerFactory<SourceFile>[]): EmitResult {
@@ -94,37 +100,11 @@ namespace ts {
let isOwnFileEmit: boolean;
let emitSkipped = false;
const sourceFiles = getSourceFilesToEmit(host, targetSourceFile);
// Transform the source files
const transform = transformNodes(resolver, host, compilerOptions, sourceFiles, transformers, /*allowDtsFiles*/ false);
// Create a printer to print the nodes
const printer = createPrinter(compilerOptions, {
// resolver hooks
hasGlobalName: resolver.hasGlobalName,
// transform hooks
onEmitNode: transform.emitNodeWithNotification,
substituteNode: transform.substituteNode,
// sourcemap hooks
onEmitSourceMapOfNode: sourceMap.emitNodeWithSourceMap,
onEmitSourceMapOfToken: sourceMap.emitTokenWithSourceMap,
onEmitSourceMapOfPosition: sourceMap.emitPos,
// emitter hooks
onEmitHelpers: emitHelpers,
onSetSourceFile: setSourceFile,
});
// Emit each output file
performance.mark("beforePrint");
forEachEmittedFile(host, emitSourceFileOrBundle, transform.transformed, emitOnlyDtsFiles);
forEachEmittedFile(host, emitSourceFileOrBundle, getSourceFilesToEmit(host, targetSourceFile), emitOnlyDtsFiles);
performance.measure("printTime", "beforePrint");
// Clean up emit nodes on parse tree
transform.dispose();
return {
emitSkipped,
@@ -134,19 +114,8 @@ namespace ts {
};
function emitSourceFileOrBundle({ jsFilePath, sourceMapFilePath, declarationFilePath }: EmitFileNames, sourceFileOrBundle: SourceFile | Bundle) {
// Make sure not to write js file and source map file if any of them cannot be written
if (!host.isEmitBlocked(jsFilePath) && !compilerOptions.noEmit && !compilerOptions.emitDeclarationOnly) {
if (!emitOnlyDtsFiles) {
printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle);
}
}
else {
emitSkipped = true;
}
if (declarationFilePath) {
emitSkipped = writeDeclarationFile(declarationFilePath, getOriginalSourceFileOrBundle(sourceFileOrBundle), host, resolver, emitterDiagnostics, emitOnlyDtsFiles) || emitSkipped;
}
emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath);
emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath);
if (!emitSkipped && emittedFilesList) {
if (!emitOnlyDtsFiles) {
@@ -161,7 +130,77 @@ namespace ts {
}
}
function printSourceFileOrBundle(jsFilePath: string, sourceMapFilePath: string, sourceFileOrBundle: SourceFile | Bundle) {
function emitJsFileOrBundle(sourceFileOrBundle: SourceFile | Bundle, jsFilePath: string, sourceMapFilePath: string) {
const sourceFiles = isSourceFile(sourceFileOrBundle) ? [sourceFileOrBundle] : sourceFileOrBundle.sourceFiles;
// Make sure not to write js file and source map file if any of them cannot be written
if (host.isEmitBlocked(jsFilePath) || compilerOptions.noEmit || compilerOptions.emitDeclarationOnly) {
emitSkipped = true;
return;
}
if (emitOnlyDtsFiles) {
return;
}
// Transform the source files
const transform = transformNodes(resolver, host, compilerOptions, sourceFiles, transformers, /*allowDtsFiles*/ false);
// Create a printer to print the nodes
const printer = createPrinter(compilerOptions, {
// resolver hooks
hasGlobalName: resolver.hasGlobalName,
// transform hooks
onEmitNode: transform.emitNodeWithNotification,
substituteNode: transform.substituteNode,
// sourcemap hooks
onEmitSourceMapOfNode: sourceMap.emitNodeWithSourceMap,
onEmitSourceMapOfToken: sourceMap.emitTokenWithSourceMap,
onEmitSourceMapOfPosition: sourceMap.emitPos,
// emitter hooks
onEmitHelpers: emitHelpers,
onSetSourceFile: setSourceFile,
});
printSourceFileOrBundle(jsFilePath, sourceMapFilePath, isSourceFile(sourceFileOrBundle) ? transform.transformed[0] : createBundle(transform.transformed), printer);
// Clean up emit nodes on parse tree
transform.dispose();
}
function emitDeclarationFileOrBundle(sourceFileOrBundle: SourceFile | Bundle, declarationFilePath: string | undefined) {
if (!(declarationFilePath && !isInJavaScriptFile(sourceFileOrBundle))) {
return;
}
const sourceFiles = isSourceFile(sourceFileOrBundle) ? [sourceFileOrBundle] : sourceFileOrBundle.sourceFiles;
// Setup and perform the transformation to retrieve declarations from the input files
const nonJsFiles = filter(sourceFiles, isSourceFileNotJavaScript);
const inputListOrBundle = (compilerOptions.outFile || compilerOptions.out) ? [createBundle(nonJsFiles)] : nonJsFiles;
const declarationTransform = transformNodes(resolver, host, compilerOptions, inputListOrBundle, [transformDeclarations], /*allowDtsFiles*/ false);
if (length(declarationTransform.diagnostics)) {
for (const diagnostic of declarationTransform.diagnostics) {
emitterDiagnostics.add(diagnostic);
}
}
const declarationPrinter = createPrinter({ ...compilerOptions, onlyPrintJsDocStyle: true } as PrinterOptions, {
// resolver hooks
hasGlobalName: resolver.hasGlobalName,
// transform hooks
onEmitNode: declarationTransform.emitNodeWithNotification,
substituteNode: declarationTransform.substituteNode,
});
const declBlocked = (!!declarationTransform.diagnostics && !!declarationTransform.diagnostics.length) || !!host.isEmitBlocked(declarationFilePath) || !!compilerOptions.noEmit;
emitSkipped = emitSkipped || declBlocked;
if (!declBlocked || emitOnlyDtsFiles) {
const previousState = sourceMap.setState(/*disabled*/ true);
printSourceFileOrBundle(declarationFilePath, /*sourceMapFilePath*/ undefined, declarationTransform.transformed[0], declarationPrinter, /*shouldSkipSourcemap*/ true);
sourceMap.setState(previousState);
}
declarationTransform.dispose();
}
function printSourceFileOrBundle(jsFilePath: string, sourceMapFilePath: string, sourceFileOrBundle: SourceFile | Bundle, printer: Printer, shouldSkipSourcemap = false) {
const bundle = sourceFileOrBundle.kind === SyntaxKind.Bundle ? sourceFileOrBundle : undefined;
const sourceFile = sourceFileOrBundle.kind === SyntaxKind.SourceFile ? sourceFileOrBundle : undefined;
const sourceFiles = bundle ? bundle.sourceFiles : [sourceFile];
@@ -180,17 +219,17 @@ namespace ts {
writer.writeLine();
const sourceMappingURL = sourceMap.getSourceMappingURL();
if (sourceMappingURL) {
if (!shouldSkipSourcemap && sourceMappingURL) {
writer.write(`//# ${"sourceMappingURL"}=${sourceMappingURL}`); // Sometimes tools can sometimes see this line as a source mapping url comment
}
// Write the source map
if (compilerOptions.sourceMap && !compilerOptions.inlineSourceMap) {
if (!shouldSkipSourcemap && compilerOptions.sourceMap && !compilerOptions.inlineSourceMap) {
writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap.getText(), /*writeByteOrderMark*/ false, sourceFiles);
}
// Record source map data for the test harness.
if (sourceMapDataList) {
if (!shouldSkipSourcemap && sourceMapDataList) {
sourceMapDataList.push(sourceMap.getSourceMapData());
}
@@ -384,6 +423,7 @@ namespace ts {
emitShebangIfNeeded(bundle);
emitPrologueDirectivesIfNeeded(bundle);
emitHelpersIndirect(bundle);
emitSyntheticTripleSlashReferencesIfNeeded(bundle);
for (const sourceFile of bundle.sourceFiles) {
print(EmitHint.SourceFile, sourceFile, sourceFile);
}
@@ -2044,6 +2084,7 @@ namespace ts {
emit(node.name);
let body = node.body;
if (!body) return writeSemicolon();
while (body.kind === SyntaxKind.ModuleDeclaration) {
writePunctuation(".");
emit((<ModuleDeclaration>body).name);
@@ -2418,11 +2459,31 @@ namespace ts {
emitSourceFileWorker(node);
}
function emitSyntheticTripleSlashReferencesIfNeeded(node: Bundle) {
emitTripleSlashDirectives(node.syntheticFileReferences || [], node.syntheticTypeReferences || []);
}
function emitTripleSlashDirectivesIfNeeded(node: SourceFile) {
if (node.isDeclarationFile) emitTripleSlashDirectives(node.referencedFiles, node.typeReferenceDirectives);
}
function emitTripleSlashDirectives(files: ReadonlyArray<FileReference>, types: ReadonlyArray<FileReference>) {
for (const directive of files) {
write(`/// <reference path="${directive.fileName}" />`);
writeLine();
}
for (const directive of types) {
write(`/// <reference types="${directive.fileName}" />`);
writeLine();
}
}
function emitSourceFileWorker(node: SourceFile) {
const statements = node.statements;
pushNameGenerationScope(node);
emitHelpersIndirect(node);
const index = findIndex(statements, statement => !isPrologueDirective(statement));
emitTripleSlashDirectivesIfNeeded(node);
emitList(node, statements, ListFormat.MultiLine, index === -1 ? statements.length : index);
popNameGenerationScope(node);
}
@@ -2668,7 +2729,7 @@ namespace ts {
if (format & ListFormat.BracketsMask) {
writePunctuation(getOpeningBracket(format));
if (isEmpty) {
if (isEmpty && !isUndefined) {
emitTrailingCommentsOfPosition(children.pos, /*prefixSpace*/ true); // Emit comments within empty bracketed lists
}
}
@@ -2796,7 +2857,7 @@ namespace ts {
}
if (format & ListFormat.BracketsMask) {
if (isEmpty) {
if (isEmpty && !isUndefined) {
emitLeadingCommentsOfPosition(children.end); // Emit leading comments within empty lists
}
writePunctuation(getClosingBracket(format));
@@ -2927,21 +2988,6 @@ namespace ts {
}
}
function guessIndentation(lines: string[]) {
let indentation: number;
for (const line of lines) {
for (let i = 0; i < line.length && (indentation === undefined || i < indentation); i++) {
if (!isWhiteSpaceLike(line.charCodeAt(i))) {
if (indentation === undefined || i < indentation) {
indentation = i;
break;
}
}
}
}
return indentation;
}
function increaseIndentIf(value: boolean, valueToWriteWhenNotIndenting?: string) {
if (value) {
increaseIndent();
@@ -3239,8 +3285,15 @@ namespace ts {
* in global scope. The name is formed by adding an '_n' suffix to the specified base name,
* where n is a positive integer. Note that names generated by makeTempVariableName and
* makeUniqueName are guaranteed to never conflict.
* If `optimistic` is set, the first instance will use 'baseName' verbatim instead of 'baseName_1'
*/
function makeUniqueName(baseName: string): string {
function makeUniqueName(baseName: string, optimistic?: boolean): string {
if (optimistic) {
if (isUniqueName(baseName)) {
generatedNames.set(baseName, true);
return baseName;
}
}
// Find the first unique 'name_n', where n is a positive number
if (baseName.charCodeAt(baseName.length - 1) !== CharacterCodes._) {
baseName += "_";
@@ -3335,6 +3388,8 @@ namespace ts {
return makeTempVariableName(TempFlags._i, !!(name.autoGenerateFlags & GeneratedIdentifierFlags.ReservedInNestedScopes));
case GeneratedIdentifierFlags.Unique:
return makeUniqueName(idText(name));
case GeneratedIdentifierFlags.OptimisticUnique:
return makeUniqueName(idText(name), /*optimistic*/ true);
}
Debug.fail("Unsupported GeneratedIdentifierKind.");
+45 -10
View File
@@ -171,6 +171,15 @@ namespace ts {
return name;
}
/** Create a unique name based on the supplied text. */
export function createOptimisticUniqueName(text: string): Identifier {
const name = createIdentifier(text);
name.autoGenerateFlags = GeneratedIdentifierFlags.OptimisticUnique;
name.autoGenerateId = nextAutoGenerateId;
nextAutoGenerateId++;
return name;
}
/** Create a unique name generated for a node. */
export function getGeneratedNameForNode(node: Node): Identifier;
/* @internal */ export function getGeneratedNameForNode(node: Node, shouldSkipNameGenerationScope?: boolean): Identifier; // tslint:disable-line unified-signatures
@@ -214,6 +223,28 @@ namespace ts {
return <BooleanLiteral & Token<SyntaxKind.FalseKeyword>>createSynthesizedNode(SyntaxKind.FalseKeyword);
}
// Modifiers
export function createModifier<T extends Modifier["kind"]>(kind: T) {
return createToken(kind);
}
export function createModifiersFromModifierFlags(flags: ModifierFlags) {
const result: Modifier[] = [];
if (flags & ModifierFlags.Export) { result.push(createModifier(SyntaxKind.ExportKeyword)); }
if (flags & ModifierFlags.Ambient) { result.push(createModifier(SyntaxKind.DeclareKeyword)); }
if (flags & ModifierFlags.Default) { result.push(createModifier(SyntaxKind.DefaultKeyword)); }
if (flags & ModifierFlags.Const) { result.push(createModifier(SyntaxKind.ConstKeyword)); }
if (flags & ModifierFlags.Public) { result.push(createModifier(SyntaxKind.PublicKeyword)); }
if (flags & ModifierFlags.Private) { result.push(createModifier(SyntaxKind.PrivateKeyword)); }
if (flags & ModifierFlags.Protected) { result.push(createModifier(SyntaxKind.ProtectedKeyword)); }
if (flags & ModifierFlags.Abstract) { result.push(createModifier(SyntaxKind.AbstractKeyword)); }
if (flags & ModifierFlags.Static) { result.push(createModifier(SyntaxKind.StaticKeyword)); }
if (flags & ModifierFlags.Readonly) { result.push(createModifier(SyntaxKind.ReadonlyKeyword)); }
if (flags & ModifierFlags.Async) { result.push(createModifier(SyntaxKind.AsyncKeyword)); }
return result;
}
// Names
export function createQualifiedName(left: EntityName, right: string | Identifier) {
@@ -2349,8 +2380,13 @@ namespace ts {
// Top-level nodes
export function updateSourceFileNode(node: SourceFile, statements: ReadonlyArray<Statement>) {
if (node.statements !== statements) {
export function updateSourceFileNode(node: SourceFile, statements: ReadonlyArray<Statement>, isDeclarationFile?: boolean, referencedFiles?: SourceFile["referencedFiles"], typeReferences?: SourceFile["typeReferenceDirectives"]) {
if (
node.statements !== statements ||
(isDeclarationFile !== undefined && node.isDeclarationFile !== isDeclarationFile) ||
(referencedFiles !== undefined && node.referencedFiles !== referencedFiles) ||
(typeReferences !== undefined && node.typeReferenceDirectives !== typeReferences)
) {
const updated = <SourceFile>createSynthesizedNode(SyntaxKind.SourceFile);
updated.flags |= node.flags;
updated.statements = createNodeArray(statements);
@@ -2358,12 +2394,12 @@ namespace ts {
updated.fileName = node.fileName;
updated.path = node.path;
updated.text = node.text;
updated.isDeclarationFile = isDeclarationFile === undefined ? node.isDeclarationFile : isDeclarationFile;
updated.referencedFiles = referencedFiles === undefined ? node.referencedFiles : referencedFiles;
updated.typeReferenceDirectives = typeReferences === undefined ? node.typeReferenceDirectives : typeReferences;
if (node.amdDependencies !== undefined) updated.amdDependencies = node.amdDependencies;
if (node.moduleName !== undefined) updated.moduleName = node.moduleName;
if (node.referencedFiles !== undefined) updated.referencedFiles = node.referencedFiles;
if (node.typeReferenceDirectives !== undefined) updated.typeReferenceDirectives = node.typeReferenceDirectives;
if (node.languageVariant !== undefined) updated.languageVariant = node.languageVariant;
if (node.isDeclarationFile !== undefined) updated.isDeclarationFile = node.isDeclarationFile;
if (node.renamedDependencies !== undefined) updated.renamedDependencies = node.renamedDependencies;
if (node.hasNoDefaultLib !== undefined) updated.hasNoDefaultLib = node.hasNoDefaultLib;
if (node.languageVersion !== undefined) updated.languageVersion = node.languageVersion;
@@ -2958,7 +2994,8 @@ namespace ts {
requestEmitHelper: noop,
resumeLexicalEnvironment: noop,
startLexicalEnvironment: noop,
suspendLexicalEnvironment: noop
suspendLexicalEnvironment: noop,
addDiagnostic: noop,
};
// Compound nodes
@@ -3157,8 +3194,7 @@ namespace ts {
return { value: o && o[i++], done: !o };
}
};
};
`
};`
};
export function createValuesHelper(context: TransformationContext, expression: Expression, location?: TextRange) {
@@ -3192,8 +3228,7 @@ namespace ts {
finally { if (e) throw e.error; }
}
return ar;
};
`
};`
};
export function createReadHelper(context: TransformationContext, iteratorRecord: Expression, count: number | undefined, location?: TextRange) {
+8 -8
View File
@@ -52,6 +52,13 @@ namespace ts {
}
}
/*@internal*/
export function isJSDocLikeText(text: string, start: number) {
return text.charCodeAt(start + 1) === CharacterCodes.asterisk &&
text.charCodeAt(start + 2) === CharacterCodes.asterisk &&
text.charCodeAt(start + 3) !== CharacterCodes.slash;
}
/**
* Invokes a callback for each child of the given node. The 'cbNode' callback is invoked for all child nodes
* stored in properties. If a 'cbNodes' callback is specified, it is invoked for embedded arrays; otherwise,
@@ -6219,7 +6226,7 @@ namespace ts {
let result: JSDoc;
// Check for /** (JSDoc opening part)
if (!isJsDocStart(content, start)) {
if (!isJSDocLikeText(content, start)) {
return result;
}
@@ -6331,13 +6338,6 @@ namespace ts {
}
}
function isJsDocStart(content: string, start: number) {
return content.charCodeAt(start) === CharacterCodes.slash &&
content.charCodeAt(start + 1) === CharacterCodes.asterisk &&
content.charCodeAt(start + 2) === CharacterCodes.asterisk &&
content.charCodeAt(start + 3) !== CharacterCodes.asterisk;
}
function createJSDocComment(): JSDoc {
const result = <JSDoc>createNode(SyntaxKind.JSDocComment, start);
result.tags = tags && createNodeArray(tags, tagsPos, tagsEnd);
+12
View File
@@ -67,6 +67,11 @@ namespace ts {
* Gets test data for source maps.
*/
getSourceMapData(): SourceMapData;
/**
* @returns the previous disabled state
*/
setState(disabled: boolean): boolean;
}
// Used for initialize lastEncodedSourceMapSpan and reset lastEncodedSourceMapSpan when updateLastEncodedAndRecordedSpans
@@ -107,8 +112,15 @@ namespace ts {
emitTokenWithSourceMap,
getText,
getSourceMappingURL,
setState,
};
function setState(state: boolean) {
const last = disabled;
disabled = state;
return last;
}
/**
* Skips trivia such as comments and white-space that can optionally overriden by the source map source
*/
+7 -1
View File
@@ -11,6 +11,7 @@
/// <reference path="transformers/module/module.ts" />
/// <reference path="transformers/module/system.ts" />
/// <reference path="transformers/module/es2015.ts" />
/// <reference path="transformers/declarations.ts" />
/* @internal */
namespace ts {
@@ -104,6 +105,7 @@ namespace ts {
let onSubstituteNode: TransformationContext["onSubstituteNode"] = (_, node) => node;
let onEmitNode: TransformationContext["onEmitNode"] = (hint, node, callback) => callback(hint, node);
let state = TransformationState.Uninitialized;
const diagnostics: Diagnostic[] = [];
// The transformation context is provided to each transformer as part of transformer
// initialization.
@@ -134,6 +136,9 @@ namespace ts {
Debug.assert(state < TransformationState.Initialized, "Cannot modify transformation hooks after initialization has completed.");
Debug.assert(value !== undefined, "Value must not be 'undefined'");
onEmitNode = value;
},
addDiagnostic(diag) {
diagnostics.push(diag);
}
};
@@ -163,7 +168,8 @@ namespace ts {
transformed,
substituteNode,
emitNodeWithNotification,
dispose
dispose,
diagnostics
};
function transformRoot(node: T) {
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,469 @@
/* @internal */
namespace ts {
export type GetSymbolAccessibilityDiagnostic = (symbolAccessibilityResult: SymbolAccessibilityResult) => (SymbolAccessibilityDiagnostic | undefined);
export interface SymbolAccessibilityDiagnostic {
errorNode: Node;
diagnosticMessage: DiagnosticMessage;
typeName?: DeclarationName | QualifiedName;
}
export type DeclarationDiagnosticProducing =
| VariableDeclaration
| PropertyDeclaration
| PropertySignature
| BindingElement
| SetAccessorDeclaration
| GetAccessorDeclaration
| ConstructSignatureDeclaration
| CallSignatureDeclaration
| MethodDeclaration
| MethodSignature
| FunctionDeclaration
| ParameterDeclaration
| TypeParameterDeclaration
| ExpressionWithTypeArguments
| ImportEqualsDeclaration
| TypeAliasDeclaration
| ConstructorDeclaration
| IndexSignatureDeclaration;
export function canProduceDiagnostics(node: Node): node is DeclarationDiagnosticProducing {
return isVariableDeclaration(node) ||
isPropertyDeclaration(node) ||
isPropertySignature(node) ||
isBindingElement(node) ||
isSetAccessor(node) ||
isGetAccessor(node) ||
isConstructSignatureDeclaration(node) ||
isCallSignatureDeclaration(node) ||
isMethodDeclaration(node) ||
isMethodSignature(node) ||
isFunctionDeclaration(node) ||
isParameter(node) ||
isTypeParameterDeclaration(node) ||
isExpressionWithTypeArguments(node) ||
isImportEqualsDeclaration(node) ||
isTypeAliasDeclaration(node) ||
isConstructorDeclaration(node) ||
isIndexSignatureDeclaration(node);
}
export function createGetSymbolAccessibilityDiagnosticForNodeName(node: DeclarationDiagnosticProducing) {
if (isSetAccessor(node) || isGetAccessor(node)) {
return getAccessorNameVisibilityError;
}
else if (isMethodSignature(node) || isMethodDeclaration(node)) {
return getMethodNameVisibilityError;
}
else {
return createGetSymbolAccessibilityDiagnosticForNode(node);
}
function getAccessorNameVisibilityError(symbolAccessibilityResult: SymbolAccessibilityResult) {
const diagnosticMessage = getAccessorNameVisibilityDiagnosticMessage(symbolAccessibilityResult);
return diagnosticMessage !== undefined ? {
diagnosticMessage,
errorNode: node,
typeName: (node as NamedDeclaration).name
} : undefined;
}
function getAccessorNameVisibilityDiagnosticMessage(symbolAccessibilityResult: SymbolAccessibilityResult) {
if (hasModifier(node, ModifierFlags.Static)) {
return symbolAccessibilityResult.errorModuleName ?
symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 :
Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1;
}
else if (node.parent.kind === SyntaxKind.ClassDeclaration) {
return symbolAccessibilityResult.errorModuleName ?
symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 :
Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1;
}
else {
return symbolAccessibilityResult.errorModuleName ?
Diagnostics.Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 :
Diagnostics.Property_0_of_exported_interface_has_or_is_using_private_name_1;
}
}
function getMethodNameVisibilityError(symbolAccessibilityResult: SymbolAccessibilityResult): SymbolAccessibilityDiagnostic {
const diagnosticMessage = getMethodNameVisibilityDiagnosticMessage(symbolAccessibilityResult);
return diagnosticMessage !== undefined ? {
diagnosticMessage,
errorNode: node,
typeName: (node as NamedDeclaration).name
} : undefined;
}
function getMethodNameVisibilityDiagnosticMessage(symbolAccessibilityResult: SymbolAccessibilityResult) {
if (hasModifier(node, ModifierFlags.Static)) {
return symbolAccessibilityResult.errorModuleName ?
symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 :
Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_private_name_1;
}
else if (node.parent.kind === SyntaxKind.ClassDeclaration) {
return symbolAccessibilityResult.errorModuleName ?
symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 :
Diagnostics.Public_method_0_of_exported_class_has_or_is_using_private_name_1;
}
else {
return symbolAccessibilityResult.errorModuleName ?
Diagnostics.Method_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 :
Diagnostics.Method_0_of_exported_interface_has_or_is_using_private_name_1;
}
}
}
export function createGetSymbolAccessibilityDiagnosticForNode(node: DeclarationDiagnosticProducing) {
if (isVariableDeclaration(node) || isPropertyDeclaration(node) || isPropertySignature(node) || isBindingElement(node) || isConstructorDeclaration(node)) {
return getVariableDeclarationTypeVisibilityError;
}
else if (isSetAccessor(node) || isGetAccessor(node)) {
return getAccessorDeclarationTypeVisibilityError;
}
else if (isConstructSignatureDeclaration(node) || isCallSignatureDeclaration(node) || isMethodDeclaration(node) || isMethodSignature(node) || isFunctionDeclaration(node) || isIndexSignatureDeclaration(node)) {
return getReturnTypeVisibilityError;
}
else if (isParameter(node)) {
if (isParameterPropertyDeclaration(node) && hasModifier(node.parent, ModifierFlags.Private)) {
return getVariableDeclarationTypeVisibilityError;
}
return getParameterDeclarationTypeVisibilityError;
}
else if (isTypeParameterDeclaration(node)) {
return getTypeParameterConstraintVisibilityError;
}
else if (isExpressionWithTypeArguments(node)) {
return getHeritageClauseVisibilityError;
}
else if (isImportEqualsDeclaration(node)) {
return getImportEntityNameVisibilityError;
}
else if (isTypeAliasDeclaration(node)) {
return getTypeAliasDeclarationVisibilityError;
}
else {
Debug.assertNever(node, `Attempted to set a declaration diagnostic context for unhandled node kind: ${(ts as any).SyntaxKind[(node as any).kind]}`);
}
function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult: SymbolAccessibilityResult) {
if (node.kind === SyntaxKind.VariableDeclaration || node.kind === SyntaxKind.BindingElement) {
return symbolAccessibilityResult.errorModuleName ?
symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 :
Diagnostics.Exported_variable_0_has_or_is_using_private_name_1;
}
// This check is to ensure we don't report error on constructor parameter property as that error would be reported during parameter emit
// The only exception here is if the constructor was marked as private. we are not emitting the constructor parameters at all.
else if (node.kind === SyntaxKind.PropertyDeclaration || node.kind === SyntaxKind.PropertySignature ||
(node.kind === SyntaxKind.Parameter && hasModifier(node.parent, ModifierFlags.Private))) {
// TODO(jfreeman): Deal with computed properties in error reporting.
if (hasModifier(node, ModifierFlags.Static)) {
return symbolAccessibilityResult.errorModuleName ?
symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 :
Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1;
}
else if (node.parent.kind === SyntaxKind.ClassDeclaration || node.kind === SyntaxKind.Parameter) {
return symbolAccessibilityResult.errorModuleName ?
symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 :
Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1;
}
else {
// Interfaces cannot have types that cannot be named
return symbolAccessibilityResult.errorModuleName ?
Diagnostics.Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 :
Diagnostics.Property_0_of_exported_interface_has_or_is_using_private_name_1;
}
}
}
function getVariableDeclarationTypeVisibilityError(symbolAccessibilityResult: SymbolAccessibilityResult): SymbolAccessibilityDiagnostic {
const diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult);
return diagnosticMessage !== undefined ? {
diagnosticMessage,
errorNode: node,
typeName: (node as NamedDeclaration).name
} : undefined;
}
function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult: SymbolAccessibilityResult): SymbolAccessibilityDiagnostic {
let diagnosticMessage: DiagnosticMessage;
if (node.kind === SyntaxKind.SetAccessor) {
// Getters can infer the return type from the returned expression, but setters cannot, so the
// "_from_external_module_1_but_cannot_be_named" case cannot occur.
if (hasModifier(node, ModifierFlags.Static)) {
diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
Diagnostics.Parameter_type_of_public_static_setter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
Diagnostics.Parameter_type_of_public_static_setter_0_from_exported_class_has_or_is_using_private_name_1;
}
else {
diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
Diagnostics.Parameter_type_of_public_setter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
Diagnostics.Parameter_type_of_public_setter_0_from_exported_class_has_or_is_using_private_name_1;
}
}
else {
if (hasModifier(node, ModifierFlags.Static)) {
diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
Diagnostics.Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
Diagnostics.Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
Diagnostics.Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_private_name_1;
}
else {
diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
Diagnostics.Return_type_of_public_getter_0_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
Diagnostics.Return_type_of_public_getter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
Diagnostics.Return_type_of_public_getter_0_from_exported_class_has_or_is_using_private_name_1;
}
}
return {
diagnosticMessage,
errorNode: (node as NamedDeclaration).name,
typeName: (node as NamedDeclaration).name
};
}
function getReturnTypeVisibilityError(symbolAccessibilityResult: SymbolAccessibilityResult): SymbolAccessibilityDiagnostic {
let diagnosticMessage: DiagnosticMessage;
switch (node.kind) {
case SyntaxKind.ConstructSignature:
// Interfaces cannot have return types that cannot be named
diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 :
Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0;
break;
case SyntaxKind.CallSignature:
// Interfaces cannot have return types that cannot be named
diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 :
Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0;
break;
case SyntaxKind.IndexSignature:
// Interfaces cannot have return types that cannot be named
diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 :
Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0;
break;
case SyntaxKind.MethodDeclaration:
case SyntaxKind.MethodSignature:
if (hasModifier(node, ModifierFlags.Static)) {
diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named :
Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 :
Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0;
}
else if (node.parent.kind === SyntaxKind.ClassDeclaration) {
diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named :
Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 :
Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0;
}
else {
// Interfaces cannot have return types that cannot be named
diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1 :
Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0;
}
break;
case SyntaxKind.FunctionDeclaration:
diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named :
Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1 :
Diagnostics.Return_type_of_exported_function_has_or_is_using_private_name_0;
break;
default:
Debug.fail("This is unknown kind for signature: " + node.kind);
}
return {
diagnosticMessage,
errorNode: (node as NamedDeclaration).name || node
};
}
function getParameterDeclarationTypeVisibilityError(symbolAccessibilityResult: SymbolAccessibilityResult): SymbolAccessibilityDiagnostic {
const diagnosticMessage: DiagnosticMessage = getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult);
return diagnosticMessage !== undefined ? {
diagnosticMessage,
errorNode: node,
typeName: (node as NamedDeclaration).name
} : undefined;
}
function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult: SymbolAccessibilityResult): DiagnosticMessage {
switch (node.parent.kind) {
case SyntaxKind.Constructor:
return symbolAccessibilityResult.errorModuleName ?
symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1;
case SyntaxKind.ConstructSignature:
case SyntaxKind.ConstructorType:
// Interfaces cannot have parameter types that cannot be named
return symbolAccessibilityResult.errorModuleName ?
Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 :
Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1;
case SyntaxKind.CallSignature:
// Interfaces cannot have parameter types that cannot be named
return symbolAccessibilityResult.errorModuleName ?
Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 :
Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1;
case SyntaxKind.IndexSignature:
// Interfaces cannot have parameter types that cannot be named
return symbolAccessibilityResult.errorModuleName ?
Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 :
Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1;
case SyntaxKind.MethodDeclaration:
case SyntaxKind.MethodSignature:
if (hasModifier(node.parent, ModifierFlags.Static)) {
return symbolAccessibilityResult.errorModuleName ?
symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1;
}
else if (node.parent.parent.kind === SyntaxKind.ClassDeclaration) {
return symbolAccessibilityResult.errorModuleName ?
symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1;
}
else {
// Interfaces cannot have parameter types that cannot be named
return symbolAccessibilityResult.errorModuleName ?
Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 :
Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1;
}
case SyntaxKind.FunctionDeclaration:
case SyntaxKind.FunctionType:
return symbolAccessibilityResult.errorModuleName ?
symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 :
Diagnostics.Parameter_0_of_exported_function_has_or_is_using_private_name_1;
default:
Debug.fail(`Unknown parent for parameter: ${(ts as any).SyntaxKind[node.parent.kind]}`);
}
}
function getTypeParameterConstraintVisibilityError(): SymbolAccessibilityDiagnostic {
// Type parameter constraints are named by user so we should always be able to name it
let diagnosticMessage: DiagnosticMessage;
switch (node.parent.kind) {
case SyntaxKind.ClassDeclaration:
diagnosticMessage = Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1;
break;
case SyntaxKind.InterfaceDeclaration:
diagnosticMessage = Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1;
break;
case SyntaxKind.ConstructSignature:
diagnosticMessage = Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1;
break;
case SyntaxKind.CallSignature:
diagnosticMessage = Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1;
break;
case SyntaxKind.MethodDeclaration:
case SyntaxKind.MethodSignature:
if (hasModifier(node.parent, ModifierFlags.Static)) {
diagnosticMessage = Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1;
}
else if (node.parent.parent.kind === SyntaxKind.ClassDeclaration) {
diagnosticMessage = Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1;
}
else {
diagnosticMessage = Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1;
}
break;
case SyntaxKind.FunctionDeclaration:
diagnosticMessage = Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1;
break;
case SyntaxKind.TypeAliasDeclaration:
diagnosticMessage = Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1;
break;
default:
Debug.fail("This is unknown parent for type parameter: " + node.parent.kind);
}
return {
diagnosticMessage,
errorNode: node,
typeName: (node as NamedDeclaration).name
};
}
function getHeritageClauseVisibilityError(): SymbolAccessibilityDiagnostic {
let diagnosticMessage: DiagnosticMessage;
// Heritage clause is written by user so it can always be named
if (node.parent.parent.kind === SyntaxKind.ClassDeclaration) {
// Class or Interface implemented/extended is inaccessible
diagnosticMessage = (node as ExpressionWithTypeArguments).parent.token === SyntaxKind.ImplementsKeyword ?
Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 :
Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1;
}
else {
// interface is inaccessible
diagnosticMessage = Diagnostics.extends_clause_of_exported_interface_0_has_or_is_using_private_name_1;
}
return {
diagnosticMessage,
errorNode: node,
typeName: getNameOfDeclaration((node as ExpressionWithTypeArguments).parent.parent)
};
}
function getImportEntityNameVisibilityError(): SymbolAccessibilityDiagnostic {
return {
diagnosticMessage: Diagnostics.Import_declaration_0_is_using_private_name_1,
errorNode: node,
typeName: (node as NamedDeclaration).name
};
}
function getTypeAliasDeclarationVisibilityError(): SymbolAccessibilityDiagnostic {
return {
diagnosticMessage: Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1,
errorNode: (node as TypeAliasDeclaration).type,
typeName: (node as TypeAliasDeclaration).name
};
}
}
}
+2 -4
View File
@@ -669,8 +669,7 @@ namespace ts {
name: "typescript:async-super",
scoped: true,
text: `
const _super = name => super[name];
`
const _super = name => super[name];`
};
export const advancedAsyncSuperHelper: EmitHelper = {
@@ -680,7 +679,6 @@ namespace ts {
const _super = (function (geti, seti) {
const cache = Object.create(null);
return name => cache[name] || (cache[name] = { get value() { return geti(name); }, set value(v) { seti(name, v); } });
})(name => super[name], (name, value) => super[name] = value);
`
})(name => super[name], (name, value) => super[name] = value);`
};
}
+4 -8
View File
@@ -887,8 +887,7 @@ namespace ts {
name: "typescript:await",
scoped: false,
text: `
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
`
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }`
};
function createAwaitHelper(context: TransformationContext, expression: Expression) {
@@ -910,8 +909,7 @@ namespace ts {
function fulfill(value) { resume("next", value); }
function reject(value) { resume("throw", value); }
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
};
`
};`
};
function createAsyncGeneratorHelper(context: TransformationContext, generatorFunc: FunctionExpression) {
@@ -940,8 +938,7 @@ namespace ts {
var i, p;
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
function verb(n, f) { if (o[n]) i[n] = function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; }; }
};
`
};`
};
function createAsyncDelegatorHelper(context: TransformationContext, expression: Expression, location?: TextRange) {
@@ -965,8 +962,7 @@ namespace ts {
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
var m = o[Symbol.asyncIterator];
return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator]();
};
`
};`
};
function createAsyncValuesHelper(context: TransformationContext, expression: Expression, location?: TextRange) {
+1 -2
View File
@@ -1698,8 +1698,7 @@ namespace ts {
text: `
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
`
}`
};
function createExportStarHelper(context: TransformationContext, module: Expression) {
+2 -1
View File
@@ -31,10 +31,11 @@
"transformers/module/module.ts",
"transformers/module/system.ts",
"transformers/module/es2015.ts",
"transformers/declarations/diagnostics.ts",
"transformers/declarations.ts",
"transformer.ts",
"comments.ts",
"sourcemap.ts",
"declarationEmitter.ts",
"emitter.ts",
"watchUtilities.ts",
"program.ts",
+18 -11
View File
@@ -536,6 +536,7 @@ namespace ts {
TypeScriptModifier = Ambient | Public | Private | Protected | Readonly | Abstract | Const,
ExportDefault = Export | Default,
All = Export | Ambient | Public | Private | Protected | Static | Readonly | Abstract | Async | Default | Const
}
export const enum JsxFlags {
@@ -697,6 +698,7 @@ namespace ts {
Loop = 2, // Automatically generated identifier with a preference for '_i'.
Unique = 3, // Unique name based on the 'text' property.
Node = 4, // Unique name based on the node in the 'original' property.
OptimisticUnique = 5, // Unique name based on the 'text' property, first instance won't use '_#' if there's no conflict
KindMask = 7, // Mask to extract the kind of identifier from its flags.
// Flags
@@ -971,9 +973,9 @@ namespace ts {
export type FunctionLikeDeclaration =
| FunctionDeclaration
| MethodDeclaration
| ConstructorDeclaration
| GetAccessorDeclaration
| SetAccessorDeclaration
| ConstructorDeclaration
| FunctionExpression
| ArrowFunction;
/** @deprecated Use SignatureDeclaration */
@@ -2581,6 +2583,8 @@ namespace ts {
export interface Bundle extends Node {
kind: SyntaxKind.Bundle;
sourceFiles: ReadonlyArray<SourceFile>;
/* @internal */ syntheticFileReferences?: ReadonlyArray<FileReference>;
/* @internal */ syntheticTypeReferences?: ReadonlyArray<FileReference>;
}
export interface JsonSourceFile extends SourceFile {
@@ -3200,15 +3204,16 @@ namespace ts {
isReferencedAliasDeclaration(node: Node, checkChildren?: boolean): boolean;
isTopLevelValueImportEqualsWithEntityName(node: ImportEqualsDeclaration): boolean;
getNodeCheckFlags(node: Node): NodeCheckFlags;
isDeclarationVisible(node: Declaration): boolean;
isDeclarationVisible(node: Declaration | AnyImportSyntax): boolean;
isLateBound(node: Declaration): node is LateBoundDeclaration;
collectLinkedAliases(node: Identifier): Node[];
isImplementationOfOverload(node: FunctionLikeDeclaration): boolean | undefined;
isImplementationOfOverload(node: FunctionLike): boolean | undefined;
isRequiredInitializedParameter(node: ParameterDeclaration): boolean;
isOptionalUninitializedParameterProperty(node: ParameterDeclaration): boolean;
writeTypeOfDeclaration(declaration: AccessorDeclaration | VariableLikeDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: EmitTextWriter): void;
writeReturnTypeOfSignatureDeclaration(signatureDeclaration: SignatureDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: EmitTextWriter): void;
writeTypeOfExpression(expr: Expression, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: EmitTextWriter): void;
createTypeOfDeclaration(declaration: AccessorDeclaration | VariableLikeDeclaration, enclosingDeclaration: Node, flags: NodeBuilderFlags, tracker: SymbolTracker, addUndefined?: boolean): TypeNode;
createReturnTypeOfSignatureDeclaration(signatureDeclaration: SignatureDeclaration, enclosingDeclaration: Node, flags: NodeBuilderFlags, tracker: SymbolTracker): TypeNode;
createTypeOfExpression(expr: Expression, enclosingDeclaration: Node, flags: NodeBuilderFlags, tracker: SymbolTracker): TypeNode;
createLiteralConstValue(node: VariableDeclaration | PropertyDeclaration | PropertySignature | ParameterDeclaration): Expression;
isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags, shouldComputeAliasToMarkVisible: boolean): SymbolAccessibilityResult;
isEntityNameVisible(entityName: EntityNameOrEntityNameExpression, enclosingDeclaration: Node): SymbolVisibilityResult;
// Returns the constant value this property access resolves to, or 'undefined' for a non-constant
@@ -3222,7 +3227,6 @@ namespace ts {
getTypeReferenceDirectivesForEntityName(name: EntityNameOrEntityNameExpression): string[];
getTypeReferenceDirectivesForSymbol(symbol: Symbol, meaning?: SymbolFlags): string[];
isLiteralConstDeclaration(node: VariableDeclaration | PropertyDeclaration | PropertySignature | ParameterDeclaration): boolean;
writeLiteralConstValue(node: VariableDeclaration | PropertyDeclaration | PropertySignature | ParameterDeclaration, writer: EmitTextWriter): void;
getJsxFactoryEntity(location?: Node): EntityName;
}
@@ -4862,6 +4866,8 @@ namespace ts {
* before returning the `NodeTransformer` callback.
*/
onEmitNode: (hint: EmitHint, node: Node, emitCallback: (hint: EmitHint, node: Node) => void) => void;
/* @internal */ addDiagnostic(diag: Diagnostic): void;
}
export interface TransformationResult<T extends Node> {
@@ -5005,6 +5011,7 @@ namespace ts {
/*@internal*/ sourceMap?: boolean;
/*@internal*/ inlineSourceMap?: boolean;
/*@internal*/ extendedDiagnostics?: boolean;
/*@internal*/ onlyPrintJsDocStyle?: boolean;
}
/* @internal */
@@ -5119,10 +5126,10 @@ namespace ts {
// Precomputed Formats
Modifiers = SingleLine | SpaceBetweenSiblings | NoInterveningComments,
HeritageClauses = SingleLine | SpaceBetweenSiblings,
SingleLineTypeLiteralMembers = SingleLine | SpaceBetweenBraces | SpaceBetweenSiblings | Indented,
MultiLineTypeLiteralMembers = MultiLine | Indented,
SingleLineTypeLiteralMembers = SingleLine | SpaceBetweenBraces | SpaceBetweenSiblings,
MultiLineTypeLiteralMembers = MultiLine | Indented | OptionalIfEmpty,
TupleTypeElements = CommaDelimited | SpaceBetweenSiblings | SingleLine | Indented,
TupleTypeElements = CommaDelimited | SpaceBetweenSiblings | SingleLine,
UnionTypeConstituents = BarDelimited | SpaceBetweenSiblings | SingleLine,
IntersectionTypeConstituents = AmpersandDelimited | SpaceBetweenSiblings | SingleLine,
ObjectBindingPatternElements = SingleLine | AllowTrailingComma | SpaceBetweenBraces | CommaDelimited | SpaceBetweenSiblings | NoSpaceIfEmpty,
@@ -5143,7 +5150,7 @@ namespace ts {
InterfaceMembers = Indented | MultiLine,
EnumMembers = CommaDelimited | Indented | MultiLine,
CaseBlockClauses = Indented | MultiLine,
NamedImportsOrExportsElements = CommaDelimited | SpaceBetweenSiblings | AllowTrailingComma | SingleLine | SpaceBetweenBraces,
NamedImportsOrExportsElements = CommaDelimited | SpaceBetweenSiblings | AllowTrailingComma | SingleLine | SpaceBetweenBraces | NoSpaceIfEmpty,
JsxElementOrFragmentChildren = SingleLine | NoInterveningComments,
JsxElementAttributes = SingleLine | SpaceBetweenSiblings | NoInterveningComments,
CaseOrDefaultClauseStatements = Indented | MultiLine | NoTrailingNewLine | OptionalIfEmpty,
+75 -4
View File
@@ -274,9 +274,9 @@ namespace ts {
return false;
}
export function isPinnedComment(text: string, comment: CommentRange) {
return text.charCodeAt(comment.pos + 1) === CharacterCodes.asterisk &&
text.charCodeAt(comment.pos + 2) === CharacterCodes.exclamation;
export function isPinnedComment(text: string, start: number) {
return text.charCodeAt(start + 1) === CharacterCodes.asterisk &&
text.charCodeAt(start + 2) === CharacterCodes.exclamation;
}
export function getTokenPosOfNode(node: Node, sourceFile?: SourceFileLike, includeJsDoc?: boolean): number {
@@ -967,6 +967,10 @@ namespace ts {
return false;
}
export function isVariableLikeOrAccessor(node: Node): node is AccessorDeclaration | VariableLikeDeclaration {
return isVariableLike(node) || isAccessor(node);
}
export function isVariableDeclarationInVariableStatement(node: VariableDeclaration) {
return node.parent.kind === SyntaxKind.VariableDeclarationList
&& node.parent.parent.kind === SyntaxKind.VariableStatement;
@@ -1423,6 +1427,10 @@ namespace ts {
return isInJavaScriptFile(file);
}
export function isSourceFileNotJavaScript(file: SourceFile): boolean {
return !isInJavaScriptFile(file);
}
export function isInJavaScriptFile(node: Node | undefined): boolean {
return node && !!(node.flags & NodeFlags.JavaScriptFile);
}
@@ -3110,7 +3118,7 @@ namespace ts {
return currentDetachedCommentInfo;
function isPinnedCommentLocal(comment: CommentRange) {
return isPinnedComment(text, comment);
return isPinnedComment(text, comment.pos);
}
}
@@ -5983,6 +5991,45 @@ namespace ts {
return !!(node as HasType).type;
}
/* True if the node could have a type node a `.type` */
/* @internal */
export function couldHaveType(node: Node): node is HasType {
switch (node.kind) {
case SyntaxKind.Parameter:
case SyntaxKind.PropertySignature:
case SyntaxKind.PropertyDeclaration:
case SyntaxKind.MethodSignature:
case SyntaxKind.MethodDeclaration:
case SyntaxKind.Constructor:
case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor:
case SyntaxKind.CallSignature:
case SyntaxKind.ConstructSignature:
case SyntaxKind.IndexSignature:
case SyntaxKind.TypePredicate:
case SyntaxKind.FunctionType:
case SyntaxKind.ConstructorType:
case SyntaxKind.ParenthesizedType:
case SyntaxKind.TypeOperator:
case SyntaxKind.MappedType:
case SyntaxKind.TypeAssertionExpression:
case SyntaxKind.FunctionExpression:
case SyntaxKind.ArrowFunction:
case SyntaxKind.AsExpression:
case SyntaxKind.VariableDeclaration:
case SyntaxKind.FunctionDeclaration:
case SyntaxKind.TypeAliasDeclaration:
case SyntaxKind.JSDocTypeExpression:
case SyntaxKind.JSDocNullableType:
case SyntaxKind.JSDocNonNullableType:
case SyntaxKind.JSDocOptionalType:
case SyntaxKind.JSDocFunctionType:
case SyntaxKind.JSDocVariadicType:
return true;
}
return false;
}
/** True if has initializer node attached to it. */
/* @internal */
export function hasInitializer(node: Node): node is HasInitializer {
@@ -6015,6 +6062,30 @@ namespace ts {
return node.kind === SyntaxKind.TypeReference || node.kind === SyntaxKind.ExpressionWithTypeArguments;
}
const MAX_SMI_X86 = 0x3fff_ffff;
/* @internal */
export function guessIndentation(lines: string[]) {
let indentation = MAX_SMI_X86;
for (const line of lines) {
if (!line.length) {
continue;
}
let i = 0;
for (; i < line.length && i < indentation; i++) {
if (!isWhiteSpaceLike(line.charCodeAt(i))) {
break;
}
}
if (i < indentation) {
indentation = i;
}
if (indentation === 0) {
return 0;
}
}
return indentation === MAX_SMI_X86 ? undefined : indentation;
}
export function isStringLiteralLike(node: Node): node is StringLiteralLike {
return node.kind === SyntaxKind.StringLiteral || node.kind === SyntaxKind.NoSubstitutionTemplateLiteral;
}
+2 -1
View File
@@ -39,10 +39,11 @@
"../compiler/transformers/module/module.ts",
"../compiler/transformers/module/system.ts",
"../compiler/transformers/module/es2015.ts",
"../compiler/transformers/declarations/diagnostics.ts",
"../compiler/transformers/declarations.ts",
"../compiler/transformer.ts",
"../compiler/comments.ts",
"../compiler/sourcemap.ts",
"../compiler/declarationEmitter.ts",
"../compiler/emitter.ts",
"../compiler/program.ts",
"../compiler/builder.ts",
+2 -2
View File
@@ -111,8 +111,6 @@ namespace ts {
}
describe("parsesIncorrectly", () => {
parsesIncorrectly("emptyComment", "/***/");
parsesIncorrectly("threeAsterisks", "/*** */");
parsesIncorrectly("multipleTypes",
`/**
* @type {number}
@@ -152,6 +150,8 @@ namespace ts {
});
describe("parsesCorrectly", () => {
parsesCorrectly("threeAsterisks", "/*** */");
parsesCorrectly("emptyComment", "/***/");
parsesCorrectly("noLeadingAsterisk",
`/**
@type {number}
+1 -1
View File
@@ -874,7 +874,7 @@ namespace ts.textChanges {
let ranges = getLeadingCommentRanges(text, position);
if (!ranges) return position;
// However we should still skip a pinned comment at the top
if (ranges.length && ranges[0].kind === SyntaxKind.MultiLineCommentTrivia && isPinnedComment(text, ranges[0])) {
if (ranges.length && ranges[0].kind === SyntaxKind.MultiLineCommentTrivia && isPinnedComment(text, ranges[0].pos)) {
position = ranges[0].end;
advancePastLineBreak();
ranges = ranges.slice(1);
+2 -1
View File
@@ -31,10 +31,11 @@
"../compiler/transformers/module/module.ts",
"../compiler/transformers/module/system.ts",
"../compiler/transformers/module/es2015.ts",
"../compiler/transformers/declarations/diagnostics.ts",
"../compiler/transformers/declarations.ts",
"../compiler/transformer.ts",
"../compiler/comments.ts",
"../compiler/sourcemap.ts",
"../compiler/declarationEmitter.ts",
"../compiler/emitter.ts",
"../compiler/program.ts",
"../compiler/builderState.ts",
@@ -0,0 +1,5 @@
{
"kind": "JSDocComment",
"pos": 0,
"end": 5
}
@@ -0,0 +1,6 @@
{
"kind": "JSDocComment",
"pos": 0,
"end": 7,
"comment": "* "
}
@@ -51,7 +51,7 @@ declare function f<T>(x: T): T;
declare enum E {
A = 0,
B = 1,
C = 2,
C = 2
}
declare const c1 = "abc";
declare const c2 = 123;
@@ -6,4 +6,4 @@ declare module "foo";
//// [ambientShorthand_declarationEmit.d.ts]
declare module "foo";
declare module "foo";
+220 -215
View File
@@ -390,7 +390,7 @@ declare namespace ts {
FirstJSDocNode = 274,
LastJSDocNode = 292,
FirstJSDocTagNode = 284,
LastJSDocTagNode = 292,
LastJSDocTagNode = 292
}
enum NodeFlags {
None = 0,
@@ -418,7 +418,7 @@ declare namespace ts {
ReachabilityCheckFlags = 384,
ReachabilityAndEmitFlags = 1408,
ContextFlags = 6387712,
TypeExcludesFlags = 20480,
TypeExcludesFlags = 20480
}
enum ModifierFlags {
None = 0,
@@ -439,6 +439,7 @@ declare namespace ts {
NonPublicAccessibilityModifier = 24,
TypeScriptModifier = 2270,
ExportDefault = 513,
All = 3071
}
enum JsxFlags {
None = 0,
@@ -446,7 +447,7 @@ declare namespace ts {
IntrinsicNamedElement = 1,
/** An element inferred from the string index signature of the JSX.IntrinsicElements interface */
IntrinsicIndexedElement = 2,
IntrinsicElement = 3,
IntrinsicElement = 3
}
interface Node extends TextRange {
kind: SyntaxKind;
@@ -644,7 +645,7 @@ declare namespace ts {
questionToken?: QuestionToken;
body?: Block | Expression;
}
type FunctionLikeDeclaration = FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | GetAccessorDeclaration | SetAccessorDeclaration | FunctionExpression | ArrowFunction;
type FunctionLikeDeclaration = FunctionDeclaration | MethodDeclaration | GetAccessorDeclaration | SetAccessorDeclaration | ConstructorDeclaration | FunctionExpression | ArrowFunction;
/** @deprecated Use SignatureDeclaration */
type FunctionLike = SignatureDeclaration;
interface FunctionDeclaration extends FunctionLikeDeclarationBase, DeclarationStatement {
@@ -1555,7 +1556,7 @@ declare namespace ts {
PreFinally = 2048,
AfterFinally = 4096,
Label = 12,
Condition = 96,
Condition = 96
}
interface FlowLock {
locked?: boolean;
@@ -1727,7 +1728,7 @@ declare namespace ts {
enum ExitStatus {
Success = 0,
DiagnosticsPresent_OutputsSkipped = 1,
DiagnosticsPresent_OutputsGenerated = 2,
DiagnosticsPresent_OutputsGenerated = 2
}
interface EmitResult {
emitSkipped: boolean;
@@ -1752,9 +1753,9 @@ declare namespace ts {
/** Note that the resulting nodes cannot be checked. */
typeToTypeNode(type: Type, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): TypeNode;
/** Note that the resulting nodes cannot be checked. */
signatureToSignatureDeclaration(signature: Signature, kind: SyntaxKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): SignatureDeclaration & {
signatureToSignatureDeclaration(signature: Signature, kind: SyntaxKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): (SignatureDeclaration & {
typeArguments?: NodeArray<TypeNode>;
} | undefined;
}) | undefined;
/** Note that the resulting nodes cannot be checked. */
indexInfoToIndexSignatureDeclaration(indexInfo: IndexInfo, kind: IndexKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): IndexSignatureDeclaration | undefined;
/** Note that the resulting nodes cannot be checked. */
@@ -1849,7 +1850,7 @@ declare namespace ts {
InObjectTypeLiteral = 4194304,
InTypeAlias = 8388608,
InInitialEntityName = 16777216,
InReverseMappedType = 33554432,
InReverseMappedType = 33554432
}
enum TypeFormatFlags {
None = 0,
@@ -1872,14 +1873,14 @@ declare namespace ts {
InFirstTypeArgument = 4194304,
InTypeAlias = 8388608,
/** @deprecated */ WriteOwnNameForAnyLike = 0,
NodeBuilderFlagsMask = 9469291,
NodeBuilderFlagsMask = 9469291
}
enum SymbolFormatFlags {
None = 0,
WriteTypeParametersOrArguments = 1,
UseOnlyExternalAliasing = 2,
AllowAnyNodeKind = 4,
UseAliasDefinedOutsideCurrentScope = 8,
UseAliasDefinedOutsideCurrentScope = 8
}
/**
* @deprecated
@@ -1916,7 +1917,7 @@ declare namespace ts {
}
enum TypePredicateKind {
This = 0,
Identifier = 1,
Identifier = 1
}
interface TypePredicateBase {
kind: TypePredicateKind;
@@ -1991,7 +1992,7 @@ declare namespace ts {
HasMembers = 6240,
BlockScoped = 418,
PropertyOrAccessor = 98308,
ClassMember = 106500,
ClassMember = 106500
}
interface Symbol {
flags: SymbolFlags;
@@ -2018,7 +2019,7 @@ declare namespace ts {
Computed = "__computed",
Resolving = "__resolving__",
ExportEquals = "export=",
Default = "default",
Default = "default"
}
/**
* This represents a string whose leading underscore have been escaped by adding extra leading underscores.
@@ -2093,7 +2094,7 @@ declare namespace ts {
Instantiable = 7897088,
StructuredOrInstantiable = 8355840,
Narrowable = 142575359,
NotUnionOrUnit = 134283777,
NotUnionOrUnit = 134283777
}
type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression;
interface Type {
@@ -2134,7 +2135,7 @@ declare namespace ts {
ReverseMapped = 2048,
JsxAttributes = 4096,
MarkerType = 8192,
ClassOrInterface = 3,
ClassOrInterface = 3
}
interface ObjectType extends Type {
objectFlags: ObjectFlags;
@@ -2220,7 +2221,7 @@ declare namespace ts {
}
enum SignatureKind {
Call = 0,
Construct = 1,
Construct = 1
}
interface Signature {
declaration?: SignatureDeclaration;
@@ -2229,7 +2230,7 @@ declare namespace ts {
}
enum IndexKind {
String = 0,
Number = 1,
Number = 1
}
interface IndexInfo {
type: Type;
@@ -2243,7 +2244,7 @@ declare namespace ts {
ReturnType = 8,
NoConstraints = 16,
AlwaysStrict = 32,
PriorityImpliesUnion = 12,
PriorityImpliesUnion = 12
}
interface JsFileExtensionInfo {
extension: string;
@@ -2281,11 +2282,11 @@ declare namespace ts {
Warning = 0,
Error = 1,
Suggestion = 2,
Message = 3,
Message = 3
}
enum ModuleResolutionKind {
Classic = 1,
NodeJs = 2,
NodeJs = 2
}
interface PluginImport {
name: string;
@@ -2379,17 +2380,17 @@ declare namespace ts {
UMD = 3,
System = 4,
ES2015 = 5,
ESNext = 6,
ESNext = 6
}
enum JsxEmit {
None = 0,
Preserve = 1,
React = 2,
ReactNative = 3,
ReactNative = 3
}
enum NewLineKind {
CarriageReturnLineFeed = 0,
LineFeed = 1,
LineFeed = 1
}
interface LineAndCharacter {
/** 0-based. */
@@ -2403,7 +2404,7 @@ declare namespace ts {
TS = 3,
TSX = 4,
External = 5,
JSON = 6,
JSON = 6
}
enum ScriptTarget {
ES3 = 0,
@@ -2413,11 +2414,11 @@ declare namespace ts {
ES2017 = 4,
ES2018 = 5,
ESNext = 6,
Latest = 6,
Latest = 6
}
enum LanguageVariant {
Standard = 0,
JSX = 1,
JSX = 1
}
/** Either a parsed command line or a parsed tsconfig.json */
interface ParsedCommandLine {
@@ -2431,7 +2432,7 @@ declare namespace ts {
}
enum WatchDirectoryFlags {
None = 0,
Recursive = 1,
Recursive = 1
}
interface ExpandResult {
fileNames: string[];
@@ -2501,7 +2502,7 @@ declare namespace ts {
Dts = ".d.ts",
Js = ".js",
Jsx = ".jsx",
Json = ".json",
Json = ".json"
}
interface ResolvedModuleWithFailedLookupLocations {
readonly resolvedModule: ResolvedModuleFull | undefined;
@@ -2571,7 +2572,7 @@ declare namespace ts {
NoHoisting = 2097152,
HasEndOfDeclarationMarker = 4194304,
Iterator = 8388608,
NoAsciiEscaping = 16777216,
NoAsciiEscaping = 16777216
}
interface EmitHelper {
readonly name: string;
@@ -2584,7 +2585,7 @@ declare namespace ts {
Expression = 1,
IdentifierName = 2,
MappedTypeParameter = 3,
Unspecified = 4,
Unspecified = 4
}
interface TransformationContext {
/** Gets the compiler options supplied to the transformer. */
@@ -2802,9 +2803,9 @@ declare namespace ts {
SingleElement = 524288,
Modifiers = 131328,
HeritageClauses = 256,
SingleLineTypeLiteralMembers = 448,
MultiLineTypeLiteralMembers = 65,
TupleTypeElements = 336,
SingleLineTypeLiteralMembers = 384,
MultiLineTypeLiteralMembers = 16449,
TupleTypeElements = 272,
UnionTypeConstituents = 260,
IntersectionTypeConstituents = 264,
ObjectBindingPatternElements = 262576,
@@ -2825,7 +2826,7 @@ declare namespace ts {
InterfaceMembers = 65,
EnumMembers = 81,
CaseBlockClauses = 65,
NamedImportsOrExportsElements = 432,
NamedImportsOrExportsElements = 262576,
JsxElementOrFragmentChildren = 131072,
JsxElementAttributes = 131328,
CaseOrDefaultClauseStatements = 81985,
@@ -2835,7 +2836,7 @@ declare namespace ts {
TypeArguments = 26896,
TypeParameters = 26896,
Parameters = 1296,
IndexSignatureParameters = 4432,
IndexSignatureParameters = 4432
}
}
declare namespace ts {
@@ -2853,7 +2854,7 @@ declare namespace ts {
enum FileWatcherEventKind {
Created = 0,
Changed = 1,
Deleted = 2,
Deleted = 2
}
type FileWatcherCallback = (fileName: string, eventKind: FileWatcherEventKind) => void;
type DirectoryWatcherCallback = (fileName: string) => void;
@@ -3438,6 +3439,8 @@ declare namespace ts {
function createLoopVariable(): Identifier;
/** Create a unique name based on the supplied text. */
function createUniqueName(text: string): Identifier;
/** Create a unique name based on the supplied text. */
function createOptimisticUniqueName(text: string): Identifier;
/** Create a unique name generated for a node. */
function getGeneratedNameForNode(node: Node): Identifier;
function createToken<TKind extends SyntaxKind>(token: TKind): Token<TKind>;
@@ -3446,6 +3449,8 @@ declare namespace ts {
function createNull(): NullLiteral & Token<SyntaxKind.NullKeyword>;
function createTrue(): BooleanLiteral & Token<SyntaxKind.TrueKeyword>;
function createFalse(): BooleanLiteral & Token<SyntaxKind.FalseKeyword>;
function createModifier<T extends Modifier["kind"]>(kind: T): Token<T>;
function createModifiersFromModifierFlags(flags: ModifierFlags): Modifier[];
function createQualifiedName(left: EntityName, right: string | Identifier): QualifiedName;
function updateQualifiedName(node: QualifiedName, left: EntityName, right: Identifier): QualifiedName;
function createComputedPropertyName(expression: Expression): ComputedPropertyName;
@@ -3700,7 +3705,7 @@ declare namespace ts {
function updateSpreadAssignment(node: SpreadAssignment, expression: Expression): SpreadAssignment;
function createEnumMember(name: string | PropertyName, initializer?: Expression): EnumMember;
function updateEnumMember(node: EnumMember, name: PropertyName, initializer: Expression | undefined): EnumMember;
function updateSourceFileNode(node: SourceFile, statements: ReadonlyArray<Statement>): SourceFile;
function updateSourceFileNode(node: SourceFile, statements: ReadonlyArray<Statement>, isDeclarationFile?: boolean, referencedFiles?: SourceFile["referencedFiles"], typeReferences?: SourceFile["typeReferenceDirectives"]): SourceFile;
/**
* Creates a shallow, memberwise clone of a node for mutation.
*/
@@ -4305,7 +4310,7 @@ declare namespace ts {
none = "none",
definition = "definition",
reference = "reference",
writtenReference = "writtenReference",
writtenReference = "writtenReference"
}
interface HighlightSpan {
fileName?: string;
@@ -4327,7 +4332,7 @@ declare namespace ts {
enum IndentStyle {
None = 0,
Block = 1,
Smart = 2,
Smart = 2
}
interface EditorOptions {
BaseIndentSize?: number;
@@ -4422,7 +4427,7 @@ declare namespace ts {
typeParameterName = 18,
enumMemberName = 19,
functionName = 20,
regularExpressionLiteral = 21,
regularExpressionLiteral = 21
}
interface SymbolDisplayPart {
text: string;
@@ -4533,7 +4538,7 @@ declare namespace ts {
enum OutputFileType {
JavaScript = 0,
SourceMap = 1,
Declaration = 2,
Declaration = 2
}
enum EndOfLineState {
None = 0,
@@ -4542,7 +4547,7 @@ declare namespace ts {
InDoubleQuoteStringLiteral = 3,
InTemplateHeadOrNoSubstitutionTemplate = 4,
InTemplateMiddleOrTail = 5,
InTemplateSubstitutionPosition = 6,
InTemplateSubstitutionPosition = 6
}
enum TokenClass {
Punctuation = 0,
@@ -4553,7 +4558,7 @@ declare namespace ts {
Identifier = 5,
NumberLiteral = 6,
StringLiteral = 7,
RegExpLiteral = 8,
RegExpLiteral = 8
}
interface ClassificationResult {
finalLexState: EndOfLineState;
@@ -4652,7 +4657,7 @@ declare namespace ts {
/**
* <JsxTagName attribute1 attribute2={0} />
*/
jsxAttribute = "JSX attribute",
jsxAttribute = "JSX attribute"
}
enum ScriptElementKindModifier {
none = "",
@@ -4663,7 +4668,7 @@ declare namespace ts {
ambientModifier = "declare",
staticModifier = "static",
abstractModifier = "abstract",
optionalModifier = "optional",
optionalModifier = "optional"
}
enum ClassificationTypeNames {
comment = "comment",
@@ -4688,7 +4693,7 @@ declare namespace ts {
jsxSelfClosingTagName = "jsx self closing tag name",
jsxAttribute = "jsx attribute",
jsxText = "jsx text",
jsxAttributeStringLiteralValue = "jsx attribute string literal value",
jsxAttributeStringLiteralValue = "jsx attribute string literal value"
}
enum ClassificationType {
comment = 1,
@@ -4714,7 +4719,7 @@ declare namespace ts {
jsxSelfClosingTagName = 21,
jsxAttribute = 22,
jsxText = 23,
jsxAttributeStringLiteralValue = 24,
jsxAttributeStringLiteralValue = 24
}
}
declare namespace ts {
@@ -4952,7 +4957,7 @@ declare namespace ts.server {
terse = 0,
normal = 1,
requestTime = 2,
verbose = 3,
verbose = 3
}
const emptyArray: SortedReadonlyArray<never>;
interface Logger {
@@ -4969,7 +4974,7 @@ declare namespace ts.server {
enum Msg {
Err = "Err",
Info = "Info",
Perf = "Perf",
Perf = "Perf"
}
namespace Msg {
/** @deprecated Only here for backwards-compatibility. Prefer just `Msg`. */
@@ -5076,7 +5081,7 @@ declare namespace ts.server.protocol {
GetSupportedCodeFixes = "getSupportedCodeFixes",
GetApplicableRefactors = "getApplicableRefactors",
GetEditsForRefactor = "getEditsForRefactor",
OrganizeImports = "organizeImports",
OrganizeImports = "organizeImports"
}
/**
* A TypeScript Server message
@@ -7065,7 +7070,7 @@ declare namespace ts.server.protocol {
enum IndentStyle {
None = "None",
Block = "Block",
Smart = "Smart",
Smart = "Smart"
}
interface EditorSettings {
baseIndentSize?: number;
@@ -7166,7 +7171,7 @@ declare namespace ts.server.protocol {
None = "None",
Preserve = "Preserve",
ReactNative = "ReactNative",
React = "React",
React = "React"
}
enum ModuleKind {
None = "None",
@@ -7176,15 +7181,15 @@ declare namespace ts.server.protocol {
System = "System",
ES6 = "ES6",
ES2015 = "ES2015",
ESNext = "ESNext",
ESNext = "ESNext"
}
enum ModuleResolutionKind {
Classic = "Classic",
Node = "Node",
Node = "Node"
}
enum NewLineKind {
Crlf = "Crlf",
Lf = "Lf",
Lf = "Lf"
}
enum ScriptTarget {
ES3 = "ES3",
@@ -7193,7 +7198,7 @@ declare namespace ts.server.protocol {
ES2015 = "ES2015",
ES2016 = "ES2016",
ES2017 = "ES2017",
ESNext = "ESNext",
ESNext = "ESNext"
}
}
declare namespace ts.server {
@@ -7247,114 +7252,114 @@ declare namespace ts.server {
protected canUseEvents: boolean;
private eventHandler;
constructor(opts: SessionOptions);
private sendRequestCompletedEvent(requestId);
private defaultEventHandler(event);
private projectsUpdatedInBackgroundEvent(openFiles);
private sendRequestCompletedEvent;
private defaultEventHandler;
private projectsUpdatedInBackgroundEvent;
logError(err: Error, cmd: string): void;
send(msg: protocol.Message): void;
event<T extends object>(body: T, eventName: string): void;
/** @deprecated */
output(info: any, cmdName: string, reqSeq?: number, errorMsg?: string): void;
private doOutput(info, cmdName, reqSeq, success, message?);
private semanticCheck(file, project);
private syntacticCheck(file, project);
private infoCheck(file, project);
private sendDiagnosticsEvent(file, project, diagnostics, kind);
private updateErrorCheck(next, checkList, ms, requireOpen?);
private cleanProjects(caption, projects);
private cleanup();
private getEncodedSemanticClassifications(args);
private getProject(projectFileName);
private getConfigFileAndProject(args);
private getConfigFileDiagnostics(configFile, project, includeLinePosition);
private convertToDiagnosticsWithLinePositionFromDiagnosticFile(diagnostics);
private getCompilerOptionsDiagnostics(args);
private convertToDiagnosticsWithLinePosition(diagnostics, scriptInfo);
private getDiagnosticsWorker(args, isSemantic, selector, includeLinePosition);
private getDefinition(args, simplifiedResult);
private getDefinitionAndBoundSpan(args, simplifiedResult);
private mapDefinitionInfo(definitions, project);
private toFileSpan(fileName, textSpan, project);
private getTypeDefinition(args);
private getImplementation(args, simplifiedResult);
private getOccurrences(args);
private getSyntacticDiagnosticsSync(args);
private getSemanticDiagnosticsSync(args);
private getSuggestionDiagnosticsSync(args);
private getDocumentHighlights(args, simplifiedResult);
private setCompilerOptionsForInferredProjects(args);
private getProjectInfo(args);
private getProjectInfoWorker(uncheckedFileName, projectFileName, needFileNameList, excludeConfigFiles);
private getRenameInfo(args);
private getProjects(args);
private getDefaultProject(args);
private getRenameLocations(args, simplifiedResult);
private getReferences(args, simplifiedResult);
private doOutput;
private semanticCheck;
private syntacticCheck;
private infoCheck;
private sendDiagnosticsEvent;
private updateErrorCheck;
private cleanProjects;
private cleanup;
private getEncodedSemanticClassifications;
private getProject;
private getConfigFileAndProject;
private getConfigFileDiagnostics;
private convertToDiagnosticsWithLinePositionFromDiagnosticFile;
private getCompilerOptionsDiagnostics;
private convertToDiagnosticsWithLinePosition;
private getDiagnosticsWorker;
private getDefinition;
private getDefinitionAndBoundSpan;
private mapDefinitionInfo;
private toFileSpan;
private getTypeDefinition;
private getImplementation;
private getOccurrences;
private getSyntacticDiagnosticsSync;
private getSemanticDiagnosticsSync;
private getSuggestionDiagnosticsSync;
private getDocumentHighlights;
private setCompilerOptionsForInferredProjects;
private getProjectInfo;
private getProjectInfoWorker;
private getRenameInfo;
private getProjects;
private getDefaultProject;
private getRenameLocations;
private getReferences;
/**
* @param fileName is the name of the file to be opened
* @param fileContent is a version of the file content that is known to be more up to date than the one on disk
*/
private openClientFile(fileName, fileContent?, scriptKind?, projectRootPath?);
private getPosition(args, scriptInfo);
private getPositionInFile(args, file);
private getFileAndProject(args);
private getFileAndLanguageServiceForSyntacticOperation(args);
private getFileAndProjectWorker(uncheckedFileName, projectFileName);
private getOutliningSpans(args, simplifiedResult);
private getTodoComments(args);
private getDocCommentTemplate(args);
private getSpanOfEnclosingComment(args);
private getIndentation(args);
private getBreakpointStatement(args);
private getNameOrDottedNameSpan(args);
private isValidBraceCompletion(args);
private getQuickInfoWorker(args, simplifiedResult);
private getFormattingEditsForRange(args);
private getFormattingEditsForRangeFull(args);
private getFormattingEditsForDocumentFull(args);
private getFormattingEditsAfterKeystrokeFull(args);
private getFormattingEditsAfterKeystroke(args);
private getCompletions(args, simplifiedResult);
private getCompletionEntryDetails(args, simplifiedResult);
private getCompileOnSaveAffectedFileList(args);
private emitFile(args);
private getSignatureHelpItems(args, simplifiedResult);
private createCheckList(fileNames, defaultProject?);
private getDiagnostics(next, delay, fileNames);
private change(args);
private reload(args, reqSeq);
private saveToTmp(fileName, tempFileName);
private closeClientFile(fileName);
private mapLocationNavigationBarItems(items, scriptInfo);
private getNavigationBarItems(args, simplifiedResult);
private toLocationNavigationTree(tree, scriptInfo);
private toLocationTextSpan(span, scriptInfo);
private getNavigationTree(args, simplifiedResult);
private getNavigateToItems(args, simplifiedResult);
private getSupportedCodeFixes();
private isLocation(locationOrSpan);
private extractPositionAndRange(args, scriptInfo);
private getApplicableRefactors(args);
private getEditsForRefactor(args, simplifiedResult);
private organizeImports({scope}, simplifiedResult);
private getCodeFixes(args, simplifiedResult);
private getCombinedCodeFix({scope, fixId}, simplifiedResult);
private applyCodeActionCommand(args);
private getStartAndEndPosition(args, scriptInfo);
private mapCodeAction(project, {description, changes: unmappedChanges, commands, fixId});
private mapTextChangesToCodeEdits(project, textChanges);
private mapTextChangesToCodeEditsUsingScriptinfo(textChanges, scriptInfo);
private convertTextChangeToCodeEdit(change, scriptInfo);
private getBraceMatching(args, simplifiedResult);
private getDiagnosticsForProject(next, delay, fileName);
private openClientFile;
private getPosition;
private getPositionInFile;
private getFileAndProject;
private getFileAndLanguageServiceForSyntacticOperation;
private getFileAndProjectWorker;
private getOutliningSpans;
private getTodoComments;
private getDocCommentTemplate;
private getSpanOfEnclosingComment;
private getIndentation;
private getBreakpointStatement;
private getNameOrDottedNameSpan;
private isValidBraceCompletion;
private getQuickInfoWorker;
private getFormattingEditsForRange;
private getFormattingEditsForRangeFull;
private getFormattingEditsForDocumentFull;
private getFormattingEditsAfterKeystrokeFull;
private getFormattingEditsAfterKeystroke;
private getCompletions;
private getCompletionEntryDetails;
private getCompileOnSaveAffectedFileList;
private emitFile;
private getSignatureHelpItems;
private createCheckList;
private getDiagnostics;
private change;
private reload;
private saveToTmp;
private closeClientFile;
private mapLocationNavigationBarItems;
private getNavigationBarItems;
private toLocationNavigationTree;
private toLocationTextSpan;
private getNavigationTree;
private getNavigateToItems;
private getSupportedCodeFixes;
private isLocation;
private extractPositionAndRange;
private getApplicableRefactors;
private getEditsForRefactor;
private organizeImports;
private getCodeFixes;
private getCombinedCodeFix;
private applyCodeActionCommand;
private getStartAndEndPosition;
private mapCodeAction;
private mapTextChangesToCodeEdits;
private mapTextChangesToCodeEditsUsingScriptinfo;
private convertTextChangeToCodeEdit;
private getBraceMatching;
private getDiagnosticsForProject;
getCanonicalFileName(fileName: string): string;
exit(): void;
private notRequired();
private requiredResponse(response);
private notRequired;
private requiredResponse;
private handlers;
addProtocolHandler(command: string, handler: (request: protocol.Request) => HandlerResponse): void;
private setCurrentRequest(requestId);
private resetCurrentRequest(requestId);
private setCurrentRequest;
private resetCurrentRequest;
executeWithRequestId<T>(requestId: number, f: () => T): T;
executeCommand(request: protocol.Request): HandlerResponse;
onMessage(message: string): void;
@@ -7382,7 +7387,7 @@ declare namespace ts.server {
open(newText: string): void;
close(fileExists?: boolean): void;
getSnapshot(): IScriptSnapshot;
private ensureRealPath();
private ensureRealPath;
getFormatCodeSettings(): FormatCodeSettings;
attachToProject(project: Project): boolean;
isAttached(project: Project): boolean;
@@ -7451,7 +7456,7 @@ declare namespace ts.server {
enum ProjectKind {
Inferred = 0,
Configured = 1,
External = 2,
External = 2
}
function allRootFilesAreJsOrDts(project: Project): boolean;
function allFilesAreJsOrDts(project: Project): boolean;
@@ -7542,7 +7547,7 @@ declare namespace ts.server {
getNewLine(): string;
getProjectVersion(): string;
getScriptFileNames(): string[];
private getOrCreateScriptInfoAndAttachToProject(fileName);
private getOrCreateScriptInfoAndAttachToProject;
getScriptKind(fileName: string): ScriptKind;
getScriptVersion(filename: string): string;
getScriptSnapshot(filename: string): IScriptSnapshot;
@@ -7559,14 +7564,14 @@ declare namespace ts.server {
getDirectories(path: string): string[];
log(s: string): void;
error(s: string): void;
private setInternalCompilerOptionsForEmittingJsFiles();
private setInternalCompilerOptionsForEmittingJsFiles;
/**
* Get the errors that dont have any file name associated
*/
getGlobalProjectErrors(): ReadonlyArray<Diagnostic>;
getAllProjectErrors(): ReadonlyArray<Diagnostic>;
getLanguageService(ensureSynchronized?: boolean): LanguageService;
private shouldEmitFile(scriptInfo);
private shouldEmitFile;
getCompileOnSaveAffectedFileList(scriptInfo: ScriptInfo): string[];
/**
* Returns true if emit was conducted
@@ -7580,7 +7585,7 @@ declare namespace ts.server {
getExternalFiles(): SortedReadonlyArray<string>;
getSourceFile(path: Path): SourceFile;
close(): void;
private detachScriptInfoIfNotRoot(uncheckedFilename);
private detachScriptInfoIfNotRoot;
isClosed(): boolean;
hasRoots(): boolean;
getRootFiles(): NormalizedPath[];
@@ -7603,10 +7608,10 @@ declare namespace ts.server {
*/
updateGraph(): boolean;
protected removeExistingTypings(include: string[]): string[];
private updateGraphWorker();
private detachScriptInfoFromProject(uncheckedFileName);
private addMissingFileWatcher(missingFilePath);
private isWatchedMissingFile(path);
private updateGraphWorker;
private detachScriptInfoFromProject;
private addMissingFileWatcher;
private isWatchedMissingFile;
getScriptInfoForNormalizedPath(fileName: NormalizedPath): ScriptInfo;
getScriptInfo(uncheckedFileName: string): ScriptInfo;
filesToString(writeProjectFileNames: boolean): string;
@@ -7614,7 +7619,7 @@ declare namespace ts.server {
protected removeRoot(info: ScriptInfo): void;
protected enableGlobalPlugins(): void;
protected enablePlugin(pluginConfigEntry: PluginImport, searchPaths: string[]): void;
private enableProxy(pluginModuleFactory, configEntry);
private enableProxy;
}
/**
* If a file is opened and no tsconfig (or jsconfig) is found,
@@ -7857,12 +7862,12 @@ declare namespace ts.server {
private readonly seenProjects;
constructor(opts: ProjectServiceOptions);
toPath(fileName: string): Path;
private loadTypesMap();
private loadTypesMap;
updateTypingsForProject(response: SetTypings | InvalidateCachedTypings | PackageInstalledResponse): void;
private delayEnsureProjectForOpenFiles();
private delayUpdateProjectGraph(project);
private sendProjectsUpdatedInBackgroundEvent();
private delayUpdateProjectGraphs(projects);
private delayEnsureProjectForOpenFiles;
private delayUpdateProjectGraph;
private sendProjectsUpdatedInBackgroundEvent;
private delayUpdateProjectGraphs;
setCompilerOptionsForInferredProjects(projectCompilerOptions: protocol.ExternalProjectCompilerOptions, projectRootPath?: string): void;
findProject(projectName: string): Project | undefined;
getDefaultProjectForFile(fileName: NormalizedPath, ensureProject: boolean): Project;
@@ -7874,47 +7879,47 @@ declare namespace ts.server {
* - if updates reflect some change in structure or there was pending request to ensure projects for open files
* ensure that each open script info has project
*/
private ensureProjectStructuresUptoDate();
private updateProjectIfDirty(project);
private ensureProjectStructuresUptoDate;
private updateProjectIfDirty;
getFormatCodeOptions(file?: NormalizedPath): FormatCodeSettings;
private onSourceFileChanged(fileName, eventKind, path);
private handleDeletedFile(info);
private onConfigChangedForConfiguredProject(project, eventKind);
private onSourceFileChanged;
private handleDeletedFile;
private onConfigChangedForConfiguredProject;
/**
* This is the callback function for the config file add/remove/change at any location
* that matters to open script info but doesnt have configured project open
* for the config file
*/
private onConfigFileChangeForOpenScriptInfo(configFileName, eventKind);
private removeProject(project);
private onConfigFileChangeForOpenScriptInfo;
private removeProject;
/**
* Remove this file from the set of open, non-configured files.
* @param info The file that has been closed or newly configured
*/
private closeOpenFile(info);
private deleteOrphanScriptInfoNotInAnyProject();
private deleteScriptInfo(info);
private configFileExists(configFileName, canonicalConfigFilePath, info);
private setConfigFileExistenceByNewConfiguredProject(project);
private closeOpenFile;
private deleteOrphanScriptInfoNotInAnyProject;
private deleteScriptInfo;
private configFileExists;
private setConfigFileExistenceByNewConfiguredProject;
/**
* Returns true if the configFileExistenceInfo is needed/impacted by open files that are root of inferred project
*/
private configFileExistenceImpactsRootOfInferredProject(configFileExistenceInfo);
private setConfigFileExistenceInfoByClosedConfiguredProject(closedProject);
private logConfigFileWatchUpdate(configFileName, canonicalConfigFilePath, configFileExistenceInfo, status);
private configFileExistenceImpactsRootOfInferredProject;
private setConfigFileExistenceInfoByClosedConfiguredProject;
private logConfigFileWatchUpdate;
/**
* Create the watcher for the configFileExistenceInfo
*/
private createConfigFileWatcherOfConfigFileExistence(configFileName, canonicalConfigFilePath, configFileExistenceInfo);
private createConfigFileWatcherOfConfigFileExistence;
/**
* Close the config file watcher in the cached ConfigFileExistenceInfo
* if there arent any open files that are root of inferred project
*/
private closeConfigFileWatcherOfConfigFileExistenceInfo(configFileExistenceInfo);
private closeConfigFileWatcherOfConfigFileExistenceInfo;
/**
* This is called on file close, so that we stop watching the config file for this script info
*/
private stopWatchingConfigFilesForClosedScriptInfo(info);
private stopWatchingConfigFilesForClosedScriptInfo;
/**
* This function tries to search for a tsconfig.json for the given file.
* This is different from the method the compiler uses because
@@ -7923,7 +7928,7 @@ declare namespace ts.server {
* The server must start searching from the directory containing
* the newly opened file.
*/
private forEachConfigFileLocation(info, action, projectRootPath?);
private forEachConfigFileLocation;
/**
* This function tries to search for a tsconfig.json for the given file.
* This is different from the method the compiler uses because
@@ -7932,31 +7937,31 @@ declare namespace ts.server {
* The server must start searching from the directory containing
* the newly opened file.
*/
private getConfigFileNameForFile(info, projectRootPath);
private printProjects();
private findConfiguredProjectByProjectName(configFileName);
private getConfiguredProjectByCanonicalConfigFilePath(canonicalConfigFilePath);
private findExternalProjectByProjectName(projectFileName);
private convertConfigFileContentToProjectOptions(configFilename, cachedDirectoryStructureHost);
private getConfigFileNameForFile;
private printProjects;
private findConfiguredProjectByProjectName;
private getConfiguredProjectByCanonicalConfigFilePath;
private findExternalProjectByProjectName;
private convertConfigFileContentToProjectOptions;
/** Get a filename if the language service exceeds the maximum allowed program size; otherwise returns undefined. */
private getFilenameForExceededTotalSizeLimitForNonTsFiles<T>(name, options, fileNames, propertyReader);
private createExternalProject(projectFileName, files, options, typeAcquisition, excludedFiles);
private sendProjectTelemetry(projectKey, project, projectOptions?);
private addFilesToNonInferredProjectAndUpdateGraph<T>(project, files, propertyReader, typeAcquisition);
private createConfiguredProject(configFileName);
private updateNonInferredProjectFiles<T>(project, files, propertyReader);
private updateNonInferredProject<T>(project, newUncheckedFiles, propertyReader, newOptions, newTypeAcquisition, compileOnSave);
private sendConfigFileDiagEvent(project, triggerFile);
private getOrCreateInferredProjectForProjectRootPathIfEnabled(info, projectRootPath);
private getOrCreateSingleInferredProjectIfEnabled();
private createInferredProject(currentDirectory, isSingleInferredProject?, projectRootPath?);
private getFilenameForExceededTotalSizeLimitForNonTsFiles;
private createExternalProject;
private sendProjectTelemetry;
private addFilesToNonInferredProjectAndUpdateGraph;
private createConfiguredProject;
private updateNonInferredProjectFiles;
private updateNonInferredProject;
private sendConfigFileDiagEvent;
private getOrCreateInferredProjectForProjectRootPathIfEnabled;
private getOrCreateSingleInferredProjectIfEnabled;
private createInferredProject;
getScriptInfo(uncheckedFileName: string): ScriptInfo;
private watchClosedScriptInfo(info);
private stopWatchingScriptInfo(info);
private watchClosedScriptInfo;
private stopWatchingScriptInfo;
getOrCreateScriptInfoForNormalizedPath(fileName: NormalizedPath, openedByClient: boolean, fileContent?: string, scriptKind?: ScriptKind, hasMixedContent?: boolean, hostToQueryFileExistsOn?: {
fileExists(path: string): boolean;
}): ScriptInfo;
private getOrCreateScriptInfoWorker(fileName, currentDirectory, openedByClient, fileContent?, scriptKind?, hasMixedContent?, hostToQueryFileExistsOn?);
private getOrCreateScriptInfoWorker;
/**
* This gets the script info for the normalized path. If the path is not rooted disk path then the open script info with project root context is preferred
*/
@@ -7969,7 +7974,7 @@ declare namespace ts.server {
* This does not reload contents of open files from disk. But we could do that if needed
*/
reloadProjects(): void;
private delayReloadConfiguredProjectForFiles(configFileExistenceInfo, ignoreIfNotRootOfInferredProject);
private delayReloadConfiguredProjectForFiles;
/**
* This function goes through all the openFiles and tries to file the config file for them.
* If the config file is found and it refers to existing project, it reloads it either immediately
@@ -7977,11 +7982,11 @@ declare namespace ts.server {
* If the there is no existing project it just opens the configured project for the config file
* reloadForInfo provides a way to filter out files to reload configured project for
*/
private reloadConfiguredProjectForFiles<T>(openFiles, delayReload, shouldReloadProjectFor);
private reloadConfiguredProjectForFiles;
/**
* Remove the root of inferred project if script info is part of another project
*/
private removeRootOfInferredProjectIfNowPartOfOtherProject(info);
private removeRootOfInferredProjectIfNowPartOfOtherProject;
/**
* This function is to update the project structure for every inferred project.
* It is called on the premise that all the configured projects are
@@ -7989,27 +7994,27 @@ declare namespace ts.server {
* This will go through open files and assign them to inferred project if open file is not part of any other project
* After that all the inferred project graphs are updated
*/
private ensureProjectForOpenFiles();
private ensureProjectForOpenFiles;
/**
* Open file whose contents is managed by the client
* @param filename is absolute pathname
* @param fileContent is a known version of the file content that is more up to date than the one on disk
*/
openClientFile(fileName: string, fileContent?: string, scriptKind?: ScriptKind, projectRootPath?: string): OpenConfiguredProjectResult;
private findExternalProjetContainingOpenScriptInfo(info);
private findExternalProjetContainingOpenScriptInfo;
openClientFileWithNormalizedPath(fileName: NormalizedPath, fileContent?: string, scriptKind?: ScriptKind, hasMixedContent?: boolean, projectRootPath?: NormalizedPath): OpenConfiguredProjectResult;
/**
* Close file whose contents is managed by the client
* @param filename is absolute pathname
*/
closeClientFile(uncheckedFileName: string): void;
private collectChanges(lastKnownProjectVersions, currentProjects, result);
private closeConfiguredProjectReferencedFromExternalProject(configFile);
private collectChanges;
private closeConfiguredProjectReferencedFromExternalProject;
closeExternalProject(uncheckedFileName: string): void;
openExternalProjects(projects: protocol.ExternalProject[]): void;
/** Makes a filename safe to insert in a RegExp */
private static readonly filenameEscapeRegexp;
private static escapeFilenameForRegex(filename);
private static escapeFilenameForRegex;
resetSafeList(): void;
applySafeList(proj: protocol.ExternalProject): NormalizedPath[];
openExternalProject(proj: protocol.ExternalProject): void;
+53 -48
View File
@@ -390,7 +390,7 @@ declare namespace ts {
FirstJSDocNode = 274,
LastJSDocNode = 292,
FirstJSDocTagNode = 284,
LastJSDocTagNode = 292,
LastJSDocTagNode = 292
}
enum NodeFlags {
None = 0,
@@ -418,7 +418,7 @@ declare namespace ts {
ReachabilityCheckFlags = 384,
ReachabilityAndEmitFlags = 1408,
ContextFlags = 6387712,
TypeExcludesFlags = 20480,
TypeExcludesFlags = 20480
}
enum ModifierFlags {
None = 0,
@@ -439,6 +439,7 @@ declare namespace ts {
NonPublicAccessibilityModifier = 24,
TypeScriptModifier = 2270,
ExportDefault = 513,
All = 3071
}
enum JsxFlags {
None = 0,
@@ -446,7 +447,7 @@ declare namespace ts {
IntrinsicNamedElement = 1,
/** An element inferred from the string index signature of the JSX.IntrinsicElements interface */
IntrinsicIndexedElement = 2,
IntrinsicElement = 3,
IntrinsicElement = 3
}
interface Node extends TextRange {
kind: SyntaxKind;
@@ -644,7 +645,7 @@ declare namespace ts {
questionToken?: QuestionToken;
body?: Block | Expression;
}
type FunctionLikeDeclaration = FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | GetAccessorDeclaration | SetAccessorDeclaration | FunctionExpression | ArrowFunction;
type FunctionLikeDeclaration = FunctionDeclaration | MethodDeclaration | GetAccessorDeclaration | SetAccessorDeclaration | ConstructorDeclaration | FunctionExpression | ArrowFunction;
/** @deprecated Use SignatureDeclaration */
type FunctionLike = SignatureDeclaration;
interface FunctionDeclaration extends FunctionLikeDeclarationBase, DeclarationStatement {
@@ -1555,7 +1556,7 @@ declare namespace ts {
PreFinally = 2048,
AfterFinally = 4096,
Label = 12,
Condition = 96,
Condition = 96
}
interface FlowLock {
locked?: boolean;
@@ -1727,7 +1728,7 @@ declare namespace ts {
enum ExitStatus {
Success = 0,
DiagnosticsPresent_OutputsSkipped = 1,
DiagnosticsPresent_OutputsGenerated = 2,
DiagnosticsPresent_OutputsGenerated = 2
}
interface EmitResult {
emitSkipped: boolean;
@@ -1752,9 +1753,9 @@ declare namespace ts {
/** Note that the resulting nodes cannot be checked. */
typeToTypeNode(type: Type, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): TypeNode;
/** Note that the resulting nodes cannot be checked. */
signatureToSignatureDeclaration(signature: Signature, kind: SyntaxKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): SignatureDeclaration & {
signatureToSignatureDeclaration(signature: Signature, kind: SyntaxKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): (SignatureDeclaration & {
typeArguments?: NodeArray<TypeNode>;
} | undefined;
}) | undefined;
/** Note that the resulting nodes cannot be checked. */
indexInfoToIndexSignatureDeclaration(indexInfo: IndexInfo, kind: IndexKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): IndexSignatureDeclaration | undefined;
/** Note that the resulting nodes cannot be checked. */
@@ -1849,7 +1850,7 @@ declare namespace ts {
InObjectTypeLiteral = 4194304,
InTypeAlias = 8388608,
InInitialEntityName = 16777216,
InReverseMappedType = 33554432,
InReverseMappedType = 33554432
}
enum TypeFormatFlags {
None = 0,
@@ -1872,14 +1873,14 @@ declare namespace ts {
InFirstTypeArgument = 4194304,
InTypeAlias = 8388608,
/** @deprecated */ WriteOwnNameForAnyLike = 0,
NodeBuilderFlagsMask = 9469291,
NodeBuilderFlagsMask = 9469291
}
enum SymbolFormatFlags {
None = 0,
WriteTypeParametersOrArguments = 1,
UseOnlyExternalAliasing = 2,
AllowAnyNodeKind = 4,
UseAliasDefinedOutsideCurrentScope = 8,
UseAliasDefinedOutsideCurrentScope = 8
}
/**
* @deprecated
@@ -1916,7 +1917,7 @@ declare namespace ts {
}
enum TypePredicateKind {
This = 0,
Identifier = 1,
Identifier = 1
}
interface TypePredicateBase {
kind: TypePredicateKind;
@@ -1991,7 +1992,7 @@ declare namespace ts {
HasMembers = 6240,
BlockScoped = 418,
PropertyOrAccessor = 98308,
ClassMember = 106500,
ClassMember = 106500
}
interface Symbol {
flags: SymbolFlags;
@@ -2018,7 +2019,7 @@ declare namespace ts {
Computed = "__computed",
Resolving = "__resolving__",
ExportEquals = "export=",
Default = "default",
Default = "default"
}
/**
* This represents a string whose leading underscore have been escaped by adding extra leading underscores.
@@ -2093,7 +2094,7 @@ declare namespace ts {
Instantiable = 7897088,
StructuredOrInstantiable = 8355840,
Narrowable = 142575359,
NotUnionOrUnit = 134283777,
NotUnionOrUnit = 134283777
}
type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression;
interface Type {
@@ -2134,7 +2135,7 @@ declare namespace ts {
ReverseMapped = 2048,
JsxAttributes = 4096,
MarkerType = 8192,
ClassOrInterface = 3,
ClassOrInterface = 3
}
interface ObjectType extends Type {
objectFlags: ObjectFlags;
@@ -2220,7 +2221,7 @@ declare namespace ts {
}
enum SignatureKind {
Call = 0,
Construct = 1,
Construct = 1
}
interface Signature {
declaration?: SignatureDeclaration;
@@ -2229,7 +2230,7 @@ declare namespace ts {
}
enum IndexKind {
String = 0,
Number = 1,
Number = 1
}
interface IndexInfo {
type: Type;
@@ -2243,7 +2244,7 @@ declare namespace ts {
ReturnType = 8,
NoConstraints = 16,
AlwaysStrict = 32,
PriorityImpliesUnion = 12,
PriorityImpliesUnion = 12
}
interface JsFileExtensionInfo {
extension: string;
@@ -2281,11 +2282,11 @@ declare namespace ts {
Warning = 0,
Error = 1,
Suggestion = 2,
Message = 3,
Message = 3
}
enum ModuleResolutionKind {
Classic = 1,
NodeJs = 2,
NodeJs = 2
}
interface PluginImport {
name: string;
@@ -2379,17 +2380,17 @@ declare namespace ts {
UMD = 3,
System = 4,
ES2015 = 5,
ESNext = 6,
ESNext = 6
}
enum JsxEmit {
None = 0,
Preserve = 1,
React = 2,
ReactNative = 3,
ReactNative = 3
}
enum NewLineKind {
CarriageReturnLineFeed = 0,
LineFeed = 1,
LineFeed = 1
}
interface LineAndCharacter {
/** 0-based. */
@@ -2403,7 +2404,7 @@ declare namespace ts {
TS = 3,
TSX = 4,
External = 5,
JSON = 6,
JSON = 6
}
enum ScriptTarget {
ES3 = 0,
@@ -2413,11 +2414,11 @@ declare namespace ts {
ES2017 = 4,
ES2018 = 5,
ESNext = 6,
Latest = 6,
Latest = 6
}
enum LanguageVariant {
Standard = 0,
JSX = 1,
JSX = 1
}
/** Either a parsed command line or a parsed tsconfig.json */
interface ParsedCommandLine {
@@ -2431,7 +2432,7 @@ declare namespace ts {
}
enum WatchDirectoryFlags {
None = 0,
Recursive = 1,
Recursive = 1
}
interface ExpandResult {
fileNames: string[];
@@ -2501,7 +2502,7 @@ declare namespace ts {
Dts = ".d.ts",
Js = ".js",
Jsx = ".jsx",
Json = ".json",
Json = ".json"
}
interface ResolvedModuleWithFailedLookupLocations {
readonly resolvedModule: ResolvedModuleFull | undefined;
@@ -2571,7 +2572,7 @@ declare namespace ts {
NoHoisting = 2097152,
HasEndOfDeclarationMarker = 4194304,
Iterator = 8388608,
NoAsciiEscaping = 16777216,
NoAsciiEscaping = 16777216
}
interface EmitHelper {
readonly name: string;
@@ -2584,7 +2585,7 @@ declare namespace ts {
Expression = 1,
IdentifierName = 2,
MappedTypeParameter = 3,
Unspecified = 4,
Unspecified = 4
}
interface TransformationContext {
/** Gets the compiler options supplied to the transformer. */
@@ -2802,9 +2803,9 @@ declare namespace ts {
SingleElement = 524288,
Modifiers = 131328,
HeritageClauses = 256,
SingleLineTypeLiteralMembers = 448,
MultiLineTypeLiteralMembers = 65,
TupleTypeElements = 336,
SingleLineTypeLiteralMembers = 384,
MultiLineTypeLiteralMembers = 16449,
TupleTypeElements = 272,
UnionTypeConstituents = 260,
IntersectionTypeConstituents = 264,
ObjectBindingPatternElements = 262576,
@@ -2825,7 +2826,7 @@ declare namespace ts {
InterfaceMembers = 65,
EnumMembers = 81,
CaseBlockClauses = 65,
NamedImportsOrExportsElements = 432,
NamedImportsOrExportsElements = 262576,
JsxElementOrFragmentChildren = 131072,
JsxElementAttributes = 131328,
CaseOrDefaultClauseStatements = 81985,
@@ -2835,7 +2836,7 @@ declare namespace ts {
TypeArguments = 26896,
TypeParameters = 26896,
Parameters = 1296,
IndexSignatureParameters = 4432,
IndexSignatureParameters = 4432
}
}
declare namespace ts {
@@ -2853,7 +2854,7 @@ declare namespace ts {
enum FileWatcherEventKind {
Created = 0,
Changed = 1,
Deleted = 2,
Deleted = 2
}
type FileWatcherCallback = (fileName: string, eventKind: FileWatcherEventKind) => void;
type DirectoryWatcherCallback = (fileName: string) => void;
@@ -3385,6 +3386,8 @@ declare namespace ts {
function createLoopVariable(): Identifier;
/** Create a unique name based on the supplied text. */
function createUniqueName(text: string): Identifier;
/** Create a unique name based on the supplied text. */
function createOptimisticUniqueName(text: string): Identifier;
/** Create a unique name generated for a node. */
function getGeneratedNameForNode(node: Node): Identifier;
function createToken<TKind extends SyntaxKind>(token: TKind): Token<TKind>;
@@ -3393,6 +3396,8 @@ declare namespace ts {
function createNull(): NullLiteral & Token<SyntaxKind.NullKeyword>;
function createTrue(): BooleanLiteral & Token<SyntaxKind.TrueKeyword>;
function createFalse(): BooleanLiteral & Token<SyntaxKind.FalseKeyword>;
function createModifier<T extends Modifier["kind"]>(kind: T): Token<T>;
function createModifiersFromModifierFlags(flags: ModifierFlags): Modifier[];
function createQualifiedName(left: EntityName, right: string | Identifier): QualifiedName;
function updateQualifiedName(node: QualifiedName, left: EntityName, right: Identifier): QualifiedName;
function createComputedPropertyName(expression: Expression): ComputedPropertyName;
@@ -3647,7 +3652,7 @@ declare namespace ts {
function updateSpreadAssignment(node: SpreadAssignment, expression: Expression): SpreadAssignment;
function createEnumMember(name: string | PropertyName, initializer?: Expression): EnumMember;
function updateEnumMember(node: EnumMember, name: PropertyName, initializer: Expression | undefined): EnumMember;
function updateSourceFileNode(node: SourceFile, statements: ReadonlyArray<Statement>): SourceFile;
function updateSourceFileNode(node: SourceFile, statements: ReadonlyArray<Statement>, isDeclarationFile?: boolean, referencedFiles?: SourceFile["referencedFiles"], typeReferences?: SourceFile["typeReferenceDirectives"]): SourceFile;
/**
* Creates a shallow, memberwise clone of a node for mutation.
*/
@@ -4557,7 +4562,7 @@ declare namespace ts {
none = "none",
definition = "definition",
reference = "reference",
writtenReference = "writtenReference",
writtenReference = "writtenReference"
}
interface HighlightSpan {
fileName?: string;
@@ -4579,7 +4584,7 @@ declare namespace ts {
enum IndentStyle {
None = 0,
Block = 1,
Smart = 2,
Smart = 2
}
interface EditorOptions {
BaseIndentSize?: number;
@@ -4674,7 +4679,7 @@ declare namespace ts {
typeParameterName = 18,
enumMemberName = 19,
functionName = 20,
regularExpressionLiteral = 21,
regularExpressionLiteral = 21
}
interface SymbolDisplayPart {
text: string;
@@ -4785,7 +4790,7 @@ declare namespace ts {
enum OutputFileType {
JavaScript = 0,
SourceMap = 1,
Declaration = 2,
Declaration = 2
}
enum EndOfLineState {
None = 0,
@@ -4794,7 +4799,7 @@ declare namespace ts {
InDoubleQuoteStringLiteral = 3,
InTemplateHeadOrNoSubstitutionTemplate = 4,
InTemplateMiddleOrTail = 5,
InTemplateSubstitutionPosition = 6,
InTemplateSubstitutionPosition = 6
}
enum TokenClass {
Punctuation = 0,
@@ -4805,7 +4810,7 @@ declare namespace ts {
Identifier = 5,
NumberLiteral = 6,
StringLiteral = 7,
RegExpLiteral = 8,
RegExpLiteral = 8
}
interface ClassificationResult {
finalLexState: EndOfLineState;
@@ -4904,7 +4909,7 @@ declare namespace ts {
/**
* <JsxTagName attribute1 attribute2={0} />
*/
jsxAttribute = "JSX attribute",
jsxAttribute = "JSX attribute"
}
enum ScriptElementKindModifier {
none = "",
@@ -4915,7 +4920,7 @@ declare namespace ts {
ambientModifier = "declare",
staticModifier = "static",
abstractModifier = "abstract",
optionalModifier = "optional",
optionalModifier = "optional"
}
enum ClassificationTypeNames {
comment = "comment",
@@ -4940,7 +4945,7 @@ declare namespace ts {
jsxSelfClosingTagName = "jsx self closing tag name",
jsxAttribute = "jsx attribute",
jsxText = "jsx text",
jsxAttributeStringLiteralValue = "jsx attribute string literal value",
jsxAttributeStringLiteralValue = "jsx attribute string literal value"
}
enum ClassificationType {
comment = 1,
@@ -4966,7 +4971,7 @@ declare namespace ts {
jsxSelfClosingTagName = 21,
jsxAttribute = 22,
jsxText = 23,
jsxAttributeStringLiteralValue = 24,
jsxAttributeStringLiteralValue = 24
}
}
declare namespace ts {
+5 -8
View File
@@ -220,11 +220,10 @@ declare class a {
x: number;
y: number;
};
private static d2();
private static d2;
private static readonly p3;
private pv3;
private foo(n);
private foo(s);
private foo;
}
declare class b extends a {
}
@@ -259,13 +258,11 @@ declare class aAmbient {
static d2(): any;
static p3: any;
private pv3;
private foo(s);
private foo;
}
declare class d {
private foo(n);
private foo(s);
private foo;
}
declare class e {
private foo(s);
private foo(n);
private foo;
}
+1 -1
View File
@@ -187,7 +187,7 @@ declare var i7_c: typeof c7;
*/
declare class c8 {
/** s1 comment */
static s1: number;
static s1: number; /** s1 comment2 */
/** constructor comment
*/
constructor();
@@ -491,7 +491,7 @@ declare class c1 {
/** pp1 is property of c1*/
private pp1;
/** sum with property*/
private pp2(/** number to add*/ b);
private pp2;
/** getter property*/
/** setter property*/
private pp3;
@@ -508,7 +508,7 @@ declare class c1 {
nc_p2(b: number): number;
nc_p3: number;
private nc_pp1;
private nc_pp2(b);
private nc_pp2;
private nc_pp3;
static nc_s1: number;
static nc_s2(b: number): number;
@@ -517,7 +517,7 @@ declare class c1 {
a_p2(b: number): number;
a_p3: number;
private a_pp1;
private a_pp2(b);
private a_pp2;
private a_pp3;
static a_s1: number;
static a_s2(b: number): number;
@@ -532,7 +532,7 @@ declare class c1 {
/** pp1 is property of c1 */
private b_pp1;
/** sum with property */
private b_pp2(b);
private b_pp2;
/** getter property */
/** setter property */
private b_pp3;
+1 -1
View File
@@ -30,6 +30,6 @@ declare enum Colors {
/** Fancy name for 'blue'*/
Cornflower = 0,
/** Fancy name for 'pink'*/
FancyPink = 1,
FancyPink = 1
}
declare var x: Colors;
@@ -104,8 +104,8 @@ function foo2() {
declare function foo(): void;
/** This is comment for function signature*/
declare function fooWithParameters(/** this is comment about a*/ a: string,
/** this is comment for b*/
b: number): void;
/** this is comment for b*/
b: number): void;
/** fooFunc
* comment
*/
@@ -115,6 +115,6 @@ declare var lambddaNoVarComment: (a: number, b: number) => number;
declare function blah(a: string): void;
declare function blah2(a: string): void;
declare function blah3(a: string): void;
declare function blah4(a: string, b: string): void;
declare function blah4(/*1*/ a: string, /*3*/ b: string): void;
declare function foo1(): void;
declare function foo2(): void;
@@ -38,7 +38,7 @@ function compare(a, b) {
declare class C</**docComment for type parameter*/ T> {
method</**docComment of method type parameter */ U extends T>(a: U): void;
static staticmethod</**docComment of method type parameter */ U>(a: U): void;
private privatemethod</**docComment of method type parameter */ U>(a);
private static privatestaticmethod</**docComment of method type parameter */ U>(a);
private privatemethod;
private static privatestaticmethod;
}
declare function compare</**type*/ T>(a: T, b: T): boolean;
@@ -169,6 +169,6 @@ declare var x: any;
declare const enum color {
red = 0,
green = 1,
blue = 2,
blue = 2
}
declare var shade: color;
@@ -178,7 +178,7 @@ interface i1 {
/**indexer property*/
[a: number]: string;
/** function property;*/
myFoo(a: number): string;
myFoo(/*param prop*/ a: number): string;
/** prop*/
prop: string;
}
@@ -8,5 +8,4 @@ var v;
//// [computedPropertyNamesDeclarationEmit4_ES5.d.ts]
declare var v: {
};
declare var v: {};
@@ -8,5 +8,4 @@ var v;
//// [computedPropertyNamesDeclarationEmit4_ES6.d.ts]
declare var v: {
};
declare var v: {};
+1 -1
View File
@@ -29,5 +29,5 @@ declare const enum E {
d = -13,
f = 20,
g = 20,
h = 10,
h = 10
}
+1 -1
View File
@@ -27,5 +27,5 @@ declare const enum D {
d = 10,
e,
f,
g,
g
}
@@ -18,10 +18,10 @@ const enum E2 {
declare const enum E {
A = 1,
B = 2,
C = 3,
C = 3
}
declare const enum E2 {
A = 1,
B = 2,
C = 3,
C = 3
}
@@ -54,7 +54,7 @@ declare const enum G {
A = 1,
B = 2,
C = 3,
D = 2,
D = 2
}
declare var o: {
[idx: number]: boolean;
@@ -37,7 +37,7 @@ declare const enum G {
A = 1,
B = 2,
C = 3,
D = 2,
D = 2
}
declare var z: typeof G;
declare var z1: any;
@@ -78,8 +78,8 @@ export interface ICallSignature {
export interface ICallSignatureWithParameters {
/** This is comment for function signature*/
(/** this is comment about a*/ a: string,
/** this is comment for b*/
b: number): void;
/** this is comment for b*/
b: number): void;
}
export interface ICallSignatureWithRestParameters {
(a: string, ...rests: string[]): string;
@@ -103,8 +103,8 @@ interface IGlobalCallSignature {
interface IGlobalCallSignatureWithParameters {
/** This is comment for function signature*/
(/** this is comment about a*/ a: string,
/** this is comment for b*/
b: number): void;
/** this is comment for b*/
b: number): void;
}
interface IGlobalCallSignatureWithRestParameters {
(a: string, ...rests: string[]): string;
@@ -78,8 +78,8 @@ export interface IConstructSignature {
export interface IConstructSignatureWithParameters {
/** This is comment for function signature*/
new (/** this is comment about a*/ a: string,
/** this is comment for b*/
b: number): any;
/** this is comment for b*/
b: number): any;
}
export interface IConstructSignatureWithRestParameters {
new (a: string, ...rests: string[]): string;
@@ -103,8 +103,8 @@ interface IGlobalConstructSignature {
interface IGlobalConstructSignatureWithParameters {
/** This is comment for function signature*/
new (/** this is comment about a*/ a: string,
/** this is comment for b*/
b: number): any;
/** this is comment for b*/
b: number): any;
}
interface IGlobalConstructSignatureWithRestParameters {
new (a: string, ...rests: string[]): string;
@@ -228,8 +228,8 @@ export declare class SimpleConstructor {
export declare class ConstructorWithParameters {
/** This is comment for function signature*/
constructor(/** this is comment about a*/ a: string,
/** this is comment for b*/
b: number);
/** this is comment for b*/
b: number);
}
export declare class ConstructorWithRestParamters {
constructor(a: string, ...rests: string[]);
@@ -247,7 +247,7 @@ export declare class ConstructorWithPrivateParameterProperty {
constructor(x: string);
}
export declare class ConstructorWithOptionalParameterProperty {
x: string;
x?: string;
constructor(x?: string);
}
export declare class ConstructorWithParameterInitializer {
@@ -262,8 +262,8 @@ declare class GlobalSimpleConstructor {
declare class GlobalConstructorWithParameters {
/** This is comment for function signature*/
constructor(/** this is comment about a*/ a: string,
/** this is comment for b*/
b: number);
/** this is comment for b*/
b: number);
}
declare class GlobalConstructorWithRestParamters {
constructor(a: string, ...rests: string[]);
@@ -281,7 +281,7 @@ declare class GlobalConstructorWithPrivateParameterProperty {
constructor(x: string);
}
declare class GlobalConstructorWithOptionalParameterProperty {
x: string;
x?: string;
constructor(x?: string);
}
declare class GlobalConstructorWithParameterInitializer {
@@ -20,6 +20,6 @@ var x = e;
declare enum e {
a = 0,
b = 1,
c = 2,
c = 2
}
declare var x: typeof e;
+5 -5
View File
@@ -75,28 +75,28 @@ var e5;
declare enum e1 {
a = 0,
b = 1,
c = 2,
c = 2
}
declare enum e2 {
a = 10,
b = 12,
c = 10,
c = 10
}
declare enum e3 {
a = 10,
b,
c = 13,
c = 13
}
declare enum e4 {
a = 0,
b = 1,
c = 2,
d = 10,
e = 11,
e = 11
}
declare enum e5 {
"Friday" = 0,
"Saturday" = 1,
"Sunday" = 2,
"Weekend days" = 3,
"Weekend days" = 3
}
@@ -16,6 +16,5 @@ var C = /** @class */ (function () {
//// [declFileForClassWithPrivateOverloadedFunction.d.ts]
declare class C {
private foo(x);
private foo(x);
private foo;
}
@@ -172,8 +172,8 @@ function globalfooWithOverloads(a) {
export declare function foo(): void;
/** This is comment for function signature*/
export declare function fooWithParameters(/** this is comment about a*/ a: string,
/** this is comment for b*/
b: number): void;
/** this is comment for b*/
b: number): void;
export declare function fooWithRestParameters(a: string, ...rests: string[]): string;
export declare function fooWithOverloads(a: string): string;
export declare function fooWithOverloads(a: number): number;
@@ -187,8 +187,8 @@ export declare function fooWithTypeTypePredicateAndRestParam(a: any, ...rest: an
declare function globalfoo(): void;
/** This is comment for function signature*/
declare function globalfooWithParameters(/** this is comment about a*/ a: string,
/** this is comment for b*/
b: number): void;
/** this is comment for b*/
b: number): void;
declare function globalfooWithRestParameters(a: string, ...rests: string[]): string;
declare function globalfooWithOverloads(a: string): string;
declare function globalfooWithOverloads(a: number): number;
@@ -117,7 +117,7 @@ declare module templa.dom.mvc {
}
}
declare module templa.dom.mvc {
class AbstractElementController<ModelType extends templa.mvc.IModel> extends templa.mvc.AbstractController<ModelType> implements IElementController<ModelType> {
class AbstractElementController<ModelType extends templa.mvc.IModel> extends templa.mvc.AbstractController<ModelType> implements IElementController<ModelType> {
constructor();
}
}
+28 -40
View File
@@ -364,46 +364,40 @@ export declare class c1 {
foo(): void;
/** This is comment for function signature*/
fooWithParameters(/** this is comment about a*/ a: string,
/** this is comment for b*/
b: number): void;
/** this is comment for b*/
b: number): void;
fooWithRestParameters(a: string, ...rests: string[]): string;
fooWithOverloads(a: string): string;
fooWithOverloads(a: number): number;
/** This comment should appear for privateFoo*/
private privateFoo();
private privateFoo;
/** This is comment for function signature*/
private privateFooWithParameters(/** this is comment about a*/ a,
/** this is comment for b*/
b);
private privateFooWithRestParameters(a, ...rests);
private privateFooWithOverloads(a);
private privateFooWithOverloads(a);
private privateFooWithParameters;
private privateFooWithRestParameters;
private privateFooWithOverloads;
/** This comment should appear for static foo*/
static staticFoo(): void;
/** This is comment for function signature*/
static staticFooWithParameters(/** this is comment about a*/ a: string,
/** this is comment for b*/
b: number): void;
/** this is comment for b*/
b: number): void;
static staticFooWithRestParameters(a: string, ...rests: string[]): string;
static staticFooWithOverloads(a: string): string;
static staticFooWithOverloads(a: number): number;
/** This comment should appear for privateStaticFoo*/
private static privateStaticFoo();
private static privateStaticFoo;
/** This is comment for function signature*/
private static privateStaticFooWithParameters(/** this is comment about a*/ a,
/** this is comment for b*/
b);
private static privateStaticFooWithRestParameters(a, ...rests);
private static privateStaticFooWithOverloads(a);
private static privateStaticFooWithOverloads(a);
private static privateStaticFooWithParameters;
private static privateStaticFooWithRestParameters;
private static privateStaticFooWithOverloads;
}
export interface I1 {
/** This comment should appear for foo*/
foo(): string;
/** This is comment for function signature*/
fooWithParameters(/** this is comment about a*/ a: string,
/** this is comment for b*/
b: number): void;
/** this is comment for b*/
b: number): void;
fooWithRestParameters(a: string, ...rests: string[]): string;
fooWithOverloads(a: string): string;
fooWithOverloads(a: number): number;
@@ -414,46 +408,40 @@ declare class c2 {
foo(): void;
/** This is comment for function signature*/
fooWithParameters(/** this is comment about a*/ a: string,
/** this is comment for b*/
b: number): void;
/** this is comment for b*/
b: number): void;
fooWithRestParameters(a: string, ...rests: string[]): string;
fooWithOverloads(a: string): string;
fooWithOverloads(a: number): number;
/** This comment should appear for privateFoo*/
private privateFoo();
private privateFoo;
/** This is comment for function signature*/
private privateFooWithParameters(/** this is comment about a*/ a,
/** this is comment for b*/
b);
private privateFooWithRestParameters(a, ...rests);
private privateFooWithOverloads(a);
private privateFooWithOverloads(a);
private privateFooWithParameters;
private privateFooWithRestParameters;
private privateFooWithOverloads;
/** This comment should appear for static foo*/
static staticFoo(): void;
/** This is comment for function signature*/
static staticFooWithParameters(/** this is comment about a*/ a: string,
/** this is comment for b*/
b: number): void;
/** this is comment for b*/
b: number): void;
static staticFooWithRestParameters(a: string, ...rests: string[]): string;
static staticFooWithOverloads(a: string): string;
static staticFooWithOverloads(a: number): number;
/** This comment should appear for privateStaticFoo*/
private static privateStaticFoo();
private static privateStaticFoo;
/** This is comment for function signature*/
private static privateStaticFooWithParameters(/** this is comment about a*/ a,
/** this is comment for b*/
b);
private static privateStaticFooWithRestParameters(a, ...rests);
private static privateStaticFooWithOverloads(a);
private static privateStaticFooWithOverloads(a);
private static privateStaticFooWithParameters;
private static privateStaticFooWithRestParameters;
private static privateStaticFooWithOverloads;
}
interface I2 {
/** This comment should appear for foo*/
foo(): string;
/** This is comment for function signature*/
fooWithParameters(/** this is comment about a*/ a: string,
/** this is comment for b*/
b: number): void;
/** this is comment for b*/
b: number): void;
fooWithRestParameters(a: string, ...rests: string[]): string;
fooWithOverloads(a: string): string;
fooWithOverloads(a: number): number;
@@ -29,8 +29,8 @@ declare function makePoint(x: number): {
b: number;
x: number;
};
declare var point: {
declare var /*4*/ point: {
b: number;
x: number;
};
declare var x: number;
declare var /*2*/ x: number;
@@ -23,7 +23,7 @@ var /*2*/ x = point. /*3*/x;
declare function makePoint(x: number): {
readonly x: number;
};
declare var point: {
declare var /*4*/ point: {
readonly x: number;
};
declare var x: number;
declare var /*2*/ x: number;
@@ -25,7 +25,7 @@ declare function makePoint(x: number): {
b: number;
x: number;
};
declare var point: {
declare var /*3*/ point: {
b: number;
x: number;
};
@@ -41,13 +41,10 @@ interface IContext {
someMethod(): any;
}
declare class c1 {
private _forEachBindingContext(bindingContext, fn);
private _forEachBindingContext(bindingContextArray, fn);
private overloadWithArityDifference(bindingContext);
private overloadWithArityDifference(bindingContextArray, fn);
private _forEachBindingContext;
private overloadWithArityDifference;
}
declare class c2 {
private overload1(context, fn);
private overload2(context);
private overload2(context, fn);
private overload1;
private overload2;
}
@@ -49,7 +49,7 @@ var C = /** @class */ (function () {
declare class C {
private static x;
static y: number;
private static a();
private static a;
static b(): void;
private static readonly c;
static readonly d: number;
@@ -25,12 +25,12 @@ var f6 = function () { return [10]; };
//// [declFileRestParametersOfFunctionAndFunctionType.d.ts]
declare function f1(...args: any[]): void;
declare function f2(x: (...args) => void): void;
declare function f2(x: (...args: any[]) => void): void;
declare function f3(x: {
(...args): void;
(...args: any[]): void;
}): void;
declare function f4<T extends (...args) => void>(): void;
declare function f4<T extends (...args: any[]) => void>(): void;
declare function f5<T extends {
(...args): void;
(...args: any[]): void;
}>(): void;
declare var f6: () => any[];
@@ -37,7 +37,7 @@ declare enum days {
thursday = 3,
friday = 4,
saturday = 5,
sunday = 6,
sunday = 6
}
declare var weekendDay: days;
declare var daysOfMonth: typeof days;
@@ -58,7 +58,7 @@ declare module m1 {
enum e {
weekday = 0,
weekend = 1,
holiday = 2,
holiday = 2
}
}
declare var a: {
@@ -22,4 +22,4 @@ declare const k: ({ x: z }: {
x?: string;
}) => void;
declare var a: any;
declare function f({}?: any, []?: any, {p: {}}?: any): void;
declare function f({}?: any, []?: any, { p: {} }?: any): void;
@@ -46,10 +46,10 @@ var Foo = /** @class */ (function () {
//// [declarationEmitClassMemberNameConflict2.d.ts]
declare const Bar = "bar";
declare enum Hello {
World = 0,
World = 0
}
declare enum Hello1 {
World1 = 0,
World1 = 0
}
declare class Foo {
Bar: string;
@@ -8,5 +8,5 @@ export default class {
//// [declarationEmitDefaultExport2.d.ts]
export default class {
export default class {
}
@@ -23,12 +23,12 @@ function baz(_a) {
//// [declarationEmitDestructuring1.d.ts]
declare function foo([a, b, c]: [string, string, string]): void;
declare function far([a, [b], [[c]]]: [number, boolean[], string[][]]): void;
declare function bar({a1, b1, c1}: {
declare function bar({ a1, b1, c1 }: {
a1: number;
b1: boolean;
c1: string;
}): void;
declare function baz({a2, b2: {b1, c1}}: {
declare function baz({ a2, b2: { b1, c1 } }: {
a2: number;
b2: {
b1: boolean;
@@ -20,24 +20,24 @@ function h1(_a) {
//// [declarationEmitDestructuring2.d.ts]
declare function f({x, y: [a, b, c, d]}?: {
declare function f({ x, y: [a, b, c, d] }?: {
x?: number;
y?: [number, number, number, number];
}): void;
declare function g([a, b, c, d]?: [number, number, number, number]): void;
declare function h([a, [b], [[c]], {x, y: [a, b, c], z: {a1, b1}}]: [any, [any], [[any]], {
x?: number;
y: [any, any, any];
z: {
a1: any;
b1: any;
};
}]): void;
declare function h1([a, [b], [[c]], {x, y, z: {a1, b1}}]: [any, [any], [[any]], {
x?: number;
y?: number[];
z: {
a1: any;
b1: any;
};
}]): void;
declare function h([a, [b], [[c]], { x, y: [a, b, c], z: { a1, b1 } }]: [any, [any], [[any]], {
x?: number;
y: [any, any, any];
z: {
a1: any;
b1: any;
};
}]): void;
declare function h1([a, [b], [[c]], { x, y, z: { a1, b1 } }]: [any, [any], [[any]], {
x?: number;
y?: number[];
z: {
a1: any;
b1: any;
};
}]): void;
@@ -24,8 +24,8 @@ function bar2(_a) {
//// [declarationEmitDestructuring5.d.ts]
declare function baz([ , z, , ]: [any, any, any]): void;
declare function foo([ , b, ]: [any, any]): void;
declare function bar([z, , , ]: [any, any, any]): void;
declare function bar1([z, , , ]?: [number, number, number, number, number]): void;
declare function bar2([ , , z, , , ]: [any, any, any, any, any]): void;
declare function baz([, z, ,]: [any, any, any]): void;
declare function foo([, b,]: [any, any]): void;
declare function bar([z, , ,]: [any, any, any]): void;
declare function bar1([z, , ,]?: [number, number, number, number, number]): void;
declare function bar2([, , z, , ,]: [any, any, any, any, any]): void;
@@ -25,7 +25,7 @@ function foo2() {
//// [declarationEmitDestructuringOptionalBindingParametersInOverloads.d.ts]
declare function foo([x, y, z]?: [string, number, boolean]): any;
declare function foo2({x, y, z}?: {
declare function foo2({ x, y, z }?: {
x: string;
y: number;
z: boolean;
@@ -39,12 +39,16 @@ var C3 = /** @class */ (function () {
//// [declarationEmitDestructuringParameterProperties.d.ts]
declare class C1 {
x: string, y: string, z: string;
x: string;
y: string;
z: string;
constructor([x, y, z]: string[]);
}
declare type TupleType1 = [string, number, boolean];
declare class C2 {
x: string, y: number, z: boolean;
x: string;
y: number;
z: boolean;
constructor([x, y, z]: TupleType1);
}
declare type ObjType1 = {
@@ -53,6 +57,8 @@ declare type ObjType1 = {
z: boolean;
};
declare class C3 {
x: number, y: string, z: boolean;
constructor({x, y, z}: ObjType1);
x: number;
y: string;
z: boolean;
constructor({ x, y, z }: ObjType1);
}
@@ -15,7 +15,7 @@ function foo1(_a) {
//// [declarationEmitDestructuringWithOptionalBindingParameters.d.ts]
declare function foo([x, y, z]?: [string, number, boolean]): void;
declare function foo1({x, y, z}?: {
declare function foo1({ x, y, z }?: {
x: string;
y: number;
z: boolean;
@@ -25,7 +25,7 @@ exports.v = v;
//// [0.d.ts]
export { };
export {};
//// [1.d.ts]
declare let v: string | boolean;
export { v };
@@ -32,7 +32,7 @@ exports.bar = bar;
//// [0.d.ts]
export { };
export {};
//// [1.d.ts]
declare let v: string | boolean;
declare function bar(): string | boolean;
@@ -25,7 +25,7 @@ exports["default"] = x;
//// [0.d.ts]
export { };
export {};
//// [1.d.ts]
declare var x: string | number;
export default x;
@@ -25,7 +25,7 @@ exports.v = v;
//// [0.d.ts]
export { };
export {};
//// [1.d.ts]
declare let v: string | boolean;
export { v };
@@ -105,7 +105,7 @@ declare module M.P {
class E extends C {
}
enum D {
f = 0,
f = 0
}
var v: M.D;
var w: typeof M.D.f;
@@ -19,6 +19,6 @@ exports.Foo = Foo;
//// [declarationEmitParameterProperty.d.ts]
export declare class Foo {
bar: string | undefined;
bar?: string | undefined;
constructor(bar?: string | undefined);
}
@@ -17,8 +17,7 @@ module T.U { // This needs to be emitted
declare module M {
}
declare module M {
module R.S {
}
module R.S { }
}
declare module T.U {
}
@@ -32,11 +32,11 @@ function f2(_a) {
//// [destructureOptionalParameter.d.ts]
declare function f1({a, b}?: {
declare function f1({ a, b }?: {
a: number;
b: string;
}): void;
declare function f2({a, b}?: {
declare function f2({ a, b }?: {
a: number;
b: number;
}): void;
@@ -47,11 +47,11 @@ interface QueryMetadata {
q: void;
}
interface QueryMetadataFactory {
(selector: Type | string, {descendants, read}?: {
(selector: Type | string, { descendants, read }?: {
descendants?: boolean;
read?: any;
}): ParameterDecorator;
new (selector: Type | string, {descendants, read}?: {
new (selector: Type | string, { descendants, read }?: {
descendants?: boolean;
read?: any;
}): QueryMetadata;
@@ -40,21 +40,31 @@ interface c {
c: any;
}
declare type T1 = ([a, b, c]);
declare type F1 = ([a, b, c]) => void;
declare type F1 = ([a, b, c]: [any, any, any]) => void;
declare type T2 = ({
a;
a: any;
});
declare type F2 = ({a}) => void;
declare type F2 = ({ a }: {
a: any;
}) => void;
declare type T3 = ([{
a: b;
}, {
b: a;
}]);
declare type F3 = ([{a: b}, {b: a}]) => void;
declare type F3 = ([{ a: b }, { b: a }]: [{
a: any;
}, {
b: any;
}]) => void;
declare type T4 = ([{
a: [b, c];
}]);
declare type F4 = ([{a: [b, c]}]) => void;
declare type C1 = new ([{a: [b, c]}]) => void;
declare type F4 = ([{ a: [b, c] }]: [{
a: [any, any];
}]) => void;
declare type C1 = new ([{ a: [b, c] }]: [{
a: [any, any];
}]) => void;
declare var v1: ([a, b, c]: [any, any, any]) => string;
declare var v2: ([a, b, c]) => string;
declare var v2: ([a, b, c]: [any, any, any]) => string;
+11 -11
View File
@@ -160,28 +160,28 @@ var E20;
//// [enumClassification.d.ts]
declare enum E01 {
A = 0,
A = 0
}
declare enum E02 {
A = 123,
A = 123
}
declare enum E03 {
A = "hello",
A = "hello"
}
declare enum E04 {
A = 0,
B = 1,
C = 2,
C = 2
}
declare enum E05 {
A = 0,
B = 10,
C = 11,
C = 11
}
declare enum E06 {
A = "one",
B = "two",
C = "three",
C = "three"
}
declare enum E07 {
A = 0,
@@ -189,30 +189,30 @@ declare enum E07 {
C = "hi",
D = 10,
E = 11,
F = "bye",
F = "bye"
}
declare enum E08 {
A = 10,
B = "hello",
C = 10,
D = "hello",
E = 10,
E = 10
}
declare enum E10 {
}
declare enum E11 {
A = 0,
B = 1,
C = 2,
C = 2
}
declare enum E12 {
A = 1,
B = 2,
C = 4,
C = 4
}
declare enum E20 {
A,
B,
C,
D,
D
}
+1 -1
View File
@@ -16,6 +16,6 @@ declare module mAmbient {
enum e {
x,
y,
z,
z
}
}
@@ -17,6 +17,6 @@ exports.default = default_1;
//// [es5ExportDefaultClassDeclaration2.d.ts]
export default class {
export default class {
method(): void;
}
@@ -11,6 +11,6 @@ export default class {
//// [es6ExportDefaultClassDeclaration2.d.ts]
export default class {
export default class {
method(): void;
}
@@ -12,5 +12,5 @@ function foo(args) {
//// [functionDeclarationWithArgumentOfTypeFunctionTypeArray.d.ts]
declare function foo(args: {
(x): number;
(x: any): number;
}[]): number;
+21 -30
View File
@@ -1118,14 +1118,14 @@ export declare class eC {
pV: any;
private rV;
pF(): void;
private rF();
private rF;
pgF(): void;
readonly pgF: any;
psF(param: any): void;
psF: any;
private rgF();
private rgF;
private readonly rgF;
private rsF(param);
private rsF;
private rsF;
static tV: any;
static tF(): void;
@@ -1170,14 +1170,14 @@ export declare module eM {
pV: any;
private rV;
pF(): void;
private rF();
private rF;
pgF(): void;
readonly pgF: any;
psF(param: any): void;
psF: any;
private rgF();
private rgF;
private readonly rgF;
private rsF(param);
private rsF;
private rsF;
static tV: any;
static tF(): void;
@@ -1221,14 +1221,12 @@ export declare module eM {
}
interface eI {
}
module eM {
}
module eM { }
var eaV: any;
function eaF(): void;
class eaC {
}
module eaM {
}
module eaM { }
}
var eaV: any;
function eaF(): void;
@@ -1237,14 +1235,14 @@ export declare module eM {
pV: any;
private rV;
pF(): void;
private rF();
private rF;
pgF(): void;
readonly pgF: any;
psF(param: any): void;
psF: any;
private rgF();
private rgF;
private readonly rgF;
private rsF(param);
private rsF;
private rsF;
static tV: any;
static tF(): void;
@@ -1260,16 +1258,14 @@ export declare module eM {
}
interface I {
}
module M {
}
module M { }
var eV: any;
function eF(): void;
class eC {
}
interface eI {
}
module eM {
}
module eM { }
}
}
export declare var eaV: any;
@@ -1279,14 +1275,14 @@ export declare class eaC {
pV: any;
private rV;
pF(): void;
private rF();
private rF;
pgF(): void;
readonly pgF: any;
psF(param: any): void;
psF: any;
private rgF();
private rgF;
private readonly rgF;
private rsF(param);
private rsF;
private rsF;
static tV: any;
static tF(): void;
@@ -1340,22 +1336,19 @@ export declare module eaM {
}
interface I {
}
module M {
}
module M { }
var eV: any;
function eF(): void;
class eC {
}
interface eI {
}
module eM {
}
module eM { }
var eaV: any;
function eaF(): void;
class eaC {
}
module eaM {
}
module eaM { }
}
var eV: any;
function eF(): void;
@@ -1400,15 +1393,13 @@ export declare module eaM {
function F(): void;
class C {
}
module M {
}
module M { }
var eV: any;
function eF(): void;
class eC {
}
interface eI {
}
module eM {
}
module eM { }
}
}
@@ -55,7 +55,7 @@ declare namespace My.Internal {
const enum WhichThing {
A = 0,
B = 1,
C = 2,
C = 2
}
}
//// [usage.d.ts]
@@ -35,7 +35,7 @@ declare module a {
enum weekend {
Friday = 0,
Saturday = 1,
Sunday = 2,
Sunday = 2
}
}
declare module c {
@@ -37,7 +37,7 @@ export declare module a {
enum weekend {
Friday = 0,
Saturday = 1,
Sunday = 2,
Sunday = 2
}
}
export declare module c {
@@ -37,7 +37,7 @@ export declare module a {
enum weekend {
Friday = 0,
Saturday = 1,
Sunday = 2,
Sunday = 2
}
}
export declare module c {
@@ -34,7 +34,7 @@ export declare module a {
enum weekend {
Friday = 0,
Saturday = 1,
Sunday = 2,
Sunday = 2
}
}
export import b = a.weekend;
@@ -34,7 +34,7 @@ export declare module a {
enum weekend {
Friday = 0,
Saturday = 1,
Sunday = 2,
Sunday = 2
}
}
import b = a.weekend;
@@ -29,6 +29,7 @@ function foo() {
//// [out.d.ts]
/// <reference path="tests/cases/compiler/c.js" />
declare class c {
}
declare function foo(): void;
@@ -18,6 +18,6 @@ define(["require", "exports", "./folder/test"], function (require, exports) {
//// [test.d.ts]
export { };
export {};
//// [main.d.ts]
import "./folder/test";
@@ -18,7 +18,7 @@ define("app/main", ["require", "exports", "test"], function (require, exports) {
//// [outputfile.d.ts]
declare module "test" {
export { };
export {};
}
declare module "app/main" {
import "test";
@@ -18,7 +18,7 @@ define("main", ["require", "exports", "folder/test"], function (require, exports
//// [outputfile.d.ts]
declare module "folder/test" {
export { };
export {};
}
declare module "main" {
import "folder/test";
@@ -976,7 +976,7 @@ declare type NumericallyIndexed<T> = {
declare const enum E {
A = 0,
B = 1,
C = 2,
C = 2
}
declare type K00 = keyof any;
declare type K01 = keyof string;
@@ -39,7 +39,7 @@ export declare class A {
}
//// [f2.d.ts]
import { A } from "./f1";
declare global {
declare global {
interface Array<T> {
getA(): A;
}
@@ -37,7 +37,7 @@ var y = x.getCountAsString().toLowerCase();
export declare class A {
}
//// [f2.d.ts]
declare global {
declare global {
interface Array<T> {
getCountAsString(): string;
}
@@ -44,7 +44,7 @@ var y = x.getCountAsString().toLowerCase();
export declare class A {
}
//// [f2.d.ts]
declare global {
declare global {
interface Array<T> {
getCountAsString(): string;
}
@@ -30,19 +30,19 @@ require("./f2");
//// [f1.d.ts]
declare global {
declare global {
interface Something {
x: any;
}
}
export { };
export {};
//// [f2.d.ts]
declare global {
declare global {
interface Something {
y: any;
}
}
export { };
export {};
//// [f3.d.ts]
import "./f1";
import "./f2";
@@ -48,7 +48,7 @@ export { Account2 as Acc };
//// [index.d.ts]
export * from "./account";
//// [index.d.ts]
declare global {
declare global {
interface Account {
someProp: number;
}
@@ -33,8 +33,7 @@ declare module A {
}
//// [B.d.ts]
/// <reference path="A.d.ts" />
declare module A {
}
declare module A { }
declare module B {
function f(): A.I;
}
+5 -5
View File
@@ -451,12 +451,12 @@ declare module "m3" {
}
declare module exportTests {
class C1_public {
private f2();
private f2;
f3(): string;
}
class C3_public {
private getC2_private();
private setC2_private(arg);
private getC2_private;
private setC2_private;
private readonly c2;
getC1_public(): C1_public;
setC1_public(arg: C1_public): void;
@@ -476,7 +476,7 @@ declare module mAmbient {
enum e {
x,
y,
z,
z
}
module m3 {
class C {
@@ -491,7 +491,7 @@ declare module mAmbient {
enum e {
x,
y,
z,
z
}
}
}
Loaded 100 of 124 files, more files were not shown because too many files have changed in this diff. Show more