PR feedback, switched to getEmitScriptTarget/getEmitModuleKind
This commit is contained in:
parent
8ec393244b
commit
357171fb7c
3 changed files with 5 additions and 21 deletions
|
@ -140,12 +140,12 @@ namespace ts {
|
||||||
function emitLeadingComments(range: TextRange, leadingComments: CommentRange[] = getLeadingCommentsToEmit(range)) {
|
function emitLeadingComments(range: TextRange, leadingComments: CommentRange[] = getLeadingCommentsToEmit(range)) {
|
||||||
emitNewLineBeforeLeadingComments(currentLineMap, writer, range, leadingComments);
|
emitNewLineBeforeLeadingComments(currentLineMap, writer, range, leadingComments);
|
||||||
|
|
||||||
// Leading comments are emitted at /*leading comment1 */space/*leading comment*/space
|
// Leading comments are emitted as `/*leading comment1 */space/*leading comment*/space`
|
||||||
emitComments(currentText, currentLineMap, writer, leadingComments, /*trailingSeparator*/ true, newLine, writeComment);
|
emitComments(currentText, currentLineMap, writer, leadingComments, /*trailingSeparator*/ true, newLine, writeComment);
|
||||||
}
|
}
|
||||||
|
|
||||||
function emitTrailingComments(range: TextRange, trailingComments = getTrailingCommentsToEmit(range)) {
|
function emitTrailingComments(range: TextRange, trailingComments = getTrailingCommentsToEmit(range)) {
|
||||||
// trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/
|
// Trailing comments are emitted as `space/*trailing comment1 */space/*trailing comment*/`
|
||||||
emitComments(currentText, currentLineMap, writer, trailingComments, /*trailingSeparator*/ false, newLine, writeComment);
|
emitComments(currentText, currentLineMap, writer, trailingComments, /*trailingSeparator*/ false, newLine, writeComment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,7 +182,7 @@ namespace ts {
|
||||||
// get the leading comments from detachedPos
|
// get the leading comments from detachedPos
|
||||||
const pos = lastOrUndefined(detachedCommentsInfo).detachedCommentEndPos;
|
const pos = lastOrUndefined(detachedCommentsInfo).detachedCommentEndPos;
|
||||||
const leadingComments = getLeadingCommentRanges(currentText, pos);
|
const leadingComments = getLeadingCommentRanges(currentText, pos);
|
||||||
if (detachedCommentsInfo.length - 1) {
|
if (detachedCommentsInfo.length > 1) {
|
||||||
detachedCommentsInfo.pop();
|
detachedCommentsInfo.pop();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -76,8 +76,8 @@ function __export(m) {
|
||||||
})`;
|
})`;
|
||||||
|
|
||||||
const compilerOptions = host.getCompilerOptions();
|
const compilerOptions = host.getCompilerOptions();
|
||||||
const languageVersion = getLanguageVersion(compilerOptions);
|
const languageVersion = getEmitScriptTarget(compilerOptions);
|
||||||
const moduleKind = getModuleKind(compilerOptions);
|
const moduleKind = getEmitModuleKind(compilerOptions);
|
||||||
const sourceMapDataList: SourceMapData[] = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? [] : undefined;
|
const sourceMapDataList: SourceMapData[] = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? [] : undefined;
|
||||||
const emitterDiagnostics = createDiagnosticCollection();
|
const emitterDiagnostics = createDiagnosticCollection();
|
||||||
|
|
||||||
|
|
|
@ -102,22 +102,6 @@ namespace ts {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getLanguageVersion(compilerOptions: CompilerOptions) {
|
|
||||||
return compilerOptions.target || ScriptTarget.ES3;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getModuleKind(compilerOptions: CompilerOptions) {
|
|
||||||
if (compilerOptions.module) {
|
|
||||||
return compilerOptions.module;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getLanguageVersion(compilerOptions) === ScriptTarget.ES6) {
|
|
||||||
return ModuleKind.ES6;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ModuleKind.None;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function hasResolvedModule(sourceFile: SourceFile, moduleNameText: string): boolean {
|
export function hasResolvedModule(sourceFile: SourceFile, moduleNameText: string): boolean {
|
||||||
return sourceFile.resolvedModules && hasProperty(sourceFile.resolvedModules, moduleNameText);
|
return sourceFile.resolvedModules && hasProperty(sourceFile.resolvedModules, moduleNameText);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue