mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
PR Feedback
This commit is contained in:
@@ -461,7 +461,7 @@ namespace ts {
|
||||
emitSyntheticTripleSlashReferencesIfNeeded(bundle);
|
||||
|
||||
for (const prepend of bundle.prepends) {
|
||||
writeSignificantLine();
|
||||
writeLine();
|
||||
print(EmitHint.Unspecified, prepend, /*sourceFile*/ undefined);
|
||||
}
|
||||
|
||||
@@ -2613,7 +2613,7 @@ namespace ts {
|
||||
// generated line. Until we can rework the source map support in the test
|
||||
// harness, ensure each source file is on a new line, even when using a
|
||||
// whitespace-removing writer.
|
||||
writeSignificantLine();
|
||||
writeLine();
|
||||
const statements = node.statements;
|
||||
if (emitBodyWithDetachedComments) {
|
||||
// Emit detached comment if there are no prologue directives or if the first node is synthesized.
|
||||
@@ -3111,12 +3111,6 @@ namespace ts {
|
||||
writer.writeProperty(s);
|
||||
}
|
||||
|
||||
function writeSignificantLine() {
|
||||
// writer.flush();
|
||||
// if (!writer.isAtStartOfLine()) writer.rawWrite(newLine);
|
||||
writeLine();
|
||||
}
|
||||
|
||||
function writeLine() {
|
||||
writer.writeLine();
|
||||
}
|
||||
|
||||
@@ -655,12 +655,12 @@ namespace ts {
|
||||
&& typeof x.file === "string"
|
||||
&& typeof x.mappings === "string"
|
||||
&& isArray(x.sources) && every(x.sources, isString)
|
||||
&& (x.sourceRoot === undefined || typeof x.sourceRoot === "string")
|
||||
&& (x.sourcesContent === undefined || isArray(x.sourcesContent) && every(x.sourcesContent, isStringOrNull))
|
||||
&& (x.names === undefined || isArray(x.names) && every(x.names, isString));
|
||||
&& (x.sourceRoot === undefined || x.sourceRoot === null || typeof x.sourceRoot === "string")
|
||||
&& (x.sourcesContent === undefined || x.sourcesContent === null || isArray(x.sourcesContent) && every(x.sourcesContent, isStringOrNull))
|
||||
&& (x.names === undefined || x.names === null || isArray(x.names) && every(x.names, isString));
|
||||
}
|
||||
|
||||
function tryParseRawSourceMap(text: string) {
|
||||
export function tryParseRawSourceMap(text: string) {
|
||||
try {
|
||||
const parsed = JSON.parse(text);
|
||||
if (isRawSourceMap(parsed)) {
|
||||
@@ -673,6 +673,7 @@ namespace ts {
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const base64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
|
||||
function base64FormatEncode(inValue: number) {
|
||||
|
||||
@@ -30,16 +30,6 @@ namespace ts {
|
||||
|
||||
/* @internal */
|
||||
namespace ts.sourcemaps {
|
||||
export interface SourceMapData {
|
||||
version?: number;
|
||||
file?: string;
|
||||
sourceRoot?: string;
|
||||
sources: string[];
|
||||
sourcesContent?: (string | null)[];
|
||||
names?: string[];
|
||||
mappings: string;
|
||||
}
|
||||
|
||||
export interface SourceMappableLocation {
|
||||
fileName: string;
|
||||
position: number;
|
||||
@@ -59,7 +49,7 @@ namespace ts.sourcemaps {
|
||||
log(text: string): void;
|
||||
}
|
||||
|
||||
export function decode(host: SourceMapDecodeHost, mapPath: string, map: SourceMapData, program?: Program, fallbackCache = createSourceFileLikeCache(host)): SourceMapper {
|
||||
export function decode(host: SourceMapDecodeHost, mapPath: string, map: RawSourceMap, program?: Program, fallbackCache = createSourceFileLikeCache(host)): SourceMapper {
|
||||
const currentDirectory = getDirectoryPath(mapPath);
|
||||
const sourceRoot = map.sourceRoot || currentDirectory;
|
||||
let decodedMappings: ProcessedSourceMapPosition[];
|
||||
@@ -156,7 +146,7 @@ namespace ts.sourcemaps {
|
||||
}
|
||||
|
||||
/*@internal*/
|
||||
export function decodeMappings(map: SourceMapData): MappingsDecoder {
|
||||
export function decodeMappings(map: RawSourceMap): MappingsDecoder {
|
||||
const state: DecoderState = {
|
||||
encodedText: map.mappings,
|
||||
currentNameIndex: undefined,
|
||||
@@ -190,7 +180,7 @@ namespace ts.sourcemaps {
|
||||
};
|
||||
}
|
||||
|
||||
function calculateDecodedMappings<T>(map: SourceMapData, processPosition: (position: RawSourceMapPosition) => T, host?: { log?(s: string): void }): T[] {
|
||||
function calculateDecodedMappings<T>(map: RawSourceMap, processPosition: (position: RawSourceMapPosition) => T, host?: { log?(s: string): void }): T[] {
|
||||
const decoder = decodeMappings(map);
|
||||
const positions = arrayFrom(decoder, processPosition);
|
||||
if (decoder.error) {
|
||||
|
||||
@@ -5293,11 +5293,11 @@ namespace ts {
|
||||
export interface RawSourceMap {
|
||||
version: 3;
|
||||
file: string;
|
||||
sourceRoot?: string;
|
||||
sourceRoot?: string | null;
|
||||
sources: string[];
|
||||
sourcesContent?: (string | null)[];
|
||||
sourcesContent?: (string | null)[] | null;
|
||||
mappings: string;
|
||||
names?: string[];
|
||||
names?: string[] | null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -41,14 +41,8 @@ namespace ts {
|
||||
}
|
||||
|
||||
function convertDocumentToSourceMapper(file: { sourceMapper?: sourcemaps.SourceMapper }, contents: string, mapFileName: string) {
|
||||
let maps: sourcemaps.SourceMapData | undefined;
|
||||
try {
|
||||
maps = JSON.parse(contents);
|
||||
}
|
||||
catch {
|
||||
// swallow error
|
||||
}
|
||||
if (!maps || !maps.sources || !maps.file || !maps.mappings) {
|
||||
const map = tryParseRawSourceMap(contents);
|
||||
if (!map || !map.sources || !map.file || !map.mappings) {
|
||||
// obviously invalid map
|
||||
return file.sourceMapper = sourcemaps.identitySourceMapper;
|
||||
}
|
||||
@@ -57,7 +51,7 @@ namespace ts {
|
||||
fileExists: s => host.fileExists!(s), // TODO: GH#18217
|
||||
getCanonicalFileName,
|
||||
log,
|
||||
}, mapFileName, maps, getProgram(), sourcemappedFileCache);
|
||||
}, mapFileName, map, getProgram(), sourcemappedFileCache);
|
||||
}
|
||||
|
||||
function getSourceMapper(fileName: string, file: SourceFileLike): sourcemaps.SourceMapper {
|
||||
|
||||
Reference in New Issue
Block a user