mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-12-13 14:29:00 -06:00
Additional PR feedback and cleanup
This commit is contained in:
parent
d4091554cd
commit
ddb2155cb0
@ -487,7 +487,6 @@ var buildProtocolTs = path.join(scriptsDirectory, "buildProtocol.ts");
|
||||
var buildProtocolJs = path.join(scriptsDirectory, "buildProtocol.js");
|
||||
var buildProtocolDts = path.join(builtLocalDirectory, "protocol.d.ts");
|
||||
var typescriptServicesDts = path.join(builtLocalDirectory, "typescriptServices.d.ts");
|
||||
var typesMapJson = path.join(builtLocalDirectory, "typesMap.json");
|
||||
|
||||
file(buildProtocolTs);
|
||||
|
||||
@ -652,7 +651,7 @@ var serverFile = path.join(builtLocalDirectory, "tsserver.js");
|
||||
compileFile(serverFile, serverSources, [builtLocalDirectory, copyright, cancellationTokenFile, typingsInstallerFile, watchGuardFile].concat(serverSources).concat(servicesSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { types: ["node"], preserveConstEnums: true, lib: "es6" });
|
||||
var tsserverLibraryFile = path.join(builtLocalDirectory, "tsserverlibrary.js");
|
||||
var tsserverLibraryDefinitionFile = path.join(builtLocalDirectory, "tsserverlibrary.d.ts");
|
||||
file(typesMapOutputPath, undefined, function() {
|
||||
file(typesMapOutputPath, /** @type {*} */(function() {
|
||||
var content = fs.readFileSync(path.join(serverDirectory, 'typesMap.json'));
|
||||
// Validate that it's valid JSON
|
||||
try {
|
||||
@ -661,7 +660,7 @@ file(typesMapOutputPath, undefined, function() {
|
||||
console.log("Parse error in typesMap.json: " + e);
|
||||
}
|
||||
fs.writeFileSync(typesMapOutputPath, content);
|
||||
});
|
||||
}));
|
||||
compileFile(
|
||||
tsserverLibraryFile,
|
||||
languageServiceLibrarySources,
|
||||
|
||||
@ -164,15 +164,14 @@ class CompilerTest {
|
||||
tsConfigOptions.configFile.fileName = tsConfigOptions.configFilePath;
|
||||
}
|
||||
|
||||
const output = Harness.Compiler.compileFiles(
|
||||
this.result = Harness.Compiler.compileFiles(
|
||||
this.toBeCompiled,
|
||||
this.otherFiles,
|
||||
this.harnessSettings,
|
||||
/*options*/ tsConfigOptions,
|
||||
/*currentDirectory*/ this.harnessSettings.currentDirectory);
|
||||
|
||||
this.options = output.options;
|
||||
this.result = output.result;
|
||||
this.options = this.result.options;
|
||||
}
|
||||
|
||||
public static getConfigurations(fileName: string) {
|
||||
|
||||
@ -1198,18 +1198,13 @@ namespace Harness {
|
||||
fileOptions?: any;
|
||||
}
|
||||
|
||||
export interface CompilationOutput {
|
||||
result: compiler.CompilationResult;
|
||||
options: ts.CompilerOptions & HarnessOptions;
|
||||
}
|
||||
|
||||
export function compileFiles(
|
||||
inputFiles: TestFile[],
|
||||
otherFiles: TestFile[],
|
||||
harnessSettings: TestCaseParser.CompilerSettings,
|
||||
compilerOptions: ts.CompilerOptions,
|
||||
// Current directory is needed for rwcRunner to be able to use currentDirectory defined in json file
|
||||
currentDirectory: string): CompilationOutput {
|
||||
currentDirectory: string): compiler.CompilationResult {
|
||||
const options: ts.CompilerOptions & HarnessOptions = compilerOptions ? ts.cloneCompilerOptions(compilerOptions) : { noResolve: false };
|
||||
options.target = options.target || ts.ScriptTarget.ES3;
|
||||
options.newLine = options.newLine || ts.NewLineKind.CarriageReturnLineFeed;
|
||||
@ -1244,7 +1239,7 @@ namespace Harness {
|
||||
}
|
||||
}
|
||||
|
||||
const result = compiler.compileFiles(
|
||||
return compiler.compileFiles(
|
||||
new compiler.CompilerHost(
|
||||
vfs.VirtualFileSystem.createFromDocuments(
|
||||
useCaseSensitiveFileNames,
|
||||
@ -1255,14 +1250,6 @@ namespace Harness {
|
||||
),
|
||||
programFileNames,
|
||||
options);
|
||||
|
||||
// const fileOutputs = compilation.outputs.map(output => output.asGeneratedFile());
|
||||
// const traceResults = compilation.traces && compilation.traces.slice();
|
||||
// const program = compilation.program;
|
||||
// const emitResult = compilation.result;
|
||||
// const errors = compilation.diagnostics;
|
||||
// const result = new CompilerResult(fileOutputs, errors, program, compilation.vfs.currentDirectory, emitResult.sourceMaps, traceResults);
|
||||
return { result, options };
|
||||
}
|
||||
|
||||
export interface DeclarationCompilationContext {
|
||||
@ -1343,7 +1330,7 @@ namespace Harness {
|
||||
}
|
||||
const { declInputFiles, declOtherFiles, harnessSettings, options, currentDirectory } = context;
|
||||
const output = compileFiles(declInputFiles, declOtherFiles, harnessSettings, options, currentDirectory);
|
||||
return { declInputFiles, declOtherFiles, declResult: output.result };
|
||||
return { declInputFiles, declOtherFiles, declResult: output };
|
||||
}
|
||||
|
||||
export function minimalDiagnosticsToString(diagnostics: ReadonlyArray<ts.Diagnostic>, pretty?: boolean) {
|
||||
|
||||
@ -142,8 +142,7 @@ namespace RWC {
|
||||
opts.options.noLib = true;
|
||||
|
||||
// Emit the results
|
||||
compilerOptions = undefined;
|
||||
const output = Harness.Compiler.compileFiles(
|
||||
compilerResult = Harness.Compiler.compileFiles(
|
||||
inputFiles,
|
||||
otherFiles,
|
||||
/* harnessOptions */ undefined,
|
||||
@ -151,9 +150,7 @@ namespace RWC {
|
||||
// Since each RWC json file specifies its current directory in its json file, we need
|
||||
// to pass this information in explicitly instead of acquiring it from the process.
|
||||
currentDirectory);
|
||||
|
||||
compilerOptions = output.options;
|
||||
compilerResult = output.result;
|
||||
compilerOptions = compilerResult.options;
|
||||
});
|
||||
|
||||
function getHarnessCompilerInputUnit(fileName: string): Harness.Compiler.TestFile {
|
||||
|
||||
@ -52,14 +52,12 @@ class Test262BaselineRunner extends RunnerBase {
|
||||
compilerResult: undefined,
|
||||
};
|
||||
|
||||
const output = Harness.Compiler.compileFiles(
|
||||
testState.compilerResult = Harness.Compiler.compileFiles(
|
||||
[Test262BaselineRunner.helperFile].concat(inputFiles),
|
||||
/*otherFiles*/ [],
|
||||
/* harnessOptions */ undefined,
|
||||
Test262BaselineRunner.options,
|
||||
/* currentDirectory */ undefined
|
||||
);
|
||||
testState.compilerResult = output.result;
|
||||
/* currentDirectory */ undefined);
|
||||
});
|
||||
|
||||
after(() => {
|
||||
|
||||
@ -19,8 +19,8 @@ describe("Public APIs", () => {
|
||||
content: fileContent
|
||||
};
|
||||
const inputFiles = [testFile];
|
||||
const output = Harness.Compiler.compileFiles(inputFiles, [], /*harnessSettings*/ undefined, /*options*/ {}, /*currentDirectory*/ undefined);
|
||||
assert(!output.result.diagnostics || !output.result.diagnostics.length, Harness.Compiler.minimalDiagnosticsToString(output.result.diagnostics, /*pretty*/ true));
|
||||
const result = Harness.Compiler.compileFiles(inputFiles, [], /*harnessSettings*/ undefined, /*options*/ {}, /*currentDirectory*/ undefined);
|
||||
assert(!result.diagnostics || !result.diagnostics.length, Harness.Compiler.minimalDiagnosticsToString(result.diagnostics, /*pretty*/ true));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -4,17 +4,13 @@ namespace ts {
|
||||
describe("Symbol Walker", () => {
|
||||
function test(description: string, source: string, verifier: (file: SourceFile, checker: TypeChecker) => void) {
|
||||
it(description, () => {
|
||||
let {result} = Harness.Compiler.compileFiles([{
|
||||
const result = Harness.Compiler.compileFiles([{
|
||||
unitName: "main.ts",
|
||||
content: source
|
||||
}], [], {}, {}, "/");
|
||||
let file = result.program.getSourceFile("main.ts");
|
||||
let checker = result.program.getTypeChecker();
|
||||
const file = result.program.getSourceFile("main.ts");
|
||||
const checker = result.program.getTypeChecker();
|
||||
verifier(file, checker);
|
||||
|
||||
result = undefined;
|
||||
file = undefined;
|
||||
checker = undefined;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -9,10 +9,11 @@
|
||||
// support the eventual conversion of harness into a modular system.
|
||||
|
||||
namespace vfs {
|
||||
const S_IFMT = 0xf000;
|
||||
const S_IFLNK = 0xa000;
|
||||
const S_IFREG = 0x8000;
|
||||
const S_IFDIR = 0x4000;
|
||||
// file mode flags used for computing Stats
|
||||
const S_IFMT = 0xf000; // file type flags mask
|
||||
const S_IFLNK = 0xa000; // symbolic link
|
||||
const S_IFREG = 0x8000; // regular file
|
||||
const S_IFDIR = 0x4000; // regular directory
|
||||
|
||||
export interface PathMappings {
|
||||
[path: string]: string;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user