Skip to content

Commit

Permalink
Slight cleanup from code review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
weswigham committed Feb 21, 2018
1 parent 4c639b8 commit 53571a7
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
8 changes: 4 additions & 4 deletions src/compiler/comments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,10 @@ namespace ts {
}
}

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;
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;
}

function shouldWriteComment(text: string, pos: number) {
Expand Down
9 changes: 5 additions & 4 deletions src/compiler/emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ namespace ts {
}

/*@internal*/
export function getOutputPathsFor(sourceFile: SourceFile | Bundle, host: EmitHost, forceDtsPaths?: boolean) {
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;
Expand Down Expand Up @@ -129,7 +129,8 @@ namespace ts {
let declarationPrinter: Printer;
if (emitOnlyDtsFiles || compilerOptions.declaration) {
const nonJsFiles = filter(sourceFiles, isSourceFileNotJavaScript);
declarationTransform = transformNodes(resolver, host, compilerOptions, (compilerOptions.outFile || compilerOptions.out) ? [createBundle(nonJsFiles)] : nonJsFiles, [transformDeclarations], /*allowDtsFiles*/ false);
const inputListOrBundle = (compilerOptions.outFile || compilerOptions.out) ? [createBundle(nonJsFiles)] : nonJsFiles;
declarationTransform = transformNodes(resolver, host, compilerOptions, inputListOrBundle, [transformDeclarations], /*allowDtsFiles*/ false);
declarationPrinter = createPrinter({ ...compilerOptions, onlyPrintJsDocStyle: true } as PrinterOptions, {
// resolver hooks
hasGlobalName: resolver.hasGlobalName,
Expand Down Expand Up @@ -182,9 +183,9 @@ namespace ts {
return getOriginalNode(n) === getOriginalNode(sourceFileOrBundle);
});
if (associatedDeclarationTree) {
const previousState = sourceMap.setDisabled(true);
const previousState = sourceMap.setState(/*disabled*/ true);
printSourceFileOrBundle(declarationFilePath, /*sourceMapFilePath*/ undefined, associatedDeclarationTree, declarationPrinter, /*shouldSkipSourcemap*/ true);
sourceMap.setDisabled(previousState);
sourceMap.setState(previousState);
}
else {
Debug.fail(`No declaration output found for path "${declarationFilePath}" for js output file: "${jsFilePath}".`);
Expand Down
6 changes: 3 additions & 3 deletions src/compiler/sourcemap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ namespace ts {
/**
* @returns the previous disabled state
*/
setDisabled(state: boolean): boolean;
setState(disabled: boolean): boolean;
}

// Used for initialize lastEncodedSourceMapSpan and reset lastEncodedSourceMapSpan when updateLastEncodedAndRecordedSpans
Expand Down Expand Up @@ -112,10 +112,10 @@ namespace ts {
emitTokenWithSourceMap,
getText,
getSourceMappingURL,
setDisabled,
setState,
};

function setDisabled(state: boolean) {
function setState(state: boolean) {
const last = disabled;
disabled = state;
return last;
Expand Down
8 changes: 4 additions & 4 deletions src/compiler/transformers/declarations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ namespace ts {
possibleImports = undefined;
importDeclarationMap = createMap();
necessaryTypeRefernces = undefined;
const refs = collectReferences(currentSourceFile);
const refs = collectReferences(currentSourceFile, createMap());
const references: FileReference[] = [];
const outputFilePath = getDirectoryPath(normalizeSlashes(getOutputPathsFor(node, host, /*forceDtsPaths*/ true).declarationFilePath));
const referenceVisitor = mapReferencesIntoArray(references, outputFilePath);
Expand Down Expand Up @@ -234,7 +234,7 @@ namespace ts {
}
}

function collectReferences(sourceFile: SourceFile, ret = createMap<SourceFile>()) {
function collectReferences(sourceFile: SourceFile, ret: Map<SourceFile>) {
if (noResolve || isSourceFileJavaScript(sourceFile)) return ret;
forEach(sourceFile.referencedFiles, f => {
const elem = tryResolveScriptReference(host, sourceFile, f);
Expand Down Expand Up @@ -797,7 +797,7 @@ namespace ts {

switch (input.kind) {
case SyntaxKind.ExportDeclaration: {
if (!resultHasExternalModuleIndicator && isSourceFile(input.parent)) {
if (isSourceFile(input.parent)) {
resultHasExternalModuleIndicator = true;
}
// Always visible if the parent node isn't dropped for being not visible
Expand All @@ -806,7 +806,7 @@ namespace ts {
}
case SyntaxKind.ExportAssignment: {
// Always visible if the parent node isn't dropped for being not visible
if (!resultHasExternalModuleIndicator && isSourceFile(input.parent)) {
if (isSourceFile(input.parent)) {
resultHasExternalModuleIndicator = true;
}
if (input.expression.kind === SyntaxKind.Identifier) {
Expand Down

0 comments on commit 53571a7

Please sign in to comment.