mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Add dts bundling
This adds a "small" d.ts bundler script. This script is very basic, using Node printing to produce its output. Generally speaking, this is inadvisable as it completely disregards name shadowing, globals, etc. However, in our case, we don't care about the globals, and we can opt to restructure our codebase in order to avoid conflict, which we largely had to do anyway when we were namespaces and everything was in scope.
This commit is contained in:
+31
-6
@@ -128,6 +128,19 @@ task("build-src", series(preSrc, buildSrc));
|
||||
const cleanSrc = () => cleanProject("src");
|
||||
task("clean-src", cleanSrc);
|
||||
|
||||
/**
|
||||
* @param {string} entrypoint
|
||||
* @param {string} output
|
||||
*/
|
||||
async function runDtsBundler(entrypoint, output) {
|
||||
await exec(process.execPath, [
|
||||
"./scripts/dtsBundler.mjs",
|
||||
"--entrypoint",
|
||||
entrypoint,
|
||||
"--output",
|
||||
output,
|
||||
]);
|
||||
}
|
||||
|
||||
/** @type {string | undefined} */
|
||||
let copyrightHeader;
|
||||
@@ -275,6 +288,7 @@ const esbuildServices = esbuildTask("./src/typescript/typescript.ts", "./built/l
|
||||
const writeServicesCJSShim = () => writeCJSReexport("./built/local/typescript/typescript.js", "./built/local/typescript.js");
|
||||
const buildServicesProject = () => buildProject("src/typescript");
|
||||
|
||||
// TODO(jakebailey): rename this; no longer "services".
|
||||
const buildServices = () => {
|
||||
if (cmdLineOptions.bundle) return esbuildServices.build();
|
||||
writeServicesCJSShim();
|
||||
@@ -304,6 +318,9 @@ task("watch-services").flags = {
|
||||
" --built": "Compile using the built version of the compiler."
|
||||
};
|
||||
|
||||
const dtsServices = () => runDtsBundler("./built/local/typescript/typescript.d.ts", "./built/local/typescript.d.ts");
|
||||
task("dts-services", series(preBuild, buildServicesProject, dtsServices));
|
||||
task("dts-services").description = "Builds typescript.d.ts";
|
||||
|
||||
const esbuildServer = esbuildTask("./src/tsserver/server.ts", "./built/local/tsserver.js", /* exportIsTsObject */ true);
|
||||
const writeServerCJSShim = () => writeCJSReexport("./built/local/tsserver/server.js", "./built/local/tsserver.js");
|
||||
@@ -355,10 +372,11 @@ task("watch-min").flags = {
|
||||
const esbuildLssl = esbuildTask("./src/tsserverlibrary/tsserverlibrary.ts", "./built/local/tsserverlibrary.js", /* exportIsTsObject */ true);
|
||||
const writeLsslCJSShim = () => writeCJSReexport("./built/local/tsserverlibrary/tsserverlibrary.js", "./built/local/tsserverlibrary.js");
|
||||
|
||||
const buildLsslProject = () => buildProject("src/tsserverlibrary");
|
||||
const buildLssl = () => {
|
||||
if (cmdLineOptions.bundle) return esbuildLssl.build();
|
||||
writeLsslCJSShim();
|
||||
return buildProject("src/tsserverlibrary");
|
||||
return buildLsslProject();
|
||||
};
|
||||
task("lssl", series(preBuild, buildLssl));
|
||||
task("lssl").description = "Builds language service server library";
|
||||
@@ -382,6 +400,14 @@ task("watch-lssl").flags = {
|
||||
" --built": "Compile using the built version of the compiler."
|
||||
};
|
||||
|
||||
const dtsLssl = () => runDtsBundler("./built/local/tsserverlibrary/tsserverlibrary.d.ts", "./built/local/tsserverlibrary.d.ts");
|
||||
task("dts-lssl", series(preBuild, buildLsslProject, dtsLssl));
|
||||
task("dts-lssl").description = "Builds tsserverlibrary.d.ts";
|
||||
|
||||
// TODO(jakebailey): this is probably not efficient, but, gulp.
|
||||
const dts = series(preBuild, parallel(buildServicesProject, buildLsslProject), parallel(dtsServices, dtsLssl));
|
||||
task("dts", dts);
|
||||
|
||||
const testRunner = "./built/local/run.js";
|
||||
const esbuildTests = esbuildTask("./src/testRunner/_namespaces/Harness.ts", testRunner);
|
||||
const writeTestsCJSShim = () => writeCJSReexport("./built/local/testRunner/runner.js", testRunner);
|
||||
@@ -492,7 +518,7 @@ const buildOtherOutputs = parallel(buildCancellationToken, buildTypingsInstaller
|
||||
task("other-outputs", series(preBuild, buildOtherOutputs));
|
||||
task("other-outputs").description = "Builds miscelaneous scripts and documents distributed with the LKG";
|
||||
|
||||
task("local", series(preBuild, parallel(localize, buildTsc, buildServer, buildServices, buildLssl, buildOtherOutputs)));
|
||||
task("local", series(preBuild, parallel(localize, buildTsc, buildServer, buildServices, buildLssl, buildOtherOutputs, dts)));
|
||||
task("local").description = "Builds the full compiler and services";
|
||||
task("local").flags = {
|
||||
" --built": "Compile using the built version of the compiler."
|
||||
@@ -508,7 +534,7 @@ const preTest = parallel(buildTsc, buildTests, buildServices, buildLssl);
|
||||
preTest.displayName = "preTest";
|
||||
|
||||
const runTests = () => runConsoleTests(testRunner, "mocha-fivemat-progress-reporter", /*runInParallel*/ false, /*watchMode*/ false);
|
||||
task("runtests", series(preBuild, preTest, runTests));
|
||||
task("runtests", series(preBuild, preTest, dts, runTests));
|
||||
task("runtests").description = "Runs the tests using the built run.js file.";
|
||||
task("runtests").flags = {
|
||||
"-t --tests=<regex>": "Pattern for tests to run.",
|
||||
@@ -527,7 +553,7 @@ task("runtests").flags = {
|
||||
};
|
||||
|
||||
const runTestsParallel = () => runConsoleTests(testRunner, "min", /*runInParallel*/ cmdLineOptions.workers > 1, /*watchMode*/ false);
|
||||
task("runtests-parallel", series(preBuild, preTest, runTestsParallel));
|
||||
task("runtests-parallel", series(preBuild, preTest, dts, runTestsParallel));
|
||||
task("runtests-parallel").description = "Runs all the tests in parallel using the built run.js file.";
|
||||
task("runtests-parallel").flags = {
|
||||
" --light": "Run tests in light mode (fewer verifications, but tests run faster).",
|
||||
@@ -613,8 +639,7 @@ const produceLKG = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
// TODO(jakebailey): dependencies on dts
|
||||
task("LKG", series(lkgPreBuild, parallel(localize, buildTsc, buildServer, buildServices, buildLssl, buildOtherOutputs), produceLKG));
|
||||
task("LKG", series(lkgPreBuild, parallel(localize, buildTsc, buildServer, buildServices, buildLssl, buildOtherOutputs, dts), produceLKG));
|
||||
task("LKG").description = "Makes a new LKG out of the built js files";
|
||||
task("LKG").flags = {
|
||||
" --built": "Compile using the built version of the compiler.",
|
||||
|
||||
@@ -0,0 +1,413 @@
|
||||
/**
|
||||
* WARNING: this is a very, very rudimentary d.ts bundler; it only works
|
||||
* in the TS project thanks to our history using namespaces, which has
|
||||
* prevented us from duplicating names across files, and allows us to
|
||||
* bundle as namespaces again, even though the project is modules.
|
||||
*/
|
||||
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import minimist from "minimist";
|
||||
import url from "url";
|
||||
import ts from "../lib/typescript.js";
|
||||
import assert, { fail } from "assert";
|
||||
|
||||
const __filename = url.fileURLToPath(new URL(import.meta.url));
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
// /** @type {any} */ (ts).Debug.enableDebugInfo();
|
||||
|
||||
const dotDts = ".d.ts";
|
||||
|
||||
const options = minimist(process.argv.slice(2), {
|
||||
string: ["project", "entrypoint", "output"],
|
||||
});
|
||||
|
||||
const entrypoint = options.entrypoint;
|
||||
const output = options.output;
|
||||
|
||||
assert(typeof entrypoint === "string" && entrypoint);
|
||||
assert(typeof output === "string" && output);
|
||||
assert(output.endsWith(dotDts));
|
||||
|
||||
const internalOutput = output.substring(0, output.length - dotDts.length) + ".internal" + dotDts;
|
||||
|
||||
console.log(`Bundling ${entrypoint} to ${output} and ${internalOutput}`);
|
||||
|
||||
const newLineKind = ts.NewLineKind.LineFeed;
|
||||
const newLine = newLineKind === ts.NewLineKind.LineFeed ? "\n" : "\r\n";
|
||||
|
||||
/** @type {(node: ts.Node) => node is ts.DeclarationStatement} */
|
||||
function isDeclarationStatement(node) {
|
||||
return /** @type {any} */ (ts).isDeclarationStatement(node);
|
||||
}
|
||||
|
||||
/** @type {(node: ts.Node) => boolean} */
|
||||
function isInternalDeclaration(node) {
|
||||
return /** @type {any} */ (ts).isInternalDeclaration(node, node.getSourceFile());
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {ts.VariableDeclaration} node
|
||||
* @returns {ts.VariableStatement}
|
||||
*/
|
||||
function getParentVariableStatement(node) {
|
||||
const declarationList = node.parent;
|
||||
assert(ts.isVariableDeclarationList(declarationList), `expected VariableDeclarationList at ${nodeToLocation(node)}`);
|
||||
assert(declarationList.declarations.length === 1, `expected VariableDeclarationList of length 1 at ${nodeToLocation(node)}`);
|
||||
const variableStatement = declarationList.parent;
|
||||
assert(ts.isVariableStatement(variableStatement), `expected VariableStatement at ${nodeToLocation(node)}`);
|
||||
return variableStatement;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {ts.Declaration} node
|
||||
* @returns {ts.Statement | undefined}
|
||||
*/
|
||||
function getDeclarationStatement(node) {
|
||||
if (ts.isVariableDeclaration(node)) {
|
||||
return getParentVariableStatement(node);
|
||||
}
|
||||
else if (isDeclarationStatement(node)) {
|
||||
return node;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/** @type {ts.TransformationContext} */
|
||||
const nullTransformationContext = /** @type {any} */ (ts).nullTransformationContext;
|
||||
|
||||
const program = ts.createProgram([entrypoint], { target: ts.ScriptTarget.ES5 });
|
||||
|
||||
const typeChecker = program.getTypeChecker();
|
||||
|
||||
const sourceFile = program.getSourceFile(entrypoint);
|
||||
assert(sourceFile, "Failed to load source file");
|
||||
const moduleSymbol = typeChecker.getSymbolAtLocation(sourceFile);
|
||||
assert(moduleSymbol, "Failed to get module's symbol");
|
||||
|
||||
const printer = ts.createPrinter({ newLine: newLineKind });
|
||||
|
||||
/** @type {string[]} */
|
||||
const publicLines = [];
|
||||
/** @type {string[]} */
|
||||
const internalLines = [];
|
||||
|
||||
const indent = " ";
|
||||
let currentIndent = "";
|
||||
|
||||
function increaseIndent() {
|
||||
currentIndent += indent;
|
||||
}
|
||||
|
||||
function decreaseIndent() {
|
||||
currentIndent = currentIndent.slice(indent.length);
|
||||
}
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
const WriteTarget = {
|
||||
Public: 1 << 0,
|
||||
Internal: 1 << 1,
|
||||
Both: (1 << 0) | (1 << 1),
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} s
|
||||
* @param {WriteTarget} target
|
||||
*/
|
||||
function write(s, target) {
|
||||
if (!target) {
|
||||
return;
|
||||
}
|
||||
|
||||
const toPush = !s ? [""] : s.split(/\r?\n/).filter(line => line).map(line => (currentIndent + line).trimEnd());
|
||||
|
||||
if (target & WriteTarget.Public) {
|
||||
publicLines.push(...toPush);
|
||||
}
|
||||
if (target & WriteTarget.Internal) {
|
||||
internalLines.push(...toPush);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {ts.Node} node
|
||||
* @param {ts.SourceFile} sourceFile
|
||||
* @param {WriteTarget} target
|
||||
*/
|
||||
function writeNode(node, sourceFile, target) {
|
||||
write(printer.printNode(ts.EmitHint.Unspecified, node, sourceFile), target);
|
||||
}
|
||||
|
||||
/** @type {Map<ts.Symbol, boolean>} */
|
||||
const containsPublicAPICache = new Map();
|
||||
|
||||
/**
|
||||
* @param {ts.Symbol} symbol
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function containsPublicAPI(symbol) {
|
||||
const cached = containsPublicAPICache.get(symbol);
|
||||
if (cached !== undefined) {
|
||||
return cached;
|
||||
}
|
||||
|
||||
const result = containsPublicAPIWorker();
|
||||
containsPublicAPICache.set(symbol, result);
|
||||
return result;
|
||||
|
||||
function containsPublicAPIWorker() {
|
||||
if (!symbol.declarations?.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (symbol.flags & ts.SymbolFlags.Alias) {
|
||||
const resolved = typeChecker.getAliasedSymbol(symbol);
|
||||
return containsPublicAPI(resolved);
|
||||
}
|
||||
|
||||
// Namespace barrel; actual namespaces are checked below.
|
||||
if (symbol.flags & ts.SymbolFlags.ValueModule && symbol.valueDeclaration?.kind === ts.SyntaxKind.SourceFile) {
|
||||
for (const me of typeChecker.getExportsOfModule(symbol)) {
|
||||
if (containsPublicAPI(me)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
for (const decl of symbol.declarations) {
|
||||
const statement = getDeclarationStatement(decl);
|
||||
if (statement && !isInternalDeclaration(statement)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {ts.Node} node
|
||||
*/
|
||||
function nodeToLocation(node) {
|
||||
const sourceFile = node.getSourceFile();
|
||||
const lc = sourceFile.getLineAndCharacterOfPosition(node.pos);
|
||||
return `${sourceFile.fileName}:${lc.line+1}:${lc.character+1}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {ts.Node} node
|
||||
* @returns {ts.Node | undefined}
|
||||
*/
|
||||
function removeDeclareConstExport(node) {
|
||||
switch (node.kind) {
|
||||
case ts.SyntaxKind.DeclareKeyword: // No need to emit this in d.ts files.
|
||||
case ts.SyntaxKind.ConstKeyword: // Remove const from const enums.
|
||||
case ts.SyntaxKind.ExportKeyword: // No export modifier; we are already in the namespace.
|
||||
return undefined;
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
/** @type {Map<string, ts.Symbol>[]} */
|
||||
const scopeStack = [];
|
||||
|
||||
/**
|
||||
* @param {string} name
|
||||
*/
|
||||
function findInScope(name) {
|
||||
for (let i = scopeStack.length-1; i >= 0; i--) {
|
||||
const scope = scopeStack[i];
|
||||
const symbol = scope.get(name);
|
||||
if (symbol) {
|
||||
return symbol;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/** @type {(symbol: ts.Symbol | undefined, excludes?: ts.SymbolFlags) => boolean} */
|
||||
function isNonLocalAlias(symbol, excludes = ts.SymbolFlags.Value | ts.SymbolFlags.Type | ts.SymbolFlags.Namespace) {
|
||||
if (!symbol) return false;
|
||||
return (symbol.flags & (ts.SymbolFlags.Alias | excludes)) === ts.SymbolFlags.Alias || !!(symbol.flags & ts.SymbolFlags.Alias && symbol.flags & ts.SymbolFlags.Assignment);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {ts.Symbol} symbol
|
||||
*/
|
||||
function resolveAlias(symbol) {
|
||||
return typeChecker.getAliasedSymbol(symbol);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {ts.Symbol} symbol
|
||||
* @param {boolean | undefined} [dontResolveAlias]
|
||||
*/
|
||||
function resolveSymbol(symbol, dontResolveAlias = undefined) {
|
||||
return !dontResolveAlias && isNonLocalAlias(symbol) ? resolveAlias(symbol) : symbol;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {ts.Symbol} symbol
|
||||
* @returns {ts.Symbol}
|
||||
*/
|
||||
function getMergedSymbol(symbol) {
|
||||
return /** @type {any} */ (typeChecker).getMergedSymbol(symbol);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {ts.Symbol} s1
|
||||
* @param {ts.Symbol} s2
|
||||
*/
|
||||
function symbolsConflict(s1, s2) {
|
||||
// See getSymbolIfSameReference in checker.ts
|
||||
s1 = getMergedSymbol(resolveSymbol(getMergedSymbol(s1)));
|
||||
s2 = getMergedSymbol(resolveSymbol(getMergedSymbol(s2)));
|
||||
if (s1 === s2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const s1Flags = s1.flags & (ts.SymbolFlags.Type | ts.SymbolFlags.Value);
|
||||
const s2Flags = s2.flags & (ts.SymbolFlags.Type | ts.SymbolFlags.Value);
|
||||
|
||||
// If the two symbols differ by type/value space, ignore.
|
||||
if (!(s1Flags & s2Flags)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {ts.Node} node
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function isPartOfTypeNode(node) {
|
||||
return /** @type {any} */ (ts).isPartOfTypeNode(node);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {ts.Statement} decl
|
||||
*/
|
||||
function verifyMatchingSymbols(decl) {
|
||||
ts.visitEachChild(decl, /** @type {(node: ts.Node) => ts.Node} */ function visit(node) {
|
||||
if (ts.isIdentifier(node) && isPartOfTypeNode(node)) {
|
||||
if (ts.isQualifiedName(node.parent) && node !== node.parent.left) {
|
||||
return node;
|
||||
}
|
||||
if (ts.isParameter(node.parent) && node === node.parent.name) {
|
||||
return node;
|
||||
}
|
||||
if (ts.isNamedTupleMember(node.parent) && node === node.parent.name) {
|
||||
return node;
|
||||
}
|
||||
|
||||
const symbolOfNode = typeChecker.getSymbolAtLocation(node);
|
||||
if (!symbolOfNode) {
|
||||
fail(`No symbol for node at ${nodeToLocation(node)}`);
|
||||
}
|
||||
const symbolInScope = findInScope(symbolOfNode.name);
|
||||
if (!symbolInScope) {
|
||||
// We didn't find the symbol in scope at all. Just allow it and we'll fail at test time.
|
||||
return node;
|
||||
}
|
||||
|
||||
if (symbolsConflict(symbolOfNode, symbolInScope)) {
|
||||
fail(`Declaration at ${nodeToLocation(decl)}\n references ${symbolOfNode.name} at ${symbolOfNode.declarations && nodeToLocation(symbolOfNode.declarations[0])},\n but containing scope contains a symbol with the same name declared at ${symbolInScope.declarations && nodeToLocation(symbolInScope.declarations[0])}`);
|
||||
}
|
||||
}
|
||||
|
||||
return ts.visitEachChild(node, visit, nullTransformationContext);
|
||||
}, nullTransformationContext);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} name
|
||||
* @param {ts.Symbol} moduleSymbol
|
||||
*/
|
||||
function emitAsNamespace(name, moduleSymbol) {
|
||||
assert(moduleSymbol.flags & ts.SymbolFlags.ValueModule, "moduleSymbol is not a module");
|
||||
|
||||
scopeStack.push(new Map());
|
||||
const currentScope = scopeStack[scopeStack.length-1];
|
||||
|
||||
const target = containsPublicAPI(moduleSymbol) ? WriteTarget.Both : WriteTarget.Internal;
|
||||
|
||||
if (name === "ts") {
|
||||
// We will write `export = ts` at the end.
|
||||
write(`declare namespace ${name} {`, target);
|
||||
}
|
||||
else {
|
||||
// No export modifier; we are already in the namespace.
|
||||
write(`namespace ${name} {`, target);
|
||||
}
|
||||
increaseIndent();
|
||||
|
||||
const moduleExports = typeChecker.getExportsOfModule(moduleSymbol);
|
||||
for (const me of moduleExports) {
|
||||
currentScope.set(me.name, me);
|
||||
}
|
||||
|
||||
for (const me of moduleExports) {
|
||||
assert(me.declarations?.length);
|
||||
|
||||
if (me.flags & ts.SymbolFlags.Alias) {
|
||||
const resolved = typeChecker.getAliasedSymbol(me);
|
||||
emitAsNamespace(me.name, resolved);
|
||||
continue;
|
||||
}
|
||||
|
||||
for (const decl of me.declarations) {
|
||||
const statement = getDeclarationStatement(decl);
|
||||
const sourceFile = decl.getSourceFile();
|
||||
|
||||
if (!statement) {
|
||||
fail(`Unhandled declaration for ${me.name} at ${nodeToLocation(decl)}`);
|
||||
}
|
||||
|
||||
verifyMatchingSymbols(statement);
|
||||
|
||||
const isInternal = isInternalDeclaration(statement);
|
||||
if (!isInternal) {
|
||||
const publicStatement = ts.visitEachChild(statement, (node) => {
|
||||
// No @internal comments in the public API.
|
||||
if (isInternalDeclaration(node)) {
|
||||
return undefined;
|
||||
}
|
||||
return removeDeclareConstExport(node);
|
||||
}, nullTransformationContext);
|
||||
|
||||
writeNode(publicStatement, sourceFile, WriteTarget.Public);
|
||||
}
|
||||
|
||||
const internalStatement = ts.visitEachChild(statement, removeDeclareConstExport, nullTransformationContext);
|
||||
|
||||
writeNode(internalStatement, sourceFile, WriteTarget.Internal);
|
||||
}
|
||||
}
|
||||
|
||||
scopeStack.pop();
|
||||
|
||||
decreaseIndent();
|
||||
write(`}`, target);
|
||||
}
|
||||
|
||||
emitAsNamespace("ts", moduleSymbol);
|
||||
|
||||
write("export = ts;", WriteTarget.Both);
|
||||
|
||||
const copyrightNotice = fs.readFileSync(path.join(__dirname, "..", "CopyrightNotice.txt"), "utf-8");
|
||||
const publicContents = copyrightNotice + publicLines.join(newLine);
|
||||
const internalContents = copyrightNotice + internalLines.join(newLine);
|
||||
|
||||
if (publicContents.includes("@internal")) {
|
||||
console.error("Output includes untrimmed @internal nodes!");
|
||||
}
|
||||
|
||||
fs.writeFileSync(output, publicContents);
|
||||
fs.writeFileSync(internalOutput, internalContents);
|
||||
+2
-12
@@ -11,7 +11,6 @@ const __dirname = path.dirname(__filename);
|
||||
const root = path.join(__dirname, "..");
|
||||
const source = path.join(root, "built/local");
|
||||
const dest = path.join(root, "lib");
|
||||
const copyright = fs.readFileSync(path.join(__dirname, "../CopyrightNotice.txt"), "utf-8");
|
||||
|
||||
async function produceLKG() {
|
||||
console.log(`Building LKG from ${source} to ${dest}`);
|
||||
@@ -53,23 +52,14 @@ async function copyScriptOutputs() {
|
||||
}
|
||||
|
||||
async function copyDeclarationOutputs() {
|
||||
await copyWithCopyright("tsserverlibrary.d.ts");
|
||||
await copyWithCopyright("typescript.d.ts");
|
||||
await copyFromBuiltLocal("tsserverlibrary.d.ts");
|
||||
await copyFromBuiltLocal("typescript.d.ts");
|
||||
}
|
||||
|
||||
async function writeGitAttributes() {
|
||||
await fs.writeFile(path.join(dest, ".gitattributes"), `* text eol=lf`, "utf-8");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} fileName
|
||||
* @param {string} destName
|
||||
*/
|
||||
async function copyWithCopyright(fileName, destName = fileName) {
|
||||
const content = await fs.readFile(path.join(source, fileName), "utf-8");
|
||||
await fs.writeFile(path.join(dest, destName), copyright + "\n" + content);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} fileName
|
||||
*/
|
||||
|
||||
@@ -2073,7 +2073,7 @@ function getTsconfigRootOptionsMap() {
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
interface JsonConversionNotifier {
|
||||
export interface JsonConversionNotifier {
|
||||
/**
|
||||
* Notifies parent option object is being set with the optionKey and a valid optionValue
|
||||
* Currently it notifies only if there is element with type object (parentOption) and
|
||||
|
||||
@@ -2,11 +2,12 @@ import {
|
||||
AccessorDeclaration, addEmitFlags, AdditiveOperator, AdditiveOperatorOrHigher, AssertionLevel,
|
||||
AssignmentOperatorOrHigher, BinaryExpression, BinaryOperator, BinaryOperatorToken, BindingOrAssignmentElement,
|
||||
BindingOrAssignmentElementRestIndicator, BindingOrAssignmentElementTarget, BindingOrAssignmentPattern,
|
||||
BitwiseOperator, BitwiseOperatorOrHigher, BooleanLiteral, CharacterCodes, CommaListExpression,
|
||||
BitwiseOperator, BitwiseOperatorOrHigher, Block, BooleanLiteral, CharacterCodes, CommaListExpression,
|
||||
compareStringsCaseSensitive, CompilerOptions, Debug, Declaration, EmitFlags, EmitHelperFactory, EmitHost,
|
||||
EmitResolver, EntityName, EqualityOperator, EqualityOperatorOrHigher, ExclamationToken, ExponentiationOperator,
|
||||
ExportDeclaration, Expression, ExpressionStatement, externalHelpersModuleNameText, first, firstOrUndefined,
|
||||
ForInitializer, GeneratedIdentifier, GeneratedIdentifierFlags, GeneratedNamePart, GeneratedPrivateIdentifier,
|
||||
GetAccessorDeclaration,
|
||||
getAllAccessorDeclarations, getEmitFlags, getEmitHelpers, getEmitModuleKind, getESModuleInterop,
|
||||
getExternalModuleName, getExternalModuleNameFromPath, getJSDocType, getJSDocTypeTag, getModifiers,
|
||||
getNamespaceDeclarationNode, getOrCreateEmitNode, getOriginalNode, getParseTreeNode,
|
||||
@@ -26,7 +27,7 @@ import {
|
||||
NumericLiteral, ObjectLiteralElementLike, ObjectLiteralExpression, or, OuterExpression, OuterExpressionKinds,
|
||||
outFile, parseNodeFactory, PlusToken, PostfixUnaryExpression, PrefixUnaryExpression, PrivateIdentifier,
|
||||
PropertyAssignment, PropertyDeclaration, PropertyName, pushIfUnique, QuestionToken, ReadonlyKeyword,
|
||||
RelationalOperator, RelationalOperatorOrHigher, setOriginalNode, setParent, setStartsOnNewLine, setTextRange,
|
||||
RelationalOperator, RelationalOperatorOrHigher, SetAccessorDeclaration, setOriginalNode, setParent, setStartsOnNewLine, setTextRange,
|
||||
ShiftOperator, ShiftOperatorOrHigher, ShorthandPropertyAssignment, some, SourceFile, Statement, StringLiteral,
|
||||
SyntaxKind, TextRange, ThisTypeNode, Token, TypeNode, TypeParameterDeclaration,
|
||||
} from "../_namespaces/ts";
|
||||
@@ -185,7 +186,7 @@ export function createForOfBindingStatement(factory: NodeFactory, node: ForIniti
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function insertLeadingStatement(factory: NodeFactory, dest: Statement, source: Statement) {
|
||||
export function insertLeadingStatement(factory: NodeFactory, dest: Statement, source: Statement): Block {
|
||||
if (isBlock(dest)) {
|
||||
return factory.updateBlock(dest, setTextRange(factory.createNodeArray([source, ...dest.statements]), dest.statements));
|
||||
}
|
||||
@@ -1456,7 +1457,7 @@ export function createAccessorPropertyBackingField(factory: NodeFactory, node: P
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export function createAccessorPropertyGetRedirector(factory: NodeFactory, node: PropertyDeclaration, modifiers: ModifiersArray | undefined, name: PropertyName) {
|
||||
export function createAccessorPropertyGetRedirector(factory: NodeFactory, node: PropertyDeclaration, modifiers: ModifiersArray | undefined, name: PropertyName): GetAccessorDeclaration {
|
||||
return factory.createGetAccessorDeclaration(
|
||||
modifiers,
|
||||
name,
|
||||
@@ -1478,7 +1479,7 @@ export function createAccessorPropertyGetRedirector(factory: NodeFactory, node:
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export function createAccessorPropertySetRedirector(factory: NodeFactory, node: PropertyDeclaration, modifiers: ModifiersArray | undefined, name: PropertyName) {
|
||||
export function createAccessorPropertySetRedirector(factory: NodeFactory, node: PropertyDeclaration, modifiers: ModifiersArray | undefined, name: PropertyName): SetAccessorDeclaration {
|
||||
return factory.createSetAccessorDeclaration(
|
||||
modifiers,
|
||||
name,
|
||||
|
||||
@@ -128,7 +128,7 @@ function createResolvedModuleWithFailedLookupLocations(
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
interface ModuleResolutionState {
|
||||
export interface ModuleResolutionState {
|
||||
host: ModuleResolutionHost;
|
||||
compilerOptions: CompilerOptions;
|
||||
traceEnabled: boolean;
|
||||
@@ -146,7 +146,7 @@ interface ModuleResolutionState {
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
interface PackageJsonPathFields {
|
||||
export interface PackageJsonPathFields {
|
||||
typings?: string;
|
||||
types?: string;
|
||||
typesVersions?: MapLike<MapLike<string[]>>;
|
||||
@@ -226,7 +226,7 @@ function readPackageJsonTypesVersionsField(jsonContent: PackageJson, state: Modu
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
interface VersionPaths {
|
||||
export interface VersionPaths {
|
||||
version: string;
|
||||
paths: MapLike<string[]>;
|
||||
}
|
||||
@@ -1290,7 +1290,7 @@ export function resolveJSModule(moduleName: string, initialDir: string, host: Mo
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
enum NodeResolutionFeatures {
|
||||
export enum NodeResolutionFeatures {
|
||||
None = 0,
|
||||
// resolving `#local` names in your own package.json
|
||||
Imports = 1 << 1,
|
||||
|
||||
@@ -9830,7 +9830,7 @@ export function processCommentPragmas(context: PragmaContext, sourceText: string
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
type PragmaDiagnosticReporter = (pos: number, length: number, message: DiagnosticMessage) => void;
|
||||
export type PragmaDiagnosticReporter = (pos: number, length: number, message: DiagnosticMessage) => void;
|
||||
|
||||
/** @internal */
|
||||
export function processPragmasIntoFields(context: PragmaContext, reportDiagnostic: PragmaDiagnosticReporter): void {
|
||||
|
||||
@@ -1,6 +1,29 @@
|
||||
import { noop } from "./_namespaces/ts";
|
||||
|
||||
type PerfLogger = typeof import("@microsoft/typescript-etw");
|
||||
/** @internal */
|
||||
export interface PerfLogger {
|
||||
logEvent(msg: string): void;
|
||||
logErrEvent(msg: string): void;
|
||||
logPerfEvent(msg: string): void;
|
||||
logInfoEvent(msg: string): void;
|
||||
logStartCommand(command: string, msg: string): void;
|
||||
logStopCommand(command: string, msg: string): void;
|
||||
logStartUpdateProgram(msg: string): void;
|
||||
logStopUpdateProgram(msg: string): void;
|
||||
logStartUpdateGraph(): void;
|
||||
logStopUpdateGraph(): void;
|
||||
logStartResolveModule(name: string): void;
|
||||
logStopResolveModule(success: string): void;
|
||||
logStartParseSourceFile(filename: string): void;
|
||||
logStopParseSourceFile(): void;
|
||||
logStartReadFile(filename: string): void;
|
||||
logStopReadFile(): void;
|
||||
logStartBindFile(filename: string): void;
|
||||
logStopBindFile(): void;
|
||||
logStartScheduledOperation(operationId: string): void;
|
||||
logStopScheduledOperation(): void;
|
||||
}
|
||||
|
||||
const nullLogger: PerfLogger = {
|
||||
logEvent: noop,
|
||||
logErrEvent: noop,
|
||||
@@ -26,7 +49,7 @@ const nullLogger: PerfLogger = {
|
||||
|
||||
// Load optional module to enable Event Tracing for Windows
|
||||
// See https://github.com/microsoft/typescript-etw for more information
|
||||
let etwModule;
|
||||
let etwModule: typeof import("@microsoft/typescript-etw") | undefined;
|
||||
try {
|
||||
const etwModulePath = process.env.TS_ETW_MODULE_PATH ?? "./node_modules/@microsoft/typescript-etw";
|
||||
|
||||
@@ -43,4 +66,4 @@ catch (e) {
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export const perfLogger: PerfLogger = etwModule && etwModule.logEvent ? etwModule : nullLogger;
|
||||
export const perfLogger: PerfLogger = etwModule?.logEvent ? etwModule : nullLogger;
|
||||
|
||||
@@ -230,7 +230,7 @@ export function createCompilerHostWorker(options: CompilerOptions, setParentNode
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
interface CompilerHostLikeForCache {
|
||||
export interface CompilerHostLikeForCache {
|
||||
fileExists(fileName: string): boolean;
|
||||
readFile(fileName: string, encoding?: string): string | undefined;
|
||||
directoryExists?(directory: string): boolean;
|
||||
@@ -4358,7 +4358,7 @@ export function filterSemanticDiagnostics(diagnostic: readonly Diagnostic[], opt
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
interface CompilerHostLike {
|
||||
export interface CompilerHostLike {
|
||||
useCaseSensitiveFileNames(): boolean;
|
||||
getCurrentDirectory(): string;
|
||||
fileExists(fileName: string): boolean;
|
||||
|
||||
@@ -59,7 +59,8 @@ export interface ResolutionCache {
|
||||
clear(): void;
|
||||
}
|
||||
|
||||
interface ResolutionWithFailedLookupLocations {
|
||||
/** @internal */
|
||||
export interface ResolutionWithFailedLookupLocations {
|
||||
readonly failedLookupLocations: string[];
|
||||
readonly affectingLocations: string[];
|
||||
isInvalidated?: boolean;
|
||||
@@ -73,7 +74,8 @@ interface ResolutionWithResolvedFileName {
|
||||
packagetId?: PackageId;
|
||||
}
|
||||
|
||||
interface CachedResolvedModuleWithFailedLookupLocations extends ResolvedModuleWithFailedLookupLocations, ResolutionWithFailedLookupLocations {
|
||||
/** @internal */
|
||||
export interface CachedResolvedModuleWithFailedLookupLocations extends ResolvedModuleWithFailedLookupLocations, ResolutionWithFailedLookupLocations {
|
||||
}
|
||||
|
||||
interface CachedResolvedTypeReferenceDirectiveWithFailedLookupLocations extends ResolvedTypeReferenceDirectiveWithFailedLookupLocations, ResolutionWithFailedLookupLocations {
|
||||
|
||||
+2
-2
@@ -1260,7 +1260,7 @@ export function patchWriteFileEnsuringDirectory(sys: System) {
|
||||
export type BufferEncoding = "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex";
|
||||
|
||||
/** @internal */
|
||||
interface NodeBuffer extends Uint8Array {
|
||||
export interface NodeBuffer extends Uint8Array {
|
||||
constructor: any;
|
||||
write(str: string, encoding?: BufferEncoding): number;
|
||||
write(str: string, offset: number, encoding?: BufferEncoding): number;
|
||||
@@ -1336,7 +1336,7 @@ interface NodeBuffer extends Uint8Array {
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
interface Buffer extends NodeBuffer { }
|
||||
export interface Buffer extends NodeBuffer { }
|
||||
|
||||
// TODO: GH#18217 Methods on System are often used as if they are certainly defined
|
||||
export interface System {
|
||||
|
||||
@@ -12,8 +12,11 @@ import {
|
||||
export let tracing: typeof tracingEnabled | undefined;
|
||||
// enable the above using startTracing()
|
||||
|
||||
// `tracingEnabled` should never be used directly, only through the above
|
||||
namespace tracingEnabled {
|
||||
/**
|
||||
* Do not use this directly; instead @see {tracing}.
|
||||
* @internal
|
||||
*/
|
||||
export namespace tracingEnabled {
|
||||
type Mode = "project" | "build" | "server";
|
||||
|
||||
let fs: typeof import("fs");
|
||||
|
||||
@@ -33,7 +33,7 @@ import {
|
||||
startOnNewLine, Statement, SuperProperty, SyntaxKind, TaggedTemplateExpression, ThisExpression,
|
||||
TransformationContext, TransformFlags, tryGetTextOfPropertyName, UnderscoreEscapedMap, unescapeLeadingUnderscores,
|
||||
VariableStatement, visitArray, visitEachChild, visitFunctionBody, visitIterationBody, visitNode, visitNodes,
|
||||
visitParameterList, VisitResult,
|
||||
visitParameterList, VisitResult, Bundle,
|
||||
} from "../_namespaces/ts";
|
||||
|
||||
const enum ClassPropertySubstitutionFlags {
|
||||
@@ -168,7 +168,7 @@ const enum ClassFacts {
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export function transformClassFields(context: TransformationContext) {
|
||||
export function transformClassFields(context: TransformationContext): (x: SourceFile | Bundle) => SourceFile | Bundle {
|
||||
const {
|
||||
factory,
|
||||
hoistVariableDeclaration,
|
||||
|
||||
@@ -33,7 +33,7 @@ import {
|
||||
SyntaxKind, TaggedTemplateExpression, takeWhile, TemplateExpression, TextRange, TokenFlags, TransformationContext,
|
||||
TransformFlags, tryCast, unescapeLeadingUnderscores, unwrapInnermostStatementOfLabel, VariableDeclaration,
|
||||
VariableDeclarationList, VariableStatement, visitEachChild, visitNode, visitNodes, visitParameterList, VisitResult,
|
||||
VoidExpression, WhileStatement, YieldExpression,
|
||||
VoidExpression, WhileStatement, YieldExpression, Bundle,
|
||||
} from "../_namespaces/ts";
|
||||
|
||||
const enum ES2015SubstitutionFlags {
|
||||
@@ -299,7 +299,7 @@ function createSpreadSegment(kind: SpreadSegmentKind, expression: Expression): S
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function transformES2015(context: TransformationContext) {
|
||||
export function transformES2015(context: TransformationContext): (x: SourceFile | Bundle) => SourceFile | Bundle {
|
||||
const {
|
||||
factory,
|
||||
getEmitHelperFactory: emitHelpers,
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import {
|
||||
BinaryExpression, chainBundle, Expression, isElementAccessExpression, isExpression, isPropertyAccessExpression,
|
||||
BinaryExpression, Bundle, chainBundle, Expression, isElementAccessExpression, isExpression, isPropertyAccessExpression,
|
||||
Node, setTextRange, SourceFile, SyntaxKind, TransformationContext, TransformFlags, visitEachChild, visitNode,
|
||||
VisitResult,
|
||||
} from "../_namespaces/ts";
|
||||
|
||||
/** @internal */
|
||||
export function transformES2016(context: TransformationContext) {
|
||||
export function transformES2016(context: TransformationContext): (x: SourceFile | Bundle) => SourceFile | Bundle {
|
||||
const {
|
||||
factory,
|
||||
hoistVariableDeclaration
|
||||
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
setOriginalNode, setSourceMapRange, setTextRange, some, SourceFile, Statement, SyntaxKind, TextRange,
|
||||
TransformationContext, TransformFlags, TypeNode, TypeReferenceSerializationKind, unescapeLeadingUnderscores,
|
||||
VariableDeclaration, VariableDeclarationList, VariableStatement, visitEachChild, visitFunctionBody,
|
||||
visitIterationBody, visitNode, visitNodes, visitParameterList, VisitResult,
|
||||
visitIterationBody, visitNode, visitNodes, visitParameterList, VisitResult, Bundle,
|
||||
} from "../_namespaces/ts";
|
||||
|
||||
type SuperContainer = ClassDeclaration | MethodDeclaration | GetAccessorDeclaration | SetAccessorDeclaration | ConstructorDeclaration;
|
||||
@@ -30,7 +30,7 @@ const enum ContextFlags {
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function transformES2017(context: TransformationContext) {
|
||||
export function transformES2017(context: TransformationContext): (x: SourceFile | Bundle) => SourceFile | Bundle {
|
||||
const {
|
||||
factory,
|
||||
getEmitHelperFactory: emitHelpers,
|
||||
|
||||
@@ -17,7 +17,7 @@ import {
|
||||
skipParentheses, some, SourceFile, startOnNewLine, Statement, SyntaxKind, TaggedTemplateExpression, TextRange,
|
||||
Token, TransformationContext, TransformFlags, unwrapInnermostStatementOfLabel, VariableDeclaration,
|
||||
VariableStatement, visitEachChild, visitIterationBody, visitLexicalEnvironment, visitNode, visitNodes,
|
||||
visitParameterList, VisitResult, VoidExpression, YieldExpression,
|
||||
visitParameterList, VisitResult, VoidExpression, YieldExpression, Bundle,
|
||||
} from "../_namespaces/ts";
|
||||
|
||||
const enum ESNextSubstitutionFlags {
|
||||
@@ -58,7 +58,7 @@ const enum HierarchyFacts {
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function transformES2018(context: TransformationContext) {
|
||||
export function transformES2018(context: TransformationContext): (x: SourceFile | Bundle) => SourceFile | Bundle {
|
||||
const {
|
||||
factory,
|
||||
getEmitHelperFactory: emitHelpers,
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import {
|
||||
Bundle,
|
||||
CatchClause, chainBundle, isBlock, Node, SourceFile, SyntaxKind, TransformationContext, TransformFlags,
|
||||
visitEachChild, visitNode, VisitResult,
|
||||
} from "../_namespaces/ts";
|
||||
|
||||
/** @internal */
|
||||
export function transformES2019(context: TransformationContext) {
|
||||
export function transformES2019(context: TransformationContext): (x: SourceFile | Bundle) => SourceFile | Bundle {
|
||||
const factory = context.factory;
|
||||
return chainBundle(context, transformSourceFile);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {
|
||||
AccessExpression, addEmitFlags, BinaryExpression, CallExpression, cast, chainBundle, Debug, DeleteExpression,
|
||||
AccessExpression, addEmitFlags, BinaryExpression, Bundle, CallExpression, cast, chainBundle, Debug, DeleteExpression,
|
||||
EmitFlags, Expression, isCallChain, isExpression, isGeneratedIdentifier, isIdentifier, isNonNullChain,
|
||||
isOptionalChain, isParenthesizedExpression, isSimpleCopiableExpression, isSyntheticReference,
|
||||
isTaggedTemplateExpression, Node, OptionalChain, OuterExpressionKinds, ParenthesizedExpression, setOriginalNode,
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
} from "../_namespaces/ts";
|
||||
|
||||
/** @internal */
|
||||
export function transformES2020(context: TransformationContext) {
|
||||
export function transformES2020(context: TransformationContext): (x: SourceFile | Bundle) => SourceFile | Bundle {
|
||||
const {
|
||||
factory,
|
||||
hoistVariableDeclaration,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {
|
||||
AssignmentExpression, BinaryExpression, chainBundle, getNonAssignmentOperatorForCompoundAssignment,
|
||||
AssignmentExpression, BinaryExpression, Bundle, chainBundle, getNonAssignmentOperatorForCompoundAssignment,
|
||||
isAccessExpression, isExpression, isLeftHandSideExpression, isLogicalOrCoalescingAssignmentExpression,
|
||||
isPropertyAccessExpression, isSimpleCopiableExpression, LogicalOrCoalescingAssignmentOperator, Node,
|
||||
skipParentheses, SourceFile, SyntaxKind, Token, TransformationContext, TransformFlags, visitEachChild, visitNode,
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
} from "../_namespaces/ts";
|
||||
|
||||
/** @internal */
|
||||
export function transformES2021(context: TransformationContext) {
|
||||
export function transformES2021(context: TransformationContext): (x: SourceFile | Bundle) => SourceFile | Bundle {
|
||||
const {
|
||||
hoistVariableDeclaration,
|
||||
factory
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import {
|
||||
Bundle,
|
||||
chainBundle, EmitHint, Expression, getOriginalNodeId, Identifier, idText, isIdentifier, isPrivateIdentifier,
|
||||
isPropertyAccessExpression, isPropertyAssignment, JsxClosingElement, JsxEmit, JsxOpeningElement,
|
||||
JsxSelfClosingElement, Node, nodeIsSynthesized, PropertyAccessExpression, PropertyAssignment, setTextRange,
|
||||
@@ -12,7 +13,7 @@ import {
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export function transformES5(context: TransformationContext) {
|
||||
export function transformES5(context: TransformationContext): (x: SourceFile | Bundle) => SourceFile | Bundle {
|
||||
const { factory } = context;
|
||||
const compilerOptions = context.getCompilerOptions();
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import {
|
||||
Bundle,
|
||||
chainBundle, Node, SourceFile, TransformationContext, TransformFlags, visitEachChild, VisitResult,
|
||||
} from "../_namespaces/ts";
|
||||
|
||||
/** @internal */
|
||||
export function transformESNext(context: TransformationContext) {
|
||||
export function transformESNext(context: TransformationContext): (x: SourceFile | Bundle) => SourceFile | Bundle {
|
||||
return chainBundle(context, transformSourceFile);
|
||||
|
||||
function transformSourceFile(node: SourceFile) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {
|
||||
AccessorDeclaration, addEmitHelpers, addSyntheticTrailingComment, ArrayLiteralExpression, Associativity,
|
||||
BinaryExpression, Block, BreakStatement, CallExpression, CaseClause, chainBundle, CommaListExpression,
|
||||
BinaryExpression, Block, BreakStatement, Bundle, CallExpression, CaseClause, chainBundle, CommaListExpression,
|
||||
ConditionalExpression, ContinueStatement, createExpressionForObjectLiteralElementLike, Debug, DoStatement,
|
||||
ElementAccessExpression, EmitFlags, EmitHint, ESMap, Expression, ExpressionStatement, forEach, ForInStatement,
|
||||
ForStatement, FunctionDeclaration, FunctionExpression, getEmitFlags, getEmitScriptTarget,
|
||||
@@ -247,7 +247,7 @@ function getInstructionName(instruction: Instruction): string {
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function transformGenerators(context: TransformationContext) {
|
||||
export function transformGenerators(context: TransformationContext): (x: SourceFile | Bundle) => SourceFile | Bundle {
|
||||
const {
|
||||
factory,
|
||||
getEmitHelperFactory: emitHelpers,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {
|
||||
addEmitHelpers, arrayFrom, chainBundle, createExpressionForJsxElement, createExpressionForJsxFragment,
|
||||
addEmitHelpers, arrayFrom, Bundle, chainBundle, createExpressionForJsxElement, createExpressionForJsxFragment,
|
||||
createExpressionFromEntityName, createJsxFactoryExpression, Debug, emptyArray, Expression, filter, find, flatten,
|
||||
GeneratedIdentifierFlags, getEmitScriptTarget, getEntries, getJSXImplicitImportBase, getJSXRuntimeImport,
|
||||
getLineAndCharacterOfPosition, getOriginalNode, getSemanticJsxChildren, Identifier, idText, ImportSpecifier,
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
} from "../_namespaces/ts";
|
||||
|
||||
/** @internal */
|
||||
export function transformJsx(context: TransformationContext) {
|
||||
export function transformJsx(context: TransformationContext): (x: SourceFile | Bundle) => SourceFile | Bundle {
|
||||
interface PerFileState {
|
||||
importSpecifier?: string;
|
||||
filenameDeclaration?: VariableDeclaration & { name: Identifier; };
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {
|
||||
addEmitHelpers, addRange, AllDecorators, append, canHaveDecorators, chainBundle, childIsDecorated, ClassDeclaration,
|
||||
addEmitHelpers, addRange, AllDecorators, append, Bundle, canHaveDecorators, chainBundle, childIsDecorated, ClassDeclaration,
|
||||
ClassElement, ClassExpression, ClassLikeDeclaration, classOrConstructorParameterIsDecorated, ConstructorDeclaration,
|
||||
Decorator, elideNodes, EmitFlags, EmitHint, EnumMember, Expression, filter, flatMap, GetAccessorDeclaration,
|
||||
getAllDecoratorsOfClass, getAllDecoratorsOfClassElement, getEmitFlags, getEmitScriptTarget, getOriginalNodeId,
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
} from "../_namespaces/ts";
|
||||
|
||||
/** @internal */
|
||||
export function transformLegacyDecorators(context: TransformationContext) {
|
||||
export function transformLegacyDecorators(context: TransformationContext): (x: SourceFile | Bundle) => SourceFile | Bundle {
|
||||
const {
|
||||
factory,
|
||||
getEmitHelperFactory: emitHelpers,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {
|
||||
addRange, append, chainBundle, createEmptyExports, createExternalHelpersImportDeclarationIfNeeded, Debug, EmitFlags,
|
||||
addRange, append, Bundle, chainBundle, createEmptyExports, createExternalHelpersImportDeclarationIfNeeded, Debug, EmitFlags,
|
||||
EmitHint, ESMap, ExportAssignment, ExportDeclaration, Expression, GeneratedIdentifierFlags, getEmitFlags,
|
||||
getEmitModuleKind, getEmitScriptTarget, getExternalModuleNameLiteral, hasSyntacticModifier, Identifier, idText,
|
||||
ImportDeclaration, ImportEqualsDeclaration, insertStatementsAfterCustomPrologue,
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
} from "../../_namespaces/ts";
|
||||
|
||||
/** @internal */
|
||||
export function transformECMAScriptModule(context: TransformationContext) {
|
||||
export function transformECMAScriptModule(context: TransformationContext): (x: SourceFile | Bundle) => SourceFile | Bundle {
|
||||
const {
|
||||
factory,
|
||||
getEmitHelperFactory: emitHelpers,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import {
|
||||
addEmitFlags, addEmitHelper, addEmitHelpers, addRange, append, ArrowFunction, BinaryExpression, BindingElement,
|
||||
Bundle,
|
||||
CallExpression, chainBundle, ClassDeclaration, collectExternalModuleInfo, Debug, Declaration,
|
||||
DestructuringAssignment, EmitFlags, EmitHelper, EmitHint, emptyArray, EndOfDeclarationMarker, ExportAssignment,
|
||||
ExportDeclaration, Expression, ExpressionStatement, ExternalModuleInfo, firstOrUndefined,
|
||||
@@ -27,7 +28,7 @@ import {
|
||||
} from "../../_namespaces/ts";
|
||||
|
||||
/** @internal */
|
||||
export function transformModule(context: TransformationContext) {
|
||||
export function transformModule(context: TransformationContext): (x: SourceFile | Bundle) => SourceFile | Bundle {
|
||||
interface AsynchronousDependencies {
|
||||
aliasedModuleNames: Expression[];
|
||||
unaliasedModuleNames: Expression[];
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {
|
||||
addRange, append, BinaryExpression, BindingElement, Block, CaseBlock, CaseClause, CaseOrDefaultClause, CatchClause,
|
||||
addRange, append, BinaryExpression, BindingElement, Block, Bundle, CaseBlock, CaseClause, CaseOrDefaultClause, CatchClause,
|
||||
chainBundle, ClassDeclaration, collectExternalModuleInfo, Debug, Declaration, DefaultClause,
|
||||
DestructuringAssignment, DoStatement, EmitFlags, EmitHint, EndOfDeclarationMarker, ExportAssignment,
|
||||
ExportDeclaration, Expression, ExpressionStatement, ExternalModuleInfo, firstOrUndefined,
|
||||
@@ -25,7 +25,7 @@ import {
|
||||
} from "../../_namespaces/ts";
|
||||
|
||||
/** @internal */
|
||||
export function transformSystemModule(context: TransformationContext) {
|
||||
export function transformSystemModule(context: TransformationContext): (x: SourceFile | Bundle) => SourceFile | Bundle {
|
||||
interface DependencyGroup {
|
||||
name: StringLiteral;
|
||||
externalImports: (ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration)[];
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import {
|
||||
CallExpression,
|
||||
Debug, Expression, factory, getSourceTextOfNodeFromSourceFile, hasInvalidEscape, Identifier, isExpression,
|
||||
isExternalModule, isNoSubstitutionTemplateLiteral, NoSubstitutionTemplateLiteral, setTextRange, SourceFile,
|
||||
SyntaxKind, TaggedTemplateExpression, TemplateHead, TemplateLiteralLikeNode, TemplateMiddle, TemplateTail,
|
||||
@@ -18,7 +19,7 @@ export function processTaggedTemplateExpression(
|
||||
visitor: Visitor,
|
||||
currentSourceFile: SourceFile,
|
||||
recordTaggedTemplateString: (temp: Identifier) => void,
|
||||
level: ProcessLevel) {
|
||||
level: ProcessLevel): CallExpression | TaggedTemplateExpression {
|
||||
|
||||
// Visit the tag expression
|
||||
const tag = visitNode(node.tag, visitor, isExpression);
|
||||
|
||||
@@ -14,14 +14,17 @@ import {
|
||||
VoidExpression,
|
||||
} from "../_namespaces/ts";
|
||||
|
||||
type SerializedEntityName =
|
||||
/** @internal */
|
||||
export type SerializedEntityName =
|
||||
| Identifier // Globals (i.e., `String`, `Number`, etc.)
|
||||
// Globals (i.e., `String`, `Number`, etc.)
|
||||
| PropertyAccessEntityNameExpression // `A.B`
|
||||
// `A.B`
|
||||
;
|
||||
|
||||
type SerializedTypeNode =
|
||||
|
||||
/** @internal */
|
||||
export type SerializedTypeNode =
|
||||
| SerializedEntityName
|
||||
| ConditionalExpression // Type Reference or Global fallback
|
||||
// Type Reference or Global fallback
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
isPrivateIdentifier, isPropertyDeclaration, isStatic, isStringLiteralLike, isSuperCall, LogicalOperatorOrHigher,
|
||||
map, Map, MethodDeclaration, ModifierFlags, NamedImportBindings, NamespaceExport, Node, NodeArray,
|
||||
parameterIsThisKeyword, PrivateIdentifierAccessorDeclaration, PrivateIdentifierAutoAccessorPropertyDeclaration,
|
||||
PrivateIdentifierMethodDeclaration, PropertyDeclaration, skipParentheses, some, SourceFile, Statement, SyntaxKind,
|
||||
PrivateIdentifierMethodDeclaration, PropertyDeclaration, skipParentheses, some, SourceFile, Statement, SuperCall, SyntaxKind,
|
||||
TransformationContext, VariableDeclaration, VariableStatement,
|
||||
} from "../_namespaces/ts";
|
||||
|
||||
@@ -332,7 +332,7 @@ export function getNonAssignmentOperatorForCompoundAssignment(kind: CompoundAssi
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export function getSuperCallFromStatement(statement: Statement) {
|
||||
export function getSuperCallFromStatement(statement: Statement): SuperCall | undefined {
|
||||
if (!isExpressionStatement(statement)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@@ -5093,7 +5093,7 @@ export interface SymbolWalker {
|
||||
|
||||
// This was previously deprecated in our public API, but is still used internally
|
||||
/** @internal */
|
||||
interface SymbolWriter extends SymbolTracker {
|
||||
export interface SymbolWriter extends SymbolTracker {
|
||||
writeKeyword(text: string): void;
|
||||
writeOperator(text: string): void;
|
||||
writePunctuation(text: string): void;
|
||||
@@ -9250,7 +9250,7 @@ export const enum PragmaKindFlags {
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
interface PragmaArgumentSpecification<TName extends string> {
|
||||
export interface PragmaArgumentSpecification<TName extends string> {
|
||||
name: TName; // Determines the name of the key in the resulting parsed type, type parameter to cause literal type inference
|
||||
optional?: boolean;
|
||||
captureSpan?: boolean;
|
||||
@@ -9314,20 +9314,20 @@ export const commentPragmas = {
|
||||
} as const;
|
||||
|
||||
/** @internal */
|
||||
type PragmaArgTypeMaybeCapture<TDesc> = TDesc extends {captureSpan: true} ? {value: string, pos: number, end: number} : string;
|
||||
export type PragmaArgTypeMaybeCapture<TDesc> = TDesc extends {captureSpan: true} ? {value: string, pos: number, end: number} : string;
|
||||
|
||||
/** @internal */
|
||||
type PragmaArgTypeOptional<TDesc, TName extends string> =
|
||||
export type PragmaArgTypeOptional<TDesc, TName extends string> =
|
||||
TDesc extends {optional: true}
|
||||
? {[K in TName]?: PragmaArgTypeMaybeCapture<TDesc>}
|
||||
: {[K in TName]: PragmaArgTypeMaybeCapture<TDesc>};
|
||||
|
||||
/** @internal */
|
||||
type UnionToIntersection<U> =
|
||||
export type UnionToIntersection<U> =
|
||||
(U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
|
||||
|
||||
/** @internal */
|
||||
type ArgumentDefinitionToFieldUnion<T extends readonly PragmaArgumentSpecification<any>[]> = {
|
||||
export type ArgumentDefinitionToFieldUnion<T extends readonly PragmaArgumentSpecification<any>[]> = {
|
||||
[K in keyof T]: PragmaArgTypeOptional<T[K], T[K] extends {name: infer TName} ? TName extends string ? TName : never : never>
|
||||
}[Extract<keyof T, number>]; // The mapped type maps over only the tuple members, but this reindex gets _all_ members - by extracting only `number` keys, we get only the tuple members
|
||||
|
||||
@@ -9336,13 +9336,13 @@ type ArgumentDefinitionToFieldUnion<T extends readonly PragmaArgumentSpecificati
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
type PragmaArgumentType<KPrag extends keyof ConcretePragmaSpecs> =
|
||||
export type PragmaArgumentType<KPrag extends keyof ConcretePragmaSpecs> =
|
||||
ConcretePragmaSpecs[KPrag] extends { args: readonly PragmaArgumentSpecification<any>[] }
|
||||
? UnionToIntersection<ArgumentDefinitionToFieldUnion<ConcretePragmaSpecs[KPrag]["args"]>>
|
||||
: never;
|
||||
|
||||
/** @internal */
|
||||
type ConcretePragmaSpecs = typeof commentPragmas;
|
||||
export type ConcretePragmaSpecs = typeof commentPragmas;
|
||||
|
||||
/** @internal */
|
||||
export type PragmaPseudoMap = {[K in keyof ConcretePragmaSpecs]: {arguments: PragmaArgumentType<K>, range: CommentRange}};
|
||||
|
||||
@@ -721,7 +721,8 @@ export function getEmitFlags(node: Node): EmitFlags {
|
||||
return emitNode && emitNode.flags || 0;
|
||||
}
|
||||
|
||||
interface ScriptTargetFeatures {
|
||||
/** @internal */
|
||||
export interface ScriptTargetFeatures {
|
||||
[key: string]: { [key: string]: string[] | undefined };
|
||||
}
|
||||
|
||||
@@ -6743,14 +6744,14 @@ export function formatStringFromArgs(text: string, args: ArrayLike<string | numb
|
||||
let localizedDiagnosticMessages: MapLike<string> | undefined;
|
||||
|
||||
/** @internal */
|
||||
export function setLocalizedDiagnosticMessages(messages: typeof localizedDiagnosticMessages) {
|
||||
export function setLocalizedDiagnosticMessages(messages: MapLike<string> | undefined) {
|
||||
localizedDiagnosticMessages = messages;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
// If the localized messages json is unset, and if given function use it to set the json
|
||||
|
||||
export function maybeSetLocalizedDiagnosticMessages(getMessages: undefined | (() => typeof localizedDiagnosticMessages)) {
|
||||
export function maybeSetLocalizedDiagnosticMessages(getMessages: undefined | (() => MapLike<string> | undefined)) {
|
||||
if (!localizedDiagnosticMessages && getMessages) {
|
||||
localizedDiagnosticMessages = getMessages();
|
||||
}
|
||||
|
||||
+12
-9
@@ -1,11 +1,10 @@
|
||||
import * as ts from "./_namespaces/ts";
|
||||
import {
|
||||
addRange, BuilderProgram, CancellationToken, chainDiagnosticMessages, CharacterCodes, combinePaths, CompilerHost,
|
||||
CompilerOptions, contains, convertToRelativePath, copyProperties, countWhere, createCompilerDiagnostic,
|
||||
createEmitAndSemanticDiagnosticsBuilderProgram, createGetCanonicalFileName, createGetSourceFile,
|
||||
createIncrementalCompilerHost, createIncrementalProgram, CreateProgram, createWriteFileMeasuringIO,
|
||||
CustomTransformers, Debug, Diagnostic, DiagnosticCategory, DiagnosticMessage, DiagnosticMessageChain,
|
||||
DiagnosticReporter, Diagnostics, DirectoryStructureHost, EmitAndSemanticDiagnosticsBuilderProgram, emptyArray,
|
||||
DiagnosticReporter, Diagnostics, DirectoryStructureHost, EmitAndSemanticDiagnosticsBuilderProgram, EmitResult, emptyArray,
|
||||
endsWith, ExitStatus, ExtendedConfigCacheEntry, Extension, externalHelpersModuleNameText, FileExtensionInfo,
|
||||
fileExtensionIs, FileIncludeKind, FileIncludeReason, FileWatcher, filter, find, flattenDiagnosticMessageText,
|
||||
forEach, forEachEntry, ForegroundColorEscapeSequences, formatColorAndReset, formatDiagnostic, FormatDiagnosticsHost,
|
||||
@@ -14,10 +13,10 @@ import {
|
||||
getParsedCommandLineOfConfigFile, getPatternFromSpec, getReferencedFileLocation, getRegexFromPattern,
|
||||
getRelativePathFromDirectory, getWatchFactory, HasCurrentDirectory, isExternalOrCommonJsModule, isLineBreak,
|
||||
isReferencedFile, isReferenceFileLocation, isString, last, Map, maybeBind, memoize, ModuleKind, noop, normalizePath,
|
||||
outFile, packageIdToString, ParseConfigFileHost, pathIsAbsolute, Program, ProgramHost, ProjectReference,
|
||||
ReportEmitErrorSummary, ReportFileInError, sortAndDeduplicateDiagnostics, SourceFile, sourceMapCommentRegExp,
|
||||
outFile, packageIdToString, ParseConfigFileHost, ParsedCommandLine, pathIsAbsolute, Program, ProgramHost, ProjectReference,
|
||||
ReportEmitErrorSummary, ReportFileInError, sortAndDeduplicateDiagnostics, SortedReadonlyArray, SourceFile, sourceMapCommentRegExp,
|
||||
sourceMapCommentRegExpDontCareLineStart, sys, System, targetOptionDeclaration, WatchCompilerHost,
|
||||
WatchCompilerHostOfConfigFile, WatchCompilerHostOfFilesAndCompilerOptions, WatchFactoryHost, WatchHost,
|
||||
WatchCompilerHostOfConfigFile, WatchCompilerHostOfFilesAndCompilerOptions, WatchFactory, WatchFactoryHost, WatchHost,
|
||||
WatchLogLevel, WatchOptions, WatchStatusReporter, whitespaceOrMapCommentRegExp, WriteFileCallback,
|
||||
} from "./_namespaces/ts";
|
||||
|
||||
@@ -121,7 +120,7 @@ export function createWatchStatusReporter(system: System, pretty?: boolean): Wat
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export function parseConfigFileWithSystem(configFileName: string, optionsToExtend: CompilerOptions, extendedConfigCache: Map<ExtendedConfigCacheEntry> | undefined, watchOptionsToExtend: WatchOptions | undefined, system: System, reportDiagnostic: DiagnosticReporter) {
|
||||
export function parseConfigFileWithSystem(configFileName: string, optionsToExtend: CompilerOptions, extendedConfigCache: Map<ExtendedConfigCacheEntry> | undefined, watchOptionsToExtend: WatchOptions | undefined, system: System, reportDiagnostic: DiagnosticReporter): ParsedCommandLine | undefined {
|
||||
const host: ParseConfigFileHost = system as any;
|
||||
host.onUnRecoverableConfigFileDiagnostic = diagnostic => reportUnrecoverableDiagnostic(system, reportDiagnostic, diagnostic);
|
||||
const result = getParsedCommandLineOfConfigFile(configFileName, optionsToExtend, host, extendedConfigCache, watchOptionsToExtend);
|
||||
@@ -481,7 +480,10 @@ export function emitFilesAndReportErrors<T extends BuilderProgram>(
|
||||
cancellationToken?: CancellationToken,
|
||||
emitOnlyDtsFiles?: boolean,
|
||||
customTransformers?: CustomTransformers
|
||||
) {
|
||||
): {
|
||||
emitResult: EmitResult;
|
||||
diagnostics: SortedReadonlyArray<Diagnostic>;
|
||||
} {
|
||||
const isListFilesOnly = !!program.getCompilerOptions().listFilesOnly;
|
||||
|
||||
// First get and report any syntactic errors.
|
||||
@@ -632,7 +634,8 @@ export interface WatchTypeRegistry {
|
||||
NodeModulesForModuleSpecifierCache: "node_modules for module specifier cache invalidation",
|
||||
}
|
||||
|
||||
interface WatchFactory<X, Y = undefined> extends ts.WatchFactory<X, Y> {
|
||||
/** @internal */
|
||||
export interface WatchFactoryWithLog<X, Y = undefined> extends WatchFactory<X, Y> {
|
||||
writeLog: (s: string) => void;
|
||||
}
|
||||
|
||||
@@ -640,7 +643,7 @@ interface WatchFactory<X, Y = undefined> extends ts.WatchFactory<X, Y> {
|
||||
export function createWatchFactory<Y = undefined>(host: WatchFactoryHost & { trace?(s: string): void; }, options: { extendedDiagnostics?: boolean; diagnostics?: boolean; }) {
|
||||
const watchLogLevel = host.trace ? options.extendedDiagnostics ? WatchLogLevel.Verbose : options.diagnostics ? WatchLogLevel.TriggerOnly : WatchLogLevel.None : WatchLogLevel.None;
|
||||
const writeLog: (s: string) => void = watchLogLevel !== WatchLogLevel.None ? (s => host.trace!(s)) : noop;
|
||||
const result = getWatchFactory<WatchType, Y>(host, watchLogLevel, writeLog) as WatchFactory<WatchType, Y>;
|
||||
const result = getWatchFactory<WatchType, Y>(host, watchLogLevel, writeLog) as WatchFactoryWithLog<WatchType, Y>;
|
||||
result.writeLog = writeLog;
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -30,7 +30,8 @@ export interface DirectoryStructureHost {
|
||||
writeFile?(path: string, data: string, writeByteOrderMark?: boolean): void;
|
||||
}
|
||||
|
||||
interface FileAndDirectoryExistence {
|
||||
/** @internal */
|
||||
export interface FileAndDirectoryExistence {
|
||||
fileExists: boolean;
|
||||
directoryExists: boolean;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
||||
import { Debug, DeprecationOptions, hasProperty } from "./_namespaces/ts";
|
||||
import { Debug, DeprecationOptions, hasProperty, UnionToIntersection } from "./_namespaces/ts";
|
||||
|
||||
// The following are deprecations for the public API. Deprecated exports are removed from the compiler itself
|
||||
// and compatible implementations are added here, along with an appropriate deprecation warning using
|
||||
@@ -12,31 +12,54 @@ import { Debug, DeprecationOptions, hasProperty } from "./_namespaces/ts";
|
||||
//
|
||||
// Once we have determined enough time has passed after a deprecation has been marked as `"warn"` or `"error"`, it will be removed from the public API.
|
||||
|
||||
/** Defines a list of overloads by ordinal */
|
||||
type OverloadDefinitions = { readonly [P in number]: (...args: any[]) => any; };
|
||||
/**
|
||||
* Defines a list of overloads by ordinal
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export type OverloadDefinitions = { readonly [P in number]: (...args: any[]) => any; };
|
||||
|
||||
/** A function that returns the ordinal of the overload that matches the provided arguments */
|
||||
type OverloadBinder<T extends OverloadDefinitions> = (args: OverloadParameters<T>) => OverloadKeys<T> | undefined;
|
||||
|
||||
/** Extracts the ordinals from an set of overload definitions. */
|
||||
type OverloadKeys<T extends OverloadDefinitions> = Extract<keyof T, number>;
|
||||
/**
|
||||
* Extracts the ordinals from an set of overload definitions.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export type OverloadKeys<T extends OverloadDefinitions> = Extract<keyof T, number>;
|
||||
|
||||
/** Extracts a union of the potential parameter lists for each overload. */
|
||||
type OverloadParameters<T extends OverloadDefinitions> = Parameters<{ [P in OverloadKeys<T>]: T[P]; }[OverloadKeys<T>]>;
|
||||
/**
|
||||
* Extracts a union of the potential parameter lists for each overload.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export type OverloadParameters<T extends OverloadDefinitions> = Parameters<{ [P in OverloadKeys<T>]: T[P]; }[OverloadKeys<T>]>;
|
||||
|
||||
// NOTE: the following doesn't work in TS 4.4 (the current LKG in main), so we have to use UnionToIntersection for now
|
||||
/** Constructs an intersection of each overload in a set of overload definitions. */
|
||||
// type OverloadFunction<T extends OverloadDefinitions, R extends ((...args: any[]) => any)[] = [], O = unknown> =
|
||||
// R["length"] extends keyof T ? OverloadFunction<T, [...R, T[R["length"]]], O & T[R["length"]]> :
|
||||
// unknown extends O ? never : O;
|
||||
type UnionToIntersection<T> = (T extends any ? (x: T) => any : never) extends (x: infer R) => any ? R : never;
|
||||
type OverloadFunction<T extends OverloadDefinitions> = UnionToIntersection<T[keyof T]>;
|
||||
/**
|
||||
* Constructs an intersection of each overload in a set of overload definitions.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export type OverloadFunction<T extends OverloadDefinitions> = UnionToIntersection<T[keyof T]>;
|
||||
|
||||
/** Maps each ordinal in a set of overload definitions to a function that can be used to bind its arguments. */
|
||||
type OverloadBinders<T extends OverloadDefinitions> = { [P in OverloadKeys<T>]: (args: OverloadParameters<T>) => boolean | undefined; };
|
||||
/**
|
||||
* Maps each ordinal in a set of overload definitions to a function that can be used to bind its arguments.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export type OverloadBinders<T extends OverloadDefinitions> = { [P in OverloadKeys<T>]: (args: OverloadParameters<T>) => boolean | undefined; };
|
||||
|
||||
/** Defines deprecations for specific overloads by ordinal. */
|
||||
type OverloadDeprecations<T extends OverloadDefinitions> = { [P in OverloadKeys<T>]?: DeprecationOptions; };
|
||||
/**
|
||||
* Defines deprecations for specific overloads by ordinal.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export type OverloadDeprecations<T extends OverloadDefinitions> = { [P in OverloadKeys<T>]?: DeprecationOptions; };
|
||||
|
||||
/** @internal */
|
||||
export function createOverload<T extends OverloadDefinitions>(name: string, overloads: T, binder: OverloadBinders<T>, deprecations?: OverloadDeprecations<T>) {
|
||||
@@ -75,19 +98,23 @@ function createBinder<T extends OverloadDefinitions>(overloads: T, binder: Overl
|
||||
};
|
||||
}
|
||||
|
||||
interface OverloadBuilder {
|
||||
/** @internal */
|
||||
export interface OverloadBuilder {
|
||||
overload<T extends OverloadDefinitions>(overloads: T): BindableOverloadBuilder<T>;
|
||||
}
|
||||
|
||||
interface BindableOverloadBuilder<T extends OverloadDefinitions> {
|
||||
/** @internal */
|
||||
export interface BindableOverloadBuilder<T extends OverloadDefinitions> {
|
||||
bind(binder: OverloadBinders<T>): BoundOverloadBuilder<T>;
|
||||
}
|
||||
|
||||
interface FinishableOverloadBuilder<T extends OverloadDefinitions> {
|
||||
/** @internal */
|
||||
export interface FinishableOverloadBuilder<T extends OverloadDefinitions> {
|
||||
finish(): OverloadFunction<T>;
|
||||
}
|
||||
|
||||
interface BoundOverloadBuilder<T extends OverloadDefinitions> extends FinishableOverloadBuilder<T> {
|
||||
/** @internal */
|
||||
export interface BoundOverloadBuilder<T extends OverloadDefinitions> extends FinishableOverloadBuilder<T> {
|
||||
deprecate(deprecations: OverloadDeprecations<T>): FinishableOverloadBuilder<T>;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ import {
|
||||
parseJsonSourceFileConfigFileContent, parseJsonText, parsePackageName, Path, PerformanceEvent, PluginImport,
|
||||
PollingInterval, ProjectPackageJsonInfo, ProjectReference, ReadMapFile, ReadonlyCollection, removeFileExtension,
|
||||
removeIgnoredPath, removeMinAndVersionNumbers, ResolvedProjectReference, resolveProjectReferencePath,
|
||||
returnNoopFileWatcher, returnTrue, ScriptKind, Set, SharedExtendedConfigFileWatcher, some, SourceFile, startsWith,
|
||||
returnNoopFileWatcher, returnTrue, ScriptKind, Set, SharedExtendedConfigFileWatcher, some, SourceFile, SourceFileLike, startsWith,
|
||||
Ternary, TextChange, toFileNameLowerCase, toPath, tracing, tryAddToSet, tryReadFile, TsConfigSourceFile,
|
||||
TypeAcquisition, typeAcquisitionDeclarations, unorderedRemoveItem, updateSharedExtendedConfigFileWatcher,
|
||||
updateWatchingWildcardDirectories, UserPreferences, version, WatchDirectoryFlags, WatchFactory, WatchLogLevel,
|
||||
@@ -397,7 +397,7 @@ function findProjectByName<T extends Project>(projectName: string, projects: T[]
|
||||
const noopConfigFileWatcher: FileWatcher = { close: noop };
|
||||
|
||||
/** @internal */
|
||||
interface ConfigFileExistenceInfo {
|
||||
export interface ConfigFileExistenceInfo {
|
||||
/**
|
||||
* Cached value of existence of config file
|
||||
* It is true if there is configured project open for this file.
|
||||
@@ -2984,7 +2984,7 @@ export class ProjectService {
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
getSourceFileLike(fileName: string, projectNameOrProject: string | Project, declarationInfo?: ScriptInfo) {
|
||||
getSourceFileLike(fileName: string, projectNameOrProject: string | Project, declarationInfo?: ScriptInfo): SourceFileLike | undefined {
|
||||
const project = (projectNameOrProject as Project).projectName ? projectNameOrProject as Project : this.findProject(projectNameOrProject as string);
|
||||
if (project) {
|
||||
const path = project.toPath(fileName);
|
||||
|
||||
@@ -6,7 +6,8 @@ import { emptyArray, protocol } from "./_namespaces/ts.server";
|
||||
|
||||
const lineCollectionCapacity = 4;
|
||||
|
||||
interface LineCollection {
|
||||
/** @internal */
|
||||
export interface LineCollection {
|
||||
charCount(): number;
|
||||
lineCount(): number;
|
||||
isLeaf(): this is LineLeaf;
|
||||
@@ -19,7 +20,8 @@ export interface AbsolutePositionAndLineText {
|
||||
lineText: string | undefined;
|
||||
}
|
||||
|
||||
const enum CharRangeSection {
|
||||
/** @internal */
|
||||
export const enum CharRangeSection {
|
||||
PreStart,
|
||||
Start,
|
||||
Entire,
|
||||
@@ -28,7 +30,8 @@ const enum CharRangeSection {
|
||||
PostEnd
|
||||
}
|
||||
|
||||
interface LineIndexWalker {
|
||||
/** @internal */
|
||||
export interface LineIndexWalker {
|
||||
goSubtree: boolean;
|
||||
done: boolean;
|
||||
leaf(relativeStart: number, relativeLength: number, lineCollection: LineLeaf): void;
|
||||
@@ -568,7 +571,8 @@ export class LineIndex {
|
||||
}
|
||||
}
|
||||
|
||||
class LineNode implements LineCollection {
|
||||
/** @internal */
|
||||
export class LineNode implements LineCollection {
|
||||
totalChars = 0;
|
||||
totalLines = 0;
|
||||
|
||||
@@ -819,7 +823,8 @@ class LineNode implements LineCollection {
|
||||
}
|
||||
}
|
||||
|
||||
class LineLeaf implements LineCollection {
|
||||
/** @internal */
|
||||
export class LineLeaf implements LineCollection {
|
||||
constructor(public text: string) {
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,8 @@ function getDeclaration(file: SourceFile, pos: number): DeclarationWithType | un
|
||||
return tryCast(isParameter(name.parent) ? name.parent.parent : name.parent, parameterShouldGetTypeFromJSDoc);
|
||||
}
|
||||
|
||||
type DeclarationWithType =
|
||||
/** @internal */
|
||||
export type DeclarationWithType =
|
||||
| FunctionLikeDeclaration
|
||||
| VariableDeclaration
|
||||
| PropertySignature
|
||||
|
||||
@@ -11,12 +11,17 @@ import {
|
||||
SymbolFlags, SyntaxKind, textChanges, TypeChecker, TypeNode,
|
||||
} from "../_namespaces/ts";
|
||||
|
||||
type AcceptedDeclaration = ParameterPropertyDeclaration | PropertyDeclaration | PropertyAssignment;
|
||||
type AcceptedNameType = Identifier | StringLiteral;
|
||||
type ContainerDeclaration = ClassLikeDeclaration | ObjectLiteralExpression;
|
||||
/** @internal */
|
||||
export type AcceptedDeclaration = ParameterPropertyDeclaration | PropertyDeclaration | PropertyAssignment;
|
||||
/** @internal */
|
||||
export type AcceptedNameType = Identifier | StringLiteral;
|
||||
/** @internal */
|
||||
export type ContainerDeclaration = ClassLikeDeclaration | ObjectLiteralExpression;
|
||||
|
||||
type Info = AccessorInfo | refactor.RefactorErrorInfo;
|
||||
interface AccessorInfo {
|
||||
/** @internal */
|
||||
export type AccessorOrRefactorErrorInfo = AccessorInfo | refactor.RefactorErrorInfo;
|
||||
/** @internal */
|
||||
export interface AccessorInfo {
|
||||
readonly container: ContainerDeclaration;
|
||||
readonly isStatic: boolean;
|
||||
readonly isReadonly: boolean;
|
||||
@@ -117,7 +122,7 @@ function prepareModifierFlagsForField(modifierFlags: ModifierFlags): ModifierFla
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function getAccessorConvertiblePropertyAtPosition(file: SourceFile, program: Program, start: number, end: number, considerEmptySpans = true): Info | undefined {
|
||||
export function getAccessorConvertiblePropertyAtPosition(file: SourceFile, program: Program, start: number, end: number, considerEmptySpans = true): AccessorOrRefactorErrorInfo | undefined {
|
||||
const node = getTokenAtPosition(file, start);
|
||||
const cursorRequest = start === end && considerEmptySpans;
|
||||
const declaration = findAncestor(node.parent, isAcceptedDeclaration);
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
IntersectionType, isArrowFunction, isAutoAccessorPropertyDeclaration, isFunctionDeclaration, isFunctionExpression,
|
||||
isGetAccessorDeclaration, isIdentifier, isImportTypeNode, isInJSFile, isLiteralImportTypeNode, isMethodDeclaration,
|
||||
isObjectLiteralExpression, isPropertyAccessExpression, isPropertyAssignment, isSetAccessorDeclaration,
|
||||
isStringLiteral, isYieldExpression, LanguageServiceHost, length, map, Map, MethodDeclaration, Modifier,
|
||||
isStringLiteral, isYieldExpression, LanguageServiceHost, length, map, Map, MethodDeclaration, MethodSignature, Modifier,
|
||||
ModifierFlags, Node, NodeArray, NodeBuilderFlags, NodeFlags, nullTransformationContext, ObjectFlags,
|
||||
ObjectLiteralExpression, ObjectType, ParameterDeclaration, Program, PropertyAssignment, PropertyDeclaration,
|
||||
PropertyName, QuotePreference, sameMap, ScriptTarget, Set, SetAccessorDeclaration, setTextRange, Signature,
|
||||
@@ -57,7 +57,8 @@ export interface TypeConstructionContext {
|
||||
host: LanguageServiceHost;
|
||||
}
|
||||
|
||||
type AddNode = PropertyDeclaration | GetAccessorDeclaration | SetAccessorDeclaration | MethodDeclaration | FunctionExpression | ArrowFunction;
|
||||
/** @internal */
|
||||
export type AddNode = PropertyDeclaration | GetAccessorDeclaration | SetAccessorDeclaration | MethodDeclaration | FunctionExpression | ArrowFunction;
|
||||
|
||||
/** @internal */
|
||||
export const enum PreserveOptionalFlags {
|
||||
@@ -353,7 +354,7 @@ export function createSignatureDeclarationFromCallExpression(
|
||||
name: Identifier | string,
|
||||
modifierFlags: ModifierFlags,
|
||||
contextNode: Node
|
||||
) {
|
||||
): MethodDeclaration | FunctionDeclaration | MethodSignature {
|
||||
const quotePreference = getQuotePreference(context.sourceFile, context.preferences);
|
||||
const scriptTarget = getEmitScriptTarget(context.program.getCompilerOptions());
|
||||
const tracker = getNoopSymbolTrackerWithResolver(context);
|
||||
@@ -417,7 +418,8 @@ export function createSignatureDeclarationFromCallExpression(
|
||||
}
|
||||
}
|
||||
|
||||
interface ArgumentTypeParameterAndConstraint {
|
||||
/** @internal */
|
||||
export interface ArgumentTypeParameterAndConstraint {
|
||||
argumentType: Type;
|
||||
constraint?: TypeNode;
|
||||
}
|
||||
|
||||
@@ -124,7 +124,8 @@ export enum CompletionSource {
|
||||
ObjectLiteralMethodSnippet = "ObjectLiteralMethodSnippet/",
|
||||
}
|
||||
|
||||
const enum SymbolOriginInfoKind {
|
||||
/** @internal */
|
||||
export const enum SymbolOriginInfoKind {
|
||||
ThisType = 1 << 0,
|
||||
SymbolMember = 1 << 1,
|
||||
Export = 1 << 2,
|
||||
@@ -138,7 +139,8 @@ const enum SymbolOriginInfoKind {
|
||||
SymbolMemberExport = SymbolMember | Export,
|
||||
}
|
||||
|
||||
interface SymbolOriginInfo {
|
||||
/** @internal */
|
||||
export interface SymbolOriginInfo {
|
||||
kind: SymbolOriginInfoKind;
|
||||
isDefaultExport?: boolean;
|
||||
isFromPackageJson?: boolean;
|
||||
@@ -210,18 +212,25 @@ function originIsObjectLiteralMethod(origin: SymbolOriginInfo | undefined): orig
|
||||
return !!(origin && origin.kind & SymbolOriginInfoKind.ObjectLiteralMethod);
|
||||
}
|
||||
|
||||
interface UniqueNameSet {
|
||||
/** @internal */
|
||||
export interface UniqueNameSet {
|
||||
add(name: string): void;
|
||||
has(name: string): boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Map from symbol index in `symbols` -> SymbolOriginInfo.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
type SymbolOriginInfoMap = Record<number, SymbolOriginInfo>;
|
||||
export type SymbolOriginInfoMap = Record<number, SymbolOriginInfo>;
|
||||
|
||||
/** Map from symbol id -> SortText. */
|
||||
type SymbolSortTextMap = (SortText | undefined)[];
|
||||
/**
|
||||
* Map from symbol id -> SortText.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export type SymbolSortTextMap = (SortText | undefined)[];
|
||||
|
||||
const enum KeywordCompletionFilters {
|
||||
None, // No keywords
|
||||
@@ -1882,8 +1891,12 @@ export function getCompletionEntrySymbol(
|
||||
}
|
||||
|
||||
const enum CompletionDataKind { Data, JsDocTagName, JsDocTag, JsDocParameterName, Keywords }
|
||||
/** true: after the `=` sign but no identifier has been typed yet. Else is the Identifier after the initializer. */
|
||||
type IsJsxInitializer = boolean | Identifier;
|
||||
/**
|
||||
* true: after the `=` sign but no identifier has been typed yet. Else is the Identifier after the initializer.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export type IsJsxInitializer = boolean | Identifier;
|
||||
interface CompletionData {
|
||||
readonly kind: CompletionDataKind.Data;
|
||||
readonly symbols: readonly Symbol[];
|
||||
@@ -4320,7 +4333,8 @@ function tryGetObjectLiteralContextualType(node: ObjectLiteralExpression, typeCh
|
||||
return undefined;
|
||||
}
|
||||
|
||||
interface ImportStatementCompletionInfo {
|
||||
/** @internal */
|
||||
export interface ImportStatementCompletionInfo {
|
||||
isKeywordOnlyCompletion: boolean;
|
||||
keywordCompletion: TokenSyntaxKind | undefined;
|
||||
isNewIdentifierLocation: boolean;
|
||||
|
||||
@@ -30,8 +30,12 @@ export function getEditsForFileRename(
|
||||
});
|
||||
}
|
||||
|
||||
/** If 'path' refers to an old directory, returns path in the new directory. */
|
||||
type PathUpdater = (path: string) => string | undefined;
|
||||
/**
|
||||
* If 'path' refers to an old directory, returns path in the new directory.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export type PathUpdater = (path: string) => string | undefined;
|
||||
// exported for tests
|
||||
/** @internal */
|
||||
export function getPathUpdater(oldFileOrDirPath: string, newFileOrDirPath: string, getCanonicalFileName: GetCanonicalFileName, sourceMapper: SourceMapper | undefined): PathUpdater {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import {
|
||||
AnyImportOrRequireStatement, arrayIsSorted, binarySearch, compareBooleans, compareStringsCaseInsensitive,
|
||||
compareValues, createScanner, emptyArray, ExportDeclaration, ExportSpecifier, Expression, factory,
|
||||
compareValues, Comparison, createScanner, emptyArray, ExportDeclaration, ExportSpecifier, Expression, factory,
|
||||
FileTextChanges,
|
||||
FindAllReferences, flatMap, formatting, getNewLineOrDefaultFromHost, group, Identifier, identity, ImportDeclaration,
|
||||
ImportOrExportSpecifier, ImportSpecifier, isAmbientModule, isExportDeclaration, isExternalModuleNameRelative,
|
||||
isExternalModuleReference, isImportDeclaration, isNamedExports, isNamedImports, isNamespaceImport, isString,
|
||||
@@ -25,7 +26,7 @@ export function organizeImports(
|
||||
program: Program,
|
||||
preferences: UserPreferences,
|
||||
mode: OrganizeImportsMode,
|
||||
) {
|
||||
): FileTextChanges[] {
|
||||
const changeTracker = textChanges.ChangeTracker.fromContext({ host, formatContext, preferences });
|
||||
const shouldSort = mode === OrganizeImportsMode.SortAndCombine || mode === OrganizeImportsMode.All;
|
||||
const shouldCombine = shouldSort; // These are currently inseparable, but I draw a distinction for clarity and in case we add modes in the future.
|
||||
@@ -481,7 +482,7 @@ function sortSpecifiers<T extends ImportOrExportSpecifier>(specifiers: readonly
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function compareImportOrExportSpecifiers<T extends ImportOrExportSpecifier>(s1: T, s2: T) {
|
||||
export function compareImportOrExportSpecifiers<T extends ImportOrExportSpecifier>(s1: T, s2: T): Comparison {
|
||||
return compareBooleans(s1.isTypeOnly, s2.isTypeOnly)
|
||||
|| compareIdentifiers(s1.propertyName || s1.name, s2.propertyName || s2.name)
|
||||
|| compareIdentifiers(s1.name, s2.name);
|
||||
|
||||
@@ -255,7 +255,8 @@ export namespace Messages {
|
||||
export const cannotExtractFunctionsContainingThisToMethod = createMessage("Cannot extract functions containing this to method");
|
||||
}
|
||||
|
||||
enum RangeFacts {
|
||||
/** @internal */
|
||||
export enum RangeFacts {
|
||||
None = 0,
|
||||
HasReturn = 1 << 0,
|
||||
IsGenerator = 1 << 1,
|
||||
@@ -270,8 +271,10 @@ enum RangeFacts {
|
||||
|
||||
/**
|
||||
* Represents an expression or a list of statements that should be extracted with some extra information
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
interface TargetRange {
|
||||
export interface TargetRange {
|
||||
readonly range: Expression | Statement[];
|
||||
readonly facts: RangeFacts;
|
||||
/**
|
||||
@@ -282,8 +285,10 @@ interface TargetRange {
|
||||
|
||||
/**
|
||||
* Result of 'getRangeToExtract' operation: contains either a range or a list of errors
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
type RangeToExtract = {
|
||||
export type RangeToExtract = {
|
||||
readonly targetRange?: never;
|
||||
readonly errors: readonly Diagnostic[];
|
||||
} | {
|
||||
|
||||
@@ -149,7 +149,8 @@ export function getSymbolModifiers(typeChecker: TypeChecker, symbol: Symbol): st
|
||||
return modifiers.size > 0 ? arrayFrom(modifiers.values()).join(",") : ScriptElementKindModifier.none;
|
||||
}
|
||||
|
||||
interface SymbolDisplayPartsDocumentationAndSymbolKind {
|
||||
/** @internal */
|
||||
export interface SymbolDisplayPartsDocumentationAndSymbolKind {
|
||||
displayParts: SymbolDisplayPart[];
|
||||
documentation: SymbolDisplayPart[];
|
||||
symbolKind: ScriptElementKind;
|
||||
|
||||
@@ -1213,7 +1213,8 @@ function assignPositionsToNodeArray(nodes: NodeArray<any>, visitor: Visitor, tes
|
||||
return nodeArray;
|
||||
}
|
||||
|
||||
interface TextChangesWriter extends EmitTextWriter, PrintHandlers {}
|
||||
/** @internal */
|
||||
export interface TextChangesWriter extends EmitTextWriter, PrintHandlers {}
|
||||
|
||||
/** @internal */
|
||||
export function createWriter(newLine: string): TextChangesWriter {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {
|
||||
CompilerOptions, concatenate, DiagnosticWithLocation, factory, fixupCompilerOptions, isArray, Node,
|
||||
TransformerFactory, transformNodes,
|
||||
TransformationResult, TransformerFactory, transformNodes,
|
||||
} from "./_namespaces/ts";
|
||||
|
||||
/**
|
||||
@@ -9,11 +9,11 @@ import {
|
||||
* @param transformers An array of `TransformerFactory` callbacks used to process the transformation.
|
||||
* @param compilerOptions Optional compiler options.
|
||||
*/
|
||||
export function transform<T extends Node>(source: T | T[], transformers: TransformerFactory<T>[], compilerOptions?: CompilerOptions) {
|
||||
export function transform<T extends Node>(source: T | T[], transformers: TransformerFactory<T>[], compilerOptions?: CompilerOptions): TransformationResult<T> {
|
||||
const diagnostics: DiagnosticWithLocation[] = [];
|
||||
compilerOptions = fixupCompilerOptions(compilerOptions!, diagnostics); // TODO: GH#18217
|
||||
const nodes = isArray(source) ? source : [source];
|
||||
const result = transformNodes(/*resolver*/ undefined, /*emitHost*/ undefined, factory, compilerOptions, nodes, transformers, /*allowDtsFiles*/ true);
|
||||
result.diagnostics = concatenate(result.diagnostics, diagnostics);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1 @@
|
||||
import * as ts from "./_namespaces/ts";
|
||||
|
||||
// TODO(jakebailey): replace const enum with enum in d.ts
|
||||
|
||||
export = ts;
|
||||
export * from "./_namespaces/ts";
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
import * as ts from "./_namespaces/ts";
|
||||
import { Debug, LogLevel } from "./_namespaces/ts";
|
||||
|
||||
// TODO(jakebailey): replace const enum with enum in d.ts
|
||||
|
||||
// enable deprecation logging
|
||||
declare const console: any;
|
||||
if (typeof console !== "undefined") {
|
||||
@@ -18,4 +15,4 @@ if (typeof console !== "undefined") {
|
||||
};
|
||||
}
|
||||
|
||||
export = ts;
|
||||
export * from "./_namespaces/ts";
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
//// [tests/cases/compiler/APILibCheck.ts] ////
|
||||
|
||||
//// [package.json]
|
||||
{
|
||||
"name": "typescript",
|
||||
"types": "/.ts/typescript.d.ts"
|
||||
}
|
||||
|
||||
//// [package.json]
|
||||
{
|
||||
"name": "typescript-internal",
|
||||
"types": "/.ts/typescript.internal.d.ts"
|
||||
}
|
||||
|
||||
//// [package.json]
|
||||
{
|
||||
"name": "tsserverlibrary",
|
||||
"types": "/.ts/tsserverlibrary.d.ts"
|
||||
}
|
||||
|
||||
//// [package.json]
|
||||
{
|
||||
"name": "tsserverlibrary-internal",
|
||||
"types": "/.ts/tsserverlibrary.internal.d.ts"
|
||||
}
|
||||
|
||||
//// [index.ts]
|
||||
import ts = require("typescript");
|
||||
import tsInternal = require("typescript-internal");
|
||||
import tsserverlibrary = require("tsserverlibrary");
|
||||
import tsserverlibraryInternal = require("tsserverlibrary-internal");
|
||||
|
||||
|
||||
//// [index.js]
|
||||
"use strict";
|
||||
exports.__esModule = true;
|
||||
@@ -0,0 +1,13 @@
|
||||
=== tests/cases/compiler/index.ts ===
|
||||
import ts = require("typescript");
|
||||
>ts : Symbol(ts, Decl(index.ts, 0, 0))
|
||||
|
||||
import tsInternal = require("typescript-internal");
|
||||
>tsInternal : Symbol(tsInternal, Decl(index.ts, 0, 34))
|
||||
|
||||
import tsserverlibrary = require("tsserverlibrary");
|
||||
>tsserverlibrary : Symbol(tsserverlibrary, Decl(index.ts, 1, 51))
|
||||
|
||||
import tsserverlibraryInternal = require("tsserverlibrary-internal");
|
||||
>tsserverlibraryInternal : Symbol(tsserverlibraryInternal, Decl(index.ts, 2, 52))
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
=== tests/cases/compiler/index.ts ===
|
||||
import ts = require("typescript");
|
||||
>ts : typeof ts
|
||||
|
||||
import tsInternal = require("typescript-internal");
|
||||
>tsInternal : typeof tsInternal
|
||||
|
||||
import tsserverlibrary = require("tsserverlibrary");
|
||||
>tsserverlibrary : typeof tsserverlibrary
|
||||
|
||||
import tsserverlibraryInternal = require("tsserverlibrary-internal");
|
||||
>tsserverlibraryInternal : typeof tsserverlibraryInternal
|
||||
|
||||
+5317
-5535
File diff suppressed because it is too large
Load Diff
+1450
-1653
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,34 @@
|
||||
// @module: commonjs
|
||||
// @noImplicitAny: true
|
||||
// @strictNullChecks: true
|
||||
// @lib: es2015.iterable, es2015.generator, es5
|
||||
|
||||
// @filename: node_modules/typescript/package.json
|
||||
{
|
||||
"name": "typescript",
|
||||
"types": "/.ts/typescript.d.ts"
|
||||
}
|
||||
|
||||
// @filename: node_modules/typescript-internal/package.json
|
||||
{
|
||||
"name": "typescript-internal",
|
||||
"types": "/.ts/typescript.internal.d.ts"
|
||||
}
|
||||
|
||||
// @filename: node_modules/tsserverlibrary/package.json
|
||||
{
|
||||
"name": "tsserverlibrary",
|
||||
"types": "/.ts/tsserverlibrary.d.ts"
|
||||
}
|
||||
|
||||
// @filename: node_modules/tsserverlibrary-internal/package.json
|
||||
{
|
||||
"name": "tsserverlibrary-internal",
|
||||
"types": "/.ts/tsserverlibrary.internal.d.ts"
|
||||
}
|
||||
|
||||
// @filename: index.ts
|
||||
import ts = require("typescript");
|
||||
import tsInternal = require("typescript-internal");
|
||||
import tsserverlibrary = require("tsserverlibrary");
|
||||
import tsserverlibraryInternal = require("tsserverlibrary-internal");
|
||||
Reference in New Issue
Block a user